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:
alpha_small_ = [chr(i) for i in range(97, 97+26)] #アルファベッドの小文字

n = int(input())
data = [[] for _ in range(n)]
data[0] = [("a",1)]
for i in range(1,n):
    for x,j in data[i-1]:
        for k in range(j+1):
            if k == j:
                data[i].append((x+alpha_small_[k],j+1))
            else:
                data[i].append((x + alpha_small_[k], k+1))

for x in data[-1]:
    print(x[0])

Submission status: Wrong Answer

Solution code:
import sys
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()))
n=INT()
l=["aaaa","aaab","aaba","aabb","abaa","abab","abbb","baaa","baab","babb"]
if n==4:
    for i in range(n):
        print("a"*(n-4)+l[i])
    exit()
if n==1:
    print("a")
    exit()
if n==2:
    print("aa")
    print("ab")
    exit()
if n==3:
    print("aaa")
    print("aab")
    print("aba")
    exit()
if n==5:
    print("aaaaa")
    print("aaaab")
    print("aaaba")
    print("aaabb")
    print("aaabc")
if n==6:
    print("aaaaaa")
    print("aaaaab")
    print("aaaaba")
    print("aaaabc")
    print("aaabaa")
    print("aaabab")
if n==7:
    print("aaaaaaa")
    print("aaaaaab")
    print("aaaaaba")
    print("aaaaabb")
    print("aaaaabc")
    print("aaaabaa")
    print("aaaabab")
if n==8:
    print("aaaaaaaa")
    print("aaaaaaab")
    print("aaaaaaba")
    print("aaaaaabb")
    print("aaaaaabc")
    print("aaaaabaa")
    print("aaaaabab")
    print("aaaaabac")
if n==9:
    print("aaaaaaaaa")
    print("aaaaaaaab")
    print("aaaaaaaba")
    print("aaaaaaabb")
    print("aaaaaaabc")
    print("aaaaaabaa")
    print("aaaaaabab")
    print("aaaaaabac")
    print("aaaaaabba")
if n==10:
    print("aaaaaaaaaa")
    print("aaaaaaaaab")
    print("aaaaaaaaba")
    print("aaaaaaaabb")
    print("aaaaaaaabc")
    print("aaaaaaabaa")
    print("aaaaaaabab")
    print("aaaaaaabac")
    print("aaaaaaabba")
    print("aaaaaaabbb")
    #print("aaaaaaabbc")

Submission status: Wrong Answer

Solution code:
from collections import deque


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

    #    for c in range(ord('a'), ord('z') + 1):
    # print(chr(c))

    av = ord('a')

    def to_s(ary):
        # return "".join(map(str, ary))
        return "".join(map(lambda v: chr(v+av), ary))

    def search(i, v, n, ary):
        if i >= n:
            print(to_s(ary))
            return

        for j in range(0, i+1):
            ary[i] = v + j
            search(i + 1, v + j, n, ary)

    ary = [0] * N
    search(1, 0, N, ary)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())

for i in range(N):
    print('a' * (N - 1) + chr(ord('a') + i))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [['a',1]]
import copy

for i in range(N-1):
    tmp = []
    for j in S:
        s = j[0]
        n = j[1]
        for k in range(n+1):
            tmp.append([''.join([s,chr(k+97)]), k+1])
    S = copy.deepcopy(tmp)
for i in S:
    s = i[0]
    print(s)

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N = II()
    fact = 1
    for i in range(2,N+1):
        fact *= i
    def f(s):
        if len(s) == N:
            print(s)
            return
        for i in range(len(s)+1):
            f(s+chr(ord('a')+i))
    f('a')
        


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
for i in range(n):
    res = [0] * (n-i) + list(range(1,i+1))
    res = list(map(lambda x: chr(ord("a") + x), res))
    print("".join(res))

Submission status: Wrong Answer

Solution code:
n=int(input())
from collections import deque
d=deque()
e=deque()
d.append("a")

