input stringlengths 20 127k | target stringlengths 20 119k | problem_id stringlengths 6 6 |
|---|---|---|
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemge... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemge... | p02744 |
n = int(eval(input()))
alphabet = 'abcdefghij'
s = [-1 for i in range(n)]
lst = [[] for i in range(n)]
lst[0].append(0)
ind = 0
while lst[ind] != [] or ind > 0:
if ind < n-1 and lst[ind] != []:
s[ind] = lst[ind].pop()
for i in range(max(s)+1, -1, -1):
lst[ind+1].append(i)
... | n = int(eval(input()))
if n == 1:
print('a')
exit()
lst = ['a']
for i in range(n-1):
new_lst = []
for string in lst:
num = ord(sorted(string)[-1])
for j in range(ord('a'), num+2):
new_lst.append(string+chr(j))
lst = new_lst
for string in lst:
print(... | p02744 |
def main():
from string import ascii_lowercase
dic = {i: s for i, s in enumerate(ascii_lowercase)}
N = int(eval(input()))
ans = []
def dfs(s, mx):
if len(s) == N:
print(s)
return
else:
for i in range(mx+2):
v = s + dic[... | def main():
from string import ascii_lowercase
dic = {i: s for i, s in enumerate(ascii_lowercase)}
N = int(input())
ans = []
def dfs(s, mx):
if len(s) == N:
ans.append(s)
return
else:
for i in range(mx+2):
v = s + dic[i... | p02744 |
def main():
from string import ascii_lowercase
dic = {i: s for i, s in enumerate(ascii_lowercase)}
N = int(input())
ans = []
def dfs(s, mx):
if len(s) == N:
ans.append(s)
return
else:
for i in range(mx+2):
mx = max(mx, ... | def main():
from string import ascii_lowercase
N = int(eval(input()))
ascii_dic = {i: a for i, a in enumerate(ascii_lowercase)}
ascii_rdic = {a: i for i, a in enumerate(ascii_lowercase)}
# ans = []
def dfs(A):
if len(A) == N:
# ans.append("".join(A))
pr... | p02744 |
N = int(eval(input()))
#文字数分aで埋める
#末尾をbにする
#一桁上の文字+1文字までは許容するルールで増加させていく
import itertools
stop_combination = [chr(i) for i in range(97,97+N)]
combination_list = list(itertools.product(stop_combination, repeat=N))
printed_expression = set()
for combination in combination_list:
#print(combination,"... | N = int(eval(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
def ans_check(a... | p02744 |
N = int(input())
def it(remain,n):
if remain == 0:
yield []
else:
for x in range(n+1):
for d in it(remain-1,max(x+1,n)):
d.append(x)
yield d
print(*(''.join(chr(x+ord('a')) for x in reversed(d)) for d in it(N,0)), sep='\n')
| N = int(input())
def it(i,n):
if i == N:
yield [None]*N
else:
for x in range(n):
for d in it(i+1,n):
d[i] = x
yield d
for d in it(i+1,n+1):
d[i] = n
yield d
print(*(''.join(chr(x+ord('a')) for x in d) for... | p02744 |
N = int(eval(input()))
k = "abcdefghij"
A = []
Q = [(1,1,"a")]
while Q:
q = Q.pop()
if q[0]==N:
A.append(q[2])
continue
for i in range(q[1]+1):
Q.append((q[0]+1,max(q[1],i+1),q[2]+k[i]))
A.sort()
for a in A:print(a) | N = int(eval(input()))
S = "abcdefghijklmn"
Q = [(1,1,"a")]
A = []
while Q:
q = Q.pop(-1)
if q[0]==N:
A.append(q[2])
continue
for i in range(q[1]+1):
Q.append((q[0]+1,max(q[1],i+1),q[2]+S[i]))
for a in sorted(A):print(a) | p02744 |
def dfs(string,n):
if len(string)==n:
print(string)
else:
s=string
for i in range(97,max([ord(j)for j in string])+2):
dfs(string+chr(i),n)
dfs("a",int(eval(input()))) | n=int(eval(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")
| p02744 |
k = "a",
for _ in range(int(input()) - 1):
k = {a + b for a in k for b in a + chr(ord(max(a)) + 1)}
print(*sorted(k), sep='\n')
| k = "a",
for _ in range(int(eval(input())) - 1):
k = {a + b for a in k for b in a + chr(ord(max(a)) + 1)}
for i in sorted(k):print(i) | p02744 |
# D
N = int(eval(input()))
al = [chr(ord('a') + i) for i 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 + [al[j]], i):
yield w
for w in dfs(S + [al[i]], i + 1):
yield w
for w in dfs([], 0):
... | # D
N = int(eval(input()))
al = [chr(ord('a') + i) for i in range(26)]
def dfs(S, i):
if len(S) == N:
yield S
return
for j in range(i):
for w in dfs(S + al[j], i):
yield w
for w in dfs(S + al[i], i + 1):
yield w
for w in dfs('', 0):
print(w) | p02744 |
# D
N = int(eval(input()))
al = [chr(ord('a') + i) for i in range(26)]
def dfs(S, i):
if len(S) == N:
yield S
return
for j in range(i):
for w in dfs(S + al[j], i):
yield w
for w in dfs(S + al[i], i + 1):
yield w
for w in dfs('', 0):
print(w) | # D
N = int(eval(input()))
al = [chr(ord('a') + i) for i in range(26)]
ans = ['a']
for i in range(N-1):
tmp = []
for s in ans:
stop = ord(max(s)) + 1
for i in range(ord('a'), stop+1):
tmp.append(s + chr(i))
ans = tmp
for s in ans:
print(s) | p02744 |
import sys
def I(): return int(sys.stdin.readline())
def MI(): return list(map(int, sys.stdin.readline().split()))
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
s = 'abcdefghijklmnop'
N = I()
for c1 in range(1):
if N == 1:
print((s[c1]))
... | import sys
def I(): return int(sys.stdin.readline())
def MI(): return list(map(int, sys.stdin.readline().split()))
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
s = 'abcdefghijklmnop'
N = I()
def f(n, seq, m):
for i in range(m + 1):
if n == N:
... | p02744 |
n = int(input())
A= 'a'
# 文字数を増やして, その各々の元に対して文字を追加する.
for _ in range(n - 1):
A = {a + s for a in A for s in a + chr(ord(max(a)) + 1)}
# print(A)
# 最後にsortして調整する.
#print(*A, sep = '\n')
print(*sorted(A), sep='\n')
| n = int(eval(input()))
A = ['a']
S = 'abcdefghij'
for _ in range(n-1):
B = []
for a in A:
for s in S[:len(set(a)) + 1]:
B.append(a + s)
A = B[::]
print(('\n'.join(A))) | p02744 |
n = int(eval(input()))
A = ['a']
S = 'abcdefghij'
for _ in range(n-1):
B = []
for a in A:
for s in S[:len(set(a)) + 1]:
B.append(a + s)
A = B[::]
print(('\n'.join(A))) | n = int(eval(input()))
A = ['a']
S = 'abcdefghij'
for _ in range(n-1):
A = [ a + s for a in A for s in S[:len(set(a)) + 1]]
print(('\n'.join(A))) | p02744 |
n = int(input())
A = 'a'
S ='abcdefghij'
for _ in range(n-1):
A = [a + s for a in A for s in S[:len(set(a))+1]]
print(*A, sep='\n')
| n = int(eval(input()))
A = 'a'
S = 'abcdefghij'
for _ in range(n-1):
A = [ a + s for a in A for s in S[:len(set(a)) + 1]]
print(('\n'.join(A))) | p02744 |
import sys
import time
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(eval(input()))
groups = []
def dfs(s, n):
if n == N:
bits = [-1] * N
for i, ss in enumerate(s):
if bits[i] != -1:
continue
for ii in range(i+1, N):
... | import sys
import time
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(eval(input()))
def dfs(s, n, m):
if n > N:
print((''.join([chr(ss) for ss in s])))
return True
for ns in range(97, m+2):
s[n-1] = ns
dfs(s, n+1, max(m, ns))
s = [0] * N
dfs(s... | p02744 |
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
N = INT()
import itertools
import collections
alphabet = 'abcdefghijklmnopqrstuvwxyz'
a_set = set()
for w in itertools.product(list(range(N)), repeat=N):
# print... | # https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_d
N = int(eval(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... | p02744 |
N = int(eval(input()))
a_num = 97
def dfs(s, n): #s: 現在の文字列, n: 残りの文字数, cnt: 現在の文字列の最大の値
if n == 0:
print(s)
return
for i in range(ord("a"), ord(max(s))+2):
dfs(s+chr(i), n-1)
dfs("a", N-1)
| N = int(eval(input()))
a_num = 97
def dfs(s, n, cnt): #s: 現在の文字列, n: 残りの文字数, cnt: 現在の文字列の最大の値
if n == 0:
print(s)
return
for i in range(cnt+2):
if i == cnt+1:
dfs(s+chr(a_num+i), n-1, cnt+1)
else:
dfs(s+chr(a_num+i), n-1, cnt)
dfs("a", N-1... | p02744 |
N = int(eval(input()))-1
dic={}
ans=[]
#N=1
dic['a']=1
ans.append('a')
alp = ['a','b','c','d','e','f','g','h','i','j','k']
for i in range(N):
ans_temp = ans
dic_temp = dic
#init for N
ans = []
dic={}
#left a
for j in ans_temp:
new_j = 'a'+ j
ans.append... | N = int(eval(input()))-1
dic={}
ans=[]
#N=1
dic['a']=1
ans.append('a')
alp = ['a','b','c','d','e','f','g','h','i','j','k']
for i in range(N):
ans_temp = ans
dic_temp = dic
#init for N
ans = []
dic={}
dic_count={}
#left a
for j in ans_temp:
new_j = 'a'+ j
... | p02744 |
#
# panasonic2020b d
#
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)
... | #
# panasonic2020b d
#
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)
... | p02744 |
alps = 'abcdefghijklmnopqrstuvwxyz'
def dfs(last, curr_s, sl, n):
if len(curr_s) == n:
sl.append(curr_s)
return
for i in range(0,last+2):
s = curr_s + alps[i]
dfs( max(last,i), s, sl, n )
def main():
n = int(eval(input()))
sl = []
dfs(0, 'a', sl, n)
... | alps = 'abcdefghijklmnopqrstuvwxyz'
def dfs(last, curr_s, sl, n):
if len(curr_s) == n:
sl.append(curr_s)
return
for i in range(0,last+2):
s = curr_s + alps[i]
dfs(max(last,i), s, sl, n)
def main():
n = int(eval(input()))
sl = []
dfs(0, 'a', sl, n)
... | p02744 |
from copy import deepcopy
def f(num,N,S):
alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t"]
if N == num:
S.sort()
for i in range(len(S)):
print((S[i]))
return
else:
tmp = []
length = len(S)
for ... | from copy import deepcopy
def f(num,N,S):
alphabet = ["a","b","c","d","e","f","g","h","i","j"]
if N == num:
for i in range(len(S)):
print((S[i]))
return
else:
tmp = []
length = len(S)
for i in range(length):
ttmp = sorted(list(S[i]))... | p02744 |
from copy import deepcopy
def f(num,N,S):
alphabet = ["a","b","c","d","e","f","g","h","i","j"]
if N == num:
for i in range(len(S)):
print((S[i]))
return
else:
tmp = []
length = len(S)
for i in range(length):
ttmp = sorted(list(S[i]))... | def f(num,N,S):
alphabet = ["a","b","c","d","e","f","g","h","i","j"]
if N == num:
for i in range(len(S)):
print((S[i]))
return
else:
tmp = []
length = len(S)
for i in range(length):
ttmp = sorted(list(S[i]))
for j in rang... | p02744 |
def f(num,N,S):
alphabet = ["a","b","c","d","e","f","g","h","i","j"]
if N == num:
for i in S:
print(i)
return
else:
tmp = []
length = len(S)
for i in S:
ttmp = sorted(list(i))
for j in range(alphabet.index(ttmp[-1])+2):
... | def saiki(n,A):
if n == N:
A.sort()
for i in A:
print(i)
return
alpha = list("abcdefghijklmnopqr")
tmp = []
for i in A:
a = alpha.index(sorted(list(i))[-1])
for j in range(a+2):
tmp.append(i+alpha[j])
saiki(n+1... | p02744 |
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import... | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import... | p02744 |
n=int(eval(input()))
dic={0:'a',1:'b',2:'c',3:'d',4:'e',5:'f',6:'g',7:'h',8:'i',9:'j'}
#標準形の文字列は同型の文字列の中で辞書順最小であることから、新たに付け加えるべき文字は順にa,b,c...となる
ans=[['a',1]]
for i in range(1,n):
tmp=[]
for prev,val in ans:
for j in range(val+1):
#(今見ている文字列に使われている文字の種類数+1)種類の文字を付け加える
if j!=val:
#今見てい... | import sys
sys.setrecursionlimit(100000)
def dfs(s, mx):
if len(s) == N:
print(s)
return 0
for c in range(ord("a"), mx + 2):
t = s
t += chr(c)
dfs(t, max(mx, c))
N = int(eval(input()))
dfs("", ord("a") - 1) | p02744 |
N = int(eval(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)
l.append(s)
return
# if al[:i] == s:
# for c in al[:i+1]:
# func(s + c, i+1)... | N = int(eval(input()))
al = "abcdefghijklmnopqrstuvwxyz"
atoi = {s:i for i, s in enumerate(al)}
def func(s, i):
if i == N:
print(s)
return
maxi = max([atoi[c] for c in s])
for c in al[:maxi+2]:
func(s+c, i+1)
func("a", 1)
| p02744 |
# パナソニック2020D
from queue import deque
n = int(eval(input()))
q = deque([("a", "a")])
while True:
s, m = q.pop()
if len(s)==n:
print(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)... | # パナソニック2020D
import sys
write = lambda x: sys.stdout.write(x+"\n")
from queue import deque
n = int(eval(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:
... | p02744 |
import sys
sys.setrecursionlimit(10**8)
n = int(eval(input()))
def dfs(s, mx):
if len(s) == n:
print(s)
return
for i in range(ord('a'), mx + 2):
t = s
t += chr(i)
mx = max(mx, i)
dfs(t, mx)
return
mx = ord('a')
dfs('a', mx) | import sys
sys.setrecursionlimit(10**8)
n = int(eval(input()))
def dfs(s, mx):
if len(s) == n:
print(s)
return
for i in range(ord('a'), mx + 2):
t = s
t += chr(i)
mxc = mx
mxc = max(mxc, i)
dfs(t, mxc)
return
mx = ord('a')
dfs('a... | p02744 |
# import bisect
# # import heapq
# # from copy import deepcopy
# # from collections import deque
# # from collections import Counter
# # from itertools import accumulate
# # from itertools import permutations
# import numpy as np
# # import math
# a,b,c = map(int, input().split())
n = int(eval(input()))
# p ... | # import bisect
# # import heapq
# # from copy import deepcopy
# # from collections import deque
# # from collections import Counter
# # from itertools import accumulate
# # from itertools import permutations
# import numpy as np
# # import math
# a,b,c = map(int, input().split())
n = int(eval(input()))
# p ... | p02744 |
n = int(eval(input()))
ans = []
def dfs(x):
if len(x) == n:
ans.append(x)
return
for i in range(max(x)+1):
y = x.copy()
y.append(i+1)
dfs(y)
dfs([1])
#print(ans)
for ai in ans:
print((''.join([chr(ord('a') + x - 1) for x in ai])))
#r = ['a','b','c'... | n = int(eval(input()))
ans = []
def dfs(x):
if len(x) == n:
print((''.join([chr(ord('a') + i - 1) for i in x])))
return
for i in range(max(x)+1):
y = x.copy()
y.append(i+1)
dfs(y)
dfs([1])
| p02744 |
n = int(eval(input()))
ans = []
def dfs(x):
if len(x) == n:
print((''.join([chr(ord('a') + i - 1) for i in x])))
return
for i in range(max(x)+1):
y = x.copy()
y.append(i+1)
dfs(y)
dfs([1])
| n = int(eval(input()))
def dfs(x):
if len(x) == n:
print((''.join([chr(ord('a') + i - 1) for i in x])))
return
for i in range(max(x)+1):
y = x.copy()
y.append(i+1)
dfs(y)
dfs([1])
| p02744 |
def main():
from collections import deque
from operator import itemgetter
from string import ascii_lowercase
N = int(input())
deq = deque(), deque()
curr = 0
deq[curr].append(('a', 0)) # (word,largest_char_index)
for _ in range(N - 1):
while deq[curr]:
... | def main():
from string import ascii_lowercase
N = int(input())
ans = []
def dfs(s='a', ma='a'):
if len(s) == N:
ans.append(s)
return
for c in ascii_lowercase:
dfs(s + c, max(c, ma))
if c > ma: break
dfs()
pr... | p02744 |
n = int(eval(input()))
a1 = list("abcdefghij")
n1 = 0
for i in range(n):
n1 += (n-1)*(10**i)
for i in range(n1 + 1):
b = list(map(int, list( str(i).zfill(n) )))
c = [j < n for j in b]
if not (all(c)):
continue
else:
e = set()
f = True
g = 0
f... | n = int(eval(input()))
a1 = list("abcdefghij")
b1 = [[0]]
c1 = 1
ans = []
while c1 < n:
c1 += 1
b2 = b1 + []
b1 = []
for i in b2:
imax = max(i)
for j in range(imax+2):
b1.append(i+[j])
for i in b1:
ans = [a1[j] for j in i]
print(("".join(ans))) | p02744 |
def f(n, count=0, i=0, lst=[]):
global ans
if count == n:
s = ""
for j in range(count):
s += chr(ord("a") + lst[j])
ans.append(s)
return
if i == 0:
lst.append(i)
f(n, count + 1, i=i+1, lst=lst)
else:
for j in range(i + 1):
... | def f(n, count=0, i=0, s=""):
global ans
if count == n:
ans.append(s)
return
if i == 0:
f(n, count + 1, i=i+1, s=s+"a")
else:
for j in range(i + 1):
f(n, count + 1, i=max(i, j + 1), s=s+chr(ord("a") + j))
import sys
sys.setrecursionlimit(10000)
n... | p02744 |
# -*- coding: utf-8 -*-
import sys
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 ... | # -*- coding: utf-8 -*-
import sys
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 ... | p02744 |
import collections
N = int(eval(input()))
S = "abcdefghij"
result = []
deq = collections.deque(["a"])
while deq:
s = deq.popleft()
if len(s) == N:
result.append(s)
continue
else:
for i in S[:len(set(s))+1]:
deq.append(s + i)
print(('\n'.join(result))) | import collections
def bfs(N):
S = "abcdefghij"
result = []
deq = collections.deque(["a"])
while deq:
s = deq.popleft()
if len(s) == N:
result.append(s)
continue
else:
for i in S[:len(set(s))+1]:
deq.append(s + i... | p02744 |
import sys
input = sys.stdin.readline
n = int(eval(input()))
s = ["a"]
ord_a = ord("a")
ans = []
from copy import deepcopy
def dfs(s):
if len(s) == n:
ans.append("".join(s))
return
max_ord = 0
for i in s:
max_ord = max(max_ord, ord(i) - ord_a)
for j in range(ma... | import sys
input = sys.stdin.readline
n = int(eval(input()))
s = ["a"]
ord_a = ord("a")
ans = []
def dfs(s):
if len(s) == n:
ans.append("".join(s))
return
max_ord = 0
for i in s:
max_ord = max(max_ord, ord(i) - ord_a)
for j in range(max_ord + 2):
new_... | p02744 |
# coding: utf-8
# Your code here!
def solv1():
n=int(eval(input()))
a=[[]for i in range(n)]
a[0]=[[0]]
for i in range(n-1):
b=[]
for pa in a[i]:
# print(pa)
el=[j for j in set(pa)]
# print(el)
el.append(max(pa)+1)
... | # coding: utf-8
# Your code here!
def solv1():
n=int(eval(input()))
a=[[]for i in range(n)]
a[0]=[[0]]
for i in range(n-1):
b=[]
for pa in a[i]:
# print(pa)
el=[j for j in set(pa)]
# print(el)
el.append(max(pa)+1)
... | p02744 |
def examA():
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = I()
ans = L[K-1]
print(ans)
return
def examB():
H, W = LI()
if H==1 or W==1:
print((1))
return
ans = H*W//2 + (H*W)%2
print(ans)
... | def examA():
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = I()
ans = L[K-1]
print(ans)
return
def examB():
H, W = LI()
if H==1 or W==1:
print((1))
return
ans = H*W//2 + (H*W)%2
print(ans)
... | p02744 |
from collections import deque
D1 = {i:chr(i+96) for i in range(1,27)}
D2 = {val:key for key,val in list(D1.items())}
N = int(eval(input()))
heap = deque([(D1[1],1)])
A = []
while heap:
a,n = heap.popleft()
if n<N:
imax = 0
for i in range(len(a)):
imax = max(imax,D2[a[i]]... | from collections import deque
D1 = {i:chr(i+96) for i in range(1,27)}
D2 = {val:key for key,val in list(D1.items())}
N = int(eval(input()))
que = deque([("a",1)])
A = []
while que:
x,n = que.popleft()
if n<N:
imax = 0
for i in range(len(x)):
imax = max(imax,D2[x[i]])
... | p02744 |
import itertools
def solve():
N = int(eval(input()))
alphabets = ['a','b','c','d','e','f','g','h','i','j']
lst = []
dfs(1, N, alphabets[:N],lst, "", 0)
def dfs(depth, N, alphabets, lst, now, mx):
if depth > N:
lst.append(now)
print(now)
return
for i in range(... | def solve():
N = int(eval(input()))
dfs("", 0, N)
def dfs(cur, n_type, N):
if len(cur) == N:
print(cur)
return
for offset in range(n_type+1):
next_chr = chr(ord('a') + offset)
next_n_type = n_type + 1 if offset==n_type else n_type
dfs(cur+next_ch... | p02744 |
import sys
input = lambda: sys.stdin.readline().rstrip()
def resolve():
N = int(eval(input()))
def rec(n, maxchr, ans):
if n==N-1:
print(ans)
else:
for i in range(maxchr+1):
# print(i)
rec(n+1, maxchr, ans+chr(i+97))
... | import sys
input = lambda: sys.stdin.readline().rstrip()
def resolve():
N = int(eval(input()))
def rec(n, maxchr, ans):
if n==N:
print(ans)
else:
for i in range(maxchr):
rec(n+1, maxchr, ans+chr(i+97))
rec(n+1, maxchr+1, ans+... | p02744 |
n = int(eval(input()))
from itertools import product
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
def dfs(ans, i):
if len(ans) == n:
print(("".join(ans)))
return
for j in range(i+1):
dfs(ans+ascii_lowercase[j], max(j+1, i))
dfs("", 0) | n = int(eval(input()))
ansl = []
def dfs(s, max_s):
if len(s) == n:
ansl.append(s)
return
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
for i in range(max_s+1):
dfs(s+ascii_lowercase[i], max(i+1, max_s))
dfs("", 0)
for a in ansl:
print(a) | p02744 |
n = int(eval(input()))
l = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
def dfs(res, i):
if len(res) >= n:
print(res)
return
for k in range(i):
dfs(res+l[k], i)
dfs(res+l[i], i+1)
dfs("", 0) | n = int(eval(input()))
l = "abcdefghij"
def dfs(res, i):
if len(res) >= n:
print(res)
return
for k in range(i):
dfs(res+l[k], i)
dfs(res+l[i], i+1)
dfs("", 0) | p02744 |
#!/usr/bin/env python3
import sys
def solve(N: int):
alph = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
print("a" * N)
for i in range(N - 1, 0, -1):
s = ("a" * i) + "b"
if i == N - 1:
print(s)
continue
r_len = N - 1 - i
for j in r... | #!/usr/bin/env python3
import sys
ALH = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
def solve(N: int):
dfs("", 0, N)
def dfs(s: str, mx: int, N: int):
if len(s) == N:
print(s)
else:
for i in range(mx + 1):
dfs(s + ALH[i], mx + 1 if i == mx else mx, N)
... | p02744 |
import sys
sys.setrecursionlimit(10**8)
alpha = "abcdefghij"
ans = []
N = int(eval(input()))
def get_right(S):
alpha_idx = 0
for i in range(len(S)):
flag = S.find(alpha[i])
if flag > 0:
alpha_idx = i
return alpha_idx + 2
def dfs(S, num):
if len(S) == N:
... | import sys
sys.setrecursionlimit(10**8)
alpha = "abcdefghij"
ans = []
N = int(eval(input()))
def dfs(S, num):
if len(S) == N:
ans.append(S)
else:
right = num + 2
seq = alpha[:right]
for i, c in enumerate(seq):
dfs(S+c, max(i, num))
dfs("a", 0)
ans = ... | p02744 |
import sys
sys.setrecursionlimit(10 ** 6)
N = int(input())
ans = set()
a = ord('a')
def f(c, A, done):
global N, a
B = list(A)
done = set(done)
for i in range(N):
if i not in done:
B[i] = c
done.add(i)
break
if len(done) == N:
... | import sys
sys.setrecursionlimit(10 ** 6)
N = int(input())
ans = []
a = ord('a')
def dfs(S, mx):
global N
if len(S) == N:
ans.append(S)
else:
for c in range(0, mx + 2):
dfs(S + chr(c + a), max(mx, c))
dfs('a', 0)
print(*ans, sep='\n')
| p02744 |
n=int(eval(input()))
ans=[]
def rec(i,s):
if i == n:
ans.append(s)
return True
else:
if len(set(s)) == 1:
rec(i+1,s+"a")
rec(i+1,s+"b")
if len(set(s)) == 2:
rec(i+1,s+"a")
rec(i+1,s+"b")
rec(i+1,s+"c")
... | n=int(eval(input()))
ans=[]
def rec(i,s):
if i == n:
print(s)
return
else:
for j in range(len(set(s)) + 1):
rec(i+1,s+chr(ord("a")+j))
rec(1,"a") | p02744 |
N = int(eval(input()))
def dfs(n,i,s,ans):
if n == N:
ans.append(s)
return
for j in range(i+1):
tmp = s + chr(j + 97)
max_j = ord(max(tmp)) - 96
dfs(n+1,max_j,tmp,ans)
def main():
ans = []
dfs(1,1,'a',ans)
ans.sort()
for a in ... | def num_to_str(n):
return chr(97 + n)
def str_to_num(s):
return ord(s) - 97
def dfs(s,m,n,N,ans):
if n == N:
ans.append(s)
return
for i in range(m+2):
dfs(s+num_to_str(i),max(m,i),n+1,N,ans)
def main():
N = int(eval(input()))
ans = []
dfs('a',0,1,N,... | p02744 |
import sys
sys.setrecursionlimit(10**7)
n = int(eval(input()))
ls = []
def dfs(s):
if len(s) == n:
ls.append(s)
return 0
else:
for x in map(chr, list(range(97, ord(max(s))+2))):
dfs(s+x)
dfs("a")
ls.sort()
for x in ls:
print(x)
| import sys
sys.setrecursionlimit(10**7)
n = int(eval(input()))
def dfs(s):
if len(s) == n:
print(s)
else:
for x in map(chr, list(range(97, ord(max(s))+2))):
dfs(s+x)
dfs("a") | p02744 |
import itertools
n = int(eval(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.product(list(range(1, n+1)), repeat=n):
m = min(v)
used = []
dic = {i:0 for i in range(n+1)}
tmp = ""
... | n = int(eval(input()))
alpha_dict = {}
for i,c in enumerate(range(ord('A'),ord('Z')+1)):
alpha_dict[i] = str(chr(c)).lower()
ans = []
def dfs(s, mx, ans):
if len(s) == n:
ans += [s]
return
else:
for i in range(mx+2):
dfs(s+alpha_dict[i], max(i, mx), ans)
dfs("", -1, ans)
ans ... | p02744 |
import itertools
alp = [chr(ord('a') + i) for i in range(26)]
N = int(eval(input()))
allS = list(itertools.product(alp[0:N], repeat=N))
answers = []
PatternList = []
for s in allS:
pattern = []
letters = []
num = 0
for l in s:
if not(l in letters):
letters.append(l)
... | n = int(eval(input()))
def dfs(s, cn):
if len(s) == n:
print(s)
else:
for i in range(0, cn + 1):
c = chr(ord('a') + i)
if i == cn: dfs(s+c, cn+1)
else: dfs(s+c, cn)
dfs('', 0) | p02744 |
n=int(eval(input()))
char=[chr(i) for i in range(97, 97+26)]
ans=["a"]
before=0
for i in range(2,n+1):
for c in range(len(ans)):
From=char.index(sorted(list(ans[c]))[-1])
for m in range(From+2):
ans.append(ans[c]+char[m])
#print(ans)
b=[]
for g in range(len(ans... | import sys
sys.setrecursionlimit(10**9)
N = int(eval(input()))
def bfs(s, cnt, m):
if cnt == N:
print(s)
return
for i in range(97,ord(m)+2):
if chr(i) > m:
bfs(s+chr(i), cnt+1, chr(i))
else:
bfs(s+chr(i), cnt+1, m)
bfs('a',1,'a') | p02744 |
import sys
sys.setrecursionlimit(10**9)
N = int(eval(input()))
def bfs(s, cnt, m):
if cnt == N:
print(s)
return
for i in range(97,ord(m)+2):
if chr(i) > m:
bfs(s+chr(i), cnt+1, chr(i))
else:
bfs(s+chr(i), cnt+1, m)
bfs('a',1,'a') | def dfs(cnt, s, now):
if cnt == n:
ans.append(s)
return
for i in range(now+1):
dfs(cnt+1, s+al[i], max(i+1, now))
n = int(eval(input()))
ans = []
al = [chr(i) for i in range(97, 97+26)]
dfs(0, "", 0)
for i in ans:
print(i) | p02744 |
n = int(input())
lets = [chr(i) for i in range(ord("a"), ord("a") + n)]
d = {e: i for i, e in enumerate(lets)}
s = ["a"]
for i in range(1, n):
nxt = []
for e in s:
mx = 0
for l in e:
mx = max(mx, d[l])
for j in range(mx + 2):
nxt.append(e + lets[j])
... | n = int(input())
lets = [chr(i) for i in range(ord("a"), ord("z") + 1)]
ans = []
def dfs(s, l, mx):
if l == n:
ans.append(s)
return
for i in range(mx + 2):
dfs(s + lets[i], l + 1, max(mx, i))
dfs("", 0, -1)
print(*ans, sep="\n")
| p02744 |
N=int(eval(input()))
L=['a','b','c','d','e','f','g','h','i','j']
A = [L[0]]
B = [A[0]+L[i] for i in range(2)]
C = [i+L[j] for i in B for j in range(len(set(i))+1)]
D = [i+L[j] for i in C for j in range(len(set(i))+1)]
E = [i+L[j] for i in D for j in range(len(set(i))+1)]
F = [i+L[j] for i in E for j in range(l... | N=int(eval(input()))
L=['a','b','c','d','e','f','g','h','i','j']
Ans = [L[0]]
Backup = []
for k in range(N-1):
Backup = Ans
Ans = [i+L[j] for i in Backup for j in range(len(set(i))+1)]
for i in Ans:
print(i) | p02744 |
def DFS(word,n):
if len(word)==N:
return print(word)
else:
for i in range(n+1):
DFS(word+chr(97+i),n+1 if i==n else n)
N=int(input())
DFS("",0)
| def DFS(word,N):
if len(word)==n:
return print(word)
else:
for i in range(N+1):
DFS(word+chr(97+i),N+1 if i==N else N)
n=int(input())
DFS("",0)
| p02744 |
def f(word,N):
if len(word)==n:
return print(word)
else:
for i in range(N+1):
f(word+chr(97+i),N+1 if i==N else N)
n=int(input())
f("",0)
| def f(word,n):
if len(word)==N:return print(word)
else:
for i in range(n+1):
f(word+chr(97+i),n+1 if i==n else n)
N=int(input())
f("",0)
| p02744 |
n = int(input())
anstmp = ["a"]
cnt = 0
for i in anstmp:
t = ord(i[-1])-95
if cnt > 1000000:
break
for j in range(1,t+1):
anstmp.append(i+chr(j+96))
cnt += 1
ans = set()
for i in anstmp:
if len(i) == n:
ans.add(i)
ans = list(ans)
ans.sort()
print(*ans,sep="\n")
| n = int(input())
anstmp = ["a"]
cnt = 0
for i in anstmp:
t = max(ord(k) for k in i)-95
if cnt > 100000:
break
for j in range(1,t+1):
anstmp.append(i+chr(j+96))
cnt += 1
ans = set()
for i in anstmp:
if len(i) == n:
ans.add(i)
ans = list(ans)
ans.sort()
print(*ans,sep="\n")
| p02744 |
n = int(eval(input()))
d = 'abcdefghijklm'
def conv(s):
s = list([d[x] for x in s])
return ''.join(s)
def dfs(s):
if len(s) == n:
print((conv(s)))
else:
mx = max(s)+1
for i in range(mx+1):
dfs(s+[i])
dfs([0]) | n = int(eval(input()))
d = 'abcdefghijklm'
def conv(s):
s = list([d[x] for x in s])
return ''.join(s)
def dfs(s, k):
if len(s) == n:
print(s)
else:
for i in range(k):
dfs(s+d[i], k)
dfs(s+d[k], k+1)
dfs('a', 1)
| p02744 |
n = int(eval(input()))
s = "abcdefghij"
class Node:
__slots__ = ["string", "index"]
def __init__(self, string, index):
self.string = string
self.index = index
def get_children(self):
parent = self.string
out = [None]*(self.index+1)
for i, c in enumerate(... | class Node:
__slots__ = ["string", "index"]
def __init__(self, string, index):
self.string = string
self.index = index
def get_children(self):
s = "abcdefghij"
parent = self.string
out = [None]*(self.index+1)
for i, c in enumerate(s[:self.index]):
... | p02744 |
class Node:
__slots__ = ["string", "index"]
def __init__(self, string, index):
self.string = string
self.index = index
def get_children(self):
parent = self.string
out = [None]*(self.index+1)
for i, c in enumerate(s[:self.index]):
out[i] = Node(... | def dfs(s, mx):
if len(s) == n:
print(s)
return
for c in a[:mx]:
dfs(s+c, mx)
dfs(s+a[mx], mx+1)
n = int(eval(input()))
a = "abcdefghij"
dfs("", 0) | p02744 |
N = int(input())
strlist = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
ans = [['a']]
for i in range(1, N):
ans.append([])
for s in ans[i-1]:
n = len(set(s))
for j in range(n+1):
ans[i].append(s+strlist[j])
# ans.sort()
print(*ans[-1], sep='\n')
| N = int(input())
strlist = 'abcdefghij'
ans = [['a']]
for i in range(1, N):
ans.append([])
for s in ans[i-1]:
n = ord(max(s)) - 96
for j in range(n+1):
ans[i].append(s+strlist[j])
print(*ans[-1], sep='\n')
| p02744 |
import sys
from collections import deque
input = sys.stdin.readline
def dfs(N):
alphabet = "abcdefghij"
stack = deque(["a"])
while stack:
s = stack.pop()
if len(s) == N:
print(s)
continue
suffixes = []
for al in alphabet:
... | import sys
from collections import deque
input = sys.stdin.readline
def dfs(N):
alphabet = "abcdefghij"
stack = deque(["a"])
while stack:
s = stack.pop()
if len(s) == N:
print(s)
continue
for suffix in reversed(alphabet[:len(set(s)) + 1]):
... | p02744 |
import sys
from collections import deque
input = sys.stdin.readline
def dfs(N):
alphabet = "abcdefghij"
stack = deque(["a"])
while stack:
s = stack.pop()
if len(s) == N:
print(s)
continue
for suffix in reversed(alphabet[:len(set(s)) + 1]):
... | import sys
from collections import deque
input = sys.stdin.readline
def dfs(N):
alphabet = "abcdefghij"
stack = deque(["a"])
ans = []
while stack:
s = stack.pop()
if len(s) == N:
ans.append(s)
continue
for suffix in reversed(alphabet[:len... | p02744 |
n = int(input())
ans = []
start = ("a", 1, ord("a"))
stack = []
stack.append(start)
num = ord("a")
while stack:
v, nagasa, mx = stack.pop()
if nagasa == n:
ans.append(v)
continue
for i in range(num, mx + 2):
tuika = chr(i)
mx = max(i, mx)
stack.append((v... | n = int(input())
ans = []
start = "a"
stack = []
stack.append(start)
num = ord("a")
while stack:
v = stack.pop()
if len(v) == n:
ans.append(v)
continue
s = list(v[::])
s.sort()
nex_num = ord(s[-1])
for i in range(num, nex_num + 2):
tuika = chr(i)
s... | p02744 |
# Panasonic2020 D - String Equivalence
def generator(n):
if n == 1:
yield [0]
else:
for A in generator(n - 1):
for i in range(max(A) + 2):
A.append(i)
yield A
A.pop()
n = int(eval(input()))
for A in generator(n):
s =... | def generator(n):
if n == 1:
yield [0]
else:
for A in generator(n - 1):
for i in range(max(A) + 2):
A.append(i)
yield A
A.pop()
n = int(eval(input()))
for A in generator(n):
print((''.join([chr(a + 97) for a in A]))) | p02744 |
from collections import Counter
eval(input());a=Counter(list(map(int,input().split())))
print((sum([j if i>j else j-i for i,j in list(a.items())]))) | from collections import Counter
eval(input());print((sum(j if i>j else j-i for i,j in list(Counter(list(map(int,input().split()))).items())))) | p03487 |
import math
import collections
from sys import exit
from itertools import product
ii = lambda : int(eval(input()))
mi = lambda : list(map(int,input().split()))
li = lambda : list(map(int,input().split()))
n = ii()
a = li()
sa = set(a)
ans = 0
for i in sa:
tmp = a.count(i)
if tmp < i:
... | import math
from collections import Counter
from sys import exit
from itertools import product
ii = lambda : int(eval(input()))
mi = lambda : list(map(int,input().split()))
li = lambda : list(map(int,input().split()))
n = ii()
a = li()
cnt = Counter(a)
ans = 0
for i,j in list(cnt.items()):
if i > ... | p03487 |
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in set(a):
c = a.count(i)
if c >= i:
ans += c - i
else:
ans += c
print(ans) | n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in set(a):
if i <= n:
c = a.count(i)
if c >= i:
ans += i
print((n - ans)) | p03487 |
#!/usr/bin/env python3
import sys
import collections
def solve(N: int, a: "List[int]"):
counter = collections.Counter(a)
aset = set(a)
answer = 0
for aa in aset:
answer += (counter[aa]-aa) if counter[aa]>=aa else counter[aa]
print(answer)
return
def main():
def iterat... | #!/usr/bin/env python3
import sys
from collections import Counter
def solve(N: int, a: "List[int]"):
counter = Counter(a)
answer = 0
for key,value in list(counter.items()):
if key >value:
answer += value
else:
answer += value-key
print(answer)
re... | p03487 |
from collections import Counter
N = int(eval(input()))
a = [int(i) for i in input().split()]
b = Counter(a)
ans = 0
for x in b:
if b[x] > x:
ans += b[x] - x
elif b[x] < x:
ans += b[x]
print(ans) | from collections import Counter
N = int(eval(input()))
a = [int(i) for i in input().split()]
ans = 0
m = Counter(a)
for x, y in list(m.items()):
if x == y:
continue
elif x < y:
ans += abs(y-x)
else:
ans += y
print(ans) | p03487 |
n=eval(input())
a=list(map(int,input().split()))
a.sort()
#print(a)
i=0
ans=0
while i!=len(a):
x=a[i]
x1=a.count(x)
if x<x1:
ans=ans+x1-x
elif x>x1:
ans=ans+x1
else:
pass
i=i+x1
print(ans) | n=eval(input())
a=list(map(int,input().split()))
a.sort()
#print(a)
i=0
ans=0
while i!=len(a):
x=a[i]
x1=a.count(x)
if (x>len(a)-i):
ans=ans+len(a)-i
break
else:
if x<x1:
ans=ans+x1-x
elif x>x1:
ans=ans+x1
else:
... | p03487 |
n = int(eval(input()))
a_list = list(map(int, input().split()))
dic = {}
i_list = []
for a in a_list:
dic[a] = 0
for a in a_list:
dic[a] += 1
for i in a_list:
if i not in i_list:
i_list.append(i)
ans = 0
for i in i_list:
p = dic[i] - i
if p >= 0:
ans += p
else:
... | n = int(eval(input()))
a_list = list(map(int, input().split()))
dic = {}
i_list = []
for a in a_list:
dic[a] = 0
for a in a_list:
dic[a] += 1
if dic[a] == 1:
i_list.append(a)
ans = 0
for i in i_list:
p = dic[i] - i
if p >= 0:
ans += p
else:
ans += dic[i]
... | p03487 |
N=int(eval(input()))
s=list(map(int,input().split()))
t=list(set(s))
ans=0
for i in range(len(t)):
u=s.count(t[i])-t[i]
if u<0:
ans+=s.count(t[i])
if u>0:
ans+=u
print(ans) | N=int(eval(input()))
s,ans={},0
for i in list(map(int,input().split())):
s[i]=s.get(i,0)+1
for c,v in list(s.items()):
if c<v:
ans+=v-c
if c>v:
ans+=v
print(ans) | p03487 |
from collections import Counter
n = eval(input())
c = Counter(list(map(int, input().split())))
print((sum(0 if c[key] == key else c[key] if c[key] < key else c[key] - key for key in c)))
| from collections import Counter
n = eval(input())
c = Counter(list(map(int, input().split())))
print((sum(v if v < k else v - k for k,v in list(c.items()))))
| p03487 |
from collections import Counter
N, *a = list(map(int, open(0).read().split()))
c = Counter(a)
ans = 0
for v in c:
if v > c[v]:
ans += c[v]
else:
ans += c[v] - v
print(ans)
| from collections import Counter
N, *a = list(map(int, open(0).read().split()))
c = Counter(a)
print((sum(c[v] if v > c[v] else c[v] - v for v in c)))
| p03487 |
def C_Good_Sequence():
N=int(eval(input()))
a=list(map(int, input().split()))
b=set(a)
b=list(b)
count=0
ans=0
c=[]
for i in b:
for j in range(N):
if a[j]==i:
count += 1
c.append(count)
count=0
for i in range(... | def C_Good_Sequence():
N=int(eval(input()))
a=list(map(int, input().split()))
count={}
ans=0
for num in a:
count[num]= count.get(num,0)+1
for num in count:
if num > count[num]:
ans += count[num]
elif num < count[num]:
ans += coun... | p03487 |
n = int(eval(input()))
a = list(map(int, input().split()))
import collections
ac = collections.Counter(a)
common = ac.most_common()
operation_count = 0
for num, num_count in common:
if num < num_count:
operation_count += num_count - num
elif num_count < num:
operation_count += num_count
p... | n = int(eval(input()))
import collections
a = list(map(int, input().split()))
ac = collections.Counter(a)
la = len(a)
ans = 0
for k, c in list(ac.items()):
if c < k:
ans += c
else:
ans += c - k
print(ans)
| p03487 |
import collections
N=int(eval(input()))
a=list(map(int,input().split()))
a.sort()
cnt=0
c=collections.Counter(a)
#print(c)
for item in c:
t=c[item]
if t>item:
cnt+=t-item
elif t==item:
pass
else:
cnt+=t
#while len(a)>0:
# item=a[0]
# t=(item)
# #print(item,t,a)
# if ... | import collections
N=int(eval(input()))
a=list(map(int,input().split()))
c=collections.Counter(a)
cnt=0
for item in c:
t=c[item]
if t>item:
cnt+=t-item
elif t==item:
pass
else:
cnt+=t
print(cnt) | p03487 |
n = int(eval(input()))
arr = []
out = {}
input = input().split(" ")
for i in input:
arr.append(int(i))
if out.get(arr[-1], False):
out[arr[-1]] += 1
else:
out[arr[-1]] = 1
count = 0
for key in out:
if key > out[key]:
count += out[key]
else:
count += out[key] - key
print(count) | N = int(eval(input()))
seq = list(map(int, input().split()))
d = {}
for i in range(0,N):
e = seq[i]
if e not in list(d.keys()):
d[e] = 1
else:
d[e] += 1
r = 0
for k in list(d.keys()):
v = d[k]
if (v < k):
r += v
else:
r += v-k
print(r)
| p03487 |
import sys
from collections import Counter
input = sys.stdin.readline
def main():
N = int(eval(input()))
A = [int(x) for x in input().split()]
C = Counter(A)
ans = 0
for k in list(C.keys()):
if k > C[k]:
ans += C[k]
else:
ans += C[k] - ... | import collections
N = int(eval(input()))
A = [int(x) for x in input().split()]
c = collections.Counter(A)
ans = 0
for k in list(c.keys()):
if k <= c[k]:
ans += c[k] - k
else:
ans += c[k]
print(ans)
| p03487 |
b = []
count = []
def sarch(num):
for i in range(len(b)):
if num == b[i]:
return i
b.append(num)
count.append(0)
return len(b) - 1
N = eval(input())
a = list(map(int, input().split()))
ans = 0
for i in range(len(a)):
if a[i] != 0:
count[sarch(a[i])] +=... | N = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
i = 1
cnt = 1
key = a[0]
ans = 0
while True:
if i >= len(a):
break
if key == a[i]:
cnt += 1
else:
if key != cnt:
if cnt > key:
ans += cnt - key
else:
... | p03487 |
N=int(eval(input()))
A=list(map(int,input().split()))
A.sort()
from collections import Counter
A=Counter(A)
ret=0
for i in A.most_common():
if i[0]>i[1]:
ret+=i[1]
else:
ret+=i[1]-i[0]
print(ret) | N=int(eval(input()))
A=list(map(int,input().split()))
from collections import Counter
A=Counter(A)
ret=0
for i in A.most_common():
if i[0]>i[1]:
ret+=i[1]
else:
ret+=i[1]-i[0]
print(ret) | p03487 |
import collections
n = int(eval(input()))
a = list(map(int, input().split()))
aa = collections.Counter(a)
ans = 0
for i,j in sorted(aa.items()):
if j > i:
ans += j-i
elif j < i:
ans += j
print (ans)
| from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
c = Counter(a)
ans = 0
for i in c:
if c[i] > i:
ans += c[i] - i
elif c[i] < i:
ans += c[i]
print (ans) | p03487 |
eval(input())
from collections import *
c=Counter(list(map(int,input().split())))
print((sum(v-k*(k<=v) for k,v in list(c.items())))) | from collections import*;eval(input());print((sum(v-k*(k<=v)for k,v in list(Counter(list(map(int,input().split()))).items())))) | p03487 |
import collections
num = int(eval(input()))
val = [int(x) for x in input().split()]
cnt = collections.Counter(val)
res = 0
for x in cnt:
if cnt[x] > x:
res += cnt[x] - x
elif cnt[x] < x:
res += cnt[x]
print(res) | import collections
n = int(eval(input()))
array = [int(x) for x in input().split()]
_dict = collections.Counter(array)
res = 0
for i, j in list(_dict.items()):
if i != j:
if i > j:
res += j
else:
res += abs(i-j)
print(res) | p03487 |
n=int(eval(input()))
a=list(map(int,input().split()))
set_a=set(a)
import collections
count=0
data=collections.Counter(a)
for i,j in list(data.items()):
if i<j:
count+=j-i
elif j<i:
count+=j
print(count) | n=int(eval(input()))
a=list(map(int,input().split()))
from collections import Counter
data=Counter(a)
ans=0
for i,j in list(data.items()):
if i<j:
ans+=j-i
elif j<i:
ans+=j
print(ans)
| p03487 |
N = int(eval(input()))
a = list(map(int,input().split()))
A = list(set(a))
c = 0
ac = 0
for i in range(len(A)):
ac = a.count(A[i])
if ac >= A[i]:
c += ac - A[i]
elif ac > 0:
c += ac
print(c)
| N = int(eval(input()))
a = list(map(int, input().split()))
if N == 1:
if a[0] != 1:
print((1))
exit()
else:
print((0))
exit()
a.sort()
A = 0
c = 0
while True:
try:
#print(a)
A = a[0]
if len(a)>1:
for i in range(1, len(a)):
... | p03487 |
N=int(eval(input()))
a=list(map(int,input().split()))
dic={}
keylist=list(set(a))
cnt=0
for i in range(len(keylist)):
serchingnum=keylist[i]
num=a.count(serchingnum)
if num>=serchingnum:
cnt+=num-serchingnum
else:
cnt+=num
print(cnt)
| N=int(eval(input()))
a=list(map(int,input().split()))
cnt=0
counterarr=[0 for _ in range(N)]
others=[]
for i in range(N):
if a[i]-1<N:
counterarr[a[i]-1]+=1
else:
others.append(a[i])
for i in range(N):
shoudbe=i+1
now=counterarr[i]
if shoudbe>now:
cnt+=now
... | p03487 |
n = int(eval(input()))
a = list(map(int,input().split()))
b = set(a)
b = list(b)
x = [0 for i in range(len(b))]
for i in a:
y = b.index(i)
x[y] += 1
ans = 0
for i,j in zip(b,x):
if j < i:
ans += j
else:
ans += j - i
print(ans) | n = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
count = 0
x = 0
tmp_count = 0
for i in a:
if i != x:
if tmp_count < x:
count += tmp_count
else:
count += tmp_count - x
tmp_count = 1
x = i
else:
tmp_count += 1
if tm... | p03487 |
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
count = Counter(a)
ans = 0
for i in list(count.items()):
if i[1] < i[0]: ans += i[1]
else: ans += abs(i[1]-i[0])
print(ans) | from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
count = Counter(a)
ans = 0
for k,v in list(count.items()):
if k < v: ans += v-k
elif v < k: ans += v
print(ans) | p03487 |
import sys
N = int(eval(input()))
a = [int(n) for n in input().split()]
dic = {}
for ak in a:
if not(ak in dic):
dic[ak] = 1
else:
dic[ak] += 1
ans = 0
for k in list(dic.keys()):
if(dic[k] - k > 0):
ans+=dic[k] - k
elif(dic[k] - k < 0):
ans+=dic[k]
prin... | from sys import exit
import math
N = int(eval(input()))
dic = {}
a = [int(n) for n in input().split()]
for e in a:
if e in dic:
dic[e]+=1
else:
dic[e] = 1
ans = 0
for k in list(dic.keys()):
if k < dic[k]:
ans+=dic[k]-k
elif k > dic[k]:
ans+=dic[k]
else... | p03487 |
N = int(eval(input()))
a = list(map(int,input().split()))
ans = 0
a_as = [0 for _ in range(max(a))]
for x in a:
a_as[x-1] += 1
for i,cnt in enumerate(a_as):
if cnt == 0 or cnt == i+1:
continue
elif cnt > i+1:
ans += cnt - (i+1)
else:
ans += cnt
print(ans) |
N = int(eval(input()))
a = list(map(int,input().split()))
ans = 0
a_as = {}
for x in a:
if x in a_as:
a_as[x] += 1
else:
a_as[x] = 1
for x in a_as:
if x > a_as[x]:
ans += a_as[x]
else:
ans += abs(a_as[x]-x)
print(ans) | p03487 |
from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
C = Counter(A)
ans = 0
for c in C:
if c > C[c]:
ans += C[c]
elif c < C[c]:
ans += C[c] - c
print(ans) | import sys
from collections import Counter
input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int, input().split()))
C = Counter(A)
ans = 0
for c in C:
if c > C[c]:
ans += C[c]
elif c < C[c]:
ans += C[c] - c
print(ans) | p03487 |
if __name__=="__main__":
N = int(eval(input()))
l = list(map(int,input().split(" ")))
v = []
c = []
count = 0
for i in l:
if i not in v:
v.append(i)
c.append(1)
else:
c[v.index(i)]+=1
for j in range(len(v)):
c... | def main():
N = int(eval(input()))
l = list(map(int,input().split(" ")))
dic = {}
count = 0
for i in l:
try:
dic[i] += 1
except Exception:
dic[i] = 1
for j in list(dic.items()):
count += j[1] - j[0] if j[1] >= j[0] else j[1]
print... | p03487 |
# -*- coding: utf-8 -*-
def main():
from collections import Counter
n = int(eval(input()))
a = Counter(list(map(int, input().split())))
ans = 0
for key, value in list(a.items()):
if key < value:
ans += value - key
elif key > value:
ans += val... | # -*- coding: utf-8 -*-
def main():
from collections import Counter
n = int(eval(input()))
a = Counter(list(map(int, input().split())))
ans = 0
for key, value in list(a.items()):
if key > value:
ans += value
elif key < value:
ans += value - key... | p03487 |
import sys
import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
def main():
n, *a = (int(x) for x in sys.stdin.read().split())
c = collections.Counter(a)
count = 0
for i, j in list(c.items()):
if j < i: count += j
... | import sys
from collections import Counter
n, *a = list(map(int, sys.stdin.read().split()))
def main():
res = 0
for v, c in list(Counter(a).items()):
if c < v:
res += c
elif c > v:
res += c - v
return res
if __name__ == '__main__':
ans = main()
... | p03487 |
n = int(eval(input()))
a = list(map(int, input().split()))
b = set(a)
ans = 0
for i in b:
temp = a.count(i)
if temp > i:
ans += temp-i
elif temp < i:
ans += temp
print(ans) | n = int(eval(input()))
a = list(map(int, input().split()))
b = []
c = {}
ans = 0
for i in range(n):
if a[i] in c:
c[a[i]] += 1
else:
c[a[i]] = 1
b.append(a[i])
for i in range(len(b)):
temp=c[b[i]]
temp2=b[i]
if temp > temp2:
ans += temp-temp2
elif temp < temp2:
ans ... | p03487 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.