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):
from statistics import mean, median,variance,stdev
import sys
import math

y =input()
x = int(y)
num = 0
a = []
n=3
l = ["3","5","7","9"]
list = [["3","5","7"],["3","7","5"],["5","3","7"],["5","7","3"],["7","5","3"],["7","3","5"]]
s = [357,375,537,573,753,735]
for i in range(6):
    if s[i] <= x :num+=1



def rup(b,n):
    b[n] = '3'
    p = l.index(b[n-1])
    b[n-1] = l[p + 1]
    if b[n-1] == '9':
        b = rup(b, n-1)
    return b
st =0
b = []
d = []
while x >= pow(10,n):
    b = []
    for i in range(n+1):
        b.append('3')
    while "3" in b or "5" in b:
  
        p = l.index(b[n])
        b[n] = l[p+1]
        if b[n] == '9':
            b = rup(b,n)
        c = b
        if "3" in b and "5" in b and "7" in b:
 
            a = ''.join(b)
            if int(a) <= x:
                num += 1
 
    n+=1

print(num)

Solution (Python):
N = int(input())
L=[3,5,7]
answer = 0
for d in range(3,11):
    for x in range(pow(3,d)):
        value = 0
        prod = 1
        for dd in range(1,d+1):
            digit = L[x%pow(3,dd)//pow(3,dd-1)]
            prod *= digit
            value += digit*pow(10,dd-1)
        if value <= N and prod%3 == 0 and prod%5 == 0 and prod%7 == 0:
            answer += 1
print(answer)

Solution (Python):
ans = 0

def search(num, target):
  global ans
  if len(num) == len(target):
    if int(num) <= int(target) and "3" in num and "5" in num and "7" in num:
      ans+=1
  else:
    search(num+"3", target)
    search(num+"5", target)
    search(num+"7", target)
  

N = input()
length = len(N)
for i in range(3, length):
  ans += 3**i - 3 * (2**i - 1)
  



    
search("", N)
    
if len(N) >= 3:
  print(ans)
else:
  print(0)

Solution (Python):
s = input()
l = len(s)
N = int(s)
ans = 0
for i1, a in enumerate(" 357"):
    if l<9 and i1>0: break
    for i2, b in enumerate(" 357"):
        if l<8 and i2>0: break
        for i3, c in enumerate(" 357"):
            if l<7 and i3>0: break
            for i4, d in enumerate(" 357"):
                if l<6 and i4>0: break
                for i5, e in enumerate(" 357"):
                    if l<5 and i5>0: break
                    for i6, f in enumerate(" 357"):
                        if l<4 and i6>0: break
                        for g in " 357":
                            for h in " 357":
                                for i in " 357":
                                    for j in "357":
                                        try:
                                            s = a+b+c+d+e+f+g+h+i+j
                                            n = int(s)
                                            if N >= n and "3" in s and "5" in s and "7" in s:
                                                ans += 1
                                        except ValueError:
                                            pass
print(ans)

Solution (Python):
N = input()
keta = len(N) - 1
def rec(list1,list2,initial,time):
    for e in list1:
        for b in [0,1,2,3]:
            if b == 0:
                e_copy = e + "3"
                list2.append(e_copy)
            elif b == 1:
                e_copy = e + "5"
                list2.append(e_copy)
            elif b == 2:
                e_copy = e + "7"
                list2.append(e_copy)
            elif b == 3:
                e_copy = e
                list2.append(e_copy)
    list1.clear()
    
    if initial + 1 >= time :
        return list2
    else:
        return rec(list2,list1,initial + 1, time)
l1 = ["3","5","7"]
l2 = []
result = rec(l1,l2,0,keta)
result = [int(e) for e in result if e.count("3")*e.count("5")*e.count("7") >= 1]
result = list(set(result))
result.sort()
count = 0
for e in result:
    if int(N) < e:
        break
    count += 1
print(count)

Solution (Python):
from math import factorial as f

N = int(input())
ans = 0

def solve(S):
    
    if len(S)>2 and N<int(S):
        return 0
    cnt = 0
    if '3' in S and '5' in S and '7' in S:
        
        cnt += 1
    cnt += solve('3' + S)
    cnt += solve('5' + S)
    cnt += solve('7' + S)
    return cnt

ans = solve('')
print(ans)

Solution (Python):
def check(stmp):
    if len(set(stmp)) == 3:
        return True
    else:
        return False


def next753(stmp):
    dic = {"3": "5", "5": "7"}
    flag = True
    i = len(stmp) - 1
    while((check(stmp) is False) or (flag is True)):
        flag = False
        s = stmp[i]
        if s == "3" or s == "5":
            stmp = stmp[:i] + dic[s] + stmp[i + 1:]
            i = len(stmp) - 1
        else:
            while(stmp[i] == "7"):
                stmp = stmp[:i] + "3" + stmp[i + 1:]
                i -= 1
            stmp = stmp[:i] + dic[stmp[i]] + stmp[i + 1:]
            i = len(stmp) - 1

        

    return(int(stmp))


sN = input()
N = int(sN)

if len(sN) < 3:
    print(0)
    exit()
elif sN[0] == "8" or sN[0] == "9":
    ans = 0
    for i in range(3, len(sN) + 1):
        ans += 3 ** i - 3 * (2 ** i) + 3
    print(ans)
    exit()

ex = len(sN) - 1
ans = 0
for i in range(3, ex + 1):
    ans += 3 ** i - 3 * (2 ** i) + 3
tmp = int("3" * (len(sN) - 2) + "5" + "7")


while(tmp <= N):
    ans += 1
    tmp = next753(str(tmp))
    
print(ans)

Solution (Python):
n = input()

c = len(n)
ans = 0 
for i in range(3,c):
    ans += 3**i - ((2**i -2)*3) -3


a = [3,5,7]

for i in range(c-1):
    b = []
    for num in a:
        for s in ["3","5","7"]:
            b.append(int(str(num) + s))
        
    for ke in b:
        a.append(ke)


for num in a:
    if num <= int(n) and len(str(num)) == c:
        if str(num).count("3") >0 and str(num).count("5") >0 and str(num).count("7") >0 :
            
            ans += 1


print(ans)

Solution (Python):
import itertools
def calc_num(S,S_len):
    result = 0;
    l = [3,5,7];
    i = 3;
    while i <= S_len:
      for v in itertools.product(l,repeat=i):
        if int("".join(map(str, v))) <= S and list(set(v) & set(l)) == l: 
          result = result + 1;
      i = i + 1;
    return result
  
S = list(map(int,input()))
S_len = len(S);
S = int("".join(map(str, S)));
result = calc_num(S,S_len);
print(result)