Problem:


Score : 300 points

Problem Statement

You are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally "Seven-Five-Three numbers") are there?

Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:

When the number is written in base ten, each of the digits 7, 5 and 3 appears at least once, and the other digits never appear.

Constraints

1 \leq N < 10^9

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the number of the Shichi-Go-San numbers between 1 and N (inclusive).

Sample Input 1

575

Sample Output 1

4

There are four Shichi-Go-San numbers not greater than 575: 357, 375, 537 and 573.

Sample Input 2

3600

Sample Output 2

13

There are 13 Shichi-Go-San numbers not greater than 3600: the above four numbers, 735, 753, 3357, 3375, 3537, 3557, 3573, 3575 and 3577.

Sample Input 3

999999999

Sample Output 3

26484



Sample input:
575


Sample output:
4

Submission status: Wrong Answer

Solution code:
N = int(input())

tri_d = {0:3, 1:5, 2:7}
tri = [0,1,2]

def tri_dec(lst):
  d = 0
  for l in lst:
    d *= 10
    d += tri_d[l]
  return d

def tri_inc(lst):
  lst[-1] += 1
  i = 1
  while lst[-i] > 2:
    if i == len(lst):
      lst.insert(0, -1)
    lst[-i] -= 3
    lst[-(i+1)] += 1
    i += 1
  if set(lst) != {0,1,2}:
    tri_inc(lst)
  return lst

count = 0
while tri_dec(tri) < N:
  count += 1
  tri = tri_inc(tri)
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())

print(3**N - 3*(2**N - 2) - 3)

Submission status: Wrong Answer

Solution code:
N = input()
count = 0

for i in range(357, int(N)):
    x = ["3" in str(i), "5" in str(i), "7" in str(i)]
    y = ["0" in str(i), "1" in str(i), "2" in str(i), "4" in str(i), "6" in str(i), "8" in str(i), "9" in str(i)]
    if all(x) and not any(y):
        count += 1
    x = []
    y = []
print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力

n = int(input())

cnt = 0
pre = ["753", "357", "375", "537", "573"]

for i in range(n):

    l = [s for s in str(i+1)]
    uni = ''.join(set(l))
    
    #print(uni)
    
    for p in pre:
        if uni.find(p) > -1 : cnt+=1

print(cnt)

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
l = []
l.extend(list(itertools.product([3,5,7], repeat=i)) for i in range(3,9))
l = [int("".join(map(str,j))) for i in l for j in i if 7 in j and 5 in j and 3 in j]
print(sum([1 for i in l if n>=i]))

Submission status: Wrong Answer

Solution code:
import itertools
n = tuple(map(int,input()))
l = []
l.extend(list(itertools.product([3,5,7], repeat=i)) for i in range(3,9))
l = [j for i in l for j in i if 7 in j and 5 in j and 3 in j]
print(sum([1 for i in l if len(n) > len(i)  or (n >= i and len(n) == len(i))]))

Submission status: Wrong Answer

Solution code:
def keta(n, elements):
    results = elements
    for i in range(n - 1):
        results = [r * 10 + e for e in elements for r in results]
    return results

N = int(input())

num753 = set()
for i in range(3,10):
    n1 = keta(i, set([3, 5, 7]))
    n2 = keta(i, set([3, 5]))
    n3 = keta(i, set([5, 7]))
    n4 = keta(i, set([3, 7]))
    num753 |= set(n1) - set(n2) - set(n3) - set(n4)
num753 = sorted(num753)

ans = 0
for i in num753:
    if i < N:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

count = 0
for i in range(N):
    strN = str(i)
    if (not "0" in strN) and (not "1" in strN)and(not "2" in strN) and ("3" in strN) and (not "4" in strN) and ("5" in strN) and (not "6" in strN) and ("7" in strN) and (not "8" in strN) and (not "9" in strN):
        count += 1
    else:
        pass
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
digit = len(str(N))
list753 = ["3", "5", "7"]  # string

for i in range(digit):
    for n in list753:
        if len(n) == i:
            list753.append(n + "7")
            list753.append(n + "5")
            list753.append(n + "3")

# print(list753)
counter = 0
for num in list753:
    if int(num) < N and 0 not in [num.count("3"), num.count("5"), num.count("7")]:
        counter += 1
print(counter)

Submission status: Wrong Answer

