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:
i = int(input())
p = print
jlist = [None] * 20
def jjj(i):
    if jlist[i-1] is not None:
        return jlist[i-1]
    if i == 1:
        return ('a')
    u = []
    # u = list(map(lambda x: 'a'+x), jjj(i-1))
    for k in range(2):
        u+= list(map(lambda x: 'a'+slide(x, k), jjj(i-1)))
    jlist[i-1] = u
    return u
        

def slide(s, k):
    ss = ''
    for c in s:
        cc = ord(c) + k
        ss += chr(cc)
    return ss

p('\n'.join(jjj(i)))

Submission status: Wrong Answer

Solution code:
def dfs(y):
    global cnt,x
    if cnt==N:
        A.append(x)
        return
    for z in G[y]:
        x += z
        cnt += 1
        dfs(z)
        x = x[:-1]
        cnt -= 1
N = int(input())
G = {chr(i):[chr(j) for j in range(97,i+2)] for i in range(97,97+N-1)}
A = []
x = "a"
cnt = 1
dfs(x)
A = sorted(A)
for a in A:
    print(a)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import copy

letters = [chr(i) for i in range(97, 97+26)]

def main():

    input = stdin.readline

    N = int(input())   

    ans_list = []

    dp(ans_list,0,N)
    

def dp(ans_list,keta,N):

    for i in range(keta+1):
        tmp_list = copy.copy(ans_list)
        tmp_list.append(i)
        if keta + 1 < N:
            dp(tmp_list,keta + 1,N)
            
        else:
            ans = ""
            for i in tmp_list:
                ans += letters[i]
            print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = "abcdefghijk"

if n == 1:
    print("a")
elif n == 2:
    print("aa")
    print("ab")
elif n == 3:
    print("aaa")
    print("aab")
    print("aba")
    print("abb")
    print("abc")
elif n == 4:
    print("aaaa")
    print("aaab")
    print("aaba")
    print("aabb")
    print("aabc")
    print("abaa")
    print("abab")
    print("abba")
    print("abbb")
    print("abbc")
    print("abcc")
    print("abcd")

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('aba')
    print('abb')
elif n == 4:
    print('aaaa')
    print('abaa')
    print('abba')
    print('abbb')
elif n == 5:
    print('aaaaa')
    print('abaaa')
    print('abbaa')
    print('abbba')
    print('abbbb')
elif n == 6:
    print('aaaaaa')
    print('abaaaa')
    print('abbaaa')
    print('abbbaa')
    print('abbbba')
    print('abbbbb')
elif n == 7:
    print('aaaaaaa')
    print('abaaaaa')
    print('abbaaaa')
    print('abbbaaa')
    print('abbbbaa')
    print('abbbbba')
    print('abbbbbb')
elif n == 8:
    print('aaaaaaaa')
    print('abaaaaaa')
    print('abbaaaaa')
    print('abbbaaaa')
    print('abbbbaaa')
    print('abbbbbaa')
    print('abbbbbba')
    print('abbbbbbb')
elif n == 9:
    print('aaaaaaaaa')
    print('abaaaaaaa')
    print('abbaaaaaa')
    print('abbbaaaaa')
    print('abbbbaaaa')
    print('abbbbbaaa')
    print('abbbbbbaa')
    print('abbbbbbba')
    print('abbbbbbbb')
else:
    print('aaaaaaaaaa')
    print('abaaaaaaaa')
    print('abbaaaaaaa')
    print('abbbaaaaaa')
    print('abbbbaaaaa')
    print('abbbbbaaaa')
    print('abbbbbbaaa')
    print('abbbbbbbaa')
    print('abbbbbbbba')
    print('abbbbbbbbb')

Submission status: Wrong Answer

