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: Time Limit Exceeded

Solution code:
import math

N = int(input())
count = 0
li = [3, 5, 7]

for i in range(300, N+1):
  t = []

  while(True):
    if i % 10 not in li:
      break

    if i % 10 not in t:
      t.append(i % 10)      

    i = math.floor(i / 10)

    if i == 0 and 3 in t and 5 in t and 7 in t:
      count += 1
      break

print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
count = 0
ans = [i for i in range(1,n+1) if i%2==1]
def gcd(a,b):
    c = max(a,b)
    d = min(a,b)
    if b == 0:
        return a
    return gcd(b,a%b)

for i in ans:

    i_str = str(i)
    if i_str[0]=='3' or i_str[0]=='5' or i_str[0]=='7':
        three = i_str.count('3')
        five = i_str.count('5')
        seven = i_str.count('7')
        sum_number = three + five + seven
        if len(i_str) == sum_number and three>0 and five>0 and seven>0:
            count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
count = 0
ans = [i for i in range(1,n+1) if str(i)[0]=='3' or str(i)[0]=='5' or str(i)[0]=='7']
def gcd(a,b):
    c = max(a,b)
    d = min(a,b)
    if b == 0:
        return a
    return gcd(b,a%b)

for i in ans:

    i_str = str(i)
    if i_str[0]=='3' or i_str[0]=='5' or i_str[0]=='7':
        three = i_str.count('3')
        five = i_str.count('5')
        seven = i_str.count('7')
        sum_number = three + five + seven
        if len(i_str) == sum_number and three>0 and five>0 and seven>0:
            count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
count = 0
def gcd(a,b):
    c = max(a,b)
    d = min(a,b)
    if b == 0:
        return a
    return gcd(b,a%b)

for i in range(1,n+1):

    i_str = str(i)
    if i_str[0]=='3' or i_str[0]=='5' or i_str[0]=='7':
        three = i_str.count('3')
        five = i_str.count('5')
        seven = i_str.count('7')
        sum_number = three + five + seven
        if len(i_str) == sum_number and three>0 and five>0 and seven>0:
            count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
count = 0
for i in range(1,n+1):
    i_str = str(i)
    three = i_str.count('3')
    five = i_str.count('5')
    seven = i_str.count('7')
    sum_number = three + five + seven
    if len(i_str) == sum_number and three>0 and five>0 and seven>0:
        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
def p_c():
    import sys
    sys.setrecursionlimit(10 ** 9)
    n = int(input())
    ans = 0

    def dfs(s):
        """
        :type s: str
        """
        if int(s) > n:
            return 0
        ret = 1 if all(s.count(c) for c in "753") else 0
        for c in "753":
            ret += dfs(s.join(c))
        return ret

    print(dfs("0"))
    
p_c()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
sitigosan_list = [3, 5, 7]
count = 0

if n < 357:
    print(0)
    exit()

def make_753(num):
    b = str(num) + '3'
    c = str(num) + '5'
    d = str(num) + '7'
    sitigosan_list.append(int(b))
    sitigosan_list.append(int(c))
    sitigosan_list.append(int(d))


for i in sitigosan_list:
    make_753(i)
    if max(sitigosan_list) > n:
        break

for j in sitigosan_list:
    if '3' in str(j) and '5' in str(j) and '7' in str(j) and j <= n:
        count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
p=set(['3','5','7'])
ans=0
for i in range(357,n+1):
  ans+=((len(p-set(str(i)))==0) and (len(set(str(i))-p)==0))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n753 = set()
for i in range(357, 77777753+1):
    s = str(i)
    if "1" in s:
        continue
    if "2" in s:
        continue
    if "4" in s:
        continue
    if "6" in s:
        continue
    if "8" in s:
        continue
    if "9" in s:
        continue
    if "3" not in s:
        continue
    if "5" not in s:
        continue
    if "7" not in s:
        continue
    n753.add(i)


N = int(input())

