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
sys.setrecursionlimit(10 ** 7)

n = int(input())

def rec(before, depth):
    if depth == n:
        return before+1
    else:
        ret = 0
        for i in range(before+1):
            ret += rec(i+1, depth+1)

        return ret

print(rec(0,1))

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)

for i in cur_ret:
    print(format(i))

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]]
            Ans.append(ans)
        else:
            border = int(current[length - 1])
            for j in range(border + 2):
                q.append((current + str(j), length + 1))
    for a in Ans: print(a)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
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')
ans.sort()
print(*ans,sep='\n')

Submission status: Wrong Answer

Solution code:
n=int(input())
for i in range(2**(n-1)):
    c=ord("a")
    ans="a"
    for j in list(bin(i+2**(n-1))[3:]):
        if j=="1":
            c+=1
        ans+=chr(c)
    print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations,combinations_with_replacement
S = ['a','b','c','d','e','f','g','h','i','j']
N = int(input())
X = [i for i in range(0,N)]
s = ['a']*N
if N == 1:
    print('a')
    exit()
print('a'*N)
for i in range(1,N):
    for e in combinations(X,i):
        index = 1
        if e[0] == 0:
            continue
        else:
            for e1 in e:
                s[e1] = S[index]
                index += 1
        print("".join(s))
        s = ['a']*N

Submission status: Wrong Answer

Solution code:
numal=lambda c:chr(c+97)
n=int(input())
alp="abcdefghij"
unchi=[[],[],[],[],[],[],[],[],[],[]]
unchi[0].append("0")
k=1
if n>=2:
	while k<n:
		for i in range(len(unchi[k-1])):
			unchi[k].append(unchi[k-1][i]+str(int(unchi[k-1][i][k-1])))
			unchi[k].append(unchi[k-1][i]+str(int(unchi[k-1][i][k-1])+1))
		k+=1
for i in range(len(unchi[n-1])):
	s = []
	for k in range(n):
		s.append(numal(int(unchi[n-1][i][k])))
	print("".join(s))

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
l = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
d = [1] * (n+1)
for i in list(itertools.combinations_with_replacement(l[:n], n)):
    si = set(i)
    if d[len(si)]:
        print("".join(i))
        d[len(si)] = 0

Submission status: Wrong Answer

Solution code:
from functools import reduce
from itertools import product
n = int(input())

alphabet = "abcdefghij"
ans = ["a"]

for i in range(1, n):
	ans = [a + b for a, b in product(ans, alphabet[:(i + 1)])]

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

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('aac')
elif n==4:
  print('aaaa')
  print('aaab')
  print('aaac')
  print('aaad')
elif n==5:
  print('aaaaa')
  print('aaaab')
  print('aaaac')
  print('aaaad')
  print('aaaae')
elif n==6:
  print('aaaaaa')
  print('aaaaab')
  print('aaaaac')
  print('aaaaad')
  print('aaaaae')
  print('aaaaaf')
elif n==7:
  print('aaaaaaa')
  print('aaaaaab')
  print('aaaaaac')
  print('aaaaaad')
  print('aaaaaae')
  print('aaaaaaf')
  print('aaaaaag')
elif n==8:
  print('aaaaaaaa')
  print('aaaaaaab')
  print('aaaaaaac')
  print('aaaaaaad')
  print('aaaaaaae')
  print('aaaaaaaf')
  print('aaaaaaag')
  print('aaaaaaah')
elif n==9:
  print('aaaaaaaaa')
  print('aaaaaaaab')
  print('aaaaaaaac')
  print('aaaaaaaad')
  print('aaaaaaaae')
  print('aaaaaaaaf')
  print('aaaaaaaag')
  print('aaaaaaaah')
  print('aaaaaaaai')
elif n==10:
  print('aaaaaaaaaa')
  print('aaaaaaaaab')
  print('aaaaaaaaac')
  print('aaaaaaaaad')
  print('aaaaaaaaae')
  print('aaaaaaaaaf')
  print('aaaaaaaaag')
  print('aaaaaaaaah')
  print('aaaaaaaaai')
  print('aaaaaaaaaj')

Submission status: Wrong Answer

Solution code:
N = int(input())
print(2**(N-1))

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],j+1)

solve("a",1)
for x in ans:
    print(x)