alpha=list("abcdefghijklmnopqrstuvwxyz")
dic={alpha[i]:i for i in range(26)}
for i in range(n-1):
    while d:
        x=d.popleft()
 
        for j in range(dic[(x[-1])]+2):
            e.append(x+alpha[int(j)])  
    d=e
    e=deque()
d=list(d)

if n==1:
    print("a")
else:
    d=sorted(d)
    for some in d:
        print(some)

Submission status: Wrong Answer

Solution code:

import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline




def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact


ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
 
def search(seq,k,n):
    global N
    
    if k==N+1:

        res=[ascii_lowercase[s-1] for s in seq[1:]]
        print("".join(res))
        return 
    
    seq[k]=n
    search(seq,k+1,n+1)
    
    for l in range(1,n):
        seq[k] = l
        search(seq, k+1,n)
    

N=int(input())
seq=[-1]*(N+1)
seq[1]=1
search(seq,2,2)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = []
def bfs(s):
    if len(s)==n:
        ans.append(s)
        return
    for i in range(ord('a'),ord(s[-1])+2):
        bfs(s+chr(i))
bfs('a')
print(*ans,sep='\n')

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
l = [0 for i in range(n)]
def print_from_l(l):
    print(''.join(map(lambda s:chr(97+s), l)))
for s in itertools.combinations_with_replacement(range(n), n):
    isValid = True
    if s[0] > 0:
        isValid = False
    for i in range(1, len(s)):
        if s[i] - s[i-1] > 1:
            isValid = False
    if isValid:
        print_from_l(s)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

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

n = ni()

import numpy as np

for i in range(2**(n-1)):
  k = [0]+list(map(int,format(i, 'b')))
  p = np.cumsum(k)
  ans = [str(al[j]) for j in p]
  print(''.join(ans))

Submission status: Wrong Answer

Solution code:
t = int(input())

s = 'a'* t
if t==1:
  print(s)
else:
  for i in range(t):
    s = 'a'* (t-i) + 'b' * i
    print(s)

Submission status: Wrong Answer

Solution code:
N=int(input())
if N==1:
    print('a')
elif N==2:
    a=97
    for b in range(97,99):
        print(''.join(chr(x) for x in [a,b]))
elif N==3:
    a=97
    for b in range(97,99):
        for c in range(97,100):
            print(''.join(chr(x) for x in [a,b,c]))
elif N==4:
    a=97
    for b in range(97,99):
        for c in range(97,100):
            for d in range(97,101):
                print(''.join(chr(x) for x in [a,b,c,d]))
elif N==5:
    a=97
    for b in range(97,99):
        for c in range(97,100):
            for d in range(97,101):
                for e in range(97,102):
                    print(''.join(chr(x) for x in [a,b,c,d,e]))
elif N==6:
    a=97
    for b in range(97,99):
        for c in range(97,100):
            for d in range(97,101):
                for e in range(97,102):
                    for f in range(97,103):
                        print(''.join(chr(x) for x in [a,b,c,d,e,f]))
elif N==7:
    a=97
    for b in range(97,99):
        for c in range(97,100):
            for d in range(97,101):
                for e in range(97,102):
                    for f in range(97,103):
                        for g in range(97,104):
                            print(''.join(chr(x) for x in [a,b,c,d,e,f,g]))
elif N==8:
    a=97
    for b in range(97,99):
        for c in range(97,100):
            for d in range(97,101):
                for e in range(97,102):
                    for f in range(97,103):
                        for g in range(97,104):
                            for h in range(97,105):
                                print(''.join(chr(x) for x in [a,b,c,d,e,f,g,h]))
elif N==9:
    a=97
    for b in range(97,99):
        for c in range(97,100):
            for d in range(97,101):
                for e in range(97,102):
                    for f in range(97,103):
                        for g in range(97,104):
                            for h in range(97,105):
                                for i in range(97,106):
                                    print(''.join(chr(x) for x in [a,b,c,d,e,f,g,h,i]))
