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: Accepted

Solution code:
N = int(input())

c = ['a' for _ in range(N)]
def f(i, k):
    if i == N:
        print(''.join(c))
        return
    for j in range(k + 1):
        c[i] = chr(ord('a') + j)
        f(i + 1, max(j + 1, k))

f(0, 0)

Submission status: Accepted

Solution code:
n = int(input())

s = ['' for i in range(n)]
def dfs(k, c):
    if k == n:
        print("".join(s))
        return
    for i in range(c):
        s[k] = chr(i+ord('a'))
        dfs(k+1, c)
    s[k] = chr(c+ord('a'))
    dfs(k+1, c+1)

dfs(0, 0)

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()

ans = ["a"]
for i in range(N-1):
    nans = []

    for S in ans:
        m = max(S)
        for x in range(ord(m)-95):
            nans.append(S+chr(97+x))

    ans = copy.copy(nans)

print("\n".join(ans))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(read())

alphabets = [chr(ord('a') + x) for x in range(26)]

def dfs(S, i):
    if len(S) == N:
        yield ''.join(S)
        return
    for j in range(i):
        for w in dfs(S + [alphabets[j]], i):
            yield w
    for w in dfs(S + [alphabets[i]], i + 1):
        yield w

for w in dfs([],0):
    print(w)

Submission status: Runtime Error

Solution code:
n = int(input())

if n == 1:
  w = ['a']
elif n == 2:
  w = ['aa','ab']
elif n == 3:
  w = ['aaa','aab','aba','abb','abc']
for s in w:
  print (s)

Submission status: Runtime Error

Solution code:
n = int(input())

if n == 1:
  w = ['a']
elif n == 2:
  w = ['aa','ab']
elif n == 3:
  w = ['aaa','aab','aba','abb']
for s in w:
  print (s)

Submission status: Runtime Error

Solution code:
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    n = int(input())
    ans = ["a"]
    alt = [chr(ord("a") + i) for i in range(n)]
    for i in range(n-1):
        ans = [s+x for s in ans for x in alt [0:len(set(ans))+1]]
    for i in ans:
        print(ans)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
from collections import deque
D1 = {i:chr(i+96) for i in range(1,27)}
D2 = {val:key for key,val in D1.items()}

N = int(input())
heap = deque([(D[1],1)])
A = []
while heap:
    a,n = heap.popleft()
    if n<N:
        j = D2[a[-1]]
        for i in range(1,min(j+1,26)+1):
            heap.append((a+D1[i],n+1))
    if n==N:
        A.append(a)
A = sorted(A)
for i in range(len(A)):
    print(A[i])

Submission status: Runtime Error

Solution code:
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int N;
	cin >> N;

	vector<string> ans;
	for (int bit = 0; bit < (1 << (N - 1)); bit++) {
		string s;
		char c = 'a';
		for (int i = 0; i < N; i++) {
			s += c;
			if (bit >> i) c++;
		}
		ans.emplace_back(s);
	}

	for (const auto& e : ans) cout << e << "\n";

	return 0;
}

Submission status: Runtime Error

Solution code:
from collections import deque
import sys
n = int(input())
if n == 1:
    print('a')
    sys.exit()

