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:
a = input()
c=0
for i in range(356,int(a)):
    if str(i).find('3') == -1:
        continue
    elif str(i).find('5') == -1:
        continue
    elif str(i).find('7') == -1:
        continue
    elif (str(i).find('1') == -1) and (str(i).find('2') == -1) and (str(i).find('4') == -1) and (str(i).find('6') == -1) and (str(i).find('8') == -1) and (str(i).find('8') == -1):
        c+=1

print(c)

Submission status: Wrong Answer

Solution code:
n = int(raw_input().split()[0])

o1 = [3,5,7]
arr = [n]
ans = 0
def check(num):
    l = len(str(num))
    s = []
    for i in range(l):
        if str(num)[i] not in s:
            s.append(str(num)[i])
    if len(s) == 3:
        return True
    else:
        return False

for i in range(8):
    o2 = []
    for num in o1:
        new1 = num*10+3
        new2 = num*10+5
        new3 = num*10+7
        o2.append(new1)
        o2.append(new2)
        o2.append(new3)
        if check(new1):
            arr.append(new1)
            if n == new1:
                ans += 1
        if check(new2):
            arr.append(new2)
            if n == new2:
                ans += 1
        if check(new3):
            arr.append(new3)
            if n == new3:
                ans += 1
    o1 = o2
arr.sort()
print arr.index(n)

Submission status: Wrong Answer

Solution code:
n = int(raw_input().split()[0])

o1 = [3,5,7]
arr = []

def check(num):
    l = len(str(num))
    s = []
    for i in range(l):
        if str(num)[i] not in s:
            s.append(str(num)[i])
    if len(s) == 3:
        return True
    else:
        return False

for i in range(8):
    o2 = []
    for num in o1:
        new1 = num*10+3
        new2 = num*10+5
        new3 = num*10+7
        o2.append(new1)
        o2.append(new2)
        o2.append(new3)
        if check(new1):
            arr.append(new1)
        if check(new2):
            arr.append(new2)
        if check(new3):
            arr.append(new3)
    o1 = o2
arr.sort()
if n in arr:
    print arr.index(n)+1
else:
    arr.append(n)
    print arr.index(n)

Submission status: Wrong Answer

Solution code:
n = int(raw_input().split()[0])

o1 = [3,5,7]
arr = [n]

def check(num):
    l = len(str(num))
    s = []
    for i in range(l):
        if str(num)[i] not in s:
            s.append(str(num)[i])
    if len(s) == 3:
        return True
    else:
        return False

for i in range(8):
    o2 = []
    for num in o1:
        new1 = num*10+3
        new2 = num*10+5
        new3 = num*10+7
        o2.append(new1)
        o2.append(new2)
        o2.append(new3)
        if check(new1):
            arr.append(new1)
        if check(new2):
            arr.append(new2)
        if check(new3):
            arr.append(new3)
    o1 = o2
arr.sort()
ans = arr.index(n)
if check(n):
    ans += 1
print ans

Submission status: Wrong Answer

Solution code:
n = long(raw_input().split()[0])

arr = []

o1 = [3,5,7]


def check(num):
    l = len(str(num))
    s = []
    for i in range(l):
        if str(num)[i] not in s:
            s.append(str(num)[i])
    if len(s) == 3:
        return True
    else:
        return False

for i in range(8):
    o2 = []
    for num in o1:
        new1 = num*10+3
        new2 = num*10+5
        new3 = num*10+7
        o2.append(new1)
        o2.append(new2)
        o2.append(new3)
        if check(new1):
            arr.append(new1)
        if check(new2):
            arr.append(new2)
        if check(new3):
            arr.append(new3)
    o1 = o2
arr.sort()
ans = 0
for i in arr:
    if n > i:
        ans += 1
    else:
        break
print ans

Submission status: Wrong Answer

Solution code:
n = long(raw_input().split()[0])

arr = [n]

o1 = [3,5,7]


def check(num):
    l = len(str(num))
    s = []
    for i in range(l):
        if str(num)[i] not in s:
            s.append(str(num)[i])
    if len(s) == 3:
        return True
    else:
        return False

for i in range(8):
    o2 = []
    for num in o1:
        new1 = num*10+3
        new2 = num*10+5
        new3 = num*10+7
        o2.append(new1)
        o2.append(new2)
        o2.append(new3)
        if check(new1):
            arr.append(new1)
        if check(new2):
            arr.append(new2)
        if check(new3):
            arr.append(new3)
    o1 = o2
