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:
for i in range(357, N + 1, 2):
  hoka = False
  aru = [False] * 3
  for s in str(i):
    if s == '3':
      aru[0] = True
    elif s == '5':
      aru[1] = True
    elif s == '7':      
      aru[2] = True
    else:
      hoka = True
      break
  if hoka == False:
    if aru.count(False) == 0:
      c += 1
          
print(c)

Submission status: Runtime Error

Solution code:
= int(input())
def f(x):
    if int(x) >N:
        return 0
    if x.count('3')>0 and x.count('5')>0 and x.count('7')>0:
        z = 1
    z=0
    z +=f(x+'3')
    z +=f(x+'5')
    z +=f(x+'7')
    return z
print(f('0'))

Submission status: Runtime Error

Solution code:
limit = input()



def dfs(s):
	if int(s)>limit:
		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(dfs("0"))

Submission status: Runtime Error

Solution code:
from itertools import product

N = int(input())
ans = 0
for i in product("357", repeat=N):
    x = "".join(i)
    if 357 <= int(x) <= N and len(set(x)) = 3:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

int N;
s64 cand[] = {7, 5, 3};

bool ok(s64 x)
{
    bool t = false, f = false, s = false;
    while (x)
    {
        if (x % 10 == 3) t = true;
        else if (x % 10 == 5) f = true;
        else if (x % 10 == 7) s = true;
        x /= 10;
    }
    return t & f & s;
}

s64 dfs(s64 x)
{
    if (x > N) return 0;

    int ret = 0;
    if (ok(x)) ret = 1;

    rep (i, 3)
    {
        ret += dfs(x * 10 + cand[i]);
    }
    return ret;
}

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

    cin >> N;
    int ans = 0;
    rep (i, 3)
    {
        ans += dfs(cand[i]);
    }
    cout << ans << "\n";
    return 0;
}

Submission status: Runtime Error

Solution code:
n = input()
def f(s):
  if int(s) > n:
    return 0 #再帰終了
  if s.count("3") > 0 and s.count("5") > 0 and s.count("7") > 0:
    cnt += 1
  else:
    cnt += f(s + "3")
    cnt += f(s + "5")
    cnt += f(s + "7")
    
print(cnt)

Submission status: Runtime Error

Solution code:
def f(n, k):
  num_bit = 3 - bin(k).count('1')
  c = [0, 0, 1, 3]
  return 3**n - num_bit*2**n + c[num_bit]

# k = 0:(), 1:(3), 2(5), 3:(3, 5), 4:(7), 5:(3, 7), 6:(5, 7), 7:(3, 5, 7)
def solve(N, k=0):
  n = len(N)
  num_used = bin(k).count('1')
  if n==0 and num_used==3:
    return 1
  elif n==0 or n+num_used<3:
    return 0
  else:
    a = int(N[0])
    if a > 7:
      return f(n-1, k|1) + f(n-1, k|2) + f(n-1, k|4)
    elif a == 7:
      return f(n-1, k|2) + f(n-1, k|1) + solve(N[1:], k|4)
    elif a > 5:
      return f(n-1, k|2) + f(n-1, k|1)
    elif a == 5:
      return f(n-1, k|1) + solve(N[1:], k|2)
    elif a > 3:
      return f(n-1, k|1)
    elif a == 3:
      return solve(N[1:], k|1)
    elif a > 0:
      return 0

N = input()
base = sum([f(i, 0) for i in range(3, len(N))])
print(solve(N) + base)

Submission status: Runtime Error

Solution code:
def f(n, k):
  num_bit = 3 - bin(k).count('1')
  c = [0, 0, 1, 3]
  return 3**n - num_bit*2**n + c[num_bit]