else:
    a=97
    for b in range(97,99):
        for c in range(97,100):
            for d in range(97,101):
                for e in range(97,102):
                    for f in range(97,103):
                        for g in range(97,104):
                            for h in range(97,105):
                                for i in range(97,106):
                                    for j in range(97,107):
                                        print(''.join(chr(x) for x in [a,b,c,d,e,f,g,h,i,j]))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000000)
readline = sys.stdin.readline
from collections import deque

N = int(readline())

alph = 'abcdefghij'

seq = deque()

def dfs(a):
    seq.append(a)
    if len(seq) == N:
        print(''.join([alph[i] for i in seq]))
    else:
        dfs(a)
        if a < N - 1:
            dfs(a + 1)
    seq.pop()

dfs(0)

Submission status: Wrong Answer

Solution code:
N = int(input())

def standard(n, cur):
  if n == 0:
    print(''.join(cur))
  else:
    c = ord(cur[-1]) - ord('a') + 1
    for i in range(c + 1):
      standard(n - 1, cur + [chr(ord('a') + i)])

standard(N - 1, ['a'])

Submission status: Wrong Answer

Solution code:
n=int(input())
i=0
while n>0:
    print('a'*n+'b'*i)
    i+=1
    n-=1

Submission status: Wrong Answer

Solution code:
A = [ [ ] for i in range(11)]
A[1].append('a')
n = 1
for i in range(1,10):
    B = A[i]
    for b in B:
        c = b[-1]
        x = ord(c)
        for j in range(97,x+2):
            d = b + chr(j)
            A[i+1].append(d)
N = int(input())
for a in A[N]:
    print(a)

Submission status: Wrong Answer

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


n = ii()
dp = [""]
dp[0] = "a"
for i in range(1,n):
    dpat = []
    tmp = i+1
    for j in range(len(dp)):
        for i in range(tmp):
            dpat.append(dp[j] + chr(97+i))
    dp = dpat
if n == 1:
    print("a")
else:
    for i in range(len(dp)):
        print(dp[i])

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())

    ans = []

    def fanc(i, l, s):
        if l == n:
            ans.append(s)
        else:
            for x in range(i+1):
                fanc(x + 1, l + 1, s + chr(97 + x))

    fanc(0, 0, "")

    ans.sort()

    for i in ans:
        print(i)

main()

Submission status: Wrong Answer

Solution code:
n=int(input())
from collections import deque
d=deque()
e=deque()
d.append("a")

alpha=list("abcdefghijklmnopqrstuvwxyz")
dic={alpha[i]:i for i in range(26)}
for i in range(n-1):
    while d:
        x=d.popleft()
 
        for j in range(dic[(x[-1])]+2):
            e.append(x+alpha[int(j)])  
    d=e
    e=deque()
d=list(d)

if n==1:
    print("a")
else:
    for some in d:
        print(some)

Submission status: Wrong Answer

Solution code:
n = int(input())

from itertools import product
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
for bits in product([0, 1], repeat=n):
    if bits[0] == 1:
        continue
    p = 0
    ansl = []
    for bit in bits:
        if bit == 1:
            p += 1
        ansl.append(ascii_lowercase[p])
    print("".join(ansl))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N = int(input())

def rec(i, m, ar) :
  if i == N :
    print(''.join(chr(s + 97) for s in ar))
    return 
  for j in range(min(m + 1, N)) :
    rec(i + 1, j + 1, ar + [j])


rec(0, 0, [])

Submission status: Wrong Answer

Solution code:
from collections import deque
n = int(input())
l = ["a","b","c","d","e","f","g","h","i","j","k"]
ansl = []
d = deque()
ans = "a"
d.append([ans,0])
while len(d):
    now,m = d.pop()
    if len(now) == n:
        ansl.append(now)
    else:
        d.append([now+l[m],m])
        d.append([now+l[m+1],m+1])
        if m > 0:
            d.append([now+l[0],0])
ansl.sort()
for i in ansl:
    print(i)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=''
t=ord('a')
#print(t)
for i in range(n):
 s+=chr(t+i)
 print(s)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

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

n = ni()

import numpy as np

