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: Runtime Error

Solution code:
n = input()

def f(s):
    if int(s) > int(n):
        return 0
    if all(['3' in s,'5' in s,'7' in s]):
        ans += 1
    for t in '3','5','7':
        f(s+t)

ans = 0
f('0')
print(ans)

Submission status: Runtime Error

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: Runtime Error

Solution code:
N = int(input())

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

print(dfs('0'))

Submission status: Runtime Error

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
import numpy as np
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: Runtime Error

Solution code:
N = int(input())


# N以下の753数を全列挙
def dfs(s):
  if int(s) > N:
    return 0
  ret = 1 if all(s.count(c) > 0 for c in '753') else 0
  for c in '753':
    ret += dfs(s + c)
    
print(dfs('0'))

Submission status: Runtime Error

Solution code:
n=int(input())
import bisect
import itertools
l=len(str(n))
ans=[]
num=[]
for k in range(3,l+1):
    m=list(itertools.product(x, repeat=k))
    num.extend(m)
for i in range(len(num)):
    y=num[i]
    if '3' in y and '5' in y and '7' in y:
        number=''
        for j in range(len(y)):
            number+=y[j]
        ans.append(int(number))
ans.sort()
print(bisect.bisect_left(ans, n))

Submission status: Runtime Error

Solution code:
n=int(input())
import bisect
import itertools
ans=[]
num=[]
for i in range(3,l+1):
    m=list(itertools.product(x, repeat=i))
    num.extend(m)
for i in range(len(num)):
    y=num[i]
    if '3' in y and '5' in y and '7' in y:
        number=''
        for j in range(len(y)):
            number+=y[j]
        ans.append(int(number))
ans.sort()
print(bisect.bisect_left(ans, n))

Submission status: Runtime Error

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

def dfs(s):
    if int(s) > N:
        return

    if s.count('7') and s.count('5') and s.count('3'):
        cnt += 1
    
    dfs(s + '7')
    dfs(s + '5')
    dfs(s + '3')

dfs('')

print(ans)

Submission status: Runtime Error

Solution code:
from itertools import product
N = input()
length = len(N)
T = [''.join(t) for t in product(('3','5','7'),repeat = 3)]

def f(N,s):
    if len(s) == length:
        if int(s) < int(N) and '3' in s and '5' in s and '7' in s:
            return 1
        else:
            return 0
    else:
        if '3' in s and '5' in s and '7' in s:
            a = 1
        else:
            a = 0
        a += sum(f(N,s+c) for c in('3','5','7'))
        return a
print(sum(f(N, t) for t in T))

Submission status: Runtime Error

Solution code:
n=input()
x=[0,3,5,7]
p=[]
for c1 in x:
  for c2 in x:
    for c3 in x:
      for c4 in x:
        for c5 in x:
          for c6 in x:
            for c7 in x:
              for c8 in x:
                for c9 in x:
                  line=[c1,c2,c3,c4,c5,c6,c7,c8,c9]
                  sum_=0
                  if line.count(7)>0 and line.count(3)>0 and line.count(5)>0:
                    for i in range(9):
                      sum_+=line[i]*10**i
                    p.append(sum_)
p.sort()
for i in range(len(p)):
  if p[i]>n:
    print(i)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
n = int(raw_input())

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

for i in range(357, n+1):
    s = list(set(list(str(i))))
    if len(s) != 3: continue
    if '7' in s and '5' in s and '3' in s:
        count += 1

print count

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np
N = input(N)
digit = len(N)
ans = 0
if int(N) < 357:
    print(ans)
else:
    for i in range(3, len(N)):
        ans += 3**i - 3 * 2**i + 3
    for v in itertools.product('753', repeat=digit):
        if (len(set(list(v)))==3) & (int(''.join(list(v))) <= int(N)):
            ans +=1
    print(ans)

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np
N = input(N)
digit = len(N)
ans = 0
if int(N) < 357:
    print(ans)