# k = 0:(), 1:(3), 2(5), 3:(3, 5), 4:(7), 5:(3, 7), 6:(5, 7), 7:(3, 5, 7)
def solve(N, k=0):
  n = len(N)
  num_used = bin(k).count('1')
  if n==0 and num_used==3:
    return 1
  elif n==0 or n+num_used<3:
    return 0
  else:
    a = int(N[0])
    if a > 7:
      return sum([f(i, 0) for i in range(3, n+1)])
    elif a == 7:
      return f(n-1, k|2) + f(n-1, k|1) + solve(N[1:], k|4)
    elif a > 5:
      return f(n-1, k|2) + f(n-1, k|1)
    elif a == 5:
      return f(n-1, k|1) + solve(N[1:], k|2)
    elif a > 3:
      return f(n-1, k|1)
    elif a == 3:
      return solve(N[1:], k|1)
    elif a > 0:
      return 0

N = input()
base = sum([f(i, 0) for i in range(3, len(N))])
print(solve(N) + base)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**9)

def f(n, k):
  num_bit = 3 - bin(k).count('1')
  c = [0, 0, 1, 3]
  return 3**n - num_bit*2**n + c[num_bit]

# k = 0:(), 1:(3), 2(5), 3:(3, 5), 4:(7), 5:(3, 7), 6:(5, 7), 7:(3, 5, 7)
def solve(N, k=0):
  n = len(N)
  num_used = bin(k).count('1')
  if n + num_used < 3:
    return 0
  else:
    a = int(N[0])
    base = sum([f(i, k) for i in range(3, n)])
    if a > 7:
      return sum([f(i, k) for i in range(3, n+1)])
    elif a == 7:
      return base + f(n-1, k|2) + f(n-1, k|1) + solve(N[1:], k|4)
    elif a > 5:
      return base + f(n-1, k|2) + f(n-1, k|1)
    elif a == 5:
      return base + f(n-1, k|1) + solve(N[1:], k|2)
    elif a > 3:
      return base + f(n-1, k|1)
    elif a == 3:
      return base + solve(N[1:], k|1)
    elif a > 0:
      return base
    else: # a == 0
      return solve(N[1:])

print(solve(input()))

Submission status: Runtime Error

Solution code:
def f(n, k):
  num_bit = 3 - bin(k).count('1')
  c = [0, 0, 1, 3]
  return 3**n - num_bit*2**n + c[num_bit]

# k = 0:(), 1:(3), 2(5), 3:(3, 5), 4:(7), 5:(3, 7), 6:(5, 7), 7:(3, 5, 7)
def solve(N, k=0):
  n = len(N)
  num_used = bin(k).count('1')
  if n + num_used < 3:
    return 0
  else:
    a = int(N[0])
    base = sum([f(i, k) for i in range(3, n)])
    if a > 7:
      return sum([f(i, k) for i in range(3, n+1)])
    elif a == 7:
      return base + f(n-1, k|2) + f(n-1, k|1) + solve(N[1:], k|4)
    elif a > 5:
      return base + f(n-1, k|2) + f(n-1, k|1)
    elif a == 5:
      return base + f(n-1, k|1) + solve(N[1:], k|2)
    elif a > 3:
      return base + f(n-1, k|1)
    elif a == 3:
      return base + solve(N[1:], k|1)
    elif a > 0:
      return base
    else: # a == 0
      return solve(N[1:])

print(solve(input()))

Submission status: Runtime Error

Solution code:
N = int(input())
def dfs(s):
    if int(s) > N:
        return 0
    else:
        if '7' in s and '5' in s and '3' in s:
            ret = 1
        else:
            ret = 0
        for c in '357':
            ret += dfs(s + c)
        return ret
print(def("0"))

Submission status: Runtime Error

Solution code:
def f(a,b):
#a=7,5,3  b=0-7
#no=0, 3=1, 5=2, 7=4, all=7
    if a==7 and b>=4: return b
    if a==7 and b<4: return b+4
    if a==5 and b in (2,3,6,7): return b
    if a==5 and b not in (2,3,6,7): return b+2
    if a==3 and b in (1,3,5,7): return b
    if a==3 and b not in (1,3,5,7): return b+1

n=input()

#a,b=map(int, input().split())
#print(f(a,b))
l=[int(i) for i in "0"+n]
dp=[[[0]*9,[0]*9] for _ in "ww"]
dp[0][0][0]=1

