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 itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): #startline--------------------------------------------
    n = int(input())
    alphabet = ["a","b","c","d","e","f","g","h","i","j"]
    accumstring = {}
    for i in range(10):
        accumstring[alphabet[i]] = alphabet[:i+2]
    #print(accumstring)
    anslist = ["a"]
    for s in anslist:
        for t in accumstring[s[-1]]:
            anslist.append(s+t)
        if len(s) > 10:
            break
    ans = []
    for i in anslist:
        if len(i) == n:
            ans.append(i)
    for i in ans:
        print(i)
        
        
        
if __name__ == "__main__":
    main() #endline===============================================

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N = I()
    loop = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

    print('a' * N)
    for i in range(N-1):
        for j in range(loop[i]):
            remain = N - (i + 1)
            # print(remain, loop[i])
            a = 'a' * remain
            n = 'b' * (j + 1)
            m = 'a' * (N - remain - (j + 1))
            print(a + n + m)

    # for i in range(N):
    #     ans.append(l_alp[i] * N)

    # for i in range(N):
    #     print(ans[i])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    for i in range(1, N):
        ns = []
        for j, s in enumerate(past):
            if j + 1 < i:
                for k in range(j + 2):
                    ns.append(s + abc[k])
            else:
                for k in range(i + 1):
                    ns.append(s + abc[k])
        past = ns
        for s in past:
            print(s)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import itertools
n=int(input())
r=[]
for s in itertools.combinations_with_replacement('abcdefghij'[:n],n):
    for _r in r:
        for i in range(n):
            if ord(_r[0])-ord(_r[i]) != ord(s[0])-ord(s[i]):
                break
        else:
            break
    else:
        r.append(s)
for i in range(len(r)):
    print(''.join(r[i]))

Submission status: Wrong Answer

Solution code:
N = int(input())
def to_str(n):
    s = [chr(i + 97) for i in reversed(n)]
    s = "".join(s)
    return s
n = [0] * N
n_max = list(reversed(list(range(N))))

while True:
    for j in range(N-1):
        if n[j] < n[j+1]+1:
            n[j] += 1
            for k in range(j):
                n[k] = 0
            s = to_str(n)
            print(s)
            break
    if n == n_max:
        break

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    ans = []
    for i in range(2**(n-1)):
        s = "a"
        x = i
        for j in range(n-1):
            if x % 2 == 1:
                s += "a"
            else:
                s += "b"
            x //= 2
        ans.append(s)
    ans.sort()
    for s in ans:
        print(s)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import itertools
alp = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
N = int(input())
cnt = 0
c = itertools.product(alp[:N], repeat=N)
for j in c:
    if alp[:len(set(j))] != sorted(list(set(j))):
        continue
    print(''.join(j))
    if list(j) == alp[:len(j)]:
        break

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    al = "abcdefghij"
    if n==1:print("a")
    elif n==2:print("aa","ab",sep="\n")
    elif n==3:print("aaa","aab","aba","abb","abc",sep="\n")

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from itertools import permutations

N=int(input())

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

st=st[:N]
ans_ls=[]
if N==1:
    print("a")
else:
    print("a"*N)
    for i in range(2,len(st)):
        ans=st[:i]
        while len(ans)!=N:
            ans.append("a")
        for v in set(list(permutations(ans))):
            
            ans_ls.append("".join(v))

    ans_ls.sort()
    for i in range(len(ans_ls)):
        print(ans_ls[i])
    print("".join(st))

Submission status: Wrong Answer

Solution code:
N = int(input())
al = "abcdefghijklmnopqrstuvwxyz"
atoi = {s:i for i, s in enumerate(al)}
itoa = {i:s for i, s in enumerate(al)}

l = []
def func(s, i):
    if i == N:
        print(s)
        return
    # if al[:i] == s:
    #     for c in al[:i+1]:
    #         func(s + c, i+1)
    # else:
    #     for c in al:
    #         func(s + c, i+1 )

    # if i == N - 1:
    for c in al[:atoi[s[-1]]+2]:
        func(s+c, i+1)
    # else:
    #     for c in al[:i+1]:
    #         func(s+c, i+1) 

func("a", 1)

Submission status: Wrong Answer

Solution code:
import collections