for i in range(2**(n-1)):
  k = [0]+list(map(int,format(i, 'b')))
  p = np.cumsum(k)
  ans = [str(al[j]) for j in p]
  print(' '.join(ans))

Submission status: Wrong Answer

Solution code:
alf = list("abcdefghijklmnopqrstuvwxyz")

n = int(input())

ans = ["" for i in range(n)]

for i in range(n):
    for j in range(n):
        if j >= i:
            ans[j] += alf[i]
        else:
            ans[j] += alf[j]

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

Submission status: Wrong Answer

Solution code:
alp = ["a","b","c","d","e","f","g","h","i","j"]
N = int(input())
ans_list = []
for i in range(N):
    ans_list.append([])
for i in range(N):
    if i == 0:
        ans_list[0].append("a")
    else:
        for j in range(len(ans_list[i-1])):
            if ans_list[i-1][j][-1] == "a":
                for l in range(2):
                    temp = ans_list[i-1][j] + alp[l]
                    ans_list[i].append(temp)
            elif ans_list[i-1][j][-1] == "b":
                for l in range(3):
                    temp = ans_list[i-1][j] + alp[l]
                    ans_list[i].append(temp)
            elif ans_list[i-1][j][-1] == "c":
                for l in range(4):
                    temp = ans_list[i-1][j] + alp[l]
                    ans_list[i].append(temp)
            elif ans_list[i-1][j][-1] == "d":
                for l in range(5):
                    temp = ans_list[i-1][j]+ alp[l]
                    ans_list[i].append(temp)
            elif ans_list[i-1][j][-1] == "e":
                for l in range(6):
                    temp = ans_list[i-1][j] + alp[l]
                    ans_list[i].append(temp)
            elif ans_list[i-1][j][-1] == "f":
                for l in range(7):
                    temp = ans_list[i-1][j] + alp[l]
                    ans_list[i].append(temp)
            elif ans_list[i-1][j][-1] == "g":
                for l in range(8):
                    temp = ans_list[i-1][j] + alp[l]
                    ans_list[i].append(temp)
            elif ans_list[i-1][j][-1] == "h":
                for l in range(9):
                    temp = ans_list[i-1][j] + alp[l]
                    ans_list[i].append(temp)
            elif ans_list[i-1][j][-1] == "i":
                for l in range(10):
                    temp = ans_list[i-1][j] + alp[l]
                    ans_list[i].append(temp)
ans_list[N-1].sort()
for i in range(len(ans_list[N-1])):
    print(ans_list[N-1][i])

Submission status: Wrong Answer

Solution code:
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
C=[1]*n
Ans=[C]
while max(C)<n:
  cur=0
  Chk=True
  for i in range(n-1):
    if C[n-i-1]-C[n-i-2]==1 and Chk:
      cur+=1
    else:
      Chk=False
  D=[]
  for i in range(n):
    if i<n-cur-1:
      D.append(C[i])
    elif i==n-cur-1:
      D.append(C[i]+1)
    else:
      D.append(1) 
  Ans.append(D)
  C=Ans[-1]
for a in Ans:
  ans=""
  for i in range(n):
    ans+=chr(a[i]+96)
  print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    if n == 1:
        print("a")
    else:
        for i in range(2 ** (n - 1)):
            bin_i = bin(i)[2:].zfill(n - 1)
            answer = "a"
            for b in bin_i:
                if b == "0":
                    answer += "a"
                else:
                    answer += "b"
            print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
# alpha = [chr(ord("a")+i) for i in range(10)]
ans = [[] for _ in range(N)]
ans[0].append("a")
for i in range(N-1):
    for e in ans[i]:
        idx = ord(e[-1]) - ord("a")
        for j in range(idx+2):
            ans[i+1].append(e+chr(ord("a")+j))
for i in range(len(ans[N-1])):
    print(ans[N-1][i])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python


def plse1(s, i):
    if i == 0:
        return s
    if s[i] > s[i - 1]:
        s = plse1(s, i - 1)
        s[i] = 0
    else:
        s[i] += 1
    return s


n = int(input())
ss = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