Solution code:
'''
3^9 = 19683
3^10 = 59049
これくらいの数なら全探索して十分間に合う
'''

import itertools
from functools import reduce

n = int(input())
ketasuu = len(str(n))
ans = 0

base = itertools.product('357', repeat=ketasuu)
# baseはタプルからなるリスト

for i in base:
	if len(set(i))== 3: # 3種類の数字が1回以上使われている
		i_int = int(reduce(lambda x, y: x + y, i))
		if i_int < n:
			ans += 1

for k in range(3, ketasuu):
	temp = 3**k - 3*1**k - 3 * (2**k - 2* 1**k)
	ans += temp

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
K = 0
A = []
count = 0
while N != 0:
	if max(0, ((N%10)-1)//2) >= 3:
		A.append(3)
		N = N//10
	elif max(0, ((N%10)-1)//2) >= 2:
		A.append(2)
		N = N//10
	elif max(0, ((N%10)-1)//2) >= 1:
		A.append(1)
		N = N//10
	else:
		A.append(3)
		N = N//10 - 1

exponent = 0
for a in A:
	K += a * (4**exponent)
	exponent +=1

B = A
C = A
#print("K = " + str(K))
#print("count = " + str(count))
#print("C = " + str(C))
while len(B) == len(C):
	B = C
	if (1 in B) and (2 in B) and (3 in B) and not (0 in B):
		count += 1
#		print("C = " + str(C) )
#		print("count = " + str(count))
	K -= 1
	l  = K
#	print("K = " + str(K))
	C = []
	while l != 0:
		C.append(l%4)
		l = l//4
#	print()

#print(C)
m = len(C)
#print("count: " + str(count))
#print("m = " + str(m))
#print("rest: " + str(3**m - 3*(2**m-1)))

count += 3**m - 3*(2**m-1)

print(count)

Submission status: Wrong Answer

Solution code:
num = int(input())
datas = [i for i in range(1,num) if set(str("573")).issubset(set(str(i))) and not any(x in str(i) for x in list("12049846")) ]
print(len(datas))

Submission status: Wrong Answer

Solution code:
num = 575
datas = [i for i in range(1,num) if set(str("573")).issubset(set(str(i))) and not any(x in str(i) for x in list("12049846")) ]
print(len(datas))

Submission status: Wrong Answer

Solution code:
import itertools
N= input()
Number=int(N)
count=[]
x=0
n=3
count=0
def check (S):
    S=str(S)
    if S.count('3')!=0 and S.count('5')!=0 and S.count('7')!=0 and int(S)<=Number:
        print(S)
        return 1

def dfs(x):
    global count
    if check(x)==1:
        count+=1
    if x<=Number:
        dfs(10*x+3)
        dfs(10*x+5)
        dfs(10*x+7)


dfs(0)
print(count)

Submission status: Wrong Answer

Solution code:
import itertools
N= input()
Number=int(N)
count=[]
x=0
n=3
test=''
l=['3','5','7']
flag=1
while n<=len(N):
    for x in itertools.permutations(l,n):
        for y in x:
            test+=y
        if int(test)<=Number and count.count(test)==0:
             count.append(test)

        test=''

    if  flag==1:
        l+='3'
        n+=1
        flag+=1
    elif flag==2:
        l[l.index('3')]='5'
        flag+=1
    elif flag==3:
        l[l.index('5')]='7'
        flag=1
    l.sort()

print(len(count))

Submission status: Wrong Answer

Solution code:
import copy

ssst=str(input())
b = int(copy.copy(ssst))
th=fi=se=count=0

for i in range(100,b+1):
   
    m=str(i)
    if i%2!=1:
        for x in range(len(m)):

            for j in range(10):
                if j==int(m[x]) and j==3:
                    th=th+1
                if j==int(m[x]) and j==5:
                    fi=fi+1
                if j==int(m[x]) and j==7:
                    se=se+1
        if len(m)==(th+fi+se) and th!=0 and fi!=0 and se!=0:
            count=count+1
            #print(count,"  ",i ," ",x)
        th=fi=se=0
print(count)

Submission status: Wrong Answer

Solution code:
import itertools
import math

n = input()
if(int(n)<357):
    print(0)
    exit()

ans = 0

for i in range(3,len(n)+1):
    if len(n) == i:
        for v in itertools.product(['3','5','7'],repeat=i):
            if '3' in v and '5' in v and '7' in v:
                if int(''.join(v)) <= int(n):
                    print(v)
                    ans += 1
    else:
        ans += 3 ** i - 2 ** i * 3 + 3
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

def next(x):
    if(x==""):
        return "3"
    if(x[-1]=="3"):
        return x[0:-1]+"5"
    if(x[-1]=="5"):
        return x[0:-1]+"7"
    if(x[-1]=="7"):
        return next(x[0:-1])+"3"

cnt=0
a = "3"
while(int(a) < n):
    if all([c in a for c in "753"]):
        cnt += 1
    a = next(a)

print(cnt)

Submission status: Wrong Answer

Solution code:
s = input()
x1 = int(s[0])
n = len(s)

a2 = lambda x: 2**x-2
a3 = lambda x: 3**x - 3*a2(x) - 3

sub = sum([a3(i) for i in range(1,n)])

if x1 < 3:
    ans = sub
elif x1 < 5:
    ans = sub + (a2(n-1)+a3(n-1))
elif x1 < 7:
    ans = sub + 2 * (a2(n-1)+a3(n-1))
else:
    ans = sub + a3(n)

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=0
for i in range(n):
    a=set(str(i))
    if a=={'3','5','7'}:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

count = 0
def dfs(x):
    global count
    if int(x) > n:
        return 0
    
    for i in ('753'):
        dfs(x+i)
    
    check =  True
    for j in ('753'):
        if x.find(j) == -1:
            check = False
    if check:
        count += 1
        
    return count
dfs('0')

Submission status: Wrong Answer

Solution code:
N=int(input())

L=[3,5,7]
def is_753(x, N):
  tmp=0
  for i in L:
    p=x*10+i
    if p<N:
      if set([int(c) for c in str(p)])==set(L):
        tmp+=is_753(p, N)+1
      else:
        tmp+=is_753(p, N)
  return tmp

print(is_753(0, N))

Submission status: Wrong Answer

Solution code:
N = int(input())
l = len(str(N))

def make753(num, l, list753):
    if l == 0:
        if '3' in num and '5' in num and '7' in num and int(num) <= N:
            print(int(num))
            list753.append(int(num))
    else:
        make753(num + '3', l-1, list753)
        make753(num + '5', l-1, list753)
        make753(num + '7', l-1, list753)
    return list753

L = []
for l in range(3, l+1):
    L += make753('', l, [])
print(len(L))

Submission status: Wrong Answer

Solution code:
import itertools


def solve():

    N = int(input())
    num = str(N)

    ans = []
    dig = len(num)
    for x in range(dig):
        com = []
        com.append(('', '3', '5', '7'))
        for y in range(x):
            com.append(('3', '5', '7'))
        ans.append(com)

    temp = [list(itertools.product(*k)) for k in ans]

    tempanswer = [j for i in temp for j in i if (j.count(
        '3') >= 1 and j.count('5') >= 1 and j.count('7') >= 1)]

    answer = [int("".join(y)) for y in tempanswer if int("".join(y)) < N]
    res = list(set(answer))
    print(len(res))


solve()

Submission status: Wrong Answer

Solution code:
import itertools


def solve():

    N = int(input())
    num = str(N)

    ans = []
    dig = len(num)
    for x in range(dig):
        com = []
        com.append(('', '3', '5', '7'))
        for y in range(x):
            com.append(('3', '5', '7'))
        ans.append(com)

    temp = [list(itertools.product(*k)) for k in ans]

    tempanswer = [j for i in temp for j in i if (j.count(
        '3') >= 1 and j.count('5') >= 1 and j.count('7') >= 1)]

    answer = [int("".join(y)) for y in tempanswer if int("".join(y)) < N]
    res = list(set(answer))
    print(len(answer))
    print(answer)


solve()

Submission status: Wrong Answer

Solution code:
import itertools


def solve():

    N = int(input())
    N = N - 1
    num = str(N)

    ans = []
    dig = len(num)
    for x in range(dig):
        com = []
        com.append(('', '3', '5', '7'))
        for y in range(x):
            com.append(('3', '5', '7'))
        ans.append(com)

    temp = [list(itertools.product(*k)) for k in ans]

    tempanswer = [j for i in temp for j in i if (j.count(
        '3') >= 1 and j.count('5') >= 1 and j.count('7') >= 1)]

    answer = [int("".join(y)) for y in tempanswer if int("".join(y)) <= N]
    res = list(set(answer))
    print(len(res))


solve()

Submission status: Wrong Answer

Solution code:
n = int(input())
add = 0
for i in range(n+1):
  if set(str(i)) == {3,5,7}:
    add += 1
  else:
      pass
print(add)

Submission status: Wrong Answer

Solution code:
n = int(input())
add = 0
for i in range(n+1):
  if 7 in set(str(i)):
    if 5 in set(str(i)):
      if 3 in set(str(i)):
        add += 1
print(add)

Submission status: Wrong Answer

Solution code:
n = int(input())
add = 0
for i in range(n+1):
  if 3 in set(str(i)) and 5 in set(str(i)) and 7 in set(str(i)):
    add += 1
  else:
      pass
print(add)

Submission status: Wrong Answer

Solution code:
def gen_753(l,li=["7","5","3"]):
    if l == 1:
        return li
    new_li = []
    for cand in li:
        new_li.extend([cand + "7",cand + "5",cand + "3"])
    return gen_753(l-1,new_li)

num_str = input()
l = len(num_str)
num = int(num_str)
can_l = [int(num) for num in gen_753(l) if len(set(list(num))) == 3]
count = sum([i <= num for i in can_l])
print(count)

Submission status: Wrong Answer

Solution code:
def gen_753(l,li=["7","5","3"]):
    if l == 1:
        return li
    new_li = []
    for cand in li:
        new_li.extend([cand + "7",cand + "5",cand + "3"])
    return gen_753(l-1,new_li)

num_str = input()
l = len(num_str)
num = int(num_str)
can_l = [int(num) for num in gen_753(l) if len(set(list(num))) == 3]
count = [i for i in can_l if i <= num]
print(count)

Submission status: Wrong Answer

Solution code:
def gen_753(l,li=["7","5","3"]):
    if l == 1:
        return li
    new_li = []
    for cand in li:
        new_li.extend([cand + "7",cand + "5",cand + "3"])
    return gen_753(l-1,new_li)

num_str = input()
l = len(num_str)
num = int(num_str)
can_l = [int(num) for num in gen_753(l)]
count = sum([num >= i for i in can_l ])

Submission status: Wrong Answer

Solution code:
n = int(input())
c = 0

for i in range(n):
    sl = sorted(set(list(str(i))))
    if sl == ['3', '5', '7']:
        c += 1

print(c)

Submission status: Wrong Answer

Solution code:
import  itertools
N = int(input())
N_len = len(str(N))

ans = 0
for i in range(3,N_len+1):
    if i == N_len:
        l = list(itertools.product((3,5,7),repeat=N_len))
        ans += len(l)
        for s in l:
            a = int("".join(list(map(str,s))))
            if "3" not in str(a) or "5" not in str(a) or "7" not in str(a):
                ans -= 1
                continue
            if a > N:
                ans -= 1
        print(ans)

    else:
        ans += (3**i - 2**i*3 + 3)

Submission status: Wrong Answer

Solution code:
import itertools
from functools import lru_cache

@lru_cache(maxsize=1000)
def f(k, t='357'):
    tmp = [int(i) for i in t]
    res = []
    if k ==len(tmp):
        return list((set([i for i in itertools.permutations(tmp, k)])))
    else:
        a1 = ""
        for i in sorted(t+'3'):
            a1+=i
        a2 = ""
        for i in sorted(t+'5'):
            a2+=i
        a3 = ""
        for i in sorted(t+'7'):
            a3+=i
        return list(set(f(k, a1) + f(k, a2) + f(k, a3)))

def f2(res, N):
    cnt = 0
    n  = int(N)
    for tmp in res:
        s = ''
        for i in tmp:
            s += str(i)
        if int(s) <= n:
            cnt += 1
    return cnt
def f3(N):
    keta = len(N)
    result = 0
    for i in range(3, keta+1):
        res = f(i)
        result += f2(res, N)
    return result
if __name__ == '__main__':
    print(f3("99999999"))

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())

count = 0
for i in range(3, 11):
    for itr in itertools.product('357', repeat=i):
        value = 0
        for j in range(i):
            value += int(itr[j])*10**j
        if value <= n:
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
def check(var):
    return (0 <= var < N) and all(c in str(var) for c in '753')


def dfs(x):
    res = 0
    if check(x): res += 1
    if x <= N:
        for v in 3, 5, 7:
            res += dfs(10 * x + v)
    return res


N = int(input())
print(dfs(0))

Submission status: Wrong Answer

Solution code:
def check(x):
    return (0 <= x < N) and all(c in str(x) for c in '753')


def dfs(x):
    res = 0
    if check(x): res += 1
    if x <= N:
        for v in 3, 5, 7:
            res += dfs(10 * x + v)
    return res


N = int(input())
print(dfs(0))

Submission status: Wrong Answer

Solution code:
n=int(input())
c=0
for i in range(n):
    s=str(i)
    if s.count("7")>0 and s.count("5")>0 and s.count("3")>0 and s.count("1")==0 and s.count("2")==0 and s.count("4")==0 and s.count("6")==0 and s.count("8")==0 and s.count("9")==0 and s.count("0")==0:
        c+=1
print(c)

Submission status: Wrong Answer

Solution code:
import itertools as itt

N = input()

def check(snum):
    three = snum.count("3")
    five = snum.count("5")
    seven = snum.count("7")
    if (three == 0 or five == 0 or seven == 0) or (int(snum) > int(N)): return False
    else: return True

C = ["3", "5", "7"] #choice
digit = len(N)
cnt = 0
for d in range(3, digit+1): #3桁の入力から考える
    L = list(itt.product(C, repeat=d))
    for l in L:
        gen = "".join(l)
        if check(gen):
            print(gen)
            cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
n = input()
cnt = 0
for i in range(int(n)):
    three = str(i).count("3")
    five = str(i).count("5")
    seven = str(i).count("7")
    if three == 0 or five == 0 or seven == 0:
        pass
    elif len(str(i)) != three + five + seven:
        pass
    else:
        print(i)
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
n = input()
cnt = 0
for i in range(int(n)):
    three = str(i).count("3")
    five = str(i).count("5")
    seven = str(i).count("7")
    if three == 0 or five == 0 or seven == 0:
        pass
    else:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
S = int(input())
#S = 3600
count = 0

for i in range(S):
    ss = [int(x) for x in list(str(i))]
    
    if list(set(ss)) == [3,5,7]:
        count = count + 1

print(count)

Submission status: Wrong Answer

Solution code:
def count(lis, n):
    num = n
    keta = len(str(n))
    shurui = len(lis)
    ans = 0
    for i in range(1,keta):
        ans += shurui ** i
    while keta>0:
        keta -= 1
        kami = num // (10**keta)
        ok = sum(x<kami for x in lis)
        ans += ok * (shurui ** keta)
        if kami in lis:
            num = num % (10**keta)
        else:
            break
    return ans

N = int(input())

ans = count([7,5,3],N)-count([7,5],N)-count([5,3],N)-count([7,3],N)+count([7],N)+count([5],N)+count([3],N)
print(ans)

Submission status: Wrong Answer

Solution code:
x = input()
n = int(x)
count = 0
for i in range(n):
  tmp = str(i)
  if tmp.find("3") > -1 and tmp.find("5") > -1 and tmp.find("7") > -1 and "0" not in tmp and "1" not in tmp and "2" not in tmp and "4" not in tmp and "6" not in tmp and "8" not in tmp and "9" not in tmp:
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())
nums = [3, 5, 7]
res = 0
for i in range(10):
  for balls in itertools.product(nums, repeat=i):
    num = ''
    if 3 in balls and 5 in balls and 7 in balls:
      for j in range(i):
        num += str(balls[j])
      if int(num) >= N:
        break
      res += 1

print(res)

Submission status: Wrong Answer

Solution code:
def is753Value(x:int):
    x = str(x)
    if '1' in x or '2' in x or '4' in x or '6' in x or '8' in x or '9' in x or '0' in x :
        return False
    elif '7' in x and '5' in x and '3' in x:
        return True
    return False

def genkirinum(x:str):
    tmp = x[0:1]
    tmp += '0'*(len(x)-1)
    return tmp
    
N = input()
counter = 0

# 最初の処理でキリ番までやる
if N[0:1] == '7' or N[0:1] == '5' or N[0:1] == '3':
    for x in range(int(genkirinum(N))+3, int(N), 2):
        if is753Value(x):
            counter += 1 

N = genkirinum(N)

while 2 < len(N):
    if N[0:1] == '1':
        tmp = N.replace(N[0:2], '9', 1)
    else:
        tmp = N.replace(N[0:1], str(int(N[0:1]) - 1), 1)
    if tmp[0:1] == '7' or tmp[0:1] == '5' or tmp[0:1] == '3':
        for x in range(int(tmp)+1, int(N), 2):
            if is753Value(x):
                counter += 1
    N = tmp

print(counter)

Submission status: Wrong Answer

Solution code:
def is753Value(x:int):
    x = str(x)
    if '1' in x or '2' in x or '4' in x or '6' in x or '8' in x or '9' in x or '0' in x :
        return False
    elif '7' in x and '5' in x and '3' in x:
        return True
    return False

def genkirinum(x:str):
    tmp = x[0:1]
    tmp += '0'*(len(x)-1)
    return tmp
    
N = input()
counter = 0

# 最初の処理でキリ番までやる
if N[0:1] == '7' or N[0:1] == '5' or N[0:1] == '3':
    for x in range(int(genkirinum(N))+3, int(N), 2):
        if is753Value(x):
            counter += 1 

N = genkirinum(N)

while 2 < len(N):
    print(N)
    if N[0:1] == '1':
        tmp = N.replace(N[0:2], '9', 1)
    else:
        tmp = N.replace(N[0:1], str(int(N[0:1]) - 1), 1)
    if tmp[0:1] == '7' or tmp[0:1] == '5' or tmp[0:1] == '3':
        for x in range(int(tmp)+1, int(N), 2):
            if is753Value(x):
                counter += 1
    N = tmp

print(counter)

Submission status: Wrong Answer

Solution code:
n = input()
ans = 10000
for i in range (len(n)-2):
    if abs(int(n[i]+n[i+1]+n[i+2]))<ans:
        ans =abs(int(n[i]+n[i+1]+n[i+2]))
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
count = 0
for n in range(N+1):
    flag = 0
    count3 = 0
    count5 = 0
    count7 = 0
    tmp = list(str(n))
    for i in range(len(tmp)):
        if tmp[i] != '3':
            if tmp[i] != '5':
                if tmp[i] != '7':
                    flag = 1
                    break
        if tmp[i] == '3':
            count3 +=1
        elif tmp[i] == '5':
            count5 += 1
        else:
            count7 += 1
    if flag != 1:
        if (count3 >= 1) & (count5 >= 1) & (count7 >= 1):
            count += 1
            print(tmp)
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
print([n for n in range(N) if(str(n) in "7" and str(n) in "5" and str(n) in "3")])

Submission status: Wrong Answer

Solution code:
import itertools
import bisect

a = []
for i in range(3, 10):
    for j in itertools.product([3, 5, 7], repeat=i):
        if j.count(3) > 0 and j.count(5) > 0 and j.count(7) > 0:
            a.append(int("".join(map(str, j))))
a.sort()
n = int(input())
print(bisect.bisect_left(a, n))

Submission status: Wrong Answer

Solution code:
Num753 = {7, 5, 3}

def getDigitList(n):
    list = []
    while n>0:
        list.append(n%10)
        n //= 10
    list.reverse()
    if list==[]: list = [0]
    return list

def getDigitSet(n):
    nSet = set([])
    while n>0:
        nSet.add(n%10)
        n //= 10
    if nSet=={}: nSet = {0}
    return nSet


S = input()
num = int(S)
count = 0
for i in range(357, num):
    nSet = set(getDigitSet(i))
#    if len(nSet)!=3: continue
#    is753 = True
#    for d in nSet:
#        if not (d in Num753):
#            is753 = False 
#            break
    if nSet==Num753: 
        print(i,end=', ')
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n = input()
nl = len(n)
n = int(n)


s = set([357, 375, 537, 573, 735, 753])
a = [0, 0, 0]
a.append(s)

#setを受けて、それに3,5,7いずれかを1つ加えたsetを返す
def ext(se):
    t = set()
    for i in se:
        t = t | {int("3"+str(i)), int("5"+str(i)), int("7"+str(i))}
        t = t | {int(str(i)+"3"), int(str(i)+"5"), int(str(i)+"7")}
        for j in range(1, len(se)):
            t = t | {int(str(i)[:j]+"3"+str(i)[j:]), int(str(i)[:j]+"5"+str(i)[j:]), int(str(i)[:j]+"7"+str(i)[j:])}
        
    for k in t:
        if str(k).count("3") < 1 or str(k).count("5") < 1 or str(k).count("7") < 1:
            t.remove(k)
    return t


if n < min(a[3]):
    print(0)

elif nl == 3:
    ans = 0
    for i in a[3]:
        if n > i:
            ans += 1
    print(ans)

else:
    se = s
    for l in range(4, nl+1):
        se = ext(se)
        a.append(se)
    ans = 0
    for k in range(3, nl):
        ans += len(a[k])
    for i in a[nl]:
        if n > i:
            ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

N = int(raw_input())
count = 0

for i in range(3,10):
	for j in itertools.product("357", repeat=i):
		if int("".join(j))>N and "7" in j and "5" in j and "3" in j:
			count += 1
print count

Submission status: Wrong Answer

Solution code:
import itertools

N = int(raw_input())
count = 0

A = ["3","5","7"]
for j in range(3,10):
	for i in itertools.product(A, repeat=j):
		state = "".join(i)
		if "3" in state and "5" in state and "7" in state:
			count += 1
		if int(state) >= N:
			break
	if int(state) >= N:
		break
print count

Submission status: Wrong Answer

Solution code:
import itertools

N = int(raw_input())
count = 0

A = ["3","5","7"]
for j in range(3,10):
	for i in itertools.product(A, repeat=j):
		state = "".join(i)
		if "3" in state and "5" in state and "7" in state:
			count += 1
		if int(state) > N:
			break
	if int(state) > N:
		break
print count

Submission status: Wrong Answer

Solution code:
import itertools

N = int(raw_input())
count = 0

A = ["3","5","7"]
for j in range(3,10):
	for i in itertools.product(A, repeat=j):
		state = "".join(i)
		if "3" in state and "5" in state and "7" in state:
			count += 1
		if int(state) > N:
			break
print count

Submission status: Wrong Answer

Solution code:
N = int(input())

ans=0
for i in range(N+1):
    if ("3" in str(i)) & ("5" in str(i)) & ("7" in str(i)):
        ans+=1
    
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
from functools import reduce

N = input()

def check_357(list_A):
    count = 0
    for i in list_A:
        if i == 3 or i == 5 or i == 7:
            count+=1
    if count == len(list_A):
        return 1
    else:
        return 0

def check_num_357(list_A):
    count3 = count5 = count7 = count_o = 0
    for i in list_A:
        if i == 3:
            count3 += 1 
        elif i == 5:
            count5 += 1
        elif i == 7:
            count7 += 1
        else:
            count_o += 1

    if count3 != 0 and count5 != 0 and count7 != 0:
        return 1
    else:
        return 0

count = 0

for i in range(1,int(N)):
    S = [int(i) for i in list(str(i))]
    if check_357(S) == 1 and check_num_357(S) == 1:
        count += 1
print(int(count))

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())
d753 = ["3", "5", "7"]