def main():
    n = int(input())
    # if n == 1:
    #     print("a")
    # for i in range(2**(n-1)):
    #     bin_str = "0" + format(i, f'0{n-1}b')
    #     print(bin_str.replace("0", "a").replace("1", "b"))

    ret = [[] for _ in range(10)]
    ret[0] = ["a"]

    alp = "abcdefghijklmnopqrstuvwxyz"

    if n == 1:
        print(ret[n-1])
        return

    ind = 1
    while ind < n:
        tmp_len = len(ret[ind-1])
        for j, _r in enumerate(ret[ind-1]):
            alphabet_num = len(collections.Counter(_r))
            for k in range(alphabet_num+1):
                ret[ind].append(_r+alp[k])
        ind += 1

    print(ret[n-1])
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
import sys
from decimal import *
import itertools

n= list(map(int, input().split()))

n = n[0]

ls = []
ts =[]
for i in range(n):
    ls.append(i+1)

for cb in itertools.combinations_with_replacement(ls, n):
    ts.append(cb)

s = set()
for t in ts:
    stri = ""
    ch = 'a'
    used = {}
    for c in t:
        if c in used:
            stri += used[c]
        else:
            used[c] = ch;
            ch = chr(ord(ch) + 1)
            stri += used[c]
    s.add(stri)

ans = list(s)
sorted(ans)

for st in ans:
    print(st)

Submission status: Wrong Answer

Solution code:
N=int(input())
K=2**N-N
seq=[i for i in range(N)]
from itertools import combinations
ans=['a'*N]
ss=''
tt='a'
for i in range(N):
    ss+=tt
    tt=chr(ord(tt)+1)
ans.append(''.join(ss))
for i in range(2, N):
    for j in list(combinations(seq, i)):
        c='a'
        s=[0]*N
        s[0]=c
        first=True
        for k in range(0,N):
            if first and k in j:
                s[k]=c
                for m in j:
                    s[m]=c
                first=False
                c=chr(ord(c)+1)
            elif k in j:
                continue
            else:
                s[k]=c
                c=chr(ord(c)+1)
        ans.append(''.join(s))
ans.sort()
if N==1:
    print('a')
else:
    for i in ans:
        print(i)

Submission status: Wrong Answer

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

    p = int(input())
    lis = []
    if p == 1:
        print("a")
    else:
        for i in range(2,p+1):
            n = (2 ** (i-1)) - 1
            lis1 = []
            for j in range(n+1):
                lis1.append(format(j,"b").zfill(i))
            lis.append(lis1)
        lis_cor = [lis[0]]
        for i in range(1,len(lis)):
            lisnew = []
            for j in range(len(lis[i])):
                num = lis[i][j].count("1")
                if num > 1:
                    for x in lis_cor[num-2]:
                        x1 = str(int(x) + int(lis[i][j]))
                        lisnew.append(x1.zfill(i+2))
                else:
                    lisnew.append(lis[i][j])
            lis_cor.append(lisnew)
        str_lis = ["a","b","c","d","e","f","g","h","i","j","k"]
        st = ""
        lis_cor1 = list(set(lis_cor[p-2]))
        for y in lis_cor1:
            for j in range(len(y)):
                st1 = str_lis[int(y[j])]
                st += st1
            print(st)
            st = ""
            



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): #startline--------------------------------------------
    n = int(input())
    alphabet = ["a","b","c","d","e","f","g","h","i","j"]
    accumstring = {}
    for i in range(10):
        accumstring[alphabet[i]] = alphabet[:i+2]
    #print(accumstring)
    anslist = ["a"]
    if n == 1:
        print("a")
    else:
        for s in anslist:
            for t in accumstring[s[-1]]:
                anslist.append(s+t)
            if len(s) > 10:
                break
    ans = []
    for i in anslist:
        if len(i) == n:
            ans.append(i)

    print(*ans,sep = " ")
        
        
        
if __name__ == "__main__":
    main() #endline===============================================

Submission status: Wrong Answer

Solution code:
N = int(input())

for i in range(2**(N-1)):
  S = ["a"]*N
  a=format(i,"b").zfill(N)
  for j in range(N-1,0,-1):
    if a[j] == "1":
      S[j]="b"
  print("".join(S))

Submission status: Wrong Answer

Solution code:
N = int(input())
al = []
alphavets = "abcdefghijklmn"

def solve(N, s):

    if len(s) == N:
        al.append(s)
        return 
    
    for i in range(len(s)+1):
        solve(N, s + alphavets[i])

solve(N, alphavets[0])

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