Submission status: Wrong Answer

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

for i in range(1,n):
    for j in ans[i-1]:
        for k in range(ord(j[-1])-ord("a")+2):
            an = j + l[k]
            ans[i].append(an)
count = ans[-1]
count.sort()

for i in count:
    print(i)

Submission status: Wrong Answer

Solution code:
n = int(input())

if n >= 4:
    exit()
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:
n=int(input())

def go(s):
   global n
   if len(s)==n:
       print(s)
       return
   last=s[-1]
   for i in range(ord('a'),ord(last)+1):
       go(s+chr(i))
   if last < 'z':
       go(s + chr(ord(last) + 1))

go("a")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())

cl = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", ]
rl = itertools.product(cl[:n], repeat=n - 1)
if not rl:
    print("a")
else:
    for r in rl:
        print("".join(["a"] + list(r)))

Submission status: Wrong Answer

Solution code:

def main():
    N = int(input())
    li = 'abcdefghijklmnopqrstuvwxyz'

    def f(k):
        nonlocal li
        if k == 1:
            return ['a']
        else:
            temp = f(k-1)
            return [t+char for t in temp for char in li[:k]]

    result = f(N)
    print(sorted(result))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!python3

iim = lambda: map(int, input().rstrip().split())
from collections import deque

def resolve():
    N = int(input())
    S = "abcdefghij"

    q = deque([("", 0, 0)])
    while q:
        s1, i1, i2 = q.popleft()

        if i1 == N:
            print(s1)
            continue
        for i in range(i1):
            q.append((s1+S[i], i1+1, i2))
        q.append((s1+S[i1], i1+1, i2+1))



if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
al=[chr(ord('a') + i) for i in range(26)]
N=int(input())
ans=[[] for _ in range(N)]
ans[0].append("a")

if N==1:
  print("a")
else:
  for i in range(1,N):    
    for item in ans[i-1]:
      for j in range(i+1):
        ans[i].append(item +chr(ord('a') + j))
  for answer in ans[-1]:
    print(answer)

Submission status: Wrong Answer

Solution code:
# Panasonic2020 D

n = int(input())

for i in range(n):
    print("a"*(n-1) + chr(65+i).lower())

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 = ""
  for n in v:
    tmp += str(alpha_dict[n-diff].lower()) 
  ans.add(tmp)

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

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 u in range(0, v + 2):
            ary[i] = u
            search(i + 1, u, n, ary)

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())

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

def f(i):
    if i == 1:
        return [chars[i - 1]]
    else:
        temp = f(i - 1)
        e = []
        for j in temp:
            for k in range(i - 1):
                e.append(j + chars[k])
        e.append(''.join(chars[0:i]))
        return e

result = f(n)

result = sorted(result)
for i in result:
    print(i)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(10000000)

#const
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())
"""
def resolve():
    a,b,c=pin()
    from math import sqrt
    cond =(c-a-b)>sqrt(a*b)*2
    print(["No","Yes"][cond])
"""
def resolve():
    N,=pin()
    from collections import deque
    from collections import Counter
    ans=deque([["a",1]])
    L=1
    abc="abcdefghij"
    #("str",chars in str)のリスト？
    if N>1:
        for i in range(2,N+1):
            for l in range(L):
                temp=ans.popleft() 
                string,types=temp
                for y in range(types+1):
                    temp2=string
                    temp2+=abc[y]
                    count=Counter(temp2)
                    
                    ans.append([temp2,len(count)])
                    
    for A in ans:
        print(A[0])
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """1"""
        output = """a"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """2"""
        output = """aa
