Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, h: "List[int]"):
    dp = [float("inf")] * 10 ** 6
    h = h + [0] * 10 ** 6
    dp[0] = 0
    for i in range(N):
        for j in range(1, K + 1):
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))
    print(dp[N - 1])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)


if __name__ == "__main__":
    main()


Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [float("inf")] * 10 ** 6
h = h + [0] * 10 ** 6
dp[0] = 0
for i in range(N):
    for j in range(1, K + 1):
        dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))
print(dp[N - 1])
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())

from math import factorial
ans = 0

if n % 2 == 1:
    for i in range(1, n // 2 + 1):
        ans += factorial(n) // factorial(i) // factorial(n - i)
    ans *= 2 + 1
else:
    for i in range(1, n // 2):
        ans += factorial(n) // factorial(i) // factorial(n - i)
    ans *= 2
    ans += factorial(n) // factorial(n // 2) // factorial(n - n // 2) + 1

ans -= factorial(n) // factorial(a) // factorial(n - a)
ans -= factorial(n) // factorial(b) // factorial(n - b)
print(ans)

Fixed submission:
n, r = map(int, input().split())

if n >= 10:
  print(r)
else:
  print(r +  100 * (10 - n))

Buggy python submission (verdict: Runtime Error):
n, r = map(int, input().split())

if n >= 10:
  print(R)
else:
  print(r +  100 * (10 - n))

Fixed submission:
n, r = map(int, input().split())

if n >= 10:
  print(r)
else:
  print(r +  100 * (10 - n))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
num_list = [int(i) for i in input().split()]

ans_list = []

for i in range(n - 1):
    for j in range(i + 1, n):
        ans_list.append(num_list[i] * num_list[j])

ans_list.sort()

print(ans_list[k - 1])

Fixed submission:
import numpy as np

n, k = map(int, input().split())
num_list = [int(i) for i in input().split()]
num_list = np.array(num_list)
num_list.sort()

neg = num_list[num_list < 0]
pos = num_list[num_list > 0]
zero =  num_list[num_list == 0]

def count(x):
    ans = 0
    if x >= 0:
        ans += len(zero) * n
    ans += np.searchsorted(num_list, x // pos, side="right").sum()
    ans += n * len(neg) - np.searchsorted(num_list, -(-x // neg), side="left").sum()
    ans -= np.count_nonzero(num_list * num_list <= x)
    return ans // 2

left = -(10 ** 18)
right = 10 ** 18

while left + 1 < right:
    mid = (left + right) // 2
    if count(mid) >= k:
        right = mid
    else:
        left = mid

print(right)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
num_list = [int(i) for i in input().split()]

ans_list = []

for i in range(n - 1):
    for j in range(i + 1, n):
        ans_list.append(num_list[i] * num_list[j])

ans_list.sort()

print(ans_list[k - 1])

Fixed submission:
import numpy as np

n, k = map(int, input().split())
num_list = [int(i) for i in input().split()]
num_list = np.array(num_list)
num_list.sort()

neg = num_list[num_list < 0]
pos = num_list[num_list > 0]
zero =  num_list[num_list == 0]

def count(x):
    ans = 0
    if x >= 0:
        ans += len(zero) * n
    ans += np.searchsorted(num_list, x // pos, side="right").sum()
    ans += n * len(neg) - np.searchsorted(num_list, -(-x // neg), side="left").sum()
    ans -= np.count_nonzero(num_list * num_list <= x)
    return ans // 2

left = -(10 ** 18)
right = 10 ** 18

while left + 1 < right:
    mid = (left + right) // 2
    if count(mid) >= k:
        right = mid
    else:
        left = mid

print(right)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
num_list = [int(i) for i in input().split()]

ans_list = []

for i in range(n - 1):
    for j in range(i + 1, n):
        ans_list.append(num_list[i] * num_list[j])

ans_list.sort()

print(ans_list[k])

Fixed submission:
import numpy as np

n, k = map(int, input().split())
num_list = [int(i) for i in input().split()]
num_list = np.array(num_list)
num_list.sort()

neg = num_list[num_list < 0]
pos = num_list[num_list > 0]
zero =  num_list[num_list == 0]

def count(x):
    ans = 0
    if x >= 0:
        ans += len(zero) * n
    ans += np.searchsorted(num_list, x // pos, side="right").sum()
    ans += n * len(neg) - np.searchsorted(num_list, -(-x // neg), side="left").sum()
    ans -= np.count_nonzero(num_list * num_list <= x)
    return ans // 2

left = -(10 ** 18)
right = 10 ** 18

while left + 1 < right:
    mid = (left + right) // 2
    if count(mid) >= k:
        right = mid
    else:
        left = mid

print(right)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p_list = [i for i in map(int, input().split())]

ans = 0

for i in range(n):
    #i番目までのリストを作成
    check_part = p_list[:i+1]
    #その中で一番小さいかどうか
    if p_list[i] == min(check_part):
        ans += 1

print(ans)

Fixed submission:
n = int(input())
p_list = [i for i in map(int, input().split())]

ans = 0
min = n + 1

for i in range(n):
    if p_list[i] < min:
        min = p_list[i]
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

def main():
    k = input().replace('\n','').split()
    a = input().replace('\n','').split()
    u = input().replace('\n','')
    a[k.index(u)]=int(a[k.index(u)]) - 1
    print(str(a[0]) + ' ' + a[1])
if __name__ == '__main__':
    input = sys.stdin.readline
    main()


Fixed submission:
import sys

def main():
    k = input().replace('\n','').split()
    a = input().replace('\n','').split()
    u = input().replace('\n','')
    a[k.index(u)]=int(a[k.index(u)]) - 1
    print(str(a[0]) + ' ' + str(a[1]))
if __name__ == '__main__':
    input = sys.stdin.readline
    main()

Buggy python submission (verdict: Runtime Error):
import sys

def main():
    k = input().replace('\n','').split()
    a = input().replace('\n','').split()
    u = input().replace('\n','')
    a[k.index(u)]=int(a[k.index(u)]) - 1
    print(str(a[0]) + ' ' + a[1])
if __name__ == '__main__':
    input = sys.stdin.readline
    main()


Fixed submission:
import sys

def main():
    k = input().replace('\n','').split()
    a = input().replace('\n','').split()
    u = input().replace('\n','')
    a[k.index(u)]=int(a[k.index(u)]) - 1
    print(str(a[0]) + ' ' + str(a[1]))
if __name__ == '__main__':
    input = sys.stdin.readline
    main()
Buggy python submission (verdict: Runtime Error):
import math


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


ab = input()
a = int(ab.split(" ")[0])
b = int(ab.split(" ")[1])

print(lcm(a, b))


Fixed submission:
import fractions


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


ab = input()
a = int(ab.split(" ")[0])
b = int(ab.split(" ")[1])

print(lcm(a, b))
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b): 
    if a == 0: 
        return b 
    return gcd(b % a, a) 
  
def lcm(a,b): 
    return (a*b) // gcd(a,b) 
  
n = int(input())
arr = input()   # takes the whole line of n numbers
a = list(map(int,arr.split(' ')))
l = a[0]
ans = 0
for i in range(n):
    l = lcm(l, a[i])
for i in range(n):
    ans = ans + l//a[i]
print(ans%1000000007)

Fixed submission:
def gcd(a,b): 
    if a == 0: 
        return b 
    return gcd(b % a, a) 
  
def lcm(a,b): 
    return (a*b) // gcd(a,b) 
  
n = int(input())
arr = input()   # takes the whole line of n numbers
a = list(map(int,arr.split(' ')))
l = a[0]
ans = 0
for i in range(n):
    l = lcm(l, a[i])
for i in range(n):
    ans = ans + l//a[i]
print(ans%1000000007)

Buggy python submission (verdict: Runtime Error):
def gcd(a,b): 
    if a == 0: 
        return b 
    return gcd(b % a, a) 
  
def lcm(a,b): 
    return (a*b) // gcd(a,b) 

mod = 1000000007
n = int(input())
arr = input()
a = list(map(int, arr.split(' ')))
lc = a[0]
res = 0
for i in range(n):
    lc = lcm(lc, a[i])
for i in range(n):
    res = res + 1//a[i]
print(ans % mod)

Fixed submission:
def gcd(a,b): 
    if a == 0: 
        return b 
    return gcd(b % a, a) 
  
def lcm(a,b): 
    return (a*b) // gcd(a,b) 
  
n = int(input())
arr = input()   # takes the whole line of n numbers
a = list(map(int,arr.split(' ')))
l = a[0]
ans = 0
for i in range(n):
    l = lcm(l, a[i])
for i in range(n):
    ans = ans + l//a[i]
print(ans%1000000007)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
A, B = map(int,input().split())
C = gcd(A,B)
C0 = C

p = {}
for i in range(2,10**6):
    if C % i == 0:
        p[i] = 0
        while C % i == 0:
            C //= i
            p[i] += 1
    if i * i > C0:
        break
if C != 0:
  p[C] = 1

print(len(p) + 1)

Fixed submission:
n = int(input())

if n % 2 == 0:
  print(1/2)
else:
  print((n+1)/(2 * n))
Buggy python submission (verdict: Runtime Error):
n, K = map(int,input().split())
h =[int(_) for _ in input().split()]

res = 0
for i in range(n):
  if h[i] >= k:
    res += 1
print(res)

Fixed submission:
n, k = map(int,input().split())
h =[int(_) for _ in input().split()]
 
res = 0
for i in range(n):
  if h[i] >= k:
    res += 1
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s = s[::-1]
n = len(s)
s = '#' + s
MOD = 10**9+7
dp = [[0]*13 for _ in range(n+5)]
"""
dp[i][j] は i 桁目まで見たとき 13 で割ったあまりが j　となるようなものの個数
"""
dp[0][0] = 1
r = 1 
for i in range(1,n+1):
    for j in range(13):
        if s[i] != '?':
            dp[i][j] = dp[i-1][(j-r*int(s[i]))%13] % MOD
        if s[i] == '?':
            for k in range(10):
                dp[i][j] += dp[i-1][(j-r*k)%13]
            dp[i][j] %= MOD
    r = (r*10) % 13
print(dp[n][5])

Fixed submission:
s = input()
s = s[::-1]
n = len(s)
s = '#' + s
MOD = 10**9+7
dp = [[0]*13 for _ in range(n+5)]
"""
dp[i][j] は i 桁目まで見たとき 13 で割ったあまりが j　となるようなものの個数
"""
dp[0][0] = 1
r = 1 
for i in range(1,n+1):
    for j in range(13):
        if s[i] != '?':
            dp[i][j] = dp[i-1][(j-r*int(s[i]))%13] % MOD
        if s[i] == '?':
            for k in range(10):
                dp[i][j] += dp[i-1][(j-r*k)%13]
            dp[i][j] %= MOD
    r = (r*10) % 13
print(dp[n][5])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(_) for _ in input().split()]
res = []
m = 0
for i in range(n//2,n):
    if a[i] == 1:
        res.append(i+1)
        m += 1
for i in range(n//2):
    k = n//2-i
    cnt = 0
    for j in res:
        if j % k == 0:
            cnt = (cnt+1)%2
    if cnt != a[k-1]:
        res.append(k)
        m += 1 
if m == 0:
    print(0)
else:
    print(m)
    for i in range(m):
        if i != 0:
            print(' ',end='')
        print(res[i],end='',)
    print()

Fixed submission:
n = int(input())
a = [int(_) for _ in input().split()]
b = [0] * n
res = []
m = 0
for i in range(n//2,n):
    if a[i] == 1:
        res.append(i+1)
        b[i] = 1
        m += 1
for i in range(n//2):
    k = n//2-i
    cnt = 0
    for j in range(2*k-1,n,k):
        if b[j] == 1:
            cnt = (cnt+1)%2
    if cnt != a[k-1]:
        res.append(k)
        b[k-1] = 1
        m += 1 
if m == 0:
    print(0)
else:
    print(m)
    for i in range(m):
        if i != 0:
            print(' ',end='')
        print(res[i],end='',)
    print()
Buggy python submission (verdict: Runtime Error):
import bisect

n = int(input())
a = []

for i in range(n):
    a.append(int(input()))

a.reverse()
cnt = 0
for i in range(1,n):
    if a[i] + cnt == c[i-1]:
        cnt += 1
    a[i] += cnt
        
INF = 10000000000
dp = [INF] * n

for i in range(n):
    t = bisect.bisect_left(dp,a[i])
    if t != n:
        dp[t] = a[i]

print(bisect.bisect_left(dp,INF))

Fixed submission:
import bisect

INF = 10000000000

n = int(input())
a = [0] * n

for i in range(n):
    a[i] = int(input())
    a[i] = - a[i]

dp = [INF] * n

for i in range(n):
    dp[bisect.bisect_right(dp,a[i])] = a[i]
    
print(bisect.bisect_left(dp,INF))

Buggy python submission (verdict: Runtime Error):
import bisect

n = int(input())
c = []

for i in range(n):
    c.append(int(input()))

c.reverse()

for i in range(1,n):
    if c[i] == c[i-1]:
        c[i] += 1
        
INF = 100000000
dp = [INF] * n

for i in range(n):
    dp[bisect.bisect_left(dp,c[i])] = c[i]

print(bisect.bisect_left(dp,INF))

Fixed submission:
import bisect

INF = 10000000000

n = int(input())
a = [0] * n

for i in range(n):
    a[i] = int(input())
    a[i] = - a[i]

dp = [INF] * n

for i in range(n):
    dp[bisect.bisect_right(dp,a[i])] = a[i]
    
print(bisect.bisect_left(dp,INF))

Buggy python submission (verdict: Runtime Error):
import bisect

n = int(input())
c = []

for i in range(n):
    c.append(int(input()))

INF = 100000000
dp = [INF] * n

for i in range(n):
    dp[bisect.bisect_left(dp,c[i])] = c[i]

print(n - bisect.bisect_left(dp,INF)+1)


Fixed submission:
import bisect

INF = 10000000000

n = int(input())
a = [0] * n

for i in range(n):
    a[i] = int(input())
    a[i] = - a[i]

dp = [INF] * n

for i in range(n):
    dp[bisect.bisect_right(dp,a[i])] = a[i]
    
print(bisect.bisect_left(dp,INF))
Buggy python submission (verdict: Runtime Error):
l,r = map(int,input().split())

if r -l >= 2019:
    print(0)
else:
    res = 2018
    for i in range(l,r+1):
        for j in range(1,r+1):
            if i<j:
                res = min(res,(i*j)%2019)
print(res)

Fixed submission:
l,r = map(int,input().split())

if r -l >= 2019:
    print(0)
else:
    res = 2018
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            res = min(res,(i*j)%2019)
    print(res)
Buggy python submission (verdict: Time Limit Exceeded):
MOD=1000000007
n,m=map(int,input().split())

S=[int(_) for _ in input().split()]
T=[int(_) for _ in input().split()]

dp=[[0 for j in range(m+1)] for i in range(n+1)]
for i in range(n+1):
  dp[i][0]=1
for j in range(m+1):
  dp[0][j]=1

for i in range(n):
    for j in range(m):
        if S[i]!=T[j]:
            dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]-dp[i][j]
            dp[i+1][j+1]%=MOD
        else:
            dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]
            dp[i+1][j+1]%=MOD
print((dp[n][m])%MOD)

Fixed submission:
MOD=1000000007
n,m=map(int,input().split())

S=[int(_) for _ in input().split()]
T=[int(_) for _ in input().split()]

dp=[[0 for j in range(m+1)] for i in range(n+1)]
for i in range(n+1):
  dp[i][0]=1
for j in range(m+1):
  dp[0][j]=1

for i in range(n):
    for j in range(m):
        if S[i]!=T[j]:
            dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]-dp[i][j]
            dp[i+1][j+1]%=MOD
        else:
            dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]
            dp[i+1][j+1]%=MOD
print((dp[n][m])%MOD)
Buggy python submission (verdict: Runtime Error):
N,K = (i for i in input().split())
K = int(K)
X = list(N)
if X[K-1] == 'A':
    X[K-1] = 'a'
if X[K-1] == 'B':
    X[K-1] = 'b'
if X[K-1] == 'C':
    X[K-1] = 'c'
print(''.join(X))

Fixed submission:
T,K = (i for i in input().split())
N = input()
K = int(K)
X = list(N)
if X[K-1] == 'A':
    X[K-1] = 'a'
if X[K-1] == 'B':
    X[K-1] = 'b'
if X[K-1] == 'C':
    X[K-1] = 'c'
print(''.join(X))
Buggy python submission (verdict: Runtime Error):
s = input()
x = [s[j] for j in range(0,len(s10))]
x.insert(0,'2')
count = 0
for j in range(1,len(x)):
    if x[j] == '0' and x[j] == x[j-1]:
        x[j] = '1'
        count = count + 1
    elif x[j] == '1' and x[j] == x[j-1]:
        x[j] = '0' 
        count = count + 1
print(count)


Fixed submission:
s = input()
x = [s[j] for j in range(0,len(s))]
x.insert(0,'2')
count = 0
for j in range(1,len(x)):
    if x[j] == '0' and x[j] == x[j-1]:
        x[j] = '1'
        count = count + 1
    elif x[j] == '1' and x[j] == x[j-1]:
        x[j] = '0' 
        count = count + 1
print(count)
Buggy python submission (verdict: Runtime Error):
x = input()
if x == 'A':
	print('T')
elif x == 'T':
	print('A')
elif X == 'C':
	print('G')
else:
	print('C')

Fixed submission:
x = input()
if x == 'A':
	print('T')
elif x == 'T':
	print('A')
elif x == 'C':
	print('G')
else:
	print('C')
Buggy python submission (verdict: Time Limit Exceeded):
n,q = (int(j) for j in input().split())
s = input()
x = [[0,0] for j in range(q)]
count = [0]*q
for j in range(q):
    x[j][0], x[j][1] = (int(k) for k in input().split())
for j in range(q):
    y = x[:]
    ss = s[y[j][0]-1:y[j][1]]
    ss = ss + 'B'
    for k in range(len(ss) - 1):
        if ss[k] == 'A' and ss[k+1] == 'C':
            count[j] = count[j] + 1
for j in range(q):
    print(count[j])

Fixed submission:
n,q = map(int,input().split())
s = input()
l = [[0,0] for _ in range(q)]
for i in range(q):
    l[i][0],l[i][1] = map(int,input().split())
cnt = [0] * n
for i in range(1,n):
    if s[i] == 'C' and s[i-1] == 'A':
        cnt[i] = cnt[i-1] + 1
    else:
        cnt[i] = cnt[i-1]
cnt.insert(0,0)
for i in range(q):
    print(cnt[l[i][1]]-cnt[l[i][0]])
Buggy python submission (verdict: Runtime Error):
import numpy as np
N,M,C = (int(j) for j in input().split())
B = [int(j) for j in input().split()]
list = [[0]* M]*N
for j in range(0,N):
        list[j] = [int(k) for k in input().split()]
count = 0
for j in range(0,N):
    if np.sum(np.array(list[j]) * np.array(B)) + C > 0:
        count = count + 1
print(count)

Fixed submission:
H,W = (int(j) for j in input().split())
h,w = (int(j) for j in input().split())
print(H*W-(h*W + H*w - h*w))
Buggy python submission (verdict: Runtime Error):
import numpy as np
N,M,C = (int(j) for j in input().split())
B = [int(j) for j in input().split()]
list = [[0]* M]*N
for j in range(0,N):
        list[j] = [int(k) for k in input().split()]
count = 0
for j in range(0,N):
    if np.sum(np.array(list[j]) * np.array(B)) C >0:
        count = count + 1
print(count)

Fixed submission:
import numpy as np
N,M,C = (int(j) for j in input().split())
B = [int(j) for j in input().split()]
list = [[0]* M]*N
for j in range(0,N):
        list[j] = [int(k) for k in input().split()]
count = 0
for j in range(0,N):
    if np.sum(np.array(list[j]) * np.array(B)) + C > 0:
        count = count + 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
def co(s):
    l = list(s)
    cnt = True
    for i in range(len(s))[:0:-1]:
        if l[i] != l[i-1]:
            del l[i]
            del l[i-1]
            cnt = False
            break
    if cnt:
        return s
    if not cnt:
        return co(''.join(l))
print(len(S)-len(co(S)))

Fixed submission:
s = input()
l = list(s)
print(len(s)-abs(l.count('0')-l.count('1')))
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
x = [0] * n
u = ['string'] * n
for j in range(n):
    x[j], u[j] = input().split()
for j in range(n):
    if u[j] == 'JPY':
        x[j] = 1
    elif u[j] == 'BIT':
        x[j] = float(x[j]) * 38
print(np.sum(x) * 10000)

Fixed submission:
import numpy as np
n = int(input())
x = [0] * n
u = ['string'] * n
for j in range(n):
    x[j], u[j] = input().split()
for j in range(n):
    if u[j] == 'JPY':
        x[j] = int(x[j])
    elif u[j] == 'BTC':
        x[j] = float(x[j]) * 380000
print(np.sum(x))
Buggy python submission (verdict: Time Limit Exceeded):
match = [0,2,5,5,4,5,6,3,7,6]
n,m = map(int,input().split())
a = [int(_) for _ in input().split()]
dp = ['-1']*(n+10)
dp[0] = ''
for i in range(n+1):
    if dp[i]=='-1':
        continue
    else:
        for j in a:
            dp[i+match[j]]=str(max(int(dp[i+match[j]]),int(dp[i]+str(j))))
print(dp[n])

Fixed submission:
match = [0,2,5,5,4,5,6,3,7,6]
n,m = map(int,input().split())
a = [int(_) for _ in input().split()]
dp = [-1]*(n+10)
dp[0] = 0
for i in range(n+1):
    if dp[i]== -1:
        continue
    else:
        for j in a:
            dp[i+match[j]]= max(dp[i+match[j]],dp[i]*10+j)
print(dp[n])
Buggy python submission (verdict: Runtime Error):
D = int(imput())
if D = 25:
  print('Christmas')
elif D =24:
  print('Christmas Eve')
elif D = 23:
  print('Christmas Eve Eve')
else:
  print('Christmas Eve Eve Eve')
  

Fixed submission:
D = int(input())
if D ==25:
  print('Christmas')
elif D ==24:
  print('Christmas Eve')
elif D == 23:
  print('Christmas Eve Eve')
else:
  print('Christmas Eve Eve Eve')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0

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

Fixed submission:
n = input()
m = len(n)
ans = 0

for k in range(m+1):
    for i in range(3 ** k):
        li = [] 
        for j in range(k):
            li.insert(0,int((i%(3**(j+1)))/(3**j)))                
        for j in range(k):
            if li[j] == 0:
                li[j] = '3'
            if li[j] == 1:
                li[j] = '5'
            if li[j] == 2:
                li[j] = '7'
        if li != []:
            if int(''.join(li)) <= int(n) and len(set(li)) == 3:
                ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
def prime_factor(n):
    p = {}
    for i in range(2,n):
        if n % i == 0:
            p[i] = 0
        while n % i == 0:
            n //= i
            p[i] += 1
        if i * i > n: break
    if n != 1:
        p[n] = 1
    return p

N = int(input())
pN = {}
for i in range(2,N+1):
    p = prime_factor(i)
    for x in p:
        if x not in pN:
            pN[x] = p[x]
        else:
            pN[x] += p[x]

# 75 = 3 * 5 * 5
res = 0
for x in pN:
    for y in pN:
        for z in pN:
            if (x < y and y < z):
                if(pN[x]>=2 and pN[y]>=4 and pN[z]>=4):
                    res+=1
                if(pN[x]>=4 and pN[y]>=2 and pN[z]>=4):
                    res+=1
                if(pN[x]>=4 and pN[y]>=4 and pN[z]>=2):
                    res+=1

# 75 = 3 * 25
for x in pN:
    for y in pN:
        if x < y:
            if(pN[x]>=24 and pN[y]>= 2):
                res+=1
            if(pN[x]>= 2 and pN[y]>=24):
                res+=1

# 75 = 15 * 5
for x in pN:
    for y in pN:
        if x < y:
            if(pN[x]>=14 and pN[y]>= 4):
                res+=1
            if(pN[x]>= 4 and pN[y]>=14):
                res+=1

if pN[2] >= 74:
    res += 1
    
print(res)   

Fixed submission:
def prime_factor(n):
    p = {}
    for i in range(2,n):
        if n % i == 0:
            p[i] = 0
        while n % i == 0:
            n //= i
            p[i] += 1
        if i * i > n: break
    if n != 1:
        p[n] = 1
    return p

N = int(input())
if N == 1:
    print(0)
else:
    
    pN = {}
    for i in range(2,N+1):
        p = prime_factor(i)
        for x in p:
            if x not in pN:
                pN[x] = p[x]
            else:
                pN[x] += p[x]
    
    # 75 = 3 * 5 * 5
    res = 0
    for x in pN:
        for y in pN:
            for z in pN:
                if (x < y and y < z):
                    if(pN[x]>=2 and pN[y]>=4 and pN[z]>=4):
                        res+=1
                    if(pN[x]>=4 and pN[y]>=2 and pN[z]>=4):
                        res+=1
                    if(pN[x]>=4 and pN[y]>=4 and pN[z]>=2):
                        res+=1
    
    # 75 = 3 * 25
    for x in pN:
        for y in pN:
            if x < y:
                if(pN[x]>=24 and pN[y]>= 2):
                    res+=1
                if(pN[x]>= 2 and pN[y]>=24):
                    res+=1
    
    # 75 = 15 * 5
    for x in pN:
        for y in pN:
            if x < y:
                if(pN[x]>=14 and pN[y]>= 4):
                    res+=1
                if(pN[x]>= 4 and pN[y]>=14):
                    res+=1
    
    if pN[2] >= 74:
        res += 1
        
    print(res)