Solution code:
def cur(n):
    if ans[n]!=[]: return ans[n]
    for x in cur(n-1):
        tmp1=[0]+[x[i] for i in range(n-1)]
        tmp2=[0]+[x[i]+1 for i in range(n-1)]
        ans[n].append(tmp1)
        ans[n].append(tmp2)
        if x!=[0 for i in range(n-1)]:
            tmp3=[tmp2[i] for i in range(n)]
            for i in range(1,n):
                if tmp3[i]>2: tmp3[i]-=1
                elif tmp3[i]==2: tmp3[i]=0
            ans[n].append(tmp3)

    return ans[n]


n=int(input())
ans=[[] for i in range(11)]
ans[1]=[[0]]
ans[2]=[[0,0],[0,1]]
cur(n)
ans[n].sort()

for x in ans[n]:
    s=""
    for i in range(n):
        s+=chr( ord("a")+x[i] )
    print(s)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())

    ans = []

    def solve(s, n, xset):
        if n >= N:
            ans.append(s)
            return

        f = False
        for i in range(n + 1):
            if chr(ord('a') + i) not in xset:
                if f:
                    break
                else:
                    xset.add(chr(ord('a') + i))
                    solve(s + chr(ord('a') + i), n + 1, xset)
                    f = True
            else:
                solve(s + chr(ord('a') + i), n + 1, xset)

    sset = set()
    sset.add('a')
    solve('a', 1, sset)
    ans.sort()
    for a in ans:
        print(a)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = []
alp = ['a' ,'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

def print_a(n, ind, cnt, s):
  s = s + [alp[ind]]
  if cnt==n-1:
    for i in range(n):
    	print(s[i], end='')
    print()
  else:
    print_a(n, ind, cnt+1, s.copy())
    print_a(n, ind+1, cnt+1, s.copy())

print_a(n, 0, 0, s)

Submission status: Wrong Answer

Solution code:

N = int(input())

def n(s):
    tail = s[-1]
    tails = [chr(i) for i in range(ord('a'), ord(tail)+2)]
    return [s + t for t in tails]

def nn(li):
    r = []
    for l in li:
        r += n(l)
    return r
  
li = ['a']
for i in range(N-1):
    li = nn(li)
for i in li:
    print(i)

Submission status: Wrong Answer

Solution code:
n=int(input())
abc='abcdefghih'
def dfs(i,a,s):
    if i==n:
        print(s)
    else:
        for j in range(0,a+1):
            dfs(i+1,j+1,s+abc[j])
dfs(0,0,'')

Submission status: Wrong Answer

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

N = int(input())

def bfs(s, cnt):
	if cnt == N:
		print(s)
		return

	for i in range(97,ord(s[-1])+2):
		bfs(s+chr(i), cnt+1)

bfs('a',1)

Submission status: Wrong Answer

Solution code:
n=int(input())

A=["aa","ab"]
num2alpha = lambda c: chr(c+64)
B=[]
num2alpha(3)
if n==1:
	print("a")
	exit()
if n==2:
	print("aa")
	print("ab")

for i in range(n-2):
	k=i+3
	for s in A:
		B.append(s+"a")
		B.append(s+"b")
		if s[-1]!= "a":
			B.append(s+chr(ord(s[-1])+1))
	A=A+B
	B=[]
for x in A:
	if len(x)==n:
		print(x)

Submission status: Wrong Answer

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

DONELIST = []
PROCESSLIST = ['a']
PROCESSLIST2 = []
for i in range(N-1):
    for j in range(len(DONELIST)):
        DONELIST[j] = 'a' + DONELIST[j]
    for j in range(len(PROCESSLIST)):
        DONELIST.append('a' + PROCESSLIST[j])
        for k in range(i+1):
            if PROCESSLIST[j] + chr(97+k) not in DONELIST:
                PROCESSLIST2.append(PROCESSLIST[j] + chr(97+k))

    PROCESSLIST2.append(PROCESSLIST[-1] + chr(97+len(PROCESSLIST[-1])))
    PROCESSLIST = PROCESSLIST2
    PROCESSLIST2 = []

for w in DONELIST:
    print(w)
for w in PROCESSLIST:
    print(w)

Submission status: Wrong Answer

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

if N > 1:
  ans1 = []
  a = max(ans)+1
  for i in range(a+1):
    c = copy.copy(ans)
    c.append(i)
    ans1.append(c)
    
if N > 2:
  ans2 = []
  for j in range(len(ans1)):
    a = max(ans1[j])+1
    for i in range(a+1):
      c = copy.copy(ans1[j])
      c.append(i)
      ans2.append(c)

if N > 3:
  ans3 = []
  for j in range(len(ans2)):
    a = max(ans2[j])+1
    for i in range(a+1):
      c = copy.copy(ans2[j])
      c.append(i)
      ans3.append(c)
      

if N > 4:
  ans4 = []
  for j in range(len(ans3)):
    a = max(ans3[j])+1
    for i in range(a+1):
      c = copy.copy(ans3[j])
      c.append(i)
      ans4.append(c)


if N > 5:
  ans5 = []
  for j in range(len(ans4)):
    a = max(ans4[j])+1
    for i in range(a+1):
      c = copy.copy(ans4[j])
      c.append(i)
      ans5.append(c)

      
if N > 6:
  ans6 = []
  for j in range(len(ans5)):
    a = max(ans5[j])+1
    for i in range(a+1):
      c = copy.copy(ans5[j])
      c.append(i)
      ans6.append(c)

if N > 7:
  ans7 = []
  for j in range(len(ans6)):
    a = max(ans6[j])+1
    for i in range(a+1):
      c = copy.copy(ans6[j])
      c.append(i)
      ans7.append(c)

if N > 8:
  ans8 = []
  for j in range(len(ans7)):
    a = max(ans7[j])+1
    for i in range(a+1):
      c = copy.copy(ans7[j])
      c.append(i)
      ans8.append(c)

if N > 9:
  ans9 = []
  for j in range(len(ans8)):
    a = max(ans8[j])+1
    for i in range(a+1):
      c = copy.copy(ans8[j])
      c.append(i)
      ans9.append(c)
      

aaa = "abcdefghijklmnop"
if N == 1:
  print("a")    
    
elif N ==2:
  for i in ans1:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==3:
  for i in ans2:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==4:
  for i in ans3:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==5:
  for i in ans4:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==5:
  for i in ans1:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==7:
  for i in ans6:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==8:
  for i in ans7:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==9:
  for i in ans8:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
    
elif N ==10:
  for i in ans9:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)