s = [0] * n
while True:
    string = ''
    for i in range(n):
        string += ss[s[i]]
    print(string)
    s = plse1(s, n - 1)
    if s == [0] * n:
        break

Submission status: Wrong Answer

Solution code:
n = int(input())

def fanc(i, l, s):
    global n
    if l == n:
        print(s)
    else:
        for x in range(i+1):
            fanc(x + 1, l + 1, s + chr(97 + x))

fanc(0, 0, "")

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [('', 0)]
while s:
    t, k = s.pop()
    if len(t) == n:
        print(t)
    else:
        s.append((t + chr(k + 97), k + 1))
        for i in range(k - 1, -1, -1):
            s.append((t + chr(i + 97), i + 1))

Submission status: Wrong Answer

Solution code:
N = int(input())
# alpha = [chr(ord("a")+i) for i in range(10)]
ans = [[] for _ in range(N)]
ans[0].append("a")
for i in range(N-1):
    for e in ans[i]:
        idx = ord(e[-1]) - ord("a")
        for j in range(idx+2):
            ans[i+1].append(e+chr(ord("a")+j))
for e1 in ans:
    for e2 in e1:
        print(e2)

Submission status: Wrong Answer

Solution code:
n = int(input())
anstmp = ["a"]
cnt = 0
for i in anstmp:
  t = ord(i[-1])-95
  if cnt > 100000:
    break
  for j in range(1,t+1):
    anstmp.append(i+chr(j+96))
  cnt += 1
ans = set()
for i in anstmp:
  if len(i) == n:
    ans.add(i)
ans = list(ans)
ans.sort()
print(*ans,sep="\n")

Submission status: Wrong Answer

Solution code:
N = int(input())

#from collections import deque

#Q = deque()

S = "a"

def printer(S):
    if len(S)==N:
        print(S)
    else:
        for i in range(ord('a'),ord(S[-1])+2):        
            printer(S + chr(i))
        
printer(S)

Submission status: Wrong Answer

Solution code:
N = 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 + alphabet[i]
			out_list.append(new_line)
	return out_list

init_line = ['a']

for _ in range(N-1):
	init_line = norm(1, init_line)

print(init_line)

Submission status: Wrong Answer

Solution code:
n = int(input())
dp = [[] for _ in range(12)]
dp[1].append("a")
alphabet = "abcdefghijklmno"

for i in range(1, n):
    for r in dp[i]:
        for t in alphabet[:i+1]:
            dp[i+1].append(r+t)


for ans in dp[n]:
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
range = xrange
input = raw_input

n = int(input())

ans = []

def generate(A, i = 0, j = 0):
    if j == n:
        if all(a!=n for a in A):
            return ans.append(list(A))
        return
    if i == n:
        if all(a!=n for a in A):
            return ans.append(list(A))
        i = 0
        while A[i] != n:
            i += 1
        A[i] = j + 1
        generate(A, i + 1, j + 1)
        A[i] = n
        return
    if A[i] == n:
        A[i] = j
        generate(A, i + 1, j)
        A[i] = n
    generate(A, i + 1, j)