c = 0
for i in range(1, 9):
	for d in itertools.product(d753, repeat = i):
		if d.count("3") >= 1 and d.count("5") >= 1 and d.count("7") >= 1:
			x = int("".join(d))
			if x <= N:
				c += 1

print(c)

Submission status: Wrong Answer

Solution code:
n = int(input())
count = 0
for i in range(1, n+1):
  if "3" in str(i) and "5" in str(i) and "7" in str(i):
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())

def make753(s):
    count = 0
    if int(s) >= n:
        return 0
    if all(s.count(i) > 0 for i in '753'):
        count += 1
    for i in '753':
        count += make753(s + i)
    return count
        
print(make753('0'))

Submission status: Wrong Answer

Solution code:
N = int(input())

count = 0
for i in range(N):
    count3 = 0
    count5 = 0
    count7 = 0
    for j in range(len(str(i))):
        if int(str(i)[j]) == 3:
            count3 += 1
        elif int(str(i)[j]) == 5:
            count5 += 1
        elif int(str(i)[j]) == 7:
            count7 += 1
        else:
            break
        
    if count3>0 and count5>0 and count7>0 and count3+count5+count7 == len(str(i)):
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
A = []
def svt(now, count):
    A.append(now)
    if count > 10:
        return
    else:
        svt(now * 10 + 7, count + 1)
        svt(now * 10 + 5, count + 1)
        svt(now * 10 + 3, count + 1)