Submission status: Wrong Answer

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


def next_chr(ch):
    res = []
    for i in range(-1, 2):
        if ord(ch) + i >= ord("a") and ord(ch) + i <= ord("z"):
            res.append(chr(ord(ch)+i))
    return res


def answer(s, i):
    if i == N:
        ch = next_chr(s[-1])
        for m in ch:
            ans.append("".join([s, m]))
    else:
        i += 1
        ch = next_chr(s[-1])
        for m in ch:
            answer("".join([s, m]), i)

if N == 1:
    print("a")
else:
    answer("a", 2)

    print(sorted(ans))

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    abc = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j')
    past = [[0, 'a']]

    if N == 1:
        print('a')
    else:
        for i in range(1, N):
            ns = []
            for s in past:
                for j in range(s[0] + 2):
                    ns.append([j, s[1] + abc[j]])
            past = ns
            if i == N - 1:
                for s in past:
                    print(s[1])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import itertools
import sys
from string import ascii_lowercase

input = sys.stdin.readline


class Solution:
    def main(self):
        n = int(input())
        done = []
        for i in range(1, n + 1):
            moji = ascii_lowercase[0:i]
            for comb in itertools.combinations_with_replacement(moji, n):
                temp = []
                cnt = 0
                before = ""
                for i, c in enumerate(comb):
                    if i == 0:
                        cnt += 1

                    elif before == c:
                        cnt += 1
                        if i == len(comb) - 1:
                            temp.append(cnt)
                    else:
                        temp.append(cnt)
                        cnt = 1
                    before = c

                f = False
                for d in done:
                    if temp == d:
                        f = True
                        break
                if f:
                    continue
                else:
                    print(''.join(comb))
                    done.append(temp)