print(len([1 for n in n753 if n <= N]))

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
count = 0
for n in range(num + 1):
  is3 = False
  is5 = False
  is7 = False
  nStr = str(n)
  for i in range(len(nStr)):
    if nStr[i] == '3':
      is3 = True
    elif nStr[i] == '5':
      is5 = True
    elif nStr[i] == '7':
      is7 = True
    else:
      is3 = False
      break
  if is3 and is5 and is7:
    count += 1
print(str(count))

Submission status: Time Limit Exceeded

Solution code:
# 2019-11-11 16:07:35(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

digits = ['3', '5', '7']

def main():
    # 357 以上
    # 3, 5, 7 のいずれかを使わない数字の個数をnから引けばいい
    n = int(sys.stdin.readline().rstrip())

    if n < 357:
        print(0)
        sys.exit()

    count = 0
    for m in range(357, n+1):
        m = str(m)
        c3, c5, c7 = 0, 0, 0
        for d in m:
            if d == '3':
                c3 += 1
            elif d == '5':
                c5 += 1
            elif d == '7':
                c7 += 1
            else:
                break
        else:
            if c3 >= 1 and c5 >= 1 and c7 >= 1:
                count += 1

    print(count)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import bisect


n = int(stdin.readline().rstrip())

li = [7,5,3]
point = 0
for i in range(n+1):
    s = str(i)
    if s.count("7") > 0 and s.count("5") > 0 and s.count("3") > 0 and s.count("0") == 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:
        point += 1
print(point)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=input()
l=len(n)
n=int(n)
data=[["0"]*l for i in range(4**l)]
for i in range(4**l):
    k=i
    for j in range(l):
        a=k//4**(l-1-j)
        if a==1:
            data[i][j]="3"
        if a==2:
            data[i][j]="5"
        if a==3:
            data[i][j]="7"
        k%=4**(l-1-j)
ans=0
for u in data:
    num=int("".join(u))
    if num<=n:
        num=str(num)
        if "0" not in num and "3" in num and "5" in num and "7" in num:
            ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
N=int(input())
if N < 357 :
    print(0)
    sys.exit()
L={"3","5","7"}
ans=0
for i in range(357,N+1,2):
   A = {str(i)[n] for n in range(len(str(i)))}
   if A==L :
       ans+= 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
good=['3','5','7']
bad=['0','1','2','4','6','8','9'] 
ans=0
for i in range(n+1):
     if all(j in str(i) for j in good) and all(k not in bad for k in str(i)):
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
good=['3','5','7']
bad=['0','1','2','4','6','8','9'] 
ans=0
for i in range(n+1):
     if all(j in list(str(i)) for j in good) and all(k not in bad for k in list(str(i))):
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
good=['3','5','7']
bad=['0','1','2','4','6','8','9'] 
ans=0
for i in range(n+1):
     if all(j in list(str(i)) for j in good) and all(k not in list(str(i)) for k in bad):
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

def ju(n):
    l=list(str(n))
    j=[0]*3
    f=0
    for i in range(len(l)):
        if l[i]=='3':
            j[0]=1
        elif l[i]=='5':
            j[1]=1
        elif l[i]=='7':
            j[2]=1
        else:
            f=1
    if sum(j)==3 and f==0:
        return 1
    else:
        return 0

zenbu=[3,5,7]

for i in range(10):
    tmp=[]
    for j in zenbu:
        tmp.append(j+3*(10**(i+1)))
        tmp.append(j+5*(10**(i+1)))
        tmp.append(j+7*(10**(i+1)))
        tmp.append(j)
    zenbu=tmp
  
ans=0
for i in zenbu:
    if i<=n and ju(i)==1:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools as it


def is_753(n):
    dic753 = {}
    for i in str(n):
        if i == "7":
            dic753[7] = True
        elif i == "5":
            dic753[5] = True
        elif i == "3":
            dic753[3] = True
        else:
            return False
    if len(dic753) >= 3:
        return True
    else:
        return False


N = int(input())
dig = 3
candidate = []
dig = 3
while True:
    for i in it.product([3, 5, 7], repeat=dig):
        a = int("".join(map(str, i)))
        if a > N:
            break
        else:
            candidate.append(a)
    dig += 1