svt(753, 3)
svt(573, 3)
svt(537, 3)
svt(735, 3)
svt(357, 3)
svt(375, 3)
A.sort()
N = int(input())
ans = 0
for i in A:
    j = str(i)
    a = 0
    b = 0
    c = 0
    for k in range(len(j)):
        if j[k] == "3":
            a = 1
        elif j[k] == "5":
            b = 1
        elif j[k] == "7":
            c = 1
    if a == 1 and b == 1 and c == 1 and i <= N:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import product
from bisect import bisect_left
#pre processing
st = '753'
ls = []
for i in range(3,10):
	s = list(product(st,repeat = i))
	for i in s:
		zz = ''.join(list(i))
		ls.append(zz)

arr = []
for i in ls:
	if '7' in i and '5' in i and '3' in i:
		arr.append(int(i))
arr.sort()
n = input()
print bisect_left(arr,n)

Submission status: Wrong Answer

Solution code:
N = int(input())

def cnt(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '357') else 0
    for c in '357':
        ret += cnt(s+c)
    return ret

cnt('0')

Submission status: Wrong Answer

Solution code:
n = int(input())
count = 0

def make753(s):
    global count
    if int(s) >= n:
        return 0
    if all(s.count(i) > 0 for i in '753'):
        count += 1
    for i in '753':
        make753(s + i)
    return count
        