# Run main
if __name__ == '__main__':
    Solution().main()

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
a = ("a", "b", "c", "d", "e")
N = int(input())
L = [0]*N

alpha=list('abcdefghijk')
print('a'*N)
for i in range(N,0,-1):
    for j in range(1,i,1):
        L[-j]+=1
        print(''.join([alpha[i] for i in L]))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = "abcdefghijklmnopqrstuvwxyz"
for i in range(n):
    print("a"*(n-i) + A[1:1+i])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int):
    ans = []
    # n=1 a
    # n=2 aa ab
    # n=3 aaa aab abb aba
    # n=4 aaaa aaab aabb abbb aaba abaa
    if N == 1:
        print('a')
        return
    
    for i in range(2**(N-1)):
        s = str(format(i, 'b')).zfill(N-1).replace('0', 'a').replace('1', 'b')
        ans.append('a' + s)
        
    for i in sorted(ans):
        print(i)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())

arr=[1]*N


if(N==1):
    print("a")
    exit()

def num2alpha(num):
    return chr(num+96)

def keta(num):
    if(arr[num-1]<arr[num]):
        keta(num-1)
    else:
        for k in range(num+1,N):
            arr[k] = 1
        arr[num] += 1
        


i = N-1
while arr[0]==1:
    ans = map(num2alpha,arr)
    print((''.join(ans)))
    keta(N-1)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
n = int(input())
ans = []

def rec(s, k, len):
    if len >= n:
        ans.append("".join([chr(ord("a") + x) for x in s]))
        return
    for x in range(max(s[-1]+2, k+1)):
        rec(s + [x], max(k, x), len+1)

rec([0], 1, 1)
ans.sort()
print(*ans, sep="\n")

Submission status: Wrong Answer

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

def create_li(li):
  if len(li) >= n:
    lis.append(li)
    return
  p = li[-1]
  for i in range(1, p + 2):
    cp = li[:]
    cp.append(i)
 #   print(cp)
    create_li(cp)

lis = []
  
n = int(input())
pre = [1]
create_li(pre)
lis.sort()
al = ["a","b","c","d","e","f","g","h","i","j"]
ans = set(["".join([al[id-1] for id in i]) for i in lis])
ans = list(ans)
ans.sort()
for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
n = int(input())
c = list(map(chr, range(97, 97+26)))
for i in range(1, n+1):
    s = ""
    s += "a"*(n-i)
    s += "".join(c[0:i])
    print(s)

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