else:
    for i in range(3, len(N)):
        ans += 3**i - 3 * 2**i + 3
    print(ans)
    for v in itertools.product('753', repeat=digit):
        if (len(set(list(v)))==3) & (int(''.join(list(v))) <= int(N)):
            ans +=1
    print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())

import bisect
l = []
def dfs(num, index):
    if index == 9:
        if (num.find("3") != -1) and (num.find("5") != -1) and (num.find("7") != -1):
            l.append(int(num))
        return 0
        
    if num == "":
        ret0 = dfs(num + "" , index+1)
    ret1 = dfs(num + "3", index+1)
    ret2 = dfs(num + "5", index+1)
    ret3 = dfs(num + "7", index+1)

    return 0

dfs("", 0)

count = bisect.bisect_left(l,n)
count += 1 if n == l[bisect.bisect_left(l,n)] else 0
print (count)

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
ls = [x+1 for x in range(N)]
candidates = [str(x) for x in ls if "7" in str(x) and "5" in str(x) and "3" in str(x)]
count = 0
for _ in range len(candidates):
    candlist = list(candidates)
    ls2 = [x for x in candlist if x != "7" and x != "5"and x != "3"]
    if ls2 is False:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
ls = [x+1 for x in range(N)]
candidates = [str(x) for x in ls if "7" in str(x) and "5" in str(x) and "3" in str(x))
count = 0
for _ in range len(candidates):
    candlist = list(candidates)
    ls2 = [x for x in candlist if x != "7" and x != "5"and x != "3"]
    if ls2 is False:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
ls = [x+1 for x in range(N)]
candidates = [str(x) for x in ls if "7" in str(x) and "5" in str(x) and "3" in str(x))
count = 0
for _ in range len(candidates):
    candlist = list(candidates)
    ls2 = [x for x in candlist if x != 7 and x != 5 and x != 3]
    if ls2 is False:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
import itertools
n=input()
c=[0,0,6,36,150,540,1806,5796,18150]
b=len(list(a for a in itertools.product(["3","5","7"],repeat=len(n))if len(set(a))==3 and int("".join(a))<int(n)))
print(sum(c[:l-1])+b)

Submission status: Runtime Error

Solution code:
n=int(input())

def dfs(s):
  if int(s)>n:
    return 0
  cnt=1 if all(s.count(i)>0 for i in '753') else 0
  for j in '753':
    cnt+=dfs(s+j)
  retunr cnt
  