Submission status: Wrong Answer

Solution code:
N = int(input())

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())


A = ['a']

for i in range(n-1):
    B = A[i:]
    for j in B:
        # A.append("".join(j) + j[-1])
        # A.append("".join(j) + chr(ord(j[-1]) + 1))
        for i in range(ord("a"), ord(j[-1]) + 2):
            A.append("".join(j) + chr(i))
A = sorted(A)
for i in A:
    if len(i) == n:
        print(i)

Submission status: Wrong Answer

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

    p = int(input())
    lis = []
    if p == 1:
        print("a")
    else:
        for i in range(2,p+1):
            n = (2 ** (i-1)) - 1
            lis1 = []
            for j in range(n+1):
                lis1.append(format(j,"b").zfill(i))
            lis.append(lis1)
        lis_cor = [lis[0]]
        for i in range(1,len(lis)):
            lisnew = []
            for j in range(len(lis[i])):
                num = lis[i][j].count("1")
                if num > 1:
                    for x in lis_cor[num-2]:
                        x1 = str(int(x) + int(lis[i][j]))
                        lisnew.append(x1.zfill(i+2))
                else:
                    lisnew.append(lis[i][j])
            lis_cor.append(lisnew)
        str_lis = ["a","b","c","d","e","f","g","h","i","j","k"]
        st = ""
        lis_cor1 = list(set(lis_cor[p-2]))
        print(lis_cor1)
        for y in lis_cor1:
            for j in range(len(y)):
                st1 = str_lis[int(y[j])]
                st += st1
            print(st)
            st = ""
            



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math

def permutations_count(n, r):
  ret = 0
  for i in range(r):
    ret += (n-i)
  return ret
  
N = int(input())
#print(N)
if N == 1:
  print(1)
  sys.exit()
elif N == 2:
  print(2)
  sys.exit()

r = N - 2

ret = permutations_count(N, r) + 2
print(ret)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = "bcdefghijk"
if n == 1:
    print("a")
elif n == 2:
    print("aa")
    print("ab")
elif n == 3:
    prefix = "a"*(n-1)
    for _ in range(n):
        print("{}{}".format(prefix,s[n-1]))
elif n == 4:
    prefix = "a"*(n-1)
    for _ in range(n):
        print("{}{}".format(prefix,s[n-1]))

Submission status: Wrong Answer

Solution code:
N = int(input())
al = []
alphavets = "abcdefghijklmn"

def solve(N, s):

    if len(s) == N:
        al.append(s)
        return 
    
    for i in range(len(s)+1):
        solve(N, s + alphavets[i])

solve(N, alphavets[0])

al = sorted(al)
print(al)

Submission status: Wrong Answer

Solution code:
alpha = "abcdefghij"
N = int(input())
anss = []
for i in range(1, N+1):
    substr = alpha[:i]
    s = "a" * (N-i) + substr

    if i in [1, N]:
        anss.append(s)

    elif i == 2:
        last = s[-1]
        s = s[:-1]
        for i in reversed(range(1, N)):
            temp = s[:i] + last + s[i:]
            anss.append(temp)
    else:
        first = s[0]
        s = s[1:]
        for i in range(N-i, N):
            temp = s[:i] + first + s[i:]
            anss.append(temp)

# for ans in anss:
#     print(ans)

# print()
for ans in sorted(anss):
    print(ans)

Submission status: Wrong Answer

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

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

rec("a", 1)
ans.sort()
for x in ans:
    print(x)

Submission status: Wrong Answer

Solution code:
n = int(input())
c = "a"*n
print(c)
c = list(c)
if n > 1:
    p = n
    for j in range(n):
        for i in range(p-1):
            c[-(i+1)] = chr(ord("a") + (j+1))
            print(''.join(c))
        p -= 1

Submission status: Wrong Answer

Solution code:
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy


def f(s, m, n):
    if(len(s) == n):
        print(s)
        return
    for i in range(m):
        # dump(i)
        f(s+chr(i+ord('a')), m if chr(i+ord('a')) == s[-1] else (m+1), n)


n = int(input())
dump(n)
ans = set()
# for si in f('a', 2, n):
#    pass  # print(si)
f('a', 2, n)

Submission status: Wrong Answer

Solution code:
n = int(input())
if n == 1:
    print("a")
if n == 2:
    print("aa")
    print("ab")