chk=(7,5,3)
for i,j in enumerate(l):
    if i==0: continue
    elif i==1:
        if j in chk: dp[i%2][0][f(j,0)]=1
        if j not in chk: dp[i%2][0][0]=1
        if j>7: dp[i%2][1][4]+=1
        if j>5: dp[i%2][1][2]+=1
        if j>3: dp[i%2][1][1]+=1
        dp[i%2][1][0]=1
    else:
        dp[i%2][1][0]=1
        dp[i%2][1][4]+=1
        dp[i%2][1][2]+=1
        dp[i%2][1][1]+=1
        for k in range(8):
            if dp[i%2-1][0][k] and (k==0 or j not in chk): dp[i%2][0][0]=1
            elif dp[i%2-1][0][k] and j in chk: dp[i%2][0][f(j,k)]=1

            if dp[i%2-1][0][k] and k!=0:
                if j>7: dp[i%2][1][f(7,k)]+=1
                if j>5: dp[i%2][1][f(5,k)]+=1
                if j>3: dp[i%2][1][f(3,k)]+=1
            if dp[i%2-1][1][k] and k!=0:
                dp[i%2][1][f(7,k)]+=dp[i%2-1][1][k]
                dp[i%2][1][f(5,k)]+=dp[i%2-1][1][k]
                dp[i%2][1][f(3,k)]+=dp[i%2-1][1][k]
    for k in range(9):
        dp[i%2-1][0][k]=0
        dp[i%2-1][1][k]=0

print(dp[0][0][7]+dp[0][1][7]+dp[1][0][7]+dp[1][1][7]

Submission status: Runtime Error

Solution code:
n = int(input())

def bfs(s):
  if int(s) >= n:
    return 0
  return ('3' in s and '5' in s and '7' in s) + bfs(s+'3') + bfs(s+'5') + bfs(s+'7')

print(bfs(''))

Submission status: Runtime Error

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy,copy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    candidate = set("3","5","7")
    for i in range(9):
        for c in copy(candidate):
            candidate.add(c+"3")
            candidate.add(c+"5")
            candidate.add(c+"7")
    
    ans = 0
    for c in candidate:
        if int(c)<=N and 0 not in (c.count("3"),c.count("5"),c.count("7")):
            ans += 1
    print(ans)



if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    candidate = ["3","5","7"]
    for i in range(9):
        for c in candidate.copy():
            candidate.append(c+"3")
            candidate.append(c+"5")
            candidate.append(c+"7")
    
    ans = 0
    for c in candidate:
        if int(c)<=N and 0 not in (c.count("3"),c.count("5"),c.count("7")):
            ans += 1
    print(ans)



if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def function(n):
    digit=len(str(n))
    N=str(n)
    k=int(N[0])
    m=int(N[1])
    if digit<3:
        return 0
    else:
        if k<3:
            return function(10**(digit-1)-1)
        elif k==3 and m>0:
            return function(10**(digit-1)-1)+function(n%(10**(digit-1)))-function(10**(digit-2))+subfunction(5,7,n%(10**(digit-1)))
        elif k==3 and m==0:
            return function(10**(digit-1)-1)
        elif k==4:
            return function(4*(10**(digit-1))-1)
        elif k==5 and m>0:
            return function(4*(10**(digit-1))-1)+function(n%(10**(digit-1)))-function(10**(digit-2))+subfunction(3,7,n%(10**(digit-1)))
        elif k==5 and m==0:
            return function(4*(10**(digit-1))-1)
        elif k==6:
            return function(6*(10**(digit-1))-1)
        elif k==7 and m>0:
            return function(6*(10**(digit-1))-1)+function(n%(10**(digit-1)))-function(10**(digit-2))+subfunction(3,5,n%(10**(digit-1)))
        elif k==7 and m==0:
            return function(6*(10**(digit-1))-1)
        else:
            return function(8*(10**(digit-1))-1)

def subfunction(a,b,n):
    digit=len(str(n))
    N=str(n)
    k=int(N[0])
    if digit<2:
        return 0
    else:
        if k<a:
            return 0
        elif k==a:
            if n%(10**(digit-1))<b*(10**(digit-1)-1)//9:
                s=0
            else:
                s=1
            return subfunction(a,b,n%(10**(digit-1)))+s
        elif a<k<b:
            return subfunction(a,b,(a+1)*(10**(digit-1))-1)
        elif k==b:
            if n%(10**(digit-1))<a*(10**(digit-1)-1)//9:
                s=0
            else:
                s=1
            return subfunction(a,b,(a+1)*(10**(digit-1))-1)+subfunction(a,b,n%(10**(digit-1)))+s
        else:
            return subfunction(a,b,(b+1)*(10**(digit-1))-1)

N=int(input())
print(function(N))

Submission status: Runtime Error

Solution code:
ag=0
N=int(input())
for i in range(357,N):
  cat =list(map(int,str(i)))
  #print(cat)
  three=0
  five=0
  seven=0
  for j in range(len(cat)):
    if (cat[j]==3):
      three+=1
      elif(cat[j]==5):
      five+=1
      elif(cat[j]==7):
      seven+=1
    else:
      three=0
      five=0
      seven=0
      break
  if not((seven>0)and(five>0)and(three>0)):
	ag+=1
#else:
#print(cat)
print((N-357)-ag)

Submission status: Runtime Error

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')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく

Submission status: Runtime Error

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')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく

Submission status: Runtime Error

Solution code:
n = int(input())


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


print(dfs('0'))

Submission status: Runtime Error

Solution code:
from collections import defaultdict
p_y = defaultdict(set)

N,M = map(int,input().split())
PY = [[int(x) for x in input().split()] for _ in range(M)]
for p,y in PY:
        p_y[p].add(y)

def set_rank(retu):
        return {x:i for i,x in enumerate(sorted(retu), 1)}

p_y = {p:set_rank(retu) for p,retu in p_y.items()}
for p,y in PY:
        print('{:06g}{:06g}'.format(p,p_y[p][y]))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10000)