print(dfs('0')

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(100000)
N = int(input())
S = str(N)
def f(s, p, x):
    if len(s) == 0:
        return 1 if x == 7 else 0
    if p:
        return f(s[1:], True, x | 1) + f(s[1:], True, x | 2) + f(s[1:], True, x | 4) + (f(s[1:], True, x) if x == 0 else 0)
    if s[0] == '8' or s[0] == '9':
        return f(s[1:], True, x | 1) + f(s[1:], True, x | 2) + f(s[1:], True, x | 4) + (f(s[1:], True, x) if x == 0 else 0)
    if s[0] == '7':
        return f(s[1:], True, x | 1) + f(s[1:], True, x | 2) + f(s[1:], False, x | 4) + (f(s[1:], True, x) if x == 0 else 0)
    if s[0] == '6':
        return f(s[1:], True, x | 1) + f(s[1:], True, x | 2) + (f(s[1:], True, x) if x == 0 else 0)
    if s[0] == '5':
        return f(s[1:], True, x | 1) + f(s[1:], False, x | 2) + (f(s[1:], True, x) if x == 0 else 0)
    if s[0] == '4':
        return f(s[1:], True, x | 1) + (f(s[1:], True, x) if x == 0 else 0)
    if s[0] == '3':
        return f(s[1:], False, x | 1) + (f(s[1:], True, x) if x == 0 else 0)
    if s[0] == '2' or s[1] == '1':
        return (f(s[1:], True, x) if x == 0 else 0)
    if s[0] == '0':
        return 0
ans = f(S, False, 0)
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
S = str(N)
def f(s, p, x):
    if len(s) == 0:
        return 1 if x == 7 else 0
    if p:
        return f(s[1:], True, x | 1) + f(s[1:], True, x | 2) + f(s[1:], True, x | 4) + (f(s[1:], True, x) if x == 0 else 0)
    if s[0] == '8' or s[0] == '9':
        return f(s[1:], True, x | 1) + f(s[1:], True, x | 2) + f(s[1:], True, x | 4) + (f(s[1:], True, x) if x == 0 else 0)
    if s[0] == '7':
        return f(s[1:], True, x | 1) + f(s[1:], True, x | 2) + f(s[1:], False, x | 4) + (f(s[1:], True, x) if x == 0 else 0)
    if s[0] == '6':
        return f(s[1:], True, x | 1) + f(s[1:], True, x | 2) + (f(s[1:], True, x) if x == 0 else 0)
    if s[0] == '5':
        return f(s[1:], True, x | 1) + f(s[1:], False, x | 2) + (f(s[1:], True, x) if x == 0 else 0)
    if s[0] == '4':
        return f(s[1:], True, x | 1) + (f(s[1:], True, x) if x == 0 else 0)
    if s[0] == '3':
        return f(s[1:], False, x | 1) + (f(s[1:], True, x) if x == 0 else 0)
    if s[0] == '2' or s[1] == '1':
        return (f(s[1:], True, x) if x == 0 else 0)
    if s[0] == '0':
        return 0
ans = f(S, False, 0)
print(ans)

Submission status: Runtime Error

Solution code:
import re

max_num = input()

tgt_cnt = 0
for i in range(357, int(max_num) + 1):
  is_tfs = re.fulumatch('[357]+', str(i))
  if is_tfs and '3' in str(i) and '5' in str(i) and '7' in str(i):
    tgt_cnt += 1

print(tgt_cnt)

Submission status: Runtime Error

Solution code:
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    r = 1 if all([i in s for i in '357']) else 0
    for c in '357':
        r += dfs(s+c)
    return r

return(dfs('0'))

Submission status: Runtime Error

Solution code:
def main():
    global results, S
    S = int(input())
    S_str = str(S)
    results = []
    for i in range(len(S_str)):
        digits = len(S_str) - i
        if digits < 3:
            break

        bfs(digits, '')

    print(len(results))


def bfs(i, s):
    #  global results, S
    if i == 0:
        if int(s) <= S and len(set(s)) == 3:
            results.append(s)
        return
    i -= 1
    bfs(i, s + '3')
    bfs(i, s + '5')
    bfs(i, s + '7')


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import itertools

n = int(input())
m = len(str(n))
def f(n,m):
  s = [7,5,3]
  y = [int(''.join(list(i))) for i in itertools.product(s, repeat=m)]
  y = [i for i in y if i <= n and str(i) in 7 and str(i) in 5 and str(i) in 3]
  return len(y)
print(f(n,m))

Submission status: Runtime Error

Solution code:
1 N = int(input())
2
3 def dfs(s): # 文字列 s で始まる七五三数の個数
4 if int(s) > N:
5 return 0
6 ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
7 for c in '753':
8 ret += dfs(s + c)
9 return ret
10
11 print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく

Submission status: Runtime Error

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

def count_753(n):
    if n == 3:
        return (6, 18, 3)
    else:
        num_753 = count_753(n-1)[0] * 3 + count_753(n-1)[1]
        num_75 = count_753(n-1)[1] * 2 + count_753(n-1)[2] * 2
        return (num_753, num_75, 3)

if n <= 2:
    print(0)
else:
    count = 0
    for i in range(3, n+1):
        count += count_753(i)[0]
    #print('count :', count)

    for i in itertools.product(['7', '5', '3'], repeat=n):
        if len(set(i)) <= 2:
            continue
        s = 0
        for j,k in zip(range(n), reversed(range(n))):
            s += int(i[j]) * (10**k)
        if s > N:
            count -= 1
    
    print(count)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int n;
int lim;
vector<string> A;

void f(int digitNum, string s){ 
    vector<bool> J(3, false);
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '3') J[0] = true;
        if(s[i] == '5') J[1] = true;
        if(s[i] == '7') J[2] = true;
    }
    int idx = find(J.begin(), J.end(), false) - J.begin();
    if(idx == 3){
        A.push_back(s);
    }
    if(digitNum == lim){
        return;
    }
    f(digitNum + 1, s + '3');
    f(digitNum + 1, s + '5');
    f(digitNum + 1, s + '7');
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    
    lim = to_string(n).length();
    
    if(lim < 3){
        cout << 0 << endl;
        return 0;
    }

    f(0, "");

    vector<int> B(A.size());
    for(int i = 0; i < A.size(); i++){
        B[i] = stoi(A[i]);
    }

    sort(B.begin(), B.end());

    int idx = lower_bound(B.begin(), B.end(), n) - B.begin();

    cout << idx + (B[idx] == n) << endl;

    return 0;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