print(make753('0'))

Submission status: Wrong Answer

Solution code:
N = int(input())

count = 0
for i in range(N):
    if ('7' in str(i)) and ('5' in str(i)) and ('3' in str(i)):
        count+=1

print(count)

Submission status: Wrong Answer

Solution code:
def change_ten_to_kisu(num, kisu):      # 10進数をkisu進数に変換 (int, int) => int
    r = 0
    syo = num
    count = 0
    while syo >= kisu:
        r += (syo % kisu) * 10 ** count
        syo = syo // kisu
        count += 1
    return r + syo * 10 ** count

def change_kisu_to_ten(num, kisu):      # kisu進数を10進数に変換 (int, int) => int
    n = str(num)
    r = 0
    for i in range(len(n)):
        r += int(n[-i - 1]) * kisu ** i
        # print(r, int(n[-i - 1]), kisu ** i)
    return r

def plus(num):                   # 3, 5, 7のみを使用しnumより大きい数を返す
    change = {"3" : "0", "5" : "1", "7" : "2"}
    change_r = {"0" : "3", "1" : "5", "2" : "7"}
    t = ""
    for i in str(num):
        t += change[i]
    r = change_ten_to_kisu(change_kisu_to_ten(int(t), 3) + 1, 3)
    if len(t) < len(str(r)):
        r = "0" + str(r)[1:]
    elif len(t) > len(str(r)):
        r = "0" * (len(t) - len(str(r))) + str(r)
    t = ""
    for i in str(r):
        t += change_r[i]
    return int(t)