l=['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 main():
  n=I()

  ans='a'*n
  print(ans)
  x=1
  while True:
    a=l[x]
    f=True
    if x>n:
      break
    _ans=ans
    for k in range(n-x):
      for i in range(x+k,len(ans))[::-1]:
        print(_ans[:i]+a+_ans[i+1:])
      _ans=_ans[:k+1]+a+_ans[k+2:]

    ans=ans[:x]+a+ans[x+1:]
    x+=1

main()
# print(main())

Submission status: Wrong Answer

Solution code:
N = int(input())
if (N == 1):
  print('a')
  exit()
elif (N == 2):
  print('aa')
  print('ab')
  exit()
elif (N == 3):
  print('aaa')
  print('aab')
  print('aba')
  print('abb')
  exit()
elif (N == 4):
  print('aaaa')
  print('aaab')
  print('aaba')
  print('aabb')
  print('abaa')
  print('abab')
  print('abbb')
  exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

s = set()

def solve(n):
    global s

    if n == N:
        return

    if len(s) == 0:
        s.add('a')
        solve(n+1)
    else:
        new_s = set()
        for v in s:
            xc = chr(ord(max(v))+1)
            for vc in v:
                new_s.add(v + vc)
                new_s.add(v + xc)
        s = new_s
        solve(n+1)

solve(0)

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

Submission status: Wrong Answer

Solution code:

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

x = 1
while(x <= n):
    ll = l
    l = []
    for i in ll:
        for j in s[:x-1]:
            l.append(i + j)
    l.append("".join(s[:x]))
    x = x + 1
for i in l:
    print(i)

Submission status: Wrong Answer

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

if N > 1:
  ans1 = []
  a = max(ans)+1
  for i in range(a+1):
    c = copy.copy(ans)
    c.append(i)
    ans1.append(c)
    
if N > 2:
  ans2 = []
  for j in range(len(ans1)):
    a = max(ans1[j])+1
    for i in range(a+1):
      c = copy.copy(ans1[j])
      c.append(i)
      ans2.append(c)

if N > 3:
  ans3 = []
  for j in range(len(ans2)):
    a = max(ans2[j])+1
    for i in range(a+1):
      c = copy.copy(ans2[j])
      c.append(i)
      ans3.append(c)
      

if N > 4:
  ans4 = []
  for j in range(len(ans3)):
    a = max(ans3[j])+1
    for i in range(a+1):
      c = copy.copy(ans3[j])
      c.append(i)
      ans4.append(c)


if N > 5:
  ans5 = []
  for j in range(len(ans4)):
    a = max(ans4[j])+1
    for i in range(a+1):
      c = copy.copy(ans4[j])
      c.append(i)
      ans5.append(c)

      
if N > 6:
  ans6 = []
  for j in range(len(ans5)):
    a = max(ans5[j])+1
    for i in range(a+1):
      c = copy.copy(ans5[j])
      c.append(i)
      ans6.append(c)

if N > 7:
  ans7 = []
  for j in range(len(ans6)):
    a = max(ans6[j])+1
    for i in range(a+1):
      c = copy.copy(ans6[j])
      c.append(i)
      ans7.append(c)

if N > 8:
  ans8 = []
  for j in range(len(ans7)):
    a = max(ans7[j])+1
    for i in range(a+1):
      c = copy.copy(ans7[j])
      c.append(i)
      ans8.append(c)

      
if N > 9:
  ans9 = []
  for j in range(len(ans8)):
    a = max(ans8[j])+1
    for i in range(a+1):
      c = copy.copy(ans8[j])
      c.append(i)
      ans9.append(c)

aaa = "abcdefghijklmnop"
if N == 1:
  print("a")    
    
elif N ==2:
  for i in ans1:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==3:
  for i in ans2:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==4:
  for i in ans3:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==5:
  for i in ans4:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==5:
  for i in ans1:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==7:
  for i in ans6:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==8:
  for i in ans7:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==9:
  for i in ans8:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
    
elif N ==10:
  for i in ans9:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)

Submission status: Wrong Answer

Solution code:
N = int(input())

dic = {0:"a", 1:"b", 2:"c", 3:"d", 4:"e", 5:"f", 6:"g", 7:"h", 8:"i", 9:"j"}
dic_r = {"a":0, "b":1, "c":2, "d":3, "e":4, "f":5, "g":6, "h":7, "i":8, "j":9}

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

Submission status: Wrong Answer

Solution code:
import itertools
def solve():
    N = int(input())
    alphabets = ['a','b','c','d','e','f','g','h','i','j']
    comb = list(itertools.combinations_with_replacement(alphabets[:N],N))

    s = set() 
    for c in comb:
        if c[0] != 'a':
            break
        d = {}
        for char in c:
            if not char in d.keys():
                d[char] = alphabets[len(d.keys())]
        
        string = ""
        for char in c:
            string += d[char]
        s.add(string)

    ans = sorted(list(s))
    print(*ans, sep='\n')

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000)

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

Solution code:
N = int(input())