def dfs(s):
  if int(s) > n:
    return 0
  ret = 1 if all([s.count(c) > 0 for c in '753']) else 0
  for c in '753':
    ret += dfs(s+c)
  return ret
print(ret('0'))

Submission status: Runtime Error

Solution code:
n = int(input())
def dfs(s):
  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+c)
  return ret
print(ret('0'))

Submission status: Runtime Error

Solution code:
s = set(['7', '5', '3'])
print(sum((1 for i in range(1, n+1) if set(str(i)) == s)))

Submission status: Runtime Error

Solution code:
n = input()
N = int(n)

a = int((n[-3:]))

y = 0
if a >= 753:
    x = 6
elif a >= 735:
    x = 5
elif a >= 573:
    x = 4
elif a >= 537:
    x = 3
elif a >= 375:
    x = 2
elif a >= 357:
    x = 1
elif a < 356:
    x =0

for i in range(0, len(n)-3):
    if int(n[i]) == 0:
        y = y
    elif int(n[i]) >=7:
        y += (len(n) - i) * 3 - 9
    elif int(n[i]) >=5:
        y += (len(n) - i) * 3 - 10
    elif int(n[i]) >= 3:
        y += (len(n) - i) * 3 - 11
    elif int(n[i]) == 2 or 1:
        y += (len(n) - i) * 3 - 12

print(x + y)

Submission status: Runtime Error

Solution code:
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    #sが7,5,3をそれぞれ一つ以上含んでいる場合、+1、 else 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    #sに7,5,3のいずれかを付け足す
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs(''))

Submission status: Runtime Error

Solution code:
n = int(input())
ans = 0
for i in n:
	for j in len(i):
		if i(j) == 7 or i(j) == 5 or i(j) == 3:
			ans += 1
		else:
			ans += 0
print(ans)

Submission status: Runtime Error