for i in candidate:
    if is_753(i):
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

counter = 0
for i in range(0,n + 1):
  i_str = str(i)
  i_list = list(i_str)

  if i_list.count("0") ==0 and i_list.count("1") ==0 and i_list.count("2") == 0 and i_list.count("3") >=1 and i_list.count("4")==0 and i_list.count("6")==0 and i_list.count("8")==0 and i_list.count("9")==0 and i_list.count("5") >=1and i_list.count("7") >=1 :
    counter += 1
    
print(counter)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
se = set('357')
ans = 0
for i in range(1,n+1):
    s = str(i)
    ss = set(s)
    if ss == se:
        ans +=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
i = int(input())

count = 0;

for j  in range(i+1):
    lst = []
    while j > 0:
        lst.append(j%10)
        j //= 10 # 必須
    lst.reverse()
    
    flag3 = 3 in lst
    flag5 = 5 in lst
    flag7 = 7 in lst
    
    flag0 = 0 in lst
    flag1 = 1 in lst
    flag2 = 2 in lst
    flag4 = 4 in lst
    flag6 = 6 in lst
    flag8 = 8 in lst
    flag9 = 9 in lst

    if not flag0 and not flag1 and not flag2 and not flag4 and not flag6 and not flag8 and not flag9 :
        if flag3 and flag5 and flag7 :
            count = count + 1
            
print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def Check753(num):
    s = str(num)
    if s.count("3")==0 or s.count("5")==0 or s.count("7")==0:
        return 0
    elif s.count("3") + s.count("5") + s.count("7") != len(s):
        return 0
    else:
        return 1
