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

Solution (Python):
n = int(input())

cnt = 0
i = 1
while i <= n:
    is_broken = False
    string = list(str(i))
    for j, s in enumerate(string):
        if s not in ['3', '5', '7']:
            i = i + 10**(len(string) - j - 1)
            is_broken = True
            break
    if is_broken:
        continue

    c1 = string.count('3') >= 1
    c2 = string.count('5') >= 1
    c3 = string.count('7') >= 1
    if c1 and c2 and c3:
        cnt += 1

    i += 1

print(cnt)

Solution (Python):
N=int(input())


def pro(m):
	x=0
	for j in range(3,m+1):
		x+= (3**j) - 3*(2**j) + 3
	return(x)

def plus(s,n):
	s=list(str(s))
	if s[-n]=="3":
		s[-n]="5"
		return(int(''.join(s)))
	elif s[-n]=="5":
		s[-n]="7"
		return(int(''.join(s)))
	else:
		s[-n]="3"
		s=int(''.join(s))
		return(plus(s,n+1))

c=0

if N<=356: c=0
elif N<=999:
	x=357
	while x<=N:
		s=str(x)
		if "3" in s and "5" in s and "7" in s: c+=1
		if x==777: break
		x=plus(x,1)
else:
	m=len(str(N))-1
	c=pro(m)
	x=int("3"*(m+1))
	while x<=N:
		s=str(x)
		if "3" in s and "5" in s and "7" in s: c+=1
		if x==int("7"*(m+1)): break
		x=plus(x,1)

print(c)

Solution (Python):
N = input().strip()

maxn = ()
base = set(['357', '375', '537', '573', '735', '753'])

if int(N) < 357:
  print(0)
else:
  for n in range(len(N) - 3):
    newb = set()
    for b in base:
      new3b = set([b[:i] + '3' + b[i:] for i in range(len(b) + 1)])
      new5b = set([b[:i] + '5' + b[i:] for i in range(len(b) + 1)])
      new7b = set([b[:i] + '7' + b[i:] for i in range(len(b) + 1)])
      newb |= new3b | new5b | new7b
    base |= newb
  print(len([i for i in base if int(i) <= int(N)]))

Solution (Python):
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

def zen(n,used, new):

    usednum = len(used|set([new]))
    
    if n == 0:
        if usednum == 3:
            return 1
        else:
            return 0

    if usednum == 3:
        return 3**n
    if usednum == 2:
        return 3**n - 2**n
    if usednum == 1:
        return 3**n - 2*(2**n) +1
    return 3**n - 3*(2**n) + 3

def simo_init(n):
    if n == 0:
        return 0
    return 3 ** n - 3 * (2 ** n) + 3

n = input()
digit = len(n)

answer = 0
for i in range(digit):
    answer += simo_init(i)

def get_simo(n, dig,used):
    global answer
    if n == "":
        if len(used) == 3:
            answer += 1
        return
    if int(n[0]) > 3:
        answer += zen(dig-1, used, 3)
    if int(n[0]) > 5:
        answer += zen(dig-1, used, 5)
    if int(n[0]) > 7:
        answer += zen(dig-1, used, 7)

    
    
    first = int(n[0])
    if first in [3,5,7]:
        get_simo(n[1:], dig-1, used|set([first]))


get_simo(n,digit,set())
print(answer)

Solution (Python):
from math import log10
from math import factorial

n = int(input())
m_keta = int(log10(n)) + 1
res = 0
for i in range(3, m_keta):
    for n3 in range(i-3+1):
        for n5 in range(i-3-n3+1):
            n7 = i-3-n3-n5
            res += factorial(i)//(factorial(n3+1) * factorial(n5+1)* factorial(n7+1))
shichigo = (3,5,7)
cnt = 0
def tes(k, x):
    cnt = 0
    for s in shichigo:
        y = x + s * (10 ** (k-1))
        if y <= n:
            if k==1:
                if '3' in str(y) and '5' in str(y) and '7' in str(y):
                    cnt += 1 
                else:
                    continue
            else:
                cnt += tes(k-1, y)
        else:
            continue
    return cnt
cnt += tes(m_keta, 0)
res += cnt
print(res)

Solution (Python):
import itertools

N_st = input()
keta = len(N_st)
N = int(N_st)


hit53 =['3','5','7']
res = []

all_perm = []
for k in range(3,keta + 1):
    all_perm.extend(list(itertools.product(hit53,repeat= k)))
for a in all_perm:
    target = int(''.join(a))
    if target <= N and '3' in str(target) and '5' in str(target) and '7' in str(target):
        res.append(target)

print(len(res))