arr.sort()
print arr.index(n)

Submission status: Wrong Answer

Solution code:
n = long(raw_input().split()[0])

arr = [n]

o1 = [3,5,7]


def check(num):
    l = len(str(num))
    s = []
    for i in range(l):
        if str(num)[i] not in s:
            s.append(str(num)[i])
    if len(s) == 3:
        return True
    else:
        return False

for i in range(8):
    o2 = []
    for num in o1:
        new1 = num*10+3
        new2 = num*10+5
        new3 = num*10+7
        o2.append(new1)
        o2.append(new2)
        o2.append(new3)
        if check(new1):
            arr.append(new1)
        if check(new2):
            arr.append(new2)
        if check(new3):
            arr.append(new3)
    o1 = o2
arr.sort()
print arr
print arr.index(n)

Submission status: Wrong Answer

Solution code:
n = int(raw_input().split()[0])

arr = [n]

o1 = [3,5,7]


def check(num):
    l = len(str(num))
    s = []
    for i in range(l):
        if str(num)[i] not in s:
            s.append(str(num)[i])
    if len(s) == 3:
        return True
    else:
        return False
for i in range(8):
    o2 = []
    for num in o1:
        new1 = num*10+3
        new2 = num*10+5
        new3 = num*10+7
        o2.append(new1)
        o2.append(new2)
        o2.append(new3)
        if check(new1):
            arr.append(new1)
        if check(new2):
            arr.append(new2)
        if check(new3):
            arr.append(new3)
    o1 = o2
arr.sort()

print arr.index(n)

Submission status: Wrong Answer

Solution code:
n = int(raw_input())

arr = [n]

o1 = [3,5,7]


def check(num):
    l = len(str(num))
    s = []
    for i in range(l):
        if str(num)[i] not in s:
            s.append(str(num)[i])
    if len(s) == 3:
        return True
    else:
        return False
for i in range(8):
    o2 = []
    for num in o1:
        new1 = num*10+3
        new2 = num*10+5
        new3 = num*10+7
        o2.append(new1)
        o2.append(new2)
        o2.append(new3)
        if check(new1):
            arr.append(new1)
        if check(new2):
            arr.append(new2)
        if check(new3):
            arr.append(new3)
    o1 = o2
arr.sort()
print arr.index(n)

Submission status: Wrong Answer

Solution code:
s = input()
n = int(s)
dg = len(s)

all_list = []

for i in '753':
    for j in '753':
        for k in '753':
            all_list.append(''.join([i,j,k]))

for i in range(4,dg+1):
    add_list = []
    for c in '753':
        add_list += [''.join(c+e) for e in all_list]
    all_list += add_list

count = 0
test = []

res = sum([True for _ in all_list if set(list(_))=={'7','5','3'} and int(_) <= n])
print(res)

Submission status: Wrong Answer

Solution code:
from math import log10

n = int(input())
m = int(log10(n)) + 1

ans = 0

def dfs(i, s):
    if i == m:
        if not '0' in s and all(a in str(int(s)) for a in '753') and int(s) <= n:
            return 1
        return 0
    res = 0
    for a in '0357':
        res += dfs(i+1, s + a)
    return res

print(dfs(0, ''))

Submission status: Wrong Answer

Solution code:
from copy import deepcopy


def mk_array(init_val, *args):
    args = args[::-1]
    res = [init_val for _ in range(args[0])]
    for arg in args[1:]:
        res = [deepcopy(res) for _ in range(arg)]
    return res


N = int(input())
e = [0 for _ in range(N + 1)]

for i in range(2, N + 1):
    for j in range(2, i + 1):
        while i % j == 0:
            e[j] += 1
            i //= j

counts = list(filter(lambda x: x > 0, e))
prim_count = len(counts)
counts = [0] + counts  # 1-indexed 化
dp = mk_array(0, prim_count + 1, 75 + 1)
dp[0][1] = 1