N = int(input())
def shichigosan(n):
	if n == 356:
		return 0
	l = list(str(n))
	if "3" in l and "5" in l and "7" in l:
		return 1 + shichigosan(n-1)
	else:
		return shichigosan(n-1)
	
print(shichigosan(N))

Submission status: Runtime Error

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')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく

Submission status: Runtime Error

Solution code:
n = int(input())
sft(n, "", "3")
sft(n, "", "5")
sft(n, "", "7")
le = []
for i in range(len(l)):
    c3 = str(l[i]).count("3")
    c5 = str(l[i]).count("5")
    c7 = str(l[i]).count("7")
    if c3 > 0 and c5 > 0 and c7 > 0:
        le.append(l[i])
print(len(list(set(le))))

Submission status: Runtime Error

Solution code:
from itertools import product
n = int(input())

ans = 0

for i in range(3,len(str(n))+1):
    for p in product('753',repeat=i):
        if n >= int(''.join(list(p))) and all(list(p).count(c) > 0 for c in '753': ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())

def dfs(s):
  if n<int(s) : return 0
  res = if all(s.count(c)>0 for c in "753") : 1 else 0
  for i in "753":
    res += dfs(s+i)
  return res

print(dfs("0"))

Submission status: Runtime Error

Solution code:
n=int(input())

def dfs(s):
  if n<int(s) : return 0
  res = if all(s.count(c) for c in "753") : 1 else 0
  for i in "753":
    res += dfs(s+i)
  return res

print(dfs("0"))

Submission status: Runtime Error

Solution code:
from itertools import product
N = int(input())
ans = 0
for p in product(['0','3','5','7'],repeat=9):
  s = ''.join(p)
  if '3' in s and '5' in s and 7 in 's' and int(s) <= N:
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
Ns = input()
N = int(Ns)
Nl = len(Ns)
ret = 0
def doit(t, f , s, now):
    if t + f + s == 0:
        if int(now) <= N:
            ret += 1
        return
    if t > 0:
        doit(t - 1, f, s, now + str(3)) 
    if f > 0:
        doit(t, f - 1, s, now + str(5)) 
    if s > 0:
        doit(t, f, s - 1, now + str(7)) 
    