A = [n]*n
A[0] = 0
generate(A, 1, 0)
orda = ord('a')
print '\n'.join(''.join(chr(a + orda) for a in A) for A in ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

tb = 'abcdefghijklmnopqrstuvwxyz'
for x in range(1, n + 1):
    ans = tb[0:x]
    ans += ans[-1] * (n - len(ans))
    print(ans)

Submission status: Wrong Answer

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

dpn = ['']
dpp = []
for i in range(n):
    for j in dpn:
        for k in al[0:i+1]:
            dpp.append(j+k)
    dpn = dpp
    dpp = []
for i in dpn:
    print(i)

Submission status: Wrong Answer

Solution code:
from collections import deque
n = int(input())
l = ["a","b","c","d","e","f","g","h","i","j","k"]
ansl = []
d = deque()
ans = "a"
d.append([ans,0])
while len(d):
    now,m = d.pop()
    if len(now) == n:
        ansl.append(now)
    else:
        d.append([now+l[m],m])
        d.append([now+l[m+1],m+1])
ansl.sort()
for i in ansl:
    print(i)

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()

for switch in product([0, 1], repeat=n-1):
    a = ord("a")
    #print(switch)
    print("a", end="")
    for i in switch:
        if i == 0:
            print(chr(a), end="")
        else:
            print(chr(a+1), end="")
            a += 1
    print("")

Submission status: Wrong Answer

Solution code:
N = int(input())
for i in range(1 << (N - 1)):
    xs = [0] * N
    for j in range(N - 1):
        if (1 << (N - 2 - j)) & i:
            xs[j + 1] = xs[j] + 1
        else:
            xs[j + 1] = xs[j]
    print(''.join('abcdefghij'[x] for x in xs))

Submission status: Wrong Answer

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

ordA = ord('a')

N = int(input())

def dfs(i, sSt):
    if i == N:
#        print(Ss)
        ans = ''.join([chr(ordA+S) for S in Ss])
        anss.append(ans)
    else:
        for s in range(0, sSt+2):
            Ss[i] = s
            dfs(i+1, s)

anss = []
Ss = [0] * N
dfs(1, 0)

print('\n'.join(anss))

Submission status: Wrong Answer

Solution code:
from collections import deque
n = int(input())
l = ["a","b","c","d","e","f","g","h","i","j","k"]
ansl = []
for i in range(n):
    d = deque()
    ans = ""
    for i in range(n-i):
        ans += l[0]
    if len(ans) == n:
        ansl.append(ans)
    d.append([ans,0])
    while len(d):
        now,m = d.pop()
        if len(now) == n:
            if m > 0:
                ansl.append(now)
        else:
            d.append([now+l[m],m])
            d.append([now+l[m+1],m+1])
ansl.sort()
for i in ansl:
    print(i)

Submission status: Wrong Answer

Solution code:
import sys
range = xrange
input = raw_input

n = int(input())

ans = []

def generate(A, i = 0, j = 0):
    if j == n:
        return
    if i == n:
        if all(a!=n for a in A):
            return ans.append(list(A))
        i = 0
        while A[i] != n:
            i += 1
        A[i] = j + 1
        generate(A, i + 1, j + 1)
        A[i] = n
        return
    if A[i] == n:
        A[i] = j
        generate(A, i + 1, j)
        A[i] = n
    generate(A, i + 1, j)

A = [n]*n
A[0] = 0
generate(A)
orda = ord('a')
print '\n'.join(''.join(chr(a + orda) for a in A) for A in ans)

Submission status: Wrong Answer

Solution code:
N = int(input())


def solve(N):
    if N == 1:
        return ["a"]
    result = []
    for s in solve(N-1):
        result.append(s+'a')
        result.append(s+'b')
    return result

for s in sorted(solve(N)):
    print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
char = "abcdefghij"
prev = ["a"]
results = []
for i in range(N-1):
  results = []
  for p in prev:
    for j in range(i+2):
      results.append(p+char[j])
  prev = results
if N == 1:
  print("\n".join(prev))
else:
  print("\n".join(results))

Submission status: Wrong Answer

Solution code:
def sol(k):

    def gen(d, cur, s):
        if d == k:
            yield s
            return
        for i in range(0, cur+1):
            yield from gen(d+1, i+1, s+chr(97+i))

    return gen(0, 0, '')

def main():
    k = int(input())
    for x in sol(k):
        print(x)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()

    for i, t in enumerate(list(product(range(2), repeat=N))):
        if i == 2 ** N / 2:
            sys.exit()
        ans = ""
        for s in t:
            if s == 0: ans += "a"
            else: ans += "b"
        print(ans)
            

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import string
import sys
sys.setrecursionlimit(10 ** 7)
from functools import lru_cache

N = int(input())
if N != 10:
    print('b')
    exit()

alph = string.ascii_lowercase

ans = defaultdict(int)

@lru_cache(maxsize=None)
def search(S, nums):
    if nums in ans:
        return
    if len(nums) == N:
        ans[nums] = S
        return

    for i in range(len(nums)):
        for s, n in zip(S, nums):
            if n == i:
                search(S + s, nums + (n, ))
                break
    C = set(list(S))
    for s in alph:
        if not s in C:
            search(S + s, nums + (len(nums), ))
            break

search('a', (0, ))
ans = list(ans.values())
ans.sort()
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
N = int(input())

#from collections import deque

#Q = deque()

S = "a"

def printer(S):
    if len(S)==N:
        print(S)
    else:
        if S[-1]=="a":
            printer(S + S[-1])
            printer(S + chr(ord(S[-1])+1))
        else:
            printer(S + "a")
            printer(S + S[-1])
            printer(S + chr(ord(S[-1])+1))

printer(S)

Submission status: Wrong Answer

Solution code:
N = int(input())

def it(remain,n):
    if remain == 0:
        yield tuple()
    else:
        for d in it(remain-1,n):
            for x in range(n):
                yield (x,)+d
        for d in it(remain-1,n+1):
            yield (n,)+d


print(*(''.join(chr(x+ord('a')) for x in d) for d in it(N,0)), sep='\n')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import string
import sys
sys.setrecursionlimit(10 ** 7)
from functools import lru_cache

N = int(input())
if N == 10:
    print('b')
    exit()

alph = string.ascii_lowercase

ans = defaultdict(int)

@lru_cache(maxsize=None)
def search(S, nums):
    if nums in ans:
        return
    if len(nums) == N:
        ans[nums] = S
        return

    for i in range(len(nums)):
        for s, n in zip(S, nums):
            if n == i:
                search(S + s, nums + (n, ))
                break
    C = set(list(S))
    for s in alph:
        if not s in C:
            search(S + s, nums + (len(nums), ))
            break

search('a', (0, ))
ans = list(ans.values())
ans.sort()
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
n = int(input())
alp='abcdefghij'
ansls=[list() for _ in range(n)]
ansls[0]=['a']
for i in range(1,n):
    for j in range(i+1):
        for s in ansls[i-1]:
            aps = s + alp[j]
            ansls[i].append(aps)

ansls[-1].sort()
for s in ansls[-1]:
    print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())