Solution code:
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(srt(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)

Submission status: Runtime Error

Solution code:
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(srt(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)

Submission status: Runtime Error

Solution code:
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(srt(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)

Submission status: Runtime Error

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
  
print(dfs('0'))

Submission status: Runtime Error

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)

print(dfs('0'))

Submission status: Runtime Error

Solution code:
n = int(input())
# Recursion!
def detector(str):
  # Stop the operation if the number is bigger than n.
  if int(str) > n:
    return 0
  else:
    count = 0
    # Add 7, 5, or 3 after the number. 
    # Eliminate numbers that do not consist of only 3, 5, and 7.
    for i in "753":
      count += detector(str+i)
    # Check if the number has all 3, 5, and 7.
    if "3" not in str or "5" not in str or "7" not in str:
      return count
    else:
      return count += 1
# Start from 0 and do the operation until the number exceeds n.
detector("0")

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin
import IPython

d_in = lambda: int(stdin.readline())  # N = d_in()

cand = [0, 3, 5, 7]
N = d_in()


def check_count(count):
    if count[3] > 0 and count[5] > 0 and count[7] > 0:
        return True
    else:
        return False


def search(flag, nonzero, str_n, count):
    """
    flag : 現在の値がNと等しいか小さいか

    nonzero : 現在の値が0か否か

    str_n : 現在より小さい方の各桁を文字列として持つリスト

    count : {7: flag1, 5: flag2, 3: flag3}
    """
    if len(str_n) == 0:
        if check_count(count):
            return 1
        else:
            return 0
    elif check_count(count) and (not flag):
        return 3**(len(str_n))
    elif not flag:
        ans = 0
        for i in cand:
            if nonzero and i == 0:
                continue
            next_count = count.copy()
            next_count[i] += 1
            zeroflag = nonzero or (i != 0)
            ans += search(False, zeroflag, str_n[1:], next_count)
        return ans
    else:
        next_n = int(str_n[0])
        ans = 0
        for i in cand:
            if nonzero and i == 0:
                continue
            next_count = count.copy()
            if i > next_n:
                break
            elif i == 0:
                zeroflag = nonzero
                ans += search(False, zeroflag, str_n[1:], next_count)
            elif i == next_n:
                next_count[i] += 1
                ans += search(True, True, str_n[1:], next_count)
            else:
                next_count[i] += 1
                ans += search(False, True, str_n[1:], next_count)
        return ans


str_N = list(str(N))
cand_count = {0: 0, 3: 0, 5: 0, 7: 0}
print(search(True, False, str_N, cand_count))
# IPython.embed()

Submission status: Runtime Error

Solution code:
K=int(input())
N=str(K)


a=[]
S=int(len(str(K)))

T=0
for i in range(3,S-1):
    t=i**3
    t=t-3*(i**2)-3
    T=T+t

for j in range(0,S):
    if int(N[j])>7:
        T=T+(S-j)**3-S(S-j)**2-3
        break
    if int(N[j])>5 and int(N[j])<7:
        T=T+2*(S-1-j)**3-4*(S-1-j)**2-2
        break
    if int(N[j])>3 and int(N[j])<5:
        T=T+1*(S-1-j)**3-2*(S-1-j)**2-1
        break
    if int(N[j])==7:
        T=T+2*(S-1-j)**3-4*(S-1-j)**2-2
        continue
    if int(N[j])==5:
        T=T+1*(S-1-j)**3-2*(S-1-j)**2-1
        continue
    if int(N[j])==3:
        continue
    else:
        break

print(T)

Submission status: Runtime Error

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

pritn(cnt('0'))

Submission status: Runtime Error

Solution code:
import itertools
N = int(input())
combi = []
l = []
count = 0

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

Submission status: Runtime Error

Solution code:
N = int(input())
li = ['']
so = 0
for _ in range(9):
  l = len(li)
  for i in range(so, l):
    li.append(li[i] + '3')
    li.append(li[i] + '5')
    li.append(li[i] + '7')
  so = l
cnt = 0
for x in li:
  if int(x) <= N and '3' in x and '5' in x and '7' in x:
    cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
N = int(input())
li = ['']
so = 0
for _ in range(9):
  l = len(li)
  for i in range(so, l):
    li.append(li[i] + '3')
    li.append(li[i] + '5')
    li.append(li[i] + '7')
  so = l
cnt = 0
for x in li:
  if int(x) <= N and 3 in x and 5 in x and 7 in x:
    cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
N=int(input())
c=0
if N >= 357:
    for i in range(N):
       s = str(N)
       a3=s.count('3')
       a5=s.count('5')
       a7=s.count('7')

       if a3+a5+a7=len(s) and a3>0 and a5>0 and a7>0:
           c+=1

print(c)

Submission status: Runtime Error

Solution code:

n, x = map(int,input().split())

def rec(lv,ls):
    if lv == 0:
        return [1]
    else:
        ret = rec(lv-1,ls)
        for i in range(0,len(ret) -1):
            if ret[i]>0 and ret[i+1]>0:
                ret[i+1] += ret[i]
                ret[i] = 0  #deleted tag

        while 0 != ret.count(0):
            ret.remove(0)
        return [-1,*ret,1,*ret,-1]

#print( rec(n, list()) )


count = 0
for e in rec(n, list() ):
    abs_e = abs(e)

    if x == 0:
        break

    if x>=abs_e:
        x -= abs_e
        count += e if e>0 else 0
    else:
        count += x if e>0 else 0
        x = 0
    #print(x," ",count)

print(count)

Submission status: Runtime Error

Solution code:
N = input()

li = []
for v in itertools.product('0357', repeat=len(N)):
    a = ''
    for w in v:
        a = a + w
    li.append(a)

li2 = []
for v in li:
    if '3' in v and '5' in v and '7' in v and int(v) <= int(N):
        v = v.replace('0', '')
        li2.append(v)
    else: pass
print(len(set(li2)))

Submission status: Runtime Error

Solution code:
from itertools import product

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

for i in range(2,10):
    for t in product(num_list, repeat=i):
        check = t.count("3")*t.count("5")*t.count("7")
        if int("".join(t)): <= N and check:
            count += 1

print(count)

Submission status: Runtime Error

Solution code:
from itertools import product

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

for i in range(2,10):
    for t in product(num_list, repeat=i):
        check = t.count("3")*t.count("5").t.count("7")
        if int("".join(t)): <= N and check:
            count += 1

print(count)

Submission status: Runtime Error

Solution code:
from itertools import product

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

for i in range(2,10):
    for t in product(num_list, repeat=i):
        check = t.count("3")*t.count("5").t.count("7")
        
        if int("".join(t)): <= N and check:
            count += 1

print(count)

Submission status: Runtime Error

Solution code:
# coding: utf-8
import itertools
N = input()
ans = 0

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

Submission status: Runtime Error

Solution code:
num753 = []
num753.append([0,0,0,0,0,0,0])  #3,5,7,35,37,57,357
num753.append([1,1,1,0,0,0,0])

for i in range(1,10):
    num753.append([num753[i][0],num753[i][1],num753[i][2],num753[i][0]+num753[i][1]+nu
m753[i][3]*2,num753[i][0]+num753[i][2]+num753[i][4]*2,num753[i][1]+num753[i][2
]+num753[i][5]*2,num753[i][3]+num753[i][4]+num753[i][5]+num753[i][6]*3])

N = input()

ans = 0
for i in range(len(N)):
    ans += num753[i][6]

check3 = False
check5 = False
check7 = False
for i in range(len(N)):
    if int(N[i])<3:
        break
    if int(N[i])==3:
        check3 = True
        if i==len(N)-1 and check7 and check5 and check3:
            ans += 1
        continue
    ans += num753[len(N)-i-1][5]+num753[len(N)-i-1][6]
    if check5:
        ans += num753[len(N)-i-1][2]+num753[len(N)-i-1][4]
    if check7:
        ans += num753[len(N)-i-1][1]+num753[len(N)-i-1][3]
    if check5 and check7:
        ans += num753[len(N)-i-1][0]
    if int(N[i])<5:
        break
    if int(N[i])==5:
        check5 = True
        if i==len(N)-1 and check7 and check5 and check3:
            ans += 1
        continue
    ans += num753[len(N)-i-1][4]+num753[len(N)-i-1][6]
    if check3:
        ans += num753[len(N)-i-1][2]+num753[len(N)-i-1][5]
    if check7:
        ans += num753[len(N)-i-1][0]+num753[len(N)-i-1][3]
    if check3 and check7:
        ans += num753[len(N)-i-1][1]
    if int(N[i])<7:
        break
    if int(N[i])==7:
        check7 = True
        if i==len(N)-1 and check7 and check5 and check3:
            ans += 1
        continue
    ans += num753[len(N)-i-1][3]+num753[len(N)-i-1][6]
    if check3:
        ans += num753[len(N)-i-1][1]+num753[len(N)-i-1][5]
    if check5:
        ans += num753[len(N)-i-1][0]+num753[len(N)-i-1][4]
    if check3 and check5:
        ans += num753[len(N)-i-1][2]
    break
else:
    if check3 and check5 and check7:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
X=int(input())
def momo(s)
if int(s)>X:
  return 0
 
nagi=1 if all(s.count(c)>0 for c in '753') else 0
  for c in '753':
    nagi+=momo(s+c)
    return nagi
print(momo('0'))

Submission status: Runtime Error

Solution code:
X=int(input())
def momo(s)
if int(s)>N:
  return 0

nagi=1 if all(s.count(c)>0 for c in '753') else 0
  for c in '753':
    nagi+=momo(s+c)
    return nagi
print(momo('0'))

Submission status: Runtime Error

Solution code:
N = input()
count = int(0)
for i in range(333, N):
    judge = False
    if str(i).find("357") > -1 or str(i).find("375") > -1 or str(i).find("537") > -1 or str(i).find("573") > -1 or str(i).find("735")  > -1 or str(i).find("753") > -1:
        judge = True
    if str(i).find("0") > -1:
        judge = False
    if str(i).find("1") > -1:
        judge = False
    if str(i).find("2") > -1:
        judge = False
    if str(i).find("4") > -1:
        judge = False
    if str(i).find("6") > -1:
        judge = False
    if str(i).find("8") > -1:
        judge = False
    if str(i).find("9") > -1:
        judge = False
    if judge == True:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
num753 = []
num753.append([0,0,0,0,0,0,0])  #3,5,7,35,37,57,357
num753.append([1,1,1,0,0,0,0])

for i in range(1,10):
    num753.append([num753[i][0],num753[i][1],num753[i][2],num753[i][0]+num753[i][1]+num753[i][3]*2,num753[i][0]+num753[i][2]+nu
m753[i][4]*2,num753[i][1]+num753[i][2
]+num753[i][5]*2,num753[i][3]+num753[i][4]+num753[i][5]+num753[i][6]*3])

N = input()

ans = 0
for i in range(len(N)):
    ans += num753[i][6]

check3 = False
check5 = False
check7 = False
for i in range(len(N)):
    if int(N[i])<3:
        break
    if check5:
        ans += num753[len(N)-i-1][2]+num753[len(N)-i-1][4]
    if check7:
        ans += num753[len(N)-i-1][1]+num753[len(N)-i-1][3]
    if check5 and check7:
        ans += num753[len(N)-i-1][0]
    if int(N[i])==3:
        check3 = True
        continue
    ans += num753[len(N)-i-1][5]+num753[len(N)-i-1][6]
    if int(N[i])<5:
        break
    if check3:
        ans += num753[len(N)-i-1][2]+num753[len(N)-i-1][5]
    if check7:
        ans += num753[len(N)-i-1][0]+num753[len(N)-i-1][3]
    if check3 and check7:
        ans += num753[len(N)-i-1][1]
    if int(N[i])==5:
        check5 = True
        continue
    ans += num753[len(N)-i-1][4]+num753[len(N)-i-1][6]
    if int(N[i])<7:
        break
    if check3:
        ans += num753[len(N)-i-1][1]+num753[len(N)-i-1][5]
    if check5:
        ans += num753[len(N)-i-1][0]+num753[len(N)-i-1][4]
    if check3 and check5:
        ans += num753[len(N)-i-1][2]
    if int(N[i])==7:
        check7 = True
        continue
    ans += num753[len(N)-i-1][3]+num753[len(N)-i-1][6]
    break

print(ans)