ans = 0
for i in range(357,n+1,2):
    ans += Check753(i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
ans=0
n=int(input())
def tri(x):
	p=""
	while x>0:
		p+=str(x%4)
		x//=4
	return p[::-1]
if n>=50000000:
	ans=4470
	k=51111113
	i=32768
else:
	i=16
	k=357
while k<=n:
	c0=0
	c1=0
	c2=0
	for j in range(len(tri(i))):
		if tri(i)[j]=="1":
			c0+=1
		elif tri(i)[j]=="2":
			c1+=1
		elif tri(i)[j]=="3":
			c2+=1
		else:
			c0=0
			break
	if c0!=0 and c1!=0 and c2!=0:
		ans+=1
	i+=1
	k=0
	for j in range(len(tri(i))):
		k+=(int(tri(i)[-j-1])*2+1)*(10**j)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
ans=0
n=int(input())
cnt=0
def tri(x):
	p=""
	while x>0:
		p+=str(x%4)
		x//=4
	return p[::-1]
i=16
k=357
while k<=n:
	c0=0
	c1=0
	c2=0
	for j in range(len(tri(i))):
		if tri(i)[j]=="1":
			c0+=1
		elif tri(i)[j]=="2":
			c1+=1
		elif tri(i)[j]=="3":
			c2+=1
		else:
			c0=0
			break
	if c0!=0 and c1!=0 and c2!=0:
		ans+=1
	i+=1
	k=0
	for j in range(len(tri(i))):
		k+=(int(tri(i)[-j-1])*2+1)*(10**j)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = input()
l = ['3', '5', '7']
d = len(N)
N = int(N)

if N - 357 < 0:
    print(0)
    exit()

#d-1桁以下の753数
aa = 0
for i in range(3, d):
    aa += 3 ** i - 3 * (2 ** i - 2) - 3

#N以下のd桁の753数
a = [i for i in itertools.combinations_with_replacement(l, d)]
b = [i for i in a if len(set(i)) == 3]
c = []
count = 0
for k in b:
    temp = [i for i in itertools.permutations(k)]
    temp = list(set(temp))
    for j in temp:
        if int(''.join(j)) <= N:
            count += 1

print(aa + count)

Submission status: Time Limit Exceeded

Solution code:
print(len([i for i in range(1,int(input())+1) if sorted(list(set(str(i))))==["3","5","7"]]))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
numbers = range(1,N+1)
import re
ans = 0
for number in numbers: 
    digits = list(str(number))
    if re.match("^(3|5|7)+$",str(number)) and all(x in digits for x in ['3','5','7']):
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
count = 0
for i in range(1, n+1):
    k = 1
    hantei = 0
    s = list(map(int, list(str(i))))
    for j in range(len(s)):
        if s[j] != 3 and s[j] != 7 and s[j] != 5:
            hantei = 1
            break
        else:
            k *= s[j]
    if hantei == 0 and k%105 == 0:
        count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 0
for i in range(1,n+1):
    seven = 0
    five = 0
    three = 0
    while i > 0:
        if i % 10 == 7:
            seven = 1
        elif i % 10 == 3:
            three = 1
        elif i % 10 == 5:
            five = 1
        else:
            break
        i = i // 10
    if i == 0 and seven == 1 and five == 1 and three == 1:
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 0
for i in range(1,n+1):
    seven = 0
    five = 0
    three = 0
    while i > 0:
        if i % 10 == 7:
            seven = 1
        elif i % 10 == 3:
            three = 1
        elif i % 10 == 5:
            five = 1
        else:
            break
        i = i // 10
    if i == 0 and seven == 1 and five == 1 and three == 1:
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

n  = int(input())

if n < 357:
  print(0)
  exit()

max_m = len(str(n))

ans = 0

for m in range(3,max_m+1):
  for i in range(1, m):
    for j in range(1, m-i):
      k = m-i-j
      ls = ['7']*i+['5']*j+['3']*k
      for l in set(itertools.permutations(ls)):
        s = ''.join(l)
        s = int(s)
        if s <= n:
          ans += 1
          #print(s)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

n  = int(input())

max_m = len(str(n))

ans = 0

for m in range(1,max_m+1):
  for i in range(1, m):
    for j in range(1, m-i):
      k = m-i-j
      ls = ['7']*i+['5']*j+['3']*k
      for l in set(itertools.permutations(ls)):
        s = ''.join(l)
        s = int(s)
        if s <= n:
          ans += 1
          #print(s)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

n  = int(input())

max_m = len(str(n))

ans = 0

for m in range(1,max_m+1):
  for i in range(1, m):
    for j in range(1, m-i):
      k = m-i-j
      ls = ['7']*i+['5']*j+['3']*k
      ss = set()
      for l in itertools.permutations(ls):
        s = ''.join(l)
        s = int(s)
        if s in ss:
          continue
        elif s <= n:
          ans += 1
          # print(s)
          ss.add(s)
        else:
          ss.add(s)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lst = ["3", "5", "7"]
ans = 0
while lst:
    a = lst.pop(0)
    if int(a) <= N:
        for c in ["3", "5", "7"]:
            lst.append(a + c)
        if all(a.count(c) > 0 for c in ["3", "5", "7"]):
            ans += 1
            
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

N_str = str(N)
n = len(N_str)
num = 0
for i in range(3,n):
    num += (3**i-3*2**i+3)

def number(x):
    List = []
    X = str(x)
    for i in range(len(X)):
        List.append(int(X[i]))
    a = List.count(3)
    b = List.count(5)
    c = List.count(7)
    if a>=1 and b>=1 and c>=1 and a+b+c==len(X):
        return True
    else:
        return False

c = 10**(n-1)+1
if N > 10**7:
    if int(N_str[0]) > 7:
        num += (3**n-3*2**n+3)
        c = N+1
    elif int(N_str[0]) > 5:
        num += (3**n-3*2**n+3)*2//3
        c =6*10**(n-1)+1
    elif int(N_str[0]) > 3:
        num += (3**n-3*2**n+3)//3
        c =4*10**(n-1)+1


while c <= N:
    if number(c):
        num += 1
    c += 2

print(num)

Submission status: Time Limit Exceeded

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

for i in range(n+1):
    i2 = list(str(i))
    if i2.count("3") >= 1 and i2.count("5") >= 1 and i2.count("7") >= 1:
        if i2.count("3") + i2.count("5") + i2.count("7") == len(i2):
            c += 1

print(c)

Submission status: Time Limit Exceeded

Solution code:
from itertools import permutations

N = int(input())

A = set()
for digit in range(3, 10):
    for seven in range(1, digit - 1):
        for five in range(1, digit - seven):
            three = digit - seven - five
            for perm in permutations(["7"] * seven + ["5"] * five + ["3"] * three):
                A.add("".join(perm))
A = list(map(int, A))
A.sort()

if N in A:
    print(A.index(N) + 1)
else:
    A.append(N)
    A.sort()
    print(A.index(N))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
ans=0
for i in range(n):
    k=i+1
    if k>8*10**8:
        break
    s=set(list(str(k)))
    if len(s)==3 and "3" in s and "5" in s and "7" in s:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

# 10 -> n
def ten2n(a,n):
  x=a//n
  y=a%n
  if x:
    return ten2n(x,n)+str(y)
  return str(y)

def main():
  n=I()

  l=[]
  for i in range(pow(4,10)):
    l.append(ten2n(i,4).replace('3','7').replace('2','5').replace('1','3'))

  cnt=0
  for x in l:
    if int(x)<=n:
      if '3' in x and '5' in x and '7' in x and '0' not in x:
        cnt+=1
    else:
      break

  return cnt

print(main())

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

N = int(input())
c=0
for i in range(1,N+1):
    if '0' not in str(i) and '1' not in str(i) and '2' not in str(i) and '3' in str(i) and '4' not in str(i) and '5' in str(i) and '6' not in str(i) and '7' in str(i) and '8' not in str(i) and '9' not in str(i):
        c+=1
print(c)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ans = 0
for i in range(1,N+1):
    s = set(str(i))
    if s == {'7','5','3'}:
        ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(1,n+1):
    if set(str(i)) == {'3','5','7'}:
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

number_str = '999999999'
number_int = int(number_str)

count = 0


length = len(number_str)



def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def calc_pre(leng_pre):
    global count
    count += pow(3, leng_pre) + 3 -  3 * pow(2, leng_pre)

def calc_all(length):
    global count
    l = ['3', '5', '7']
    pre_data = set()
    for v in itertools.combinations_with_replacement(l, length):
        # print(v)
        if'3' in v and '5' in v and '7' in v:
            for vv in itertools.permutations(list(v), length):
                aaa = int(''.join(list(vv)))
                if aaa < number_int:
                    if aaa not in pre_data:
                        # print(aaa)
                        count += 1
                        pre_data.add(aaa)
                else:
                    break

if length > 3:
    for i in range(3, length):
        calc_pre(i)

calc_all(length)

print(count)

# print(pow(2, 3))

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
N = int(input())
cnt = 0
for i in range(1, N+1, 2):
    c = Counter(str(i))
    if len(c) == 3 and '7' in c and '5' in c and '3' in c:
        # print(c)
        cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
N = int(input())
cnt = 0
for i in range(N+1):
    c = Counter(str(i))
    if len(c) == 3 and '7' in c and '5' in c and '3' in c:
        # print(c)
        cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

n = int(input())

count = 0
for i in range(n+1):
    s = str(i)
    l = sorted(list(set([j for j in s])))
    if l == ['3','5','7']:
        count+= 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

c = 0
for i in range(357, N + 1):
	if (set(str(i)) == {"3", "5", "7"}):
		c += 1
print(c)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
i=1
sum=0
num = []
for i in range(1,1000000000):
  while i>0:
    amari = i % 10
    if(amari != 3 or amari != 5 or amari != 7):
      break
    i = int(i / 10)    
  num.append(i)
j = 0
while num[j] <= n:
  sum += num[j]
  j += 1
print(sum)

Submission status: Time Limit Exceeded

Solution code:
N = input()

def search(i):
        anti = [0,1,2,4,6,8,9]
        for j in anti:
                tmp = str(i).count(str(j))
                if tmp != 0:
                        return False

        cnt3 = str(i).count('3')
        if cnt3 == 0:
                return False
        cnt5 = str(i).count('5')
        if cnt5 == 0:
                return False
        cnt7 = str(i).count('7')
        if cnt7 == 0:
                return False

        return True

ans = 0
if int(N) < 357:
        print(ans)
        exit()

for i in range(357, int(N)+1):
        if search(i):
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ans = 0
for n in range(1, N + 1):
    if set(str(n)) == {"3", "5", "7"}:
      ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ans = 0
for n in range(1, N + 1):
    if set([x for x in str(n)]) == {"3", "5", "7"}:
      ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
N=str(n)
num='357'
ans=0
for i in range(n+1):
  if str(i).count('3')>0 and str(i).count('5')>0 and str(i).count('7')>0 and set(str(i))<=set(num):
    ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
count = 0
nList = [0,1,2,4,6,8,9]

for i in range(357,N + 1):
    flag3 = False
    flag5 = False
    flag7 = False
    for_flag = False
    for j in nList:
        if str(j) in str(i):
            for_flag = True
            break
    if for_flag:
        continue
    if "3"in str(i):
        flag3 = True
    if "5"in str(i):
        flag5 = True
    if "7"in str(i):
        flag7 = True
    if flag3 and flag5 and flag7:
        count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys

input_int = lambda:int(input())
input_ints = lambda:map(int,input().split())
input_ints_list = lambda:list(input_ints())
input_str = lambda:input()
input_strs = lambda:input().split()
input_lines = lambda n,f:[f() for _ in range(n)]

import functools,fractions
gcd = lambda a:functools.reduce(fractions.gcd,a) # 最大公約数（リスト）
lcm_base = lambda a,b:(a*b)//fractions.gcd(a,b) # 最小公倍数(2値)
lcm = lambda a:functools.reduce(lcm_base,a,1) # 最小公倍数(リスト)

init_dp = lambda v,n:[v]*(n)

import math
# 四捨五入はround
ceil = lambda a:math.ceil(a) # 切り上げ
floor = lambda a:math.floor(a) # 切り捨て

def dfs(i,N):
    s = str(i)
    if i > N:return 0
    ans = dfs(i+1,N)
    if all(c in s for c in '753') and all(c in '753' for c in s):
        ans += 1
    return ans

def solution():
    N = input_int()
    sys.setrecursionlimit(N+10)
    ans = dfs(100,N)
    print(ans)

if __name__ == '__main__':
    solution()

Submission status: Time Limit Exceeded

Solution code:
def shichigo(s):
    if '3' not in s:
        return False
    if '5' not in s:
        return False
    if '7' not in s:
        return False
    x = s.replace('3','').replace('5','').replace('7','')
    if x=='':
        return True
    return False


n = input()

# k = 桁数-1
k = len(n)-1

# k桁までの753数
ans = 0
for i in range(1,k+1):
    ans += 3**i - 3*2**i + 3

# nの桁の753数/3
a = 3**k - 2**(k+1) + 1

f = int(n[0])

if f<3:
    print(ans)
    exit()
elif f==3:
    for i in range(3*10**k,int(n)+1):
        if shichigo(str(i)):
            ans += 1
elif f<5:
    ans += a
elif f ==5:
    ans += a
    for i in range(5*10**k,int(n)+1):
        if shichigo(str(i)):
            ans += 1
elif f<7:
    ans += 2*a
elif f==7:
    ans += 2*a
    for i in range(7*10**k,int(n)+1):
        if shichigo(str(i)):
            ans += 1
else:
    ans += 3*a

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ret = 0
a = ['3','5','7']
for i in range(357, N+1, 2):
    t = list(set(str(i)))
    t.sort()
    if t == a:
        ret += 1
print(ret)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ret = 0
a = ['3','5','7']
for i in range(357, N+1):
    t = list(set(str(i)))
    t.sort()
    if t == a:
        ret += 1
print(ret)

Submission status: Time Limit Exceeded

Solution code:
n = int(input()) + 1
a = [0,0,0,0]
c = 0
for i in range (1, n):
  b = str(i)
  for k in range (len(b)):
    m = b[k]
    if m == "3":
      a[0] += 1
    elif m == "5":
      a[1] += 1
    elif m == "7":
      a[2] += 1
    else:
      a[3] += 1
  if a[3] == 0 and a[0] >= 1 and a[1] >= 1 and a[2] >= 1:
    c += 1
  a = [0,0,0,0]
print(c)

Submission status: Time Limit Exceeded

Solution code:
num = input()
count = 0
for i in range(1, int(num) +1):
    flg = False
    for dam in str(i):
        if dam in ["1", "2", "4", "6", "8", "9", "0"]:
            flg = True
    if (flg == False):
        if "7" in list(str(i)):
            if "5" in list(str(i)):
                if "3" in list(str(i)):
                    count += 1
            else:
                continue
        else:
            continue

print(count)

Submission status: Time Limit Exceeded

Solution code:
import re

pattern = re.compile(r'^[357]+$')
n = int(input())
ans = 0

for i in range(1, n+1):
	s = str(i)
	if re.match(pattern, s) and '3' in s and '5' in s and '7' in s:
		ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

ans = 0
for i in range(1, n+1):
	s = str(i)
	num3 = s.count('3')
	num5 = s.count('5')
	num7 = s.count('7')
	if num3 != 0 and num5 != 0 and num7 != 0 and len(s) == num3 + num5 + num7:
		ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 0
for i in range(1,n+1,2):
    i = list(str(i))
    if "1" not in i:
        if "2" not in i:
            if "3" in i:
                if "4" not in i:
                    if "5" in i:
                        if "6" not in i:
                            if "7" in i:
                                if "8" not in i:
                                    if "9" not in i:
                                        if "0" not in i:
                                            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
def to3(x,n):
  if (int(x/n)):
    return to3(int(x/n),n) + str(x%n)
  return str(x%n)
c = ["3","5","7"]
ch = ["0","3","5","7"]
ans = 0
for i in range(4 ** len(str(num))):
  s = to3(i,4)
  ss = ""
  for j in range(len(s)):
    ss += ch[int(s[j])]
  key = 1
  k1 = 0
  k2 = 0
  k3 = 0
  for k in range(len(ss)):
    if ss[k] == "0":
      key = 0
      break
    elif ss[k] == "3":
      k1 = 1
    elif ss[k] == "5":
      k2 = 1
    else:
      k3 = 1
  if key == 1 and k1 and k2 and k3 and int(ss) <= num:ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
ans=0
for i in range(n):
    k=i+1
    if k>8*10**8:
        break
    s=set(list(str(k)))
    if len(s)==3 and "3" in s and "5" in s and "7" in s:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
ans=0
for i in range(n):
    k=str(i+1)
    s=set(list(k))
    if len(s)==3 and "3" in s and "5" in s and "7" in s:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
count=0
if N<357:
    print(count)
else:
    for i in range(357,N+1):
        a=[0,0,0]#3,5,7の個数
        s=str(i)#文字列に直す
        for j in range(len(s)):# iの各桁の探索
            if s[j]=='3':
                a[0]+=1
            elif s[j]=='5':
                a[1]+=1
            elif s[j]=='7':
                a[2]+=1
            else:
                break
        b=a[0]+a[1]+a[2]#3,5,7の個数
        if a[0]>0 and a[1]>0 and a[2]>0 and b==len(s):
            count+=1
    print(count)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())
def chack(s):
    def f(s):
        return s == '5' or s == '3' or s == '7'
    if ('5' in s) & ('3' in s) & ('7' in s) :
        return all([ f(i) for i in s])
    return False
print(np.array([chack(str(i)) for i in range(0,N+1)]).sum())

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

ans=[]
for i in range(4**len(str(N))):
    num=Base_10_to_n(i,4).zfill(len(str(N))+1).replace('0','').replace('1','7').replace('2','5')
    # print(num)
    if set(list(num))==set(['3','5','7']) and int(num)<=N:
        ans.append(num)
print(len(set(ans)))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

ans=[]
for i in range(4**len(str(N))):
    num=Base_10_to_n(i,4).zfill(len(str(N))+1).replace('0','').replace('1','7').replace('2','5').replace('3','3')
    # print(num)
    if set(list(num))==set(['3','5','7']) and int(num)<=N:
        ans.append(num)
print(len(set(ans)))