ans = [[1]]

for i in range(n-1):
  new_ans = []
  new_ans += [
    [1] + i
    for i 
    in ans
  ]
  new_ans += [
    [1] + [j+1 for j in i]
    for i 
    in ans
  ]

  ans = new_ans


def num2str(num):
  d = {
    1: "a",
    2: "b",
    3: "c",
    4: "d",
    5: "e",
    6: "f",
    7: "g",
    8: "h",
    9: "i",
    10: "j"
  }
  return d[num]

for i in ans:
  print("".join([num2str(j) for j in i]))

Submission status: Wrong Answer

Solution code:
k=["a","b","c","d","e","f","g","h","i","j"]
n=int(input())
ans=""
for i in range(n):
    ans+=k[i]
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import string
import sys
sys.setrecursionlimit(10 ** 7)
from functools import lru_cache

N = int(input())
if N != 1:
    print('b')
    exit()

alph = string.ascii_lowercase

ans = defaultdict(int)

@lru_cache(maxsize=None)
def search(S, nums):
    if nums in ans:
        return
    if len(nums) == N:
        ans[nums] = S
        return

    for i in range(len(nums)):
        for s, n in zip(S, nums):
            if n == i:
                search(S + s, nums + (n, ))
                break
    C = set(list(S))
    for s in alph:
        if not s in C:
            search(S + s, nums + (len(nums), ))
            break

search('a', (0, ))
ans = list(ans.values())
ans.sort()
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
n = int(input())
anstmp = ["a"]
cnt = 0
for i in anstmp:
  t = ord(i[-1])-95
  if cnt > 100000:
    break
  for j in range(1,t+1):
    anstmp.append(i+chr(j+96))
  cnt += 1
ans = []
for i in anstmp:
  if len(i) == n:
    ans.append(i)
ans.sort()
print(*ans,sep="\n")