for i in range(1, prim_count + 1):
    for j in range(1, 75 + 1):
        for k in range(min(counts[i], 75 // j - 1) + 1):
            dp[i][j * (k + 1)] += dp[i - 1][j]

print(dp[prim_count][75])

Submission status: Wrong Answer

Solution code:
N = input()
def rec(list1,list2,initial,time):
    for e in list1:
        for b in [0,1,2,3]:
            if b == 0:
                e_copy = e
                list2.append(e_copy)
            elif b == 1:
                e_copy = e + "3"
                list2.append(e_copy)
            elif b == 2:
                e_copy = e + "5"
                list2.append(e_copy)
            elif b == 3:
                e_copy = e + "7"
                list2.append(e_copy)
    list1.clear()
    # initial + 1 がn回目のループ
    if initial + 1 >= time :
        return list2
    else:
        return rec(list2,list1,initial + 1, time)
l1 = ["3","5","7"]
l2 = []
result = rec(l1,l2,0,len(N)-2)
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)

Submission status: Wrong Answer

Solution code:
N = int(input())
def dfs(s): # 文字列 s で始まる七五三数の個数
  if int(s) > N:
    return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
    for c in '753':
      ret += dfs(s + c)
      return ret
print(dfs('0'))

Submission status: Wrong Answer

Solution code:
import itertools as t;N=input();X=[]
for i in range(9):X+=list(t.product('357',repeat=i))
print(sum(len(set(i))>2and int(''.join(i))<=int(N)for i in X))

Submission status: Wrong Answer

Solution code:
def make_candidate(N, seed, l):
    seed3 = seed+"3"
    seed5 = seed+"5"
    seed7 = seed+"7"

    if int(seed3) < N:
        l.append(seed3)
        l = make_candidate(N, seed3, l)
    
    if int(seed5) < N:
        l.append(seed5)
        l = make_candidate(N, seed5, l)
    
    if int(seed7) < N:
        l.append(seed7)
        l = make_candidate(N, seed7, l)
    
    return l


N = int(input())

l = make_candidate(N, "3", [])
l = make_candidate(N, "5", l)
l = make_candidate(N, "7", l)

num = 0
for n in l:
    s = str(n)
    exist = s.count('3') * s.count('5') * s.count('7')

    if exist>0:
        num = num + 1

print(num)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

N = int(raw_input())
Array3 = [[] for i in range(9)]
Array5 = [[] for i in range(9)]
Array7 = [[] for i in range(9)]
Array53 = [[] for i in range(9)]
Array75 = [[] for i in range(9)]
Array73 = [[] for i in range(9)]
Array753 = [[] for i in range(9)]
Array3[0].append(3)
Array5[0].append(5)
Array7[0].append(7)
Arraytot = []

for i in range(8):
    Array753[i+1].extend(map(lambda x: x*10+7, Array753[i]))
    Array753[i+1].extend(map(lambda x: x*10+5, Array753[i]))
    Array753[i+1].extend(map(lambda x: x*10+3, Array753[i]))
    Array753[i+1].extend(map(lambda x: x*10+3, Array75[i]))
    Array753[i+1].extend(map(lambda x: x*10+5, Array73[i]))
    Array753[i+1].extend(map(lambda x: x*10+7, Array53[i]))
    Array75[i+1].extend(map(lambda x: x*10+5, Array75[i]))
    Array75[i+1].extend(map(lambda x: x*10+7, Array75[i]))
    Array75[i+1].extend(map(lambda x: x*10+7, Array5[i]))
    Array75[i+1].extend(map(lambda x: x*10+5, Array7[i]))
    Array73[i+1].extend(map(lambda x: x*10+3, Array73[i]))
    Array73[i+1].extend(map(lambda x: x*10+7, Array73[i]))
    Array73[i+1].extend(map(lambda x: x*10+7, Array3[i]))
    Array73[i+1].extend(map(lambda x: x*10+3, Array7[i]))
    Array53[i+1].extend(map(lambda x: x*10+3, Array53[i]))
    Array53[i+1].extend(map(lambda x: x*10+5, Array53[i]))
    Array53[i+1].extend(map(lambda x: x*10+5, Array3[i]))
    Array53[i+1].extend(map(lambda x: x*10+3, Array5[i]))
    Array3[i+1].extend(map(lambda x:x*10+3, Array3[i]))
    Array5[i+1].extend(map(lambda x:x*10+5, Array5[i]))
    Array7[i+1].extend(map(lambda x:x*10+7, Array7[i]))
    Arraytot.extend(Array753[i+1])

Arraytot.sort()
ans = 0
for i in Arraytot:
    if i < N:
        ans+=1
    else:
        break
print ans

Submission status: Wrong Answer

Solution code:
def make753(num):
  if num == 1:
    return [3, 5, 7]
  else:
    new_table = []
    tmp_table = make753(num-1)
    for i in range(3, 8, 2):
      new_table.extend(list(map(lambda x : 10*x + i, tmp_table)))
    new_table.extend([3, 5, 7])
    return new_table

def check753(num):
  num_list = list(str(num))
  if "3" in num_list and "5" in num_list and "7" in num_list:
    return True
  else:
    return False

N = input()
length = len(N)
n = int(N)
if length < 3:
  print(0)
else:
  list_753 = make753(length)
  tmp_list = list(list_753)
  for candidate in tmp_list:
    if not check753(candidate):
      list_753.remove(candidate)
  list_753.sort()
  count = 0
  for i in list_753:
    if n > i:
      count += 1
    else: break
  print(count)

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
nd = len(str(n))
if n <= 356:
    print 0
else:
    a3 = [357, 375, 537, 573, 735, 753]
    arr_a = [[]for i in range(nd-2)]
    arr_a[0] = a3
    all_num = [357, 375, 537, 573, 735, 753]
    for i in range(1, nd-2):
        for j in arr_a[i-1]:
            arr_a[i].append(j*10+3)
            arr_a[i].append(j*10+5)
            arr_a[i].append(j*10+7)
        for k in arr_a[i]:
            all_num.append(k)
    # print arr_a
    
    def only_2kind(a,b,n):
        if n <= 3:
            return []
        else:
            all_num = []
            o = [10 * a + b, 10 * b + a, 10 * a + a, 10 * b + b]
            for j in range(n-3):
                o2 = []
                for i in range(len(o)):
                    o2.append(o[i]*10+a)
                    o2.append(o[i] * 10 + b)
                # print o2
                for i in range(len(o2)):
                    if o2[i] != int(str(a)*(j+3)) and o2[i] != int(str(b) * (j + 3)):
                        all_num.append(o2[i]*10+(15-a-b))
                o = o2
            return all_num
    
    all_num+=(only_2kind(3,5,nd)+only_2kind(5,7,nd)+only_2kind(3,7,nd))
    all_num.append(n)
    all_num.sort()
    # print len(all_num)
    # for i in all_num:
    #     print i
    print all_num.index(n)

Submission status: Wrong Answer

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

for n in range(1, max+1):
	for i in range(0, len(str(n))):
		if "7" != str(n)[i] and "5" != str(n)[i] and "3" != str(n)[i]:
			break
		if i == len(str(n))-1:
			count=count+1

print(count)

Submission status: Wrong Answer

Solution code:
N = input()
cnt = 0
flag7 = 0
flag5 = 0
flag3 = 0

for i in range(int(N)):
    flag7 = 0
    flag5 = 0
    flag3 = 0
    for j in range(0,len(str(i))):
        if(str(i)[j] == "7"):
            flag7 = 1
        elif(str(i)[j] == "5"):
            flag5 = 1
        elif(str(i)[j] == "3"):
            flag3 = 1
        else:
            flag7 = 0
            flag5 = 0
            flag3 = 0 
            break
    if(flag7 == 1 and flag5 == 1 and flag3 == 1):
        cnt = cnt +1
        #print(i)

print(cnt)

Submission status: Wrong Answer

Solution code:
max = int(input())
count=0
for x in range(1, max+1):
  for y in range(0, len(str(x))):
    currentNum = int(str(x)[y])
    if currentNum == 7 or currentNum == 5 or currentNum == 3:
      if y+1 == len(str(x)):
        count = count+1
    else:
      break
print (count)

Submission status: Wrong Answer

Solution code:
def main():
    """
    1 <= N  <= 10^9

    七五三数とは以下の条件を満たす正の整数
    十進法で表記したとき、
    数字 7, 5, 3 がそれぞれ 1回以上現れ、これら以外の数字は現れない
    """
    N = int(input())

    ans = f(N)
    print(ans)


def f(N):
    """
    Nの桁数がdのとき、d-1桁の数で753数であれば満たす
    上記d-1桁の753数に対して、
    753のそれぞれの数について
    桁追加をして、それがN以下であれば良い

    もっと簡単に考える
    d桁のとき並べる数字は3種類とその桁を使わないときに0埋めすると考えられる
    よって、並べ方の最大は (3+1)^9 = 262,144
        実際は実装上 349,525
    """
    d = len(str(N))
    ans = run_perm(N, d, [0, 3, 5, 7])
    # ans = TLE(N)

    return ans


def run_perm(N, d, types):
    """
    全列挙: TLE, 文字列処理がダメ

    http://www.geisya.or.jp/~mwm48961/kou3/onajimono1.htm
    による並べ方をやろうとしたけど断念
    """
    from collections import Counter
    a = [0] * d
    nth = 0

    def perm(N, i, d, ans):
        nonlocal nth
        nth += 1

        if i == d:
            s = "".join(str(x) for x in a).lstrip("0")
            c = Counter(s)
            if c["0"] == 0 and \
                c["7"] >= 1 and \
                c["5"] >= 1 and \
                c["3"] >= 1 and \
                    int(s) <= N:

                ans += 1

            return ans

        for t in types:
            a[i] = t
            ans = perm(N, i+1, d, ans)

        return ans

    ans = perm(N, 0, d, 0)
    print(nth)

    return ans


def TLE(N):
    ans = 0
    for i in range(357, N + 1):
        s = str(i)
        c7, c5, c3 = s.count("7"), s.count("5"), s.count("3")
        if len(s) == c7 + c5 + c3 and \
                c7 >= 1 and c5 >= 1 and c3 >= 1:
            ans += 1

    return ans


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
a = [3,5,7]
n = int(stdin.readline())
ans = 0
i = 0
while True:
 if i >= len(a):
  break
 cur = a[i]
 if cur > n:
  break
 ans+=1
 a.append(cur*10 + 3); a.append(cur*10 + 5); a.append(cur*10 + 7)
 i+=1
print ans

Submission status: Wrong Answer

Solution code:
import itertools, bisect
N = int(input())
d = len(str(N))
L =  []
for k in range(3,d+1):
    for a in itertools.product(["3","5","7"],repeat=k):
        if "3" in a and "5" in a and "7" in a:
            L.append(int("".join(a)))
L = sorted(L)
print(bisect.bisect_left(L,N))

Submission status: Wrong Answer

Solution code:
# your code goes here
max = int(input())
num = 0
count = 0
testNum = 0
for n in range(0,max):
	cnt = 0
	for n in range (0,len(str(testNum))):
		num = int(str(testNum)[cnt])
		if num == 7 or num == 5 or num == 3:
			cnt = cnt+1
		else:
			break
		if cnt+1 == len(str(testNum)):
			count = count +1
		testNum = testNum + 1
		
print(count)

Submission status: Wrong Answer

Solution code:
def prf(m):
    pf = {}
    for i in range(2,int(m**0.5)+1):
        while m % i == 0:
            pf[i] = pf.get(i,0)+1
            m //= i
    if m>1:pf[m] = 1
    return pf
import bisect
from collections import defaultdict
Pr = defaultdict(lambda: -1)

m = int(input())
for i in range(1,m+1):
    j = prf(i)
    for k, l in j.items():
        Pr[k] -= l
A = list(Pr.values())
a = dict() 
for i in [3,5,15,25,75]:
    a[i] = bisect.bisect_right(A,-i)
print(a[3]*a[5]*(a[5]-1)//2+(a[15]-a[5])*(a[5]-1)+(a[3]-1)*a[25]+a[75])

Submission status: Wrong Answer

Solution code:
def main():
	import numpy as np
	n = input()
	d = len(n)
	dd = np.zeros(d)
	for i in range(d):
		if(int(n[i]) >= 7):
			dd[i] = 3
		elif(int(n[i]) >= 5):
			dd[i] = 2
		elif(int(n[i]) >= 3):
			dd[i] = 1
		else:
			dd[i] = 0
	max = ""
	for i in range(d):
		if(dd[-i-1] == 3):
			max = "7"+max
		elif(dd[-i-1] == 2):
			max = "5"+max
		elif(dd[-i-1] == 1):
			max = "3"+max
		else:
			if(i != d-1):
				max = "7"+max
				dd[-i-1] -= 1

	r = 0		
	
	for i in range(3, d+1):#i keta wo tukuru
		for j in range(3**i):
			count = j
			buf = ""
			for k in range(1, i+1):#k keta
				if(count // 3**(i-k) == 2):
					buf = buf+"7"
					count -= 3**(i-k)*2
				elif(count // 3**(i-k) == 1):
					buf = buf+"5"
					count -= 3**(i-k)*1
				elif(count // 3**(i-k) == 0):
					buf = buf+"3"
			if("7" in buf and "5" in buf and "3" in buf and int(buf) <= int(max)):
				r += 1
				#print(buf)
	print(r)
		
main()

Submission status: Wrong Answer

Solution code:
N=int(input())
f=lambda c:sum([list(map(lambda z:z+y,f(c-1))) for y in '357'],[]) if c!=0 else ['']
print(sum([len(list(filter(lambda y:y==3,list(map(lambda x:len(set(sorted(x))),filter(lambda z:int(z)<N,f(e+1))))))) for e in range(10)]))

Submission status: Wrong Answer

Solution code:
N=int(input())

def dfs(s):
    if int(s)>N:
        return 0
    
    if all(s.count(c)>0 for c in "753"):
        ret=1
    else:
        ret=0

    for c in "753":
        ret+=dfs(s+c)
    return ret

dfs("0")

Submission status: Wrong Answer

Solution code:
import itertools
N=int(input())
L=[]
S=[]
for i in range(3,10):
    for x in itertools.product('357',repeat=i):
        L.append(x)
for x in L:
    s=""
    for y in x:
        s+=y
    if "3" in s and "5" in s and "7" in s:
        S.append(int(s))
S.append(N)
S=sorted(S)
print(S.index(N))

Submission status: Wrong Answer

Solution code:
N=input()
a=0
if 10**(len(N)-1)*5+1>int(N)>10**(len(N)-1)*3+1:
    for i in range(10**(len(N)-1)*3+1,int(N)+1,2):
        j=str(i)
        if "3"in j and "5"in j and "7"in j:
            if len(j)==j.count("3")+j.count("5")+j.count("7"):
                a+=1
    a+=3**(len(N)-1)-3*2**(len(N)-1)+3
elif 10**(len(N)-1)*7+1>int(N)>10**(len(N)-1)*5+1:
    for i in range(10**(len(N)-1)*5+1,int(N)+1,2):
        j=str(i)
        if "3"in j and "5"in j and "7"in j:
            if len(j)==j.count("3")+j.count("5")+j.count("7"):
                a+=1
    a+=2*3**(len(N)-1)-5*2**(len(N)-1)+15
elif 10**(len(N)-1)*7+1<int(N):
    for i in range(10**(len(N)-1)*7+1,int(N)+1,2):
        j=str(i)
        if "3"in j and "5"in j and "7"in j:
            if len(j)==j.count("3")+j.count("5")+j.count("7"):
                a+=1
    a+=3*3**(len(N)-1)-7*2**(len(N)-1)+21
elif int(N)<10**(len(N)-1)*3+1:
    for i in range(10**(len(N)-1)+1,int(N)+1,2):
        j=str(i)
        if "3"in j and "5"in j and "7"in j:
            if len(j)==j.count("3")+j.count("5")+j.count("7"):
                a+=1
    a+=3**(len(N)-1)-3*2**(len(N)-1)+3
print(a)

Submission status: Wrong Answer

Solution code:
N=input()
a=0
if int(N)>10**(len(N)-1)*3+1:
    for i in range(10**(len(N)-1)*3+1,int(N)+1,2):
        j=str(i)
        if "3"in j and "5"in j and "7"in j:
            if len(j)==j.count("3")+j.count("5")+j.count("7"):
                a+=1
    a+=3**(len(N)-1)-3*2**(len(N)-1)+3
if int(N)<10**(len(N)-1)*3+1:
    for i in range(10**(len(N)-1)+1,int(N)+1,2):
        j=str(i)
        if "3"in j and "5"in j and "7"in j:
            if len(j)==j.count("3")+j.count("5")+j.count("7"):
                a+=1
    a+=3**(len(N)-1)-3*2**(len(N)-1)+3
print(a)

Submission status: Wrong Answer

Solution code:
N=input()
a=0
for i in range(10**(len(N)-1)*3+1,int(N)+1,2):
    j=str(i)
    if "3"in j and "5"in j and "7"in j:
        if len(j)==j.count("3")+j.count("5")+j.count("7"):
            a+=1
a+=3**(len(N)-1)-3*2**(len(N)-1)+3
print(a)

Submission status: Wrong Answer

Solution code:
N=int(input())
X,Y=("7","5","3"),("0","1","2","4","6","8","9")
a=0
for i in range(1,N):
    i=str(i)
    b=0
    for j in X:
        if not j in i:b=1
    for k in Y:
        if k in i:b=1
    if b==0:
        a+=1
print(a)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def count357(s):
    nums = set(["3", "5", "7"])
    count = 0
    for _ in range(len(str(s)) - 1):
        r = set()
        for num in nums:
            for v in ["3", "5", "7"]:
                new_v = num+v
                r.add(new_v)
                if "3" in new_v and "5" in new_v and "7" in new_v and int(new_v) < s:
                   count += 1
        nums = r
            
    print(count)

s = int(input())
count357(s)