q = deque([])
q.append((1, 'a', 1))
cur = 1
while cur != n:
    num = len(q)
    j = 0
    while j < num:
        a, b, c = q.popleft()
        for i in range(1, c+2):
            q.append((i, b + chr(96+i), max(map(int, list(b + chr(96+i)))))
        j += 1
    cur += 1

for i in range(len(q)):
    a, b, c = q.popleft()
    print(b)

Submission status: Runtime Error

Solution code:
from collections import deque
import sys
n = int(input())
if n == 1:
    print('a')
    sys.exit()

q = deque([])
q.append((1, '1', 1))
cur = 1
while cur != n:
    num = len(q)
    j = 0
    while j < num:
        a, b, c = q.popleft()
        for i in range(1, c+2):
            q.append((i, b + str(i), max(i, a)))
        j += 1
    cur += 1

d = dict()
for i in range(1, n+1):
    d[str(i)] = chr((i-1) + 97)

for i in range(len(q)):
    a, b, c = q.popleft()
    print(b.translate(str.maketrans(d)))

Submission status: Runtime Error

Solution code:
from collections import deque
import sys
n = int(input())
if n == 1:
    print('a')
    sys.exit()

q = deque([])
q.append((1, '1'))
cur = 1
while cur != n:
    num = len(q)
    j = 0
    while j < num:
        a, b = q.popleft()
        for i in range(1, a+2):
            q.append((i, b + str(i)))
        j += 1
    cur += 1

d = dict()
for i in range(1, n+1):
    d[str(i)] = chr((i-1) + 97)

for i in range(len(q)):
    a, b = q.popleft()
    print(b.translate(str.maketrans(d)))

Submission status: Runtime Error

Solution code:
N = int(input())
string = [0 for i in range(N)]
calc_str = lambda :"".join(list(chr(i+ord('a')) for i in string))
chr_a = ord('a')
print(calc_str())
now = N-2


while True:
    if string[now+1]-max(string[:now+1]) > 0:
        if now == 0: break
        string[now+1] = 0
        now -= 1
        
    else:
        string[now+1] += 1
        now = N-2

        print(calc_str())

Submission status: Runtime Error

Solution code:
N = int(input())
string = [0 for i in range(N)]
calc_str = lambda :"".join(list(chr(i+ord('a')) for i in string))
chr_a = ord('a')
print(calc_str())
now = N-2


while True:
    if string[now+1]-string[now] > 0:
        if now == 0: break
        string[now+1] = 0
        now -= 1
        
    else:
        string[now+1] += 1
        now = N-2

        print(calc_str())

Submission status: Runtime Error

Solution code:
N = int(input())

#文字数分aで埋める
#末尾をbにする
#一桁上の文字+1文字までは許容するルールで増加させていく

ans = [0 for _ in range(N)]
stop = [i for i in range(N)]

def ans_print(ans_list):
    ans = list()
    for a in ans_list:
        ans.append(chr(a+97)) #97でaが出る

    print(''.join(map(str, ans)))
    return 0

while 1:
    ans_print(ans)
    
    ans[-1] += 1

    for i in range(N-1,0,-1):
        if ans[i] > ans[i-1]+1:
            ans[i-1] += 1
            ans[i] = 0
            
    if ans == stop:
        ans_print(ans)
        break

Submission status: Runtime Error

Solution code:
n = int(input())

def dfs(s, mx):
    if len(s) == n:
        print(s)
    else:
        for i in range(0, mx +1):
            c = chr(ord('a')+i)
            dfs(s+c, mx +1) if i == mx else dfs(s+c, mx)

df('', 0)

Submission status: Runtime Error

Solution code:

N = int(input())

alphabet = "abcdefghijklmnopqrstuvwxyz"

curr_str = []

def print_str(curr_str):
    string = ""
    for i in curr_str:
        string += alphabet[i]
    print(string)


def dfs(index, curr_str, curr_char):
    if curr_char > index:
        return None
    if curr_char > max(curr_str) + 1:
        return None

    if index == N-1:
        print_str(curr_str + [curr_char])
        return None

    for i in range(N):
        dfs(index+1, curr_str+[curr_char], i)

for i in range(N):
    dfs(1, [0], i)

Submission status: Runtime Error

Solution code:
# パナソニック2020D
import sys
def write(x):
	sys.stdout.write(x)
    sys.stdout.write("\n")
    
from queue import deque
n = int(input())
q = deque([("a", "a")])
while True:
    s, m = q.pop()
    if len(s)==n:
        write(s)
    elif len(s)>=n+1:
        break
    for o in range(ord("a"), ord(m)+2):
        if ord(m)<o:
            m = chr(o)
        q.appendleft((s + chr(o), m))

Submission status: Runtime Error

Solution code:
import sys
sys.setmaxrecursion(100000000)
def dfs(s,n,m,subs):
  if len(subs)==n:
    print(subs)
    return

  for i in range(m+1):
    t = "".join((subs,s[i]))
    dfs(s,n,i+1,t)

s = "abcdefghij"

n = int(input())
s = list(s[:n])
dfs(s,n,1,"a")

Submission status: Runtime Error

Solution code:
from collections import deque
 
n = int(input())
 
def dfs(n):
  stack = deque()
  stack.append("a")
  while stack:
    q = stack.popleft()
    if len(q) == n:
      ans.append(q) 
    if len(q) < n:
      for i in range(ord("a"), ord(max(q)) + 2):
        stack.append(q + chr(i))
    print(stack)
    
ans = []
dfs(n)
 
print("\n".join(ans))

Submission status: Runtime Error

Solution code:
N = int(input())

def standard_string(N, st):
  if st = "":
    standard_string(N, "a")
  if len(st) == N:
    print(st)
    return 
  for i in range(97, ord(st[-1])+ 1):
    st += char(i)
    standard_string(N, st)
    st = st[:-1]
standard_string(N, "")

Submission status: Runtime Error

Solution code:
N=int(input())
A=[a]
if N==1:
    print("a")
    exit()
else:
    S=abcdefghijklmn
    slist=list(S) 
    for i in range(2,N+1):
        temp=[[]*N]
        for j in range(i-1):
            for w in A[j]:
                for u in slist[:j+1]:
                    temp[j].append(w+u)
                temp[j+1].append(w+slist[j+1])
        A=temp
    for j in range(N):
        for t in A[j]:
            print(t)

Submission status: Runtime Error

Solution code:
from string import ascii_lowercase
n = int(input())
d = {s: i for i, s in enumerate(ascii_lowercase)}
a = [s for s, i in d.items()]
ans = []

def dfs(k, s):
    if n == k:
        ans.append(s)
    elif n > k:
        for i in range(max([d[c] for c in s])+2):
            v = s + a[i]
            dfs(k+1, v)
dfs(1,"a")
ans.sort()
for k in range(len(ans)):
    print(ans[k])

Submission status: Runtime Error

Solution code:
N=int(input())
A=["a"]
S="abcdefghijklmn"
for i in range(N-1):
    B=[]
    for a in A:
        for s in S[:len(set(a))+1]:
            B.append(a+s)
print("\n".join(B))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
     
using namespace std;
typedef long long ll;
const int tmax=3010;
const int nmax=3010; 
long DP[nmax][tmax];
int a[nmax],b[nmax];
char word[tmax];

int N;

void DFS(ll level){
    char climit =(char)'a';
    for (ll i=0; i< level; i++){
        climit = climit > (word[i]+1) ? climit : (word[i]+1);
    }
    for(char j='a'; j<= climit; j++){
        word[level] = j;
        if(level + 1 == N){
            word[level+1]='\0';
            cout << word << endl;
        } else
        {
            DFS(level + 1);
        }
    }
}


void solve(void){
    // cout << N << endl;  
    DFS(0);   
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    solve();
    
}

Submission status: Runtime Error

Solution code:
from itertools import combinations
def g(i):
    return chr(i+96)
def f(n,i):
    global Ind
    if n==0:
        B.append("".join(A))
        return
    if n==1:
        j = Ind.pop()
        A[j] = g(i)
        B.append("".join(A))
        A[j]=0
        Ind.append(j)
        Ind = sorted(Ind)
        return
    j = Ind.pop(0)
    A[j] = g(i)
    for k in range(n):
        for x in combinations(Ind,n-1-k):
            tmp = []
            for j in range(n-1-k):
                A[x[j]] = g(i)
                tmp.append(x[j])
            for j in tmp:
                Ind.remove(j)
            f(k,i+1)
            for j in tmp:
                A[j] = 0
                Ind.append(j)
            Ind = sorted(Ind)
    
N = int(input())
A = [0 for _ in range(N)]
Ind = list(range(N))
B = []
f(N,1)
B = sorted(B)
for b in B:
    print(b)

Submission status: Runtime Error

Solution code:
def resolve():
    '''
    code here
    '''
    import math
    a, b, c = [int(item) for item in input().split()]
    
    x = c - a - b
    y = 2 * math.sqrt(a) * math.sqrt(b)

    if y < x:
        print('Yes')
    else:
        print('No')




if __name__ == "__main__":
    resolve()

Submission status: Runtime Error

Solution code:
def resolve():
    '''
    code here
    '''
    import math
    a, b, c = [int(item) for item in input().split()]
    
    x = c - a - b
    y = 2 * math.sqrt(a*b)

    if y < x:
        print('Yes')
    else:
        print('No')




if __name__ == "__main__":
    resolve()

Submission status: Runtime Error

Solution code:
from collections import deque
n = int(input())

num_to_alp = {0:'a', 1:'b', 2:'c', 3:'d', 4:'e', 5:'f', 6:'g', 7:'h', 8:'i', 9:'j'}
alp_to_num = {'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5, 'g':6, 'h':7, 'i':8, 'j':9}
words = deque([deque([0])])

def next_letters(x):
    letters = deque([])
    for i in range(x + 2):
        letters.append(i)
    return letters

while len(words[0]) < n:
    word = words.popleft()
    letters = next_letters(max(word[-1], max(word) - 1))
    for l in letters:
        l = deque([l])
        words.append(word + l)

for word in words:
    word = [num_to_alp[i] for i in word]
    print(''.join(word))

Submission status: Runtime Error

Solution code:
n = int(input())

before = ["1"]
for i in range(n-1):
    next = []
    for elem in before:
        m = 1
        for j in range(len(elem)):
            m = max(m, int(elem[j]))
        for j in range(m+1):
            next.append(elem+str(j+1))
    before = next[:]

before.sort()
d = {"1":"a", "2":"b", "3":"c", "4":"d", "5":"e", "6":"f", "7":"g", "8":"h", "9":"i", "10":"j"}
for elem in before:
    ans = []
    for i in range(len(elem)):
        ans.append(d[elem[i]])
    print("".join(ans))

Submission status: Runtime Error

Solution code:
'''alpha10=["a","b","c","d","e","f","g","h","i","j"]
N=int(input())
answers=[[] for i in range(10)]
answers[0].append("0")
print(answers)
for i in range(9):
    for befans in answers[i]:
        answers[i+1].append("0"+befans)'''
'''import sys
n=int(input())
points=[["0","0","0"]]
for i in range(n):
    points.append(input().rstrip().split(" "))
print(points)
for i in range(n):
    delx=int(points[i+1][1])-int(points[i][1])
    dely=int(points[i+1][2])-int(points[i][2])
    delt=int(points[i+1][0])-int(points[i][0])
    if delx+dely>delt or (delt-delx-dely)%2==1:
	    print("No")
    	sys.exit()
print("Yes")'''
import sys
n=int(input())
points=[["0","0","0"]]
for i in range(n):
    points.append(input().rstrip().split(" "))
#print(points)
for i in range(n):
    delx=int(points[i+1][1])-int(points[i][1])
    dely=int(points[i+1][2])-int(points[i][2])
    delt=int(points[i+1][0])-int(points[i][0])
    if abs(delx)+abs(dely)>delt or (delt-delx-dely)%2==1:
        print("No")
        sys.exit()
print("Yes")

Submission status: Runtime Error

Solution code:
import copy

n = int(input())
#res = []
table = ['a']

def dfs(s, time, table):
    tab = copy.deepcopy(table)
    l = len(tab)
    mi = ord(s[0])
    for i in range(time):
        if mi < ord(s[i]):
            mi = ord(s[i])
            if s[i] in tab:
                 pass
            else:
                tab.append(s[i])
    mi += 1
    
    if time == n:
        #print(tab)
        if s in res:
            pass
        else:
            #res.append(s)
            print(s)
    else:
        #dfs(s+chr(mi), time+1, tab)
        for i in range(l):
            dfs(s+tab[i], time+1, tab)
        dfs(s+chr(mi), time+1, tab)
            
dfs('a', 1, table)

#res.sort()
#for i in range(len(res)):
#    print(res[i])

Submission status: Runtime Error

Solution code:
import copy

n = int(input())
#res = []
table = ['a']

def dfs(s, time, table):
    tab = copy.deepcopy(table)
    l = len(tab)
    mi = ord(s[0])
    for i in range(time):
        if mi < ord(s[i]):
            mi = ord(s[i])
            if s[i] in tab:
                 pass
            else:
                tab.append(s[i])
    mi += 1
    
    if time == n:
        #print(tab)
        if s in res:
            pass
        else:
            #res.append(s)
            print(s)
    else:
        #dfs(s+chr(mi), time+1, tab)
        for i in range(l):
            dfs(s+tab[i], time+1, tab)
        dfs(s+chr(mi), time+1, tab)
            
dfs('a', 1, table)

Submission status: Runtime Error

Solution code:
n=int(input())
alph=[a,b,c,d,e,f,g,h,i,j]
ans=[[""]*n]
ans[0]=["a"]
for i in range(n-1):
  for j in range(i+1):
	  for stri in ans[j-1]:
    	  ans[j].append(stri+alph[j])
 #squreen
print(*ans[n-1],sep='/n')

Submission status: Runtime Error

Solution code:
# D
import itertools
from scipy.special import comb
N = int(input())
ans_list = []
K = 0
for i in range(N):
    perm_list = ['a'] * (N - 1 - i)
    perm_list += ['x'] * (i)
    tmp_list = []
    al = [chr(ord('b') + j) for j in range(i)]

    K += comb(N-1, i)

    for v in itertools.permutations(perm_list, len(perm_list)):
        tmp = 'a'
        for j in range(len(perm_list)):
            tmp += v[j]
        tmp_list.append(tmp)
    tmp_list = list(set(tmp_list))
    
    n = len(tmp_list)
    for j in range(n):
        cnt = 0
        for k in range(N):
            if tmp_list[j][k] == "x":
                tmp_list[j] = tmp_list[j].replace("x", al[cnt], 1)
                cnt += 1
        ans_list.append(tmp_list[j])
ans_list.sort()
K = int(K)
for i in range(K):
    print(ans_list[i])

Submission status: Runtime Error

Solution code:
def gen_pattern(N, pre=b""):
  for c in range(0x61, max(pre or 0x60)+2):
    pat = pre+c
    if len(pat) == N:
      yield pat.decode()
    else:
      yield from gen_pattern(N, pat)

for pattern in gen_pattern(int(input())):
  print(pattern)

Submission status: Runtime Error

Solution code:
from string import ascii_lowercase as alph

def gen_pattern(N, pre="", m=-1):
  for i, c in enumerate(alph[:m+2]):
    pat = pre+c
    if len(pattern) == N:
      yield pattern
    else:
      yield from gen_pattern(N, pat, max(i,m))

for pattern in gen_pattern(int(input())):
  print(pattern)

Submission status: Runtime Error

Solution code:
from string import ascii_lowercase as alph

def gen_pattern(N, pre=""):
  for c in alp[:(ord(max(pre or "\x60"))-0x5f]:
    pattern = pre+c
    if len(pattern) == N:
      yield pattern
    else:
      yield from gen_pattern(N, pattern)

for pattern in gen_pattern(int(input())):
  print(pattern)

Submission status: Runtime Error

Solution code:
N=int(input())
S="a"
bottom=""
alpha="abcdefghijklmnopqrstuvwxyz"

for i in range(N):
    if i>25:
        bottom=bottom+"z"
    else:
        bottom=bottom+alpha[i]
    S=S+"a"
print(bottom)

C=0
S=""
def F(S,loop,N,C):
    for i in range(0,loop):
        if N==C+1:
            print(S+bottom[i])
        else:
            F(S+bottom[i],i+2,L,C+1)
    return None
            
F(S,1,L,C)

Submission status: Runtime Error

Solution code:
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

//typedef
//------------------------------------------
using LL = int64_t;
using VL = vector<LL>;
using VVL = vector<VL>;
using VS = vector<string>;
using PLL = pair<LL, LL>;

//container util
//------------------------------------------
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define EACH(i,c) for(decltype((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) whole(sort, c)
#define RSORT(c) rwhole(sort, c)

//constant
//--------------------------------------------
constexpr double EPS = 1e-10;
constexpr double PI  = M_PI;
constexpr int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
// declaretion
template<typename T> istream& operator >>(istream& is, vector<T>& vec);
template<typename T1, typename T2> ostream& operator <<(ostream& os, const pair<T1, T2>& p);
template<typename T> ostream& operator <<(ostream& os, const vector<T>& vec);
template<typename T> ostream& operator <<(ostream& os, const vector<vector<T>>& vv);
template<typename T> vector<T> make_v(size_t a);
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts);
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v);
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v);

// implementation
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
	for(T& x: vec) is >> x;
	return is;
}
template<typename T1, typename T2>
ostream& operator <<(ostream& os, const pair<T1, T2>& p) {
	os << p.first << "," << p.second;
	return os;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
	for(int i=0; i<vec.size(); i++){
		os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
	}
	return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

template<class T,class U> void chmax(T&a,U b){if(a<b)a=b;}
template<class T,class U> void chmin(T&a,U b){if(b<a)a=b;}
template<typename T> T gcd(T a, T b) { return b?gcd(b,a%b):a;}
template<typename T> T lcm(T a, T b) { return a/gcd(a,b)*b;}

//main code
int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	auto dfs = [&](auto&& dfs, int d, string s) ->void{
		s += 'a';
		if (d == n-1) {
			for (int i = 0; i < n; i++) {
				cout << s << '\n';
				s[d]++;
			}
			return;
		}
		for (int i = 0; i < d+1; i++) {
			dfs(dfs, d+1, s);
			s[d]++;
		}
	};
	dfs(dfs, 0, "");
	return 0;
}

Submission status: Runtime Error

Solution code:
n = int(input())

def dfs(str s):
  if len(s) == n:
    print(s)
  else:
    for i in range(int(s[len(s) - 1] - 'a')):
      dfs(s)

Submission status: Runtime Error

Solution code:
from collections import deque
n=int(input())
al=[chr(ord('a') + i) for i in range(26)]
norm=defaultdict(list)
for i in range(11):
  if i==0:
    norm[1]=['a']
  else:
    for char in norm[i-1]:
      last=char[-1]
      range_digit=al.index(last)+2
      for s in al[0:range_digit]:
        norm[i].append(char+s)

for char in norm[n]:
  print(char)

Submission status: Runtime Error

Solution code:
N = int(input())

answer = [(97, 'a')]
for _ in range(N - 1):
    new_answer = []
    for i, j in answer:
        for k in range(97, i + 1):
            new_answer.append((k, j + chr(k)))
        new_answer.append((i+1,j+chr(i+1))
    answer = new_answer[:]

answer = [j for _, j in answer]
answer.sort()
print('\n'.join(answer))

Submission status: Runtime Error

Solution code:
n=int(input())
def d(s):
    if len(s)==n:print(s)
    else:for i in range(97,ord(max(s))+2):d(s+chr(i))
d("a")

Submission status: Runtime Error

Solution code:
N = input()
def DFS(s, mx):
    if len(s) == N:
        print(s)
        return
    c = 'a'
    while c <= chr(ord(mx)+1):
        t = s + c
        DFS(t, chr(max(ord(c), ord(mx))))
        c = chr(ord(c) + 1)
DFS("", chr(ord('a')-1))

Submission status: Runtime Error

Solution code:
def DFS(s, mx):
    if len(s) == N:
        print(s)
        return
    c = 'a'
    while c <= chr(ord(mx)+1):
        t = s + c
        DFS(t, chr(max(ord(c), ord(mx))))
        c = chr(ord(c) + 1)
DFS("", chr(ord('a')-1))

Submission status: Runtime Error

Solution code:
q = deque()

q.append('a')

n = int(input())

ans_list = []

if n != 1:
    for i in range(n-1):
        for j in range(2**i):
            s = q.pop()
            a = list(s)
            b = s + chr(ord(a[len(a)-1]))
            q.appendleft(b)
            if i == n-2:
                ans_list.append(b)
            c = s + chr(ord(a[len(a)-1])+1)
            q.appendleft(c)
            if i == n-2:
                ans_list.append(c)
else:
    ans_list = ['a']

ans_list = sorted(ans_list)

for i in range(len(ans_list)):
    print(ans_list[i])

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**8)
N=int(input())
abc=list("abcdefghi")
def dfs(s,v):
    global N
    for i in range(v+2):
        ns=s+abc[i]
        if len(ns)<N :
            if i!=v+1:
                dfs(ns,v)
            else:
                dfs(ns,v+1)
        if len(ns)==N:
            print("".join(ns))
if N==1:
    print("a")
else:
    dfs("a",0)

Submission status: Runtime Error

Solution code:
N=int(input())
abc=list("abcdefghi")
def dfs(s,v):
    global N
    for i in range(v+2):
        ns=s+abc[i]
        if len(ns)<N :
            if i!=v+1:
                dfs(ns,v)
            else:
                dfs(ns,v+1)
        if len(ns)==N:
            print("".join(ns))
if N==1:
    print("a")
else:
    dfs("a",0)

Submission status: Runtime Error

Solution code:
#=============================================================================
# パナソニックコンテスト D
#=============================================================================
N=int(input())
ans=[]

def dfs(s):
    global N
    for i in range(max(s)+2):
        ns=s+[i]
        if len(ns)!=N:
            dfs(ns)
        if len(ns)>N:
            continue
        if len(ns)==N and ns not in ans:
            ans.append(ns)
s=[0]
dfs(s)
abc=list("abcdefghi")
ans.sort()
for item in ans:
    for i in range(N):
        item[i]=abc[item[i]]
    print("".join(item))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int n;
string ans;

void gen(char c)
{
	if(ans.size() == n)
		printf("%s\n", ans.c_str());
	else
	{
		for(char a = 'a'; a <= c; a++)
		{
			ans.push_back(a);
			gen(a == c ? c + 1 : c);
			ans.pop_back();
		}		
	}	
}

int main ()
{
	cin >> n;
	gen('a');
	return 0;
}

Submission status: Runtime Error

Solution code:
N=int(input())
ABC=["A","B","C","D","E","F","G","H","I",,"J"]
def dfs(n,s):
  if len(s)==N:
    print(s)
    return
  
  for i in range(n+1):
    _s=s+ABC[i]
    dfs(max(n,i+1),_s)
    
dfs(0,"")

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << endl
#define print10(ele) cout << fixed << setprecision(10) << (ele) << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int n;
void dfs(string s, char mx) {
  if (s.size() == n) {
    print(s);
    return;
  }
  for (char c = 'a'; c <= mx + 1; c++) {
    string t = s;
    t += c;
    dfs(t, max(mx, c));
  }
}

int main() {
  cin >> n;
  dfs("", 'a' - 1);
  print(n);
  return 0;
}

Submission status: Runtime Error

Solution code:
class Solution:
    def solve(self, H: int, W: int) -> int:

        if H == 1 or W == 1:
            return 1
        else:
            return (H*W + 1) // 2


if __name__ == '__main__':

    # standard input
    H, W = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(H, W))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N;

void dfs(string s, char mx){
	if(s.length() == N){
		printf("%s\n", s.c_str());
	}
	else{
		for(char c = 'a'; c <= mx; c++){
			dfs(s + c, ((c == mx)? (char)(mx + 1) : mx));
		}
	}
}

int main(void){
	cin >> N;

	dfs("",'a');

	return 0;
}

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N;

void dfs(string s, char mx){
	if(s.length() == N){
		printf("%s\n", s.c_str());
	}
	else{
		for(char c = 'a'; c <= mx; c++){
			dfs(s + c, ((c == mx)? (char)(mx + 1) : mx));
		}
	}
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	// ここに処理を記述

	cin >> N;

	dfs("",'a');

	return 0;
}

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N;

void dfs(string s, char mx){
	if(s.length() == N){
		printf("%s\n", s.c_str());
	}
	else{
		for(char c = 'a'; c <= mx; c++){
			dfs(s + c, ((c == mx)? (char)(mx + 1) : mx));
		}
	}
}

int main(void){
	#define int ll
	cin.tie(0);
	ios::sync_with_stdio(false);
	// ここに処理を記述

	cin >> N;

	dfs("",'a');

	return 0;
}