N = int(input())

i = 3
count = 0
while i < N:
    if "3" in str(i) and "5" in str(i) and "7" in str(i):
        # print(i)
        count += 1
    i = plus(i)
print(count)

Submission status: Wrong Answer

Solution code:
S = input()
threeS=""
flag=0
count=0
for s in S:
    if flag == 1:
        threeS = threeS + "3"
    elif s > "7":
        threeS = threeS + "3"
        flag=1
    elif s == "7":
        threeS = threeS + "3"
    elif s > "5":
        threeS = threeS + "2"
        flag=1
    elif s == "5":
        threeS = threeS + "2"
    elif s > "3":
        threeS = threeS + "1"
        flag=1
    elif s =="3":
        threeS = threeS + "1"
    elif s > "0":
        if threeS == "":
            threeS = threeS + "0"
        else:
            threeS = threeS[0:-1] + str(max(0,int(threeS[-1:])-1))
            threeS = threeS + "3"
        flag=1

x=str(111)
count = 0

def add(s):
    if s == "":
        return "1"
    s = str( int(s)+1 )
    if s[-1:] == "4":
        s = add(s[:-1]) + "1"
    return s

while int(x) <= int(threeS):
    if "1" in x:
        if "2" in x:
            if "3" in x:
                count += 1
    x = add(x)

print(count)