ab"""
        self.assertIO(input, output)

if __name__=="__main__":resolve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N = int(input())
ans = ["a"] * N
for i in range(2**(N-1)):
    tmp = i
    memo = len(ans) - 1
    while tmp > 0:
        if tmp % 2 == 0:
            ans[memo] = "a"
        else:
            ans[memo] = "b"
        tmp //= 2
        memo -= 1
    print(''.join(ans))

Submission status: Wrong Answer

Solution code:
from itertools import combinations
n = input()
a = ['a', 'b', 'c', 'd', 'e', 'f' ,'g', 'h', 'i', 'j', 'k']
a  = a[: n]
# print list(combinations(a, 0))
if(n == 1):
	print 'a'*n

def s(i):
	ret = ''
	for k in i:
		ret+=k
	return ret	 
for r in range(1, n):
	l = list(combinations(a, r))
	for i in l:
		# print i
		ans = 'a'
		ans+=s(i)
		for j in range(r+1, n):
			ans+='a'
		print ans
		# print ans, s(i), i

# print a

Submission status: Wrong Answer

Solution code:
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 500010
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''

def comp(s):
    x = ''
    for i in s:
        if i=='0':
            x+='1'
        else:
            x+='0'
    return x

n = int(input())
x = []
for i in range(n):
    a = ['a']*(n-i)
    b = ['b']*(i)
    p = permutations(a+b)
    t = [''.join(j) for j in list(p)]
    x+=t
s = set()
x.sort()
for i in x:
    t = ''
    for j in i:
        if j=='a':
            t+='0'
        else:
            t+='1'
    if not((t in s) or (comp(t) in s)):
        s.add(t)


fin = []
for i in s:
    t = ''
    for j in i:
        if j=='0':
            t+='a'
        else:
            t+='b'
    fin.append(t)
fin.sort()

for i in fin:
    print(i)

Submission status: Wrong Answer

Solution code:
A=[]
B=["a"]
N=int(input())
if N>1:
 for i in range(N-1):
  A=B
  B=[]
  C=len(A)
  for j in range(C):
   D=ord(A[j][i])-95
   for k in range(D):
    E=A[j]+chr(97+k)
    B.append(E)
for i in range(len(B)):
 print(B[i])

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())

cl = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", ]
rl = itertools.product(cl[:2], repeat=n - 1)
if not rl:
    print("a")
else:
    for r in rl:
        print("".join(["a"] + list(r)))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
ans = []
def dfs(s,keta):
  if keta == n+1:
    for sude in ans:
      for i in range(n-1):
        for j in range(i+1,n):
          if not ((sude[i] == sude[j] and s[i] == s[j]) or (sude[i] != sude[j] and s[i] != s[j])):
            return
    ans.append(s)
  else:
    for i in range(keta):
      dfs(s+chr(ord("a")+i),keta+1)

dfs("",1)
ans.sort()
print(*ans,sep = "\n")

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())


for i in itertools.combinations_with_replacement(list("abcdefghij")[:N], N):
    if i[0] not in list("abcdefghij")[:1]:
        break
    if N > 1 and i[1] not in list("abcdefghij")[:2]:
        break
    if N > 2 and i[2] not in list("abcdefghij")[:3]:
        break
    if N > 3 and i[3] not in list("abcdefghij")[:4]:
        break
    if N > 4 and i[4] not in list("abcdefghij")[:5]:
        break
    if N > 5 and i[5] not in list("abcdefghij")[:6]:
        break
    if N > 6 and i[6] not in list("abcdefghij")[:7]:
        break
    if N > 7 and i[7] not in list("abcdefghij")[:8]:
        break
    if N > 8 and i[8] not in list("abcdefghij")[:9]:
        break
    if N > 9 and i[9] not in list("abcdefghij")[:10]:
        break
    print(*i, sep="")

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
if n==1:
  print('a')
  sys.exit()
abc=list('abcdefghijklmnopqrstuvwxyz')
ans=[]
for i in range(2**(n-1)):
  f=list(bin(i)[2:].zfill(n-1))
  k=0
  tmp=abc[k]
  for j in f:
    if j=='1':
      k+=1
    tmp+=abc[k]
  ans+=[tmp]
ans=sorted(ans)
for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(100000000)
MOD = 10**9+7
INF = 10 ** 9

def main():
    n = int(input())
    S = [[] for _ in range(n)]
    S[0] = ['a']
    
    dic = {i:j for i,j in zip(range(10),'abcdefghij')}
    for i in range(1,n):
        kind = 1
        for st in S[i-1]:
            if dic[kind] in st:
                kind += 1
            for j in range(kind+1):
                S[i].append(st+ dic[j])
    print(*S[-1],sep='\n')

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import bisect
import math

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

DIV = (10**9) + 7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % mod) % mod
    return CONV()


def getStan(n):
    if n==1:
        return [[0]]
    else:
        gS = getStan(n-1)
        return [[0]+g for g in gS]+[[0]+[f+1 for f in g] for g in gS]

def main():
    N = iRaw()
    s = "a"*N
    base = ord("a")
    lastS = [chr(ord("a")+n) for n in range(N)]
    gs = getStan(N)
    for g in gs:
        print ("".join([chr(c+base) for c in g]))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

c = [chr(97 + i) for i in range(N)]

ans = []
for i in range(1, N):
    S = c[:i]
    tmp = [1] * i
    add = N - i
    for p in product(range(N - i + 1), repeat=i):
        if sum(p) == add:
            letter = ""
            for j in range(i):
                letter += S[j] * (tmp[j] + p[j])
            ans.append(letter)
ans.append("".join(c[:N]))

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

Submission status: Wrong Answer

Solution code:
from collections import deque

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

def f(i):
    if i == 1:
        return [chars[i - 1]]
    else:
        temp = f(i - 1)
        e = []
        for j in temp:
            for k in range(i - 1):
                e.append(j + chars[k])
        e.append(''.join(chars[0:i]))
        return e

result = f(n)

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

Submission status: Wrong Answer

Solution code:
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']

#print([chr(i) for i in range(97, 97+26)])

def adder(n, s, index):
    if (n == 0):
        print(s)
    else:
        #if(n == 1):
        for i in range(index +2):
            adder(n-1, s+l[i],i)


n = int(input())
#base =
if (n == 1):
    print("a")
elif (n == 2):
    print("aa")
    print("ab")
else:
    adder(n-1,"a",0)

Submission status: Wrong Answer

Solution code:
ans = []
type = [[1]]
que = []
N = int(input())
for i in range(N-1):
    que = type
    type = []
    while len(que) != 0:
        t = que.pop()
        ma = max(t)
        type.append(t + [ma])
        type.append(t + [ma+1])
type.sort()
char = " abcdefghijklmnopqrstuvwxyz"
for a in type:
    print("".join(map(lambda x: char[x], a)))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n=int(input())
al=[chr(ord('a') + i) for i in range(15)]
def dfs(c,i):
    if i==n:
        print(c)
        return
    for k in range(i+1):
        dfs(c+al[k],i+1)
dfs("",0)

Submission status: Wrong Answer

Solution code:
import copy
def make(n, data):
    out = []
    for i in range(n):
        out.append(data + chr(ord("a") + i))
    return out

n = int(input())
ans = ["a"]
for i in range(1, n):
    tmp = []

    for j in range(len(ans)):
        tmp += make(i + 1, ans[j])
            # print
    if len(tmp) >= 1:
        ans = copy.deepcopy(tmp)

for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = 'abcdefghij'
for i in range(N):
    ans = S[i]
    ans = 'a' * (N-1) + ans
    print(ans)

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

        ary[i] = v
        search(i + 1, v, n, ary)
        ary[i] = v + 1
        search(i + 1, v + 1, n, ary)

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

c = [chr(97 + i) for i in range(N)]

ans = []
for i in range(1, N):
    S = c[:i]
    tmp = [1] * i
    add = N - i
    for p in product(range(N - i + 1), repeat=i):
        if sum(p) == add:
            letter = ""
            for j in range(i):
                letter += S[j] * (tmp[j] + p[j])
            ans.append(letter)
ans.append("".join(c[:N]))

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

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()

ans = []
for i in range(1<<n):
    bit = [0]*n
    for j in range(n):
        if i >> j & 1:
            bit[j] = 1
    
    tmp = ''
    for j in range(n):
        if bit[j]:
            tmp += 'a'
        else:
            tmp += 'b'
    ans.append(tmp)

ans.sort()
for i in range((1<<n)//2):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
N = int(input())

def dfs(s):
    if(len(s) == N):
        print(s)
        return
    else:
        next_str = chr(ord(s[-1]) + 1)
        pre_str = chr(ord(s[-1]) - 1)
        dfs(s + s[-1])
        dfs(s + next_str)
        if(s[-1] != "a"):
            dfs(s + pre_str)

dfs("a")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(5000000)
N = int(input())
ans = []


def func(s):
    if len(s) == N:
        ans.append(s)
    else:
        func(s+chr(ord(s[-1])+1))
        func(s+s[-1])


func('a')
for a in sorted(ans):
    print(a)

Submission status: Wrong Answer

Solution code:
import sys
import copy
readline = sys.stdin.buffer.readline

n = int(readline())

kijun = ord("a")

ans = [kijun]*n
print("a"*n)
for i in range(n-1):
    kijun += 1
    for j in range(n-1-i):
        ans[j] = kijun
        res = copy.deepcopy(ans)
        res.reverse()
        for i in range(len(res)):
            res[i] = chr(res[i])
        print("".join(res))

Submission status: Wrong Answer

Solution code:
n=int(input())
x=["a"]*n
print("".join(x))
for i in range(n-1):
    xx=x[:] 
    xx[n-i-1]="b" 
    print("".join(xx))
if n>2:
    print("a"+"b"*(n-1))

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:
            break
rec(0, '')
[print(s) for s in ans]

Submission status: Wrong Answer

Solution code:
def dfs(n, i, s):
    global ans
    s += chr(i)
    if n == N:
        ans += [s]
        return
    for ii in range(97, i+2):
        dfs(n+1, ii, s)

N = int(input())
i = 97
ans = []
dfs(1, 97, '')
ans = sorted(ans)
for a in ans:
    print(a)

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:
        for i in range(m+2):
            d.append([now+l[i],i])
ansl.sort()
for i in ansl:
    print(i)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = []
def all_search(array):
    if len(array) == n:
        ans.append(array)
    else:
        for i in range(len(array) + 1):
            res = array + chr(i + ord('a'))
            all_search(res)
all_search("")
for i in range(len(ans)):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
n=int(input())
if n==1:
  print('a')
if n==2:
  print('aa')
  print('ab')
if n==3:
  print('aaa')
  print('aab')
  print('abc')
if n==4:
  print('aaaa')
  print('aaab')
  print('aabc')
  print('abcd')
if n==5:
  print('aaaaa')
  print('aaaab')
  print('aaabc')
  print('aabcd')
  print('abcde')
if n==6:
  print('aaaaaa')
  print('aaaaab')
  print('aaaabc')
  print('aaabcd')
  print('aabcde')
  print('abcdef')
if n==7:
  print('aaaaaaa')
  print('aaaaaab')
  print('aaaaabc')
  print('aaaabcd')
  print('aaabcde')
  print('aabcdef')
  print('abcdefg')
if n==8:
  print('aaaaaaaa')
  print('aaaaaaab')
  print('aaaaaabc')
  print('aaaaabcd')
  print('aaaabcde')
  print('aaabcdef')
  print('aabcdefg')
  print('abcdefgh')
if n==9:
  print('aaaaaaaaa')
  print('aaaaaaaab')
  print('aaaaaaabc')
  print('aaaaaabcd')
  print('aaaaabcde')
  print('aaaabcdef')
  print('aaabcdefg')
  print('aabcdefgh')
  print('abcdefghi')
if n==10:
  print('aaaaaaaaaa')
  print('aaaaaaaaab')
  print('aaaaaaaabc')
  print('aaaaaaabcd')
  print('aaaaaabcde')
  print('aaaaabcdef')
  print('aaaabcdefg')
  print('aaabcdefgh')
  print('aabcdefghi')
  print('abcdefghij')

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.product(range(n), repeat=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:
N = int(input())
for i in range(2**(N-1)):
    s = ''
    for j in range(N):
        if(i>>j&1):
            s+='b'
        else:
            s+='a'
    print(s[::-1])

Submission status: Wrong Answer

Solution code:
n = int(input())

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

def f(i):
    if i == 1:
        return [chars[i - 1]]
    else:
        temp = f(i - 1)
        e = []
        for j in temp:
            for k in range(i - 1):
                e.append(j + chars[k])
        e.append(''.join(chars[0:i]))
        return e
    
result = f(n)
for i in result:
    print(i)

Submission status: Wrong Answer

Solution code:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    l=[]
    N=int(input())
    bigbag=[]
    for i in range(2 ** (N)):
        bag = []
        for j in range(N):  # このループが一番のポイント
            if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                bag.append('b')
            else:
                bag.append('a')# フラグが立っていたら bag に果物を詰める
        bigbag.append(bag)
    bigbag.sort()
    for i in range(2**(N-1)):
        print(''.join(bigbag[i]))


resolve()

Submission status: Wrong Answer

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