for seven in range(1, Nl - 1):
    for five in range(1, Nl - seven):
        least = Nl - seven - five
        for three in range(1, least + 1):
            doit(three, five, seven, '')

print(ret)

Submission status: Runtime Error

Solution code:
from collections import deque
n=int(input())
num=0
l=["3","5","7"]
q=deque(["3","5","7"])
count=0
while q:
  a=q.popleft()
  for i in l:
    if int(i+a)<n:
    count+=1
    q.append(i+a)
print(count)

Submission status: Runtime Error

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) #allでみてるのでbadの条件は不要
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
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(dfs('0'))

Submission status: Runtime Error

Solution code:
import sys

n = int(input())
sys.setrecursionlimit(10**10)



def count(num):
    if num > n:
        return 0
    fl = 0
    s = str(num)
    if '3' in s and '5' in s and '7' in s:
        fl = 1

    return fl + count(num*10+3) + count(num*10+5) + count(num*10+7)


print(count(0))

Submission status: Runtime Error

Solution code:
import sys

n = int(input())
sys.setrecursionlimit(n)



def count(num):
    if num > n:
        return 0
    fl = 0
    s = str(num)
    if '3' in s and '5' in s and '7' in s:
        fl = 1

    return fl + count(num*10+3) + count(num*10+5) + count(num*10+7)


print(count(0))

Submission status: Runtime Error

Solution code:
n=int(input())
def dsf(s):
  if int(s)>n:
    return0
  else:
    if all(s.count(c)>0 for c in "753"):
      x=1
    else:
      x=0
    for c in "753":
      x+=dsf(s+c)
    return x
print(dsf("0"))

Submission status: Runtime Error

Solution code:
n = int(input())
s == 0
for i in range(n+1):
  l = list(str(i))
  m = [j for j in l if j='3' or j='5' or j='7']
  if m.count('3')>=1 and m.count('5')>=1 and m.count('7')>=1:
    s += 1
print(s)

Submission status: Runtime Error

Solution code:
n = int(input())
s == 0
for i in range(n+1):
  l = list(str(i))
  m = [j for j in l if j=3 or j=5 or j=7]
  if m.count('3')>=1 and m.count('5')>=1 and m.count('7')>=1:
    s += 1
print(s)

Submission status: Runtime Error

Solution code:
n = int(input())
s = 0
for i in range(n+1):
  l = list(str(i))
  m = [j for j in l if j=3 or j=5 or j=7]
  if m.count('3')>=1 and m.count('5')>=1 and m.count('7')>=1:
    s +=1
print(s)

Submission status: Runtime Error

Solution code:
n = int(input())
s = 0
for i in range(n+1):
  l = list(str(i))
  m = [j for j in l if j=3 or j=5 or j=7]
  if m.count(3)>=1 and m.count(5)>=1 and m.count(7)>=1:
    s +=1
print(s)

Submission status: Runtime Error

Solution code:
n = input()
s = 0
for i in range(n+1):
  l = list(i)
  m = [j for j in l if j=3 or j=5 or j=7]
  if m.count(3)>=1 and m.count(5)>=1 and m.count(7)>=1:
    s +=1
print(s)

Submission status: Runtime Error

Solution code:
from itertools import product
n=int(input())

ans = 0
for i in range(3, 10):
    for s in product('357', repeat=i):
        if len(set(s)) < 3:
            continue
        753num = int(''.join(s))
        if  753num> n:
            break
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())

def dts(s):
  if int(s) > n:
    return 0
  if ret = 1 if all(s.count(_) for _ in '753') else 0
  for i in '753':
    ret += dts(s+i)
  return ret
  
dts('0')

Submission status: Runtime Error

Solution code:
n = int(input())

def abc(s):
  t = all('3' in s, '5' in s, '7' in s)
  if len(s) < len(n):
    return abc(s+'3') + abc(s+'5') + abc(s+'7') + t
  elif s <= n:
    return t
  else:
    return 0
print(abc(''))