elif n == 3:
    print("aaa")
    print("aab")
    print("aac")
    print("aba")
    print("abb")
    print("abc")
    print("acb")
elif n == 4:
    print("aaaa")
    print("aaab")
    print("aabb")
    print("abbb")
else:
    print("hoge")

Submission status: Wrong Answer

Solution code:
N = int(input())
chrA = ["aaaaaaaaaa", "aaaaaaaaab", "aaaaaaaaba", "aaaaaaaabb", "aaaaaaabaa", "aaaaaaabab", "aaaaaaabba","aaaaaaabbb","aaaaaabaaa","aaaaaabaab"]

for i, chra in enumerate(chrA):
    print(chra[-N:])
    if i + 1 == N:
        exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

from string import ascii_lowercase
from itertools import combinations_with_replacement as comw

codes = set()
ans = []

def toCode(s):
    code = ''
    used = {}
    idx = 0
    for c in s:
        if c not in used.keys():
            used[c] = idx
            idx += 1
            code += str(used[c])
        else:
            code += str(used[c])
    return code

for k in comw(ascii_lowercase[:N], N):
    s = ''.join(sorted(k))
    c = toCode(s)
    if c not in codes:
        ans.append(s)
        codes.add(c)

# print(codes)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
import itertools
from collections import deque
ans = deque()
l = []
for i in range(N):
  l.append(chr(97+i))
  for x in itertools.product(l, repeat=N):
    f = [0]*10
    x = list(x)
    judge = True
    k = False
    for w in x:
      w = ord(w)-97
      f[w]=1
      if sum(f[:w])>=w:
        continue
      else:
        k = True
        
    if k:
      continue
    for j,y in enumerate(x[:i+1]):
      if y in l[:j+1]:
        continue
      else:
        judge=False
        break
    if judge:
      ans.append(''.join(x))
  
ans = set(ans)
ans = sorted(list(ans))
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
for i in range(2**(n-1)):
  s = bin(i)[2:]
  pre = '0'*(n-len(s)) + s
  print(''.join(['a' if t=='0' else 'b' for t in pre]))

Submission status: Wrong Answer

Solution code:
N = int(input())

lst = []
m = 0
temp = [[0]]

while temp:
    p = temp.pop()
    if len(p)==N:
        lst.append(p)
    else:
        for i in range(p[-1]+2):
            s = p[:]
            s.append(i)
            temp.append(s)

lst.sort()
abc = 'abcdefghij'
for l in lst:
    print(*[abc[i] for i in l], sep='')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
print('''aaaa
aaab
aaba
aabb
aabc
abaa
abab
abba
abbb
abbc
abca
abcb
abcc
abcd''')

Submission status: Wrong Answer

Solution code:
import itertools
alp = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
N = int(input())
cnt = 0
for i in range(1, N+1):
    c = itertools.product(alp[:i], repeat=i)
    for j in c:
        if alp[:len(set(j))] != sorted(list(set(j))):
            continue
        print(''.join(j))
        if list(j) == alp[:len(j)]:
            break

Submission status: Wrong Answer

Solution code:
n = int(input())
al = [chr(i) for i in range(97,97+26)]

dpn = ['a']
dpp = []
if n == 1:
    print('a')
    exit()
for i in range(1,n):
    for j in dpn:
        for k in al[:ord(j[-1])-97+2]:
            if i != n-1:
                dpp.append(j + k)
            else:
                print(j+k)
    if i != n-1:
        dpn = dpp
        dpp = []

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:
        m = min(N - 1, a + 1)
        for i in range(m + 1):
            dfs(i)
    seq.pop()

dfs(0)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    #→1,.→0として読み込む
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '#' else 0 for s in read()[:-1]])
        # 内包表記はpypyでは若干遅いことに注意
        # #numpy使うだろうからこれを残しておくけど
    return ret


# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right


N = read_a_int()


moji = 'abcdefghij'
candi = []
moji = moji[:N]


def dfs(now, i):
    # 文字を作って返す
    if i == N:
        candi.append(now)
        return
        # return now
    for j in range(0, i + 1):  # iまでのmoji種が連結する可能性がる
        dfs(now + moji[j], i + 1)


dfs('', 0)

print(*sorted(candi), sep='\n')
# for i in range(1, N + 1):  # 何番目まで使うか
#     mojisyu = moji[:i]  # ここで使う文字種類
#     # 文字種類でaを先頭にできるだけ標準形を列挙したい
#     for j in range(1, i):