dic = {0:"a", 1:"b", 2:"c", 3:"d", 4:"e", 5:"f", 6:"g", 7:"h", 8:"i", 9:"j"}
dic_r = {"a":0, "b":1, "c":2, "d":3, "e":4, "f":5, "g":6, "h":7, "i":8, "j":9}

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

Submission status: Wrong Answer

Solution code:
from itertools import product
n = int(input())
alph = 'abcdefghij'
al = [alph[i] for i in range(n)]
for p in product(al, repeat=n):
    if p[0] == 'b':
        break
    print(''.join(p))

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = ['a','b','c','d','e','f','g','h','i','j','k',]
ans = []
#for i in range(n):
t = ['a'] * n
for i in range(2 ** n):
    s = ['a'] * n
    for j in range(n):
        if ((i >> j) & 1):
            s[n - 1 - j] = 'b'
    ans.append(''.join(s))
ans.append(''.join(t))
for i in range(1,n):
    for j in range(i,n):
        s = ['a'] * n
        s[j:n] = lis[0:n-j]
        ans.append(''.join(s))
        #print(s)


ans.sort()
d = set()
for i in ans:
    if i[0] == 'a':
        if not i in d:
            print(i)
            d.add(i)

Submission status: Wrong Answer

Solution code:
i = int(input())
p = print
jlist = [None] * 10
def jjj(i):
    if jlist[i-1] is not None:
        return jlist[i-1]
    if i == 1:
        return ('a')
    # elif i== 2:
    #     return ('aa'), ('ab')
    # elif i==3:
    #     return ('aaa'), ('aab'), ('aba'), ('abb'), ('abc')
    elif i>=2:
        u = []
        # u = list(map(lambda x: 'a'+x), jjj(i-1))
        for k in range(2):
            u+= list(map(lambda x: 'a'+slide(x, k), jjj(i-1)))
        jlist[i-1] = u
        return u
        

def slide(s, k):
    ss = ''
    for c in s:
        cc = ord(c) + k
        ss += chr(cc)
    return ss

p('\n'.join(jjj(i)))

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 = res
        resstr = list(map(lambda x: chr(ord("a") + x), res))
        print("".join(resstr))
        continue
    while res[n-i] == 1:
        resstr = res
        resstr = list(map(lambda x: chr(ord("a") + x), res))
        print("".join(resstr))
        res[-1] += 1
        #print("kari:", (resstr))
        for j in range(1, i):
            #print("verf", res[: n-j], "n-j", n-j)
            if res[n-j] > max(res[:n-j]) + 1:
                res[n-j] = 0
                res[n-j-1] += 1
                break
    continue
    resstr = list(map(lambda x: chr(ord("a") + x), res))
    print("".join(res))

Submission status: Wrong Answer

Solution code:
N = int(input())
def next(S):
    ans = []
    n = len(S)
    for i in range(n):
        s = S[i]
        m = len(s)
        fin = s[m-1]
        l = (ord(fin)-18)%26
        for j in range(l+1):
            ans.append(s+chr(j+97))
    return ans
S = "a"
for i in range(N-1):
    S = next(S)
p = len(S)
for i in range(p):
  print(S[i])

Submission status: Wrong Answer

Solution code:
num = int(input())
base = ["a","b","c","d","e","f","g","h","j","k"]

if num == 1:
  print("a")
elif num == 2:
  print("aa")
  print("ab")
elif num == 3:
  print("aaa")
  print("aab")
  print("aba")
  print("abb")
  print("abc")

Submission status: Wrong Answer

Solution code:
from collections import deque
n=int(input())
L=['a','b','c','d','e','f','g','h','i','j']
ans=['a']
for i in range(2,n+1):
    que=deque(L[:i])
    temp2=[]
    while que:
        moji=que.popleft()
        temp=[]
        for a in ans:
            a+=moji
            temp.append(a)
        temp2+=temp
    ans=temp2