Submission status: Runtime Error

Solution code:
def seven_five_five(n):
    s = list(str(n))
    len_s = len(s)
    semi_753 = []
    for j in range(3,len_s+1):
        for i in itertools.product(['3','5','7'],repeat=j):
            l = ''.join(i)
            #print l
            semi_753.append(l)

    target = [i for i in semi_753 if int(i) > 356 and int(i) <= n]
    #print target
    count = 0
    for i in target:
        v = str(i)
        flag = [False,False,False]
        for j in list(v):
            if j == '7':
                flag[0] = True
            elif j == '5':
                flag[1] = True
            elif j == '3':
                flag[2] = True
            else:
                break

            if flag[0] and flag[1] and flag[2]:
                #print i
                count += 1
                break
    print count
if __name__ == '__main__':
    n =  int(raw_input())
    seven_five_five(n)

Submission status: Runtime Error

Solution code:
a

Submission status: Runtime Error

Solution code:
n1=int(input())
l1=len(str(n1))
count=0
def count1(n):
  l=len(str(n))-1
  l2=int(str(n)[0])
  if int(str(n)[0])>=8:
    return 3*(3**l+3-3*(2**l))
  elif int(str(n)[0])==7:
    return count(n-7*(10**(l-1)))+2*(3**l+3-3*(2**l))
  elif l2==6:
    return 2*(3**l+3-3*(2**l))
  elif l2==5:
    return count(n-5*(10**(l-1)))+(3**l+3-3*(2**l))
  elif l2==4:
    return (3**l+3-3*(2**l))
  elif l2==3:
    return count(n-3*(10**(l-1)))
  else:
    return 0
    
    
if l1<3:
  print(0)
else:
  if l1>=4:
    for i in range(3,l1):
      c+=3**i+3-3*(2**i)
  print(c+count1(n1))

Submission status: Runtime Error

Solution code:
n=int(input())

a=[0]*n
aa=0
for i in range(n):
    b=set(list(str(i)))
    if len(b)==3:
        if "3" in b and "5" in b and "7" in b:
            aa+=1
    a[i]+=aa

print(a[n-1])

Submission status: Runtime Error

Solution code:
n=int(input())

a=[0]*n
aa=0
for i in range(n):
    b=set(list(str(i)))
    if len(b)==3:
        if b.count("7")>0 and b.count("5")>0 and b.count("3")>0:
            aa+=1
    a[i]+=aa


print(a[n-1])

Submission status: Runtime Error

Solution code:
N = input()

l = len(N)
ans = 0
#各桁を「数字無し（０）」「７（１）」「５（２）」「３（３）」で記述するような4進数を作る
for n in range(1, 4**l):
  n4 = ""
  while n > 0:
    mod = n % 4
    n4 = str(mod) + n4
    n //= 4
  
  if "0" in n4:
    continue
  
  if ("1" in n4) and ("2" in n4) and ("3" in n4):
    n4_10 = ""
    for i in range(len(n4)):
      if n4[i] == "1":
        n4_10 = n4_10 + "7"
      elif n4[i] == "2":
        n4_10 = n4_10 + "5"
      else:
        n4_10 = n4_10 + "3"
    if int(n4_10) =< int(N):
      ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
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(dfs('0'))

Submission status: Runtime Error

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')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく

Submission status: Runtime Error

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

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

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

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 =7*10**(n-1)
elif int(N_str[0]) > 3:
    num += (3**n-3*2**n+3)//3
    c = 5*10**(n-1)


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