Submission status: Wrong Answer

Solution code:
n = int(input())

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

ans = ['a'] * n

print(''.join(ans))

# 桁 最後 to 1
count = 1
for i in reversed(range(1, n)):
    temp = ans[:]
    for j in range(i, n):
        current = a[j - i]
        for k in range(j, n):
            temp[k] = current
            print(''.join(temp))

Submission status: Wrong Answer

Solution code:
N = int(input())

ans_check = set()
ans = list()
for i in range(2**N):
    n = i
    s = ""
    sr = ""
    for j in range(N):
        s = s + ("a" if n % 2 == 0 else "b")
        sr = sr + ("b" if n % 2 == 0 else "a")
        n >>= 1
    if sr < s:
        s, sr = sr, s
    if sr in ans_check or s in ans_check:
        continue
    else:
        ans_check.add(s)
        ans.append(s)

ans.sort()
for a in ans:
    print(a)

Submission status: Wrong Answer

Solution code:
#pypyは内包表記使わない, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    N = int(input())
    d = deque(['a'])
    while len(d[0])<N:
        s = d.popleft()
        if s[-1]=='a':
            d.append(s+'a')
            d.append(s+'b')
        elif s[-1]=='b':
            d.append(s+'a')
            d.append(s+'b')
            d.append(s+'c')
        else:
            diff = ord(s[-1]) - ord('a')
            for i in range(diff+2):
                x = ord('a')
                d.append(s+chr(x+i))
    while len(d)!=0:
        print(d.popleft())


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = 'a'

def func(s, count):
    if count == n:
        print(s)
        return
    for i in range(count + 1):
        func(s + chr(ord('a') + i), count + 1)

func(s, 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [97] * n
i = n-1
while i >= 0:
  print("".join(list(map(chr, a))))
  a[i] += 1
  i -= 1

Submission status: Wrong Answer

Solution code:
n = int(input())
words = ['a', 'b', 'c', 'd', 'e', 'f','g','h', 'i', 'j']
ans = [[] for _ in range(n)]
ans[0].append("a")
for i in range(n - 1):
    for ai in ans[i]:
        for j in range(i + 2):
            ans[i + 1].append(ai + words[j])
# print(ans[n - 1])
for a in ans[n - 1]:
    print(a)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)
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()
a=["a" for i in range(n)]
def f(num):
    global n,a
    if num==n:
        print("".join([str(n) for n in a]))
        return
    elif num==1:
        a[num]="a"
        f(num+1)
        a[num]="b"
        f(num+1)
    else:
        a[num]="a"
        f(num+1)
        a[num]="b"
        f(num+1)
        if a.index("b")!=num:
            a[num]="c"
            f(num+1)
f(1)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    #→1,.→0として読み込む
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '#' else 0 for s in read()[:-1]])
        # 内包表記はpypyでは若干遅いことに注意
        # #numpy使うだろうからこれを残しておくけど
    return ret


# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right


N = read_a_int()


moji = 'abcdefghij'
candi = []
moji = moji[:N]


def dfs(now, i):
    # 文字を作って返す
    if i == N:
        candi.append(now)
        return
        # return now
    for j in range(0, i + 1):  # iまでのmoji種が連結する可能性がる
        dfs(now + moji[j], i + 1)


dfs('', 0)

print(*sorted(candi))
# for i in range(1, N + 1):  # 何番目まで使うか
#     mojisyu = moji[:i]  # ここで使う文字種類
#     # 文字種類でaを先頭にできるだけ標準形を列挙したい
#     for j in range(1, i):

Submission status: Wrong Answer

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    c = 'a'
    S = [c]*n
    ret = [''.join(S)]
    for i in range(n):
        for j in reversed(range(i, n)):
            if S[j] < c:
                S[j] = c
                ret.append(''.join(S))
            else:
                break

        c = chr(ord(c)+1)

    return '\n'.join(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Wrong Answer

Solution code:
N = 3
alpha = ["a","b","c","d","e","f","g","h","i","j"]
s = "".join(alpha[:N])
print("a"*N)
print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = "bcdefghijk"
if n == 1:
    print("a")
elif n == 2:
    print("aa")
    print("ab")
elif n >= 3:
    prefix = "a"*(n-1)
    for _ in range(n):
        print("{}{}".format(prefix,s[n-1]))