ans.sort()
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
output = []
for i in range(2 ** N):
    ans = ""
    ones = []
    zeros = []
    for j in range(N):
        if i >> j & 1 == 1:
            ones.append(N - 1 - j)
        else:
            zeros.append(N - 1 - j)
    charset = collections.deque([chr(ord("a") + i) for i in range(26)])
    used_index = 1
    for k in range(N):
        if len(ones) > 1:
            if k in ones:
                ans += "a"
            else:
                ans += charset[used_index]
                used_index += 1
        else:
            ans += charset.popleft()
    output.append(ans)
    
[print(ans) for ans in sorted(list(set(output)))]

Submission status: Wrong Answer

Solution code:
# input1 = list(map(int, (input().split())))


def func(n, sss, d):
    for i in range(n):
        if d == N:
            print(sss + s[i])
        else:
            func(i + 2, sss + s[i], d+1)


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

N = int(input())

func(1, "", 1)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())

    ans = []

    def solve(s, n, xset):
        if n >= N:
            ans.append(s)
            return

        for i in range(n + 1):
            if chr(ord('a') + i) not in xset:
                xset.add(chr(ord('a') + i))
                solve(s + chr(ord('a') + i), n + 1, xset)
                break
            else:
                solve(s + chr(ord('a') + i), n + 1, xset)

    sset = set()
    sset.add('a')
    solve('a', 1, sset)
    ans.sort()
    for a in ans:
        print(a)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())

dic = {0:"a", 1:"b", 2:"c", 3:"d", 4:"e", 5:"f", 6:"g", 7:"h", 8:"i", 9:"j"}
dic_r = {"a":0, "b":1, "c":2, "d":3, "e":4, "f":5, "g":6, "h":7, "i":8, "j":9}

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000)

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)

Submission status: Wrong Answer

Solution code:
n=int(input())
for i in range(2**(n-1)):
  print("a",end="")
  for j in range(n-1):
    print("a" if (i>>(n-j-2))%2==0 else "b", end="")
  print()

Submission status: Wrong Answer

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

n = int(input())

result = []

def fig(v, num):
    if v == n:
        result.append(num)
        return
    
    for i in range(v+1):
        fig(v+1, num + d[i])

fig(0, '')
result.sort()
for r in result:
    print(r)

Submission status: Wrong Answer

Solution code:

s = ["a","b","c","d","e","f","g","h","i"]
n=int(input())
l = ["a"]

x = 1
while(x <= n):
    ll = l
    l = []
    for i in ll:
        for j in s[:x-1]:
            l.append(i + j)
    l.append("".join(s[:x]))
    x = x + 1
for i in l:
    print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = []
from string import ascii_letters
from itertools import combinations
for g in range(N):
    if g == 0:
        ans.append(ascii_letters[0]*N)
        continue
    for l in combinations(range(N-1), g):
        t = ""
        for i, v in enumerate(l):
            m = ascii_letters[i]
            if i == 0:
                n = l[i] + 1
            else:
                n = l[i] - l[i-1]
            t += (m * n)
        
        t += ascii_letters[i+1] * (N - len(t))
        ans.append(t)


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

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
x = list(product([0, 1], repeat=N))
ans = []

def dfs(s):
	if len(s) == N:
		idx = -1
		char_set = set()
		t = ""
		for i in range(N):
			if s[i] not in char_set:
				t += ascii_lowercase[i]
				idx += 1
				char_set.add(ascii_lowercase[i])
			else:
				t += s[i]

		ans.append(t)
		return
	for i in range(len(s)+1):
		dfs(s+ascii_lowercase[i])

dfs("a")
ans = sorted(list(set(ans)))

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

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    abc = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j')
    past = [[0, 'a']]

    for i in range(1, N):
        ns = []
        for s in past:
            for j in range(s[0] + 2):
                ns.append([j, s[1] + abc[j]])
        past = ns
        if i == N - 1:
            for s in sorted(past):
                print(s[1])


if __name__ == '__main__':
    main()