print(num)

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
/* TLEだった orz 
int main() {
  ll N; cin >> N;
  ll val = 357, cnt = 0;
  while (N >= val) {
    string s = to_string(val);
    bool three=false,five=false,seven=false,ok=true;
    for(int i=0; i < s.size(); i++) {
      if(s[i]=='3')three=true;
      else if(s[i]=='5')five=true;
      else if(s[i]=='7')seven=true;
      else ok = false;
    }
    if(three&&five&&seven&&ok){
      cnt++;
      //cout<<"s = "<<s<<endl;
      //printf("cnt=%d\n",cnt);
    }
    val++;
  }
  cout << cnt << endl;
} 
*/
int N, ans;
void dfs(ll x,bool flag3,bool flag5,bool flag7) {
    if(x > N) {
        return ;
    }
    if(flag3 && flag5 && flag7) {
        ans++;
    }
    dfs(x*10+3, true, flag5, flag7);
    dfs(x*10+5, flag3, true, flag7);
    dfs(x*10+7, flag3, flag5, true);
}
int main() {
    cin >> N;
    dfs(0,0,0,0);
    cout << ans << endl;
}

Submission status: Runtime Error

Solution code:
# https://atcoder.jp/contests/abc114/submissions/6262572

from itertools import product
N = input()
n = int(N)
ans = 0
for i in range(len(N)+1):
    for s in product(["3","5","7"],repeat=i):
        if int("".join(s)) <= n and "3" in s and "5" in s and "7" in s:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
N=input()

if len(N)<3:
    print(0)
else:
    arr=set([357, 375, 537, 573, 735, 753])
    for i in range(len(N)-3):
        new=set()
        for num in arr:
            for j in range(len(str(num))+1):
                n=str(num)[:j]+'3'+str(num)[j:]
                new.add(int(n))
                n=str(num)[:j]+'5'+str(num)[j:]
                new.add(int(n))
                n=str(num)[:j]+'7'+str(num)[j:]
                new.add(int(n))
        arr |= new

arr=list(arr)
arr.sort()
cnt=0
for i in range(len(arr)):
    if arr[i]<=int(N):
        cnt+=1
    else:
        break
print(cnt)

Submission status: Runtime Error

Solution code:
n = int(input())
def dfs(cur, a, b, c):
    if cur == n:
        return 0
    ret = 1 if all(s.count(c)) > 0 for c in "753") else 0
    for i in "753":
        ret += dfs(s+c)
    return ret
print(dfs("0"))

Submission status: Runtime Error

Solution code:
N = int(input)

def dfs(s):
#文字列sで始まる七五三数の個数
    if int(s) > N:
        return 0
    #s自体が七五三数なら+1
    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(dfs('0'))

Submission status: Runtime Error

Solution code:
# ABC114C - 755
n = input()
digit = len(n)
ans = 0
for i in range(1, digit):
    ans += len([i for i in itertools.product("357", repeat=i) if len(set(i)) == 3])
tup = tuple(i for i in n)
lst = [i for i in itertools.product("357", repeat=digit) if len(set(i)) == 3] + [tup]
lst.sort()
ans += lst.index(tup)
print(ans)

Submission status: Runtime Error

Solution code:
N = 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: 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 # s 自体が七五三数なら +1
	
    for c in '753':
		ret += dfs(s + c)
	return ret

print(dfs('0'))

Submission status: Runtime Error

Solution code:
import itertools

N = int(input())

number = [7, 5, 3]

ans = 0
for i in range(10):
    for conv in itertools.product(number, repeat=i+1):
        
        tmp = 0
        for j in range(len(conv)):
            tmp += conv[j] * 10 ** (len(conv) - j - 1)
            
        
        if ((3 in conv) and (5 in conv) and (7 in conv)) and tmp =< N:
            ans += 1
            
        
print(ans)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
if (a * b) % 2 == 0:
    print("Even")
else:
    print("Odd")

Submission status: Runtime Error

Solution code:
N = input()
Nlen = len(N)
N = int(N)

def f(i, n, T, F, S):
  if i >= Nlen:
    return 1 if n <= N and T > 0 and F > 0 and S > 0 else 0
  n *= 10
  cnt = 0
  if n == 0:
    cnt += f(i+1, n, T  , F  , S  )
  cnt += f(i+1, n+3, T+1, F  , S  )
  cnt += f(i+1, n+5, T  , F+1, S  )
  cnt += f(i+1, n+7, T  , F  , S+1)

print(f(0, 0, 0, 0, 0))

Submission status: Runtime Error

Solution code:
n = input()

def dfs(s) > N:
    return 0

print(def('0'))