Problem:


Score : 200 points

Problem Statement

Today is August 24, one of the five Product Days in a year.

A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day):

d_1 \geq 2

d_{10} \geq 2

d_1 \times d_{10} = m

Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D.

In Takahashi Calendar, how many Product Days does a year have?

Constraints

All values in input are integers.

1 \leq M \leq 100

1 \leq D \leq 99

Input

Input is given from Standard Input in the following format:

M D

Output

Print the number of Product Days in a year in Takahashi Calender.

Sample Input 1

15 40

Sample Output 1

10

There are 10 Product Days in a year, as follows (m-d denotes Month m, Day d):

4-22

6-23

6-32

8-24

9-33

10-25

12-26

12-34

14-27

15-35

Sample Input 2

12 31

Sample Output 2

5

Sample Input 3

1 1

Sample Output 3

0



Sample input:
15 40


Sample output:
10

Submission status: Accepted

Solution code:
M, D = map(int, input().split())

ans = 0
for i in range(1, M+1):
    for j in range(1, D+1):
        d1 = j % 10
        d10 = j // 10
        if d1 >= 2 and d10 >= 2 and d1 * d10 == i:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
M, D = list(map(int,input().split()))


count=0
for i in range(1,M+1):
        for j in range(1,D+1):
                if j>=20:
                        if j%10>=2:
                                if (j%10)*(j//10)==i:
                                        count+=1

print(count)

Submission status: Accepted

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

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

#n = int(input())
m,d = [int(i) for i in readline().split()]
#xy = [[int(i) for i in readline().split()] for i in range(n)]

ans = 0
for d in range(1,d+1):
    for j in range(1,m+1):
        dd, ddd = d//10, d%10
        if dd >= 2 and ddd >= 2 and j == dd*ddd:
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
m, d = list(map(int, input().split()))
ans = 0
for mm in range(1, m+1):
  for dd in range(1, d+1):
    d1 = dd%10
    d2 = dd//10
    if d1>=2 and d2>=2 and d1*d2==mm:
      ans += 1
print(ans)

Submission status: Accepted

Solution code:
M,D = map(int,input().split())

ans = 0
for m in range(1,M+1):
    for d in range(22,D+1):
        d1 = d%10
        d2 = d//10
        if d1>=2 and d2>=2 and d1*d2 == m:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
M,D = map(int, input().split())

def check(m,d):
    d1 = d%10
    d2 = d//10
    return d1>=2 and d2>=2 and d1*d2==m

res = 0
for m in range(1,M+1):
    for d in range(1,D+1):
        if check(m,d):
            res += 1

print(res)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

M,D=map(int,input().split())

ANS=0

for i in range(1,M+1):
    for j in range(1,D+1):

        if (j%10)>=2 and (j//10)>=2 and (j%10)*(j//10)==i:

            ANS+=1

print(ANS)

Submission status: Accepted

Solution code:
# @author 

import sys

class ATakahashiCalendar:
    def solve(self):
        m, d = [int(_) for _ in input().split()]
        ans = 0
        for mi in range(1, m + 1):
            for di in range(1, d + 1):
                d1, d2 = di % 10, (di // 10) % 10
                if d1 >= 2 and d2 >= 2 and d1 * d2 == mi:
                    ans += 1

        print(ans)

solver = ATakahashiCalendar()
input = sys.stdin.readline

solver.solve()

Submission status: Accepted

Solution code:
M, D = map(int,input().split())
ans = 0
for m in range(1,M+1):
    for d in range(1,D+1):
        d1 = d % 10
        d10 = d // 10
        if d1 >= 2 and d10 >= 2 and d1 * d10 == m:
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

M, D = list(map(int, sys.stdin.readline().split()))


def ok(m, d):
    return len(str(d)) == 2 and int(str(d)[0]) >= 2 and int(str(d)[1]) >= 2 and int(str(d)[0]) * int(str(d)[1]) == m


ans = 0
for m in range(1, M + 1):
    for d in range(1, D + 1):
        ans += ok(m, d)
print(ans)

Submission status: Accepted

Solution code:
M, D = map(int, input().split())
r = 0
for d1 in range(2, 10):
  for d2 in range(2, 10):
    if d1*10+d2 <= D and d1*d2 <= M:
      r += 1
print(r)

Submission status: Accepted

Solution code:
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7

def sol():
    M, D = map(int, input().split())

    ans = 0
    for month in range(1, M + 1):
        for day in range(1, D + 1):
            d1 = day % 10
            d2 = day // 10
            if d1 >= 2 and d2 >= 2 and d1 * d2 == month:
                ans += 1

    print(ans)


sol()

Submission status: Accepted

Solution code:
import numpy as np
m,d = map(int,input().split())
ans = 0
for i in range(1,m+1):
    for j in range(10,d+1):
        temp = str(j)
        l = int(temp[0])
        r = int(temp[1])
        if l >= 2 and r >= 2 and l*r == i:
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
M, D = map(int, input().split())

cnt = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        d = str(d)
        if len(d) == 1:
            continue
        d1, d2 = map(int, d)
        if d1 > 1 and d2 > 1 and m == d1*d2:
            cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
M, D = map(int,input().split())
ans = 0
for m in range(1,M+1):
    for d in range(2,D+1):
        if m == (d%10)*(d//10) and d%10 >= 2 and d//10 >= 2:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

M,D = inpl()

ans = 0
for m in range(1,M+1):
    for d in range(10,D+1):
        d1,d2 = int(str(d)[0]), int(str(d)[1])
        if d1 >= 2 and d2 >= 2 and m == d1*d2:
            #print(m,d)
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
m, d = map(int, input().split(" "))

ans = 0
for i in range(1, m + 1):
    for j in range(22, d + 1):
        x = j % 10
        y = j // 10
        if x >= 2 and y >= 2 and y*x == i:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

M, D = map(int, input().split())

ans = 0
for i in range(1, M + 1):
    for j in range(10, D + 1):
        a, b = map(int, list(str(j)))
        if a >= 2 and b >= 2:
            if a * b == i:
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
M, D = map(int, input().split())
ans = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        d1 = d%10
        d10 = d//10
        if d1>=2 and d10>=2 and m==d1*d10:
            ans+=1
print(ans)

Submission status: Accepted

Solution code:

m,d=map(int,input().split())
ans=0
for i in range(1,m+1):
  for j in range(1,d+1):
    if j%10>=2 and j//10>=2:
      if (j%10)*(j//10)==i:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
m, d = map(int, input().split())
ans = 0
for mm in range(1, m + 1):
    for dd in range(1, d + 1):
        d1 = dd % 10
        d10 = dd // 10
        if d1 >= 2 and d10 >= 2 and d1 * d10 == mm:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


m, d = li()
ans = 0
for mi in range(1, m+1):
    for di in range(1, d+1):
        if di%10 >= 2 and di//10 >= 2:
            if (di%10) * (di//10) == mi:
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
m, d = map(int, input().split())

count = 0
for i in range(1, m+1):
    for j in range(1, d+1):
        a = j % 10
        b = j // 10
        if a >= 2 and b >=2:
            if i == a*b:
                count += 1
print(count)

Submission status: Accepted

Solution code:
M,D=[int(i) for i in input().split(" ")]

retval=0

for i in range(1,M+1):
    for j in range(1,D+1):
        a=j%10
        b=int(j/10)
        if i==a*b and a>1 and b>1:
            retval+=1

print(retval)

Submission status: Accepted

Solution code:
m, d = map(int, input().split())

ans = 0
for mi in range(1, m+1):
    for di in range(1, d+1):
        if di % 10 >= 2 and di // 10 >= 2 and mi == (di // 10) * (di % 10):
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
M, D = map(int, input().split())
ans = 0
for m in range(1, M + 1):
    for d in range(1, D + 1):
        if d >= 22 and d % 10 >= 2 and (d // 10) * (d % 10) == m:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
M,D = map(int,input().split())

ans = 0
for m in range(1,M+1):
    for d in range(10,D+1):
        d10 = d//10
        d1 = d%10
        ans += (d1 >= 2) and (d10 >= 2) and (d1 * d10 == m)

print(ans)

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
m,d = m()

su = 0

for i in range(1,m+1):
    for j in range(1,d+1):
        d1 = j%10
        d2 = j//10
        if d1 >= 2 and d2 >= 2 and d1*d2 == i:
            su += 1
print(su)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    m,d = LI()
    ans = 0
    for i in range(1,m+1):
        for j in range(1,d+1):
            d1 = j%10
            d2 = j//10
            if d1 >= 2 and d2 >= 2 and d1*d2 == i:
                ans += 1
    print(ans)
    return

#B
def B():

    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    A()

Submission status: Accepted

Solution code:
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')

m,d = map(int,input().split())
res = 0
for i in range(1, m + 1):
    for j in range(1, d + 1):
        if len(str(j)) != 2:
            continue
        a = j // 10
        b = j % 10
        if a * b != i or a < 2 or b < 2:
            continue
        # print(a, b, i)
        res += 1
print(res)

Submission status: Accepted

Solution code:
m,d=map(int,input().split())

res=0
for x in range(1,m+1):
	for y in range(20,d+1):
		if y%10>=2 and (y%10)*(y//10)==x:
			res+=1
print(res)

Submission status: Accepted

Solution code:
M,D = map(int,input().split())

ans = 0
for m in range(1,M+1):
    for d in range(1,D+1):
        a,b = divmod(d,10)
        if a>=2 and b>=2 and m==a*b:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    
    m, d = map(int, input().split())
    
    ans = 0
    for i in range(1, m + 1):
        for j in range(1, d + 1):
            a = j % 10
            b = j // 10
            if a >= 2 and b >= 2 and a * b == i:
                ans += 1
    
    print(ans)
    
    return 0

main()

Submission status: Accepted

Solution code:
m, d = map(int, input().split())
ans = 0
for i in range(1, d+1):
    d1 = i%10
    d10 = i//10
    if d1 >= 2 and d10 >= 2 and d1*d10 <= m:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
m,d = map(int,input().split())
cnt = 0
for i in range(d):
  temp = str(i)
  if int(temp[0]) >= 2 and int(temp[1]) >= 2 and int(temp[1]) * int(temp[1]) =< m:
    cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
m,d = map(int,input().split())
cnt = 0
for i in range(d):
  temp = str(i)
  if int(temp[0]) >= 2 and int(temp[1]) >= 2 and int(temp[1]) * int(temp[1]) =< m:
    cnt += 1

Submission status: Runtime Error

Solution code:
#二部グラフにできるのか
#ここからよ
#実は奇サイクルを含まない=二部グラフとなる
#それぞれのレベルで奇サイクルかどうか
#二部グラフを考えて残りでもどんどん二部グラフを考えるイメージ

#最終的には1or2の状態で残る
N=int(input())
ans=[[0]*N for j in range(N)]
#nはvecの長さ
#次の通路のレベル
def dfs(n,vec,level):
    global ans
    #print(vec)
    #print(n)
    l=vec[:n//2]
    r=vec[n//2:]
    for i in l:
        for j in r:
            ans[i][j]=level
    if len(l)>1:
        dfs(len(l),l,level+1)
    if len(r)>1:
        dfs(len(r),r,level+1)


dfs(N,[i for i in range(N)],1)
for i in range(N-1):
    a=[]
    for j in range(N):
        if i<j:
            a.append(str(ans[i][j]))
    print(" ".join(a))

Submission status: Runtime Error

Solution code:
m,d= map(int, input().split())

ans=0
for mon in range(1,m+1):
	for day in range(1,d+1):
    	if day<22:
        	continue
        d1,d2=str(day)
  		if d1*d2==mon:
            ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, floor
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np

M, D = MAP()
ans = 0
for m in range(1, M+1):
	for d in range(1, D+1):
		if len(str(d)) == 2:
			d1 = int(str(d)[1])
			d10 = int(str(d)[0])
			if 2 <= d1 and 2 <= d10 and d1*d10 == m:
				ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, floor
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np

M, D = MAP()

ans = 0
for i in range(1, M+1):
	for j in range(1, D+1):
		if 2 <= j//10 and 2 <= j%10 and (j//10)*(j%10) == i:
			ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
m=int(input())
d=int(input())
ans=0
for i in range(1,m+1):
  for j in range(10,d+1):
    if i==(j//10)*(j%10) and j//10>1 and j%10>1:ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))

# 数列の自分より後方で自分より小さい数
c1 = sum([1 if a[i]>j else 0 for i in range(n) for j in a[i+1:]])

# 数列内で自分より小さい数
from collections import Counter
ca = Counter(a)

c2 = 0
for n1 in ca.keys():
    for n2,cnt2 in ca.items():
        if n2<n1:
            c2+=cnt2

MOD=10**9+7
k %= MOD
ans = (c1*k)%MOD + (c2*k*(k-1)//2)%MOD
ans %= MOD
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 11:25:07 2020

@author: NEC-PCuser
"""

N, K = map(int, input().split())

A = list(map(int, input().split()))

tentosu = 0

MOD = 1000000007

for i in range(0, N):
    a = 0
    d = 0
    """
    for j in range(0, N):
        if (i == j):
            continue
        if (i < j and A[i] > A[j]):
            a += 1
        if (A[i] > A[j]):
            d += 1
    """
    for j in range(0, N):
        if (A[i] > A[j]):
            d += 1
    for j in range(i, N):
        if (A[i] > A[j]):
            a += 1
    
    
    tentosu += a * K % MOD;
    tentosu %= MOD;
    tentosu += (K - 1) * K / 2 % MOD * d % MOD;
    tentosu %= MOD;
    
print(int(tentosu))

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
l = list(map(int,input().split()))
mod = 10**9+7
a = 0
for i in range(n):
  b = l[i]
  t = (len([1 for m in l if  m<b])%mod)*(int( (k-1)%mod*k//2)%mod)%mod
 # print(i,b,t)
  s = (len([1 for m in l[i:] if m<b])%mod)*k%mod
#  print(s)
  a += (s+t)%mod
print(a%mod)

Submission status: Runtime Error

Solution code:
m, d = input().split()
ans=0
for i in range(10):
    if int(m) >= int(d[0]) * int(d[1]):
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int m, d;
	cin >> m >> d;

	int cnt = 0;
	for(int mi=1;mi<=m;mi++) {
		for (int di = 1; di <= d; di++) {
			int d1 = di % 10;
			int d10 = di / 10;
			d10 %= 10;

			if (2 <= d1 && 2 <= d10 && d1*d10 == mi) cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
CNT=0
for i in range(2,N):
	if(N % i) == 0:
    	K = (N // i) * 10 + i
        if K <= M:
        	CNT+=1
print(CNT)

Submission status: Runtime Error

Solution code:
n,m=input().split()
ans=0
for i in range(4,int(n)+1):
  for j in range(2,int(m[0])):
    for k in range(10):
      if i==j*k:
        ans+=1
for i in range(4,int(n)+1):
  for j in range(2,int(m[1])+1):
      if i==j*int(m[0]):
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
A = [int(x) for x in input().split()]

nums = []
nums_2 = []
for i in range(N):
  num = int(A[i])
  s = 0
  k = 0
  for j in range(i+1,N):
    if A[j] < num:
      s += 1
  nums.append(s)
  for t in range(N):
    if A[t] < num:
      k += 1
  nums_2.append(k)

result = 0
for i in range(N):
  result += ((K*(K-1))/2)*(nums_2[i]) + K*nums[i]


print(int(result%(10e+8+7)))

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
A = [int(x) for x in input().split()]

nums = []
nums_2 = []
for i in range(N):
  num = int(A[i])
  s = 0
  k = 0
  for j in range(i,N):
    if A[j] < num:
      s += 1
  nums.append(s)
  for t in range(N):
    if A[t] < num:
      k += 1
  nums_2.append(k)

result = 0
for i in range(N):
  result += ((K*(K-1))/2)*(nums_2[i]) + K*nums[i]


print(int(result%(N,K = map(int,input().split())
A = [int(x) for x in input().split()]

nums = []
nums_2 = []
for i in range(N):
  num = int(A[i])
  s = 0
  k = 0
  for j in range(i,N):
    if A[j] < num:
      s += 1
  nums.append(s)
  for t in range(N):
    if A[t] < num:
      k += 1
  nums_2.append(k)

result = 0
for i in range(N):
  result += ((K*(K-1))/2)*(nums_2[i]) + K*nums[i]

print(int(result/(10**9+7)))

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
A = [int(x) for x in input().split()]

nums = []
nums_2 = []
for i in range(N):
  num = int(A[i])
  s = 0
  k = 0
  for j in range(i,N):
    if A[j] < num:
      s += 1
  nums.append(s)
  for t in range(N):
    if A[t] < num:
      k += 1
  nums_2.append(k)

result = 0
for i in range(N):
  result += ((K*(K-1))/2)*(nums_2[i]) + K*nums[i]


print(int(result%(10E9+7)))

Submission status: Runtime Error

Solution code:
import sys


def solve():
    M, D = input().split()
    ans = 0
    m, d_1, d_2 = int(M), int(D[0]), int(D[1])

    if int(M) < 4 or d_1 < 2 and d_2 < 2:
        print(0)
        sys.exit()

    for i in range(4, m+1):
        for j in range(2, d_1+1):
            for k in range(2, 10):
                if j == d_1 and k > d_2:
                    break
                if i == j * k:
                    ans += 1
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N,H,W = map(int,readline().split())
RCA = [tuple(int(x) for x in line.split()) for line in readlines()]

RCA.sort(key = lambda x: -x[2])

RCA

root = list(range(H+W))
size = [0] * (H+W)
no_cycle = [True] * (H+W)

def find_root(x):
    y = root[x]
    if x == y:
        return y
    z = find_root(y)
    root[x] = z
    return z

def merge(x,y):
    x,y = find_root(x),find_root(y)
    sx,sy = size[x],size[y]
    if sx < sy:
        sx,sy = sy,sx
        x,y = y,x
    root[y] = x
    no_cycle[x] = no_cycle[x] and no_cycle[y]

answer = 0
for R,C,A in RCA:
    x,y = R-1,H+C-1
    rx,ry = find_root(x),find_root(y)
    if rx == ry:
        if not no_cycle[rx]:
            continue
        no_cycle[rx] = False
    else:
        if (not no_cycle[rx]) and (not no_cycle[ry]):
            continue
        merge(rx,ry)
    answer += A

print(answer)

Submission status: Runtime Error

Solution code:
print "10"

Submission status: Runtime Error

Solution code:
m, d = map(int, input())
cnt = 0
for i in range(m):
  for j in range(d):
    d_1 = d % 10
    d_10 = d // 10
    if(d_1 * d_10 == m):
      cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
    M, D = map(int,input().split())
    if D<22:
      print(0)
    else:
      count = 0
      for i in range(22,D+1):
        d1 = D%10
        d2 = (D-d1)//10
        if d1*d2 <= M:
          count+=1
      print(count)

Submission status: Runtime Error

Solution code:
M, D = map(int,input())
if D<22:
  print(0)
else:
  count = 0
  for i in range(22,D+1):
    d1 = D%10
    d2 = (D-d1)//10
    if d1*d2 <= M:
      count+=1
  print(count)

Submission status: Runtime Error

Solution code:
m,d=input().strip().split(' ')
m,d=[int(m),int(d)]
c=0
for i in range(22,d+1):
  d1=str(d)
  if int(d1[1])>=2 and int(d1[1]*d1[0])<=m:
    c+=1
print (c)

Submission status: Runtime Error

Solution code:
m,d=input().strip().split(' ')
m,d=[int(m),int(d)]
c=0
for i in range(22,d+1):
  d1=str(d)
  if int(d1[1])>=2 and int(d1[1]*d1[0])<=m:
    c+=1
print c

Submission status: Runtime Error

Solution code:
import math

mod = 1000000007
N = int(input())
S = input()
cnt_L = 0
cnt = 1
newS = ''
if S.count('B') != N:
  cnt = 0
else:
  for i,s in enumerate(S):
    if i%2 == 0:
      s='W' if s=='B' else 'B'
    newS += s
    if s=='W':
      cnt_L += 1
    else:
      cnt = cnt * cnt_L
      cnt_L -= 1
print((cnt*math.factorial(N))%mod)

Submission status: Runtime Error

Solution code:
m,d = map(int(input().split()))
count = 0
for month in range(1,m+1):
  for day in range(1,d):
    if (day%10) >= 2 and (day//10) >= 2:
      if (day%10)*(day//10) == m:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
M,D = input().strip().split()
count = 0
for m in range(2,M+1):
    for d in range(22, D+1):
        if m = (d / 10) % 10 * (d % 10):
            count += 1
print(count)

Submission status: Runtime Error

Solution code:
M,D = input().strip().split()
count = 0
for m in range(2,M+1):
    for d in range(22, D+1):
      if m = (d / 10) % 10 * (d % 10):
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
M = input()
D = input()

M, D = int(M), int(D)

# print("M:", M, "D:", D)

count = 0
# days = []

for m in range(1, M+1):
    for d in range(1, D+1):
        # print("m: ", m, " d: ", d, " d10: ", d/10, " d1", d%10)
        d1 = d % 10
        d10 = d // 10
        if (d1 * d10) == m and d1 != 1 and d10 != 1:
            # days.append("{}月{}日".format(m, d))
            count += 1

# for day in days:
#     print(day)
print(count)

Submission status: Runtime Error

Solution code:
m, d = map(int, input().split())
if m < 4 or d < 22:
  print("0")
else:
  res=0
  for i in range(22, d+1):
    d1, d2 = int(d/10), d%10
    res += 1 if d1*d2<=m else 0
   print(res)

Submission status: Runtime Error

Solution code:
M,D = map(int,input().split())

if D < 22:
  print("0")
  exit()

count = 0
  
for m in range(1,M+1):
  for d in range(22,N+1):
    if int(str(d)[1]) < 2:
      continue
   	if int(str(d)[0]) * int(str(d)[1]) == m:
      count += 1
print(count)

Submission status: Runtime Error

Solution code:
N=int(input())
S=list(input())
mod=10**9+7

rl=["L"]
for i in range(1,2*N):
  if S[i]==S[i-1]:
    if rl[i-1]=="R":
      rl.append("L")
    elif rl[i-1]=="L":
      rl.append("R")
  elif S[i]!=S[i-1]:
    if rl[i-1]=="R":
      rl.append("R")
    elif rl[i-1]=="L":
      rl.append("L")

if rl.count("L")!=N or S[0]=="W" or S[2*N-1]=="W":
  print(0)
  exit()

ans=1
for i in range(2*N):
  if rl[i]=="R":
    if rl[:i].count("L")-rl[:i].count("R")<0:
      print(0)
      exit()
    else:
      ans*=(rl[:i].count("L")-rl[:i].count("R"))%mod

for i in range(1,N+1):
  ans=ans%mod*i

print(ans%mod)

Submission status: Runtime Error

Solution code:
m,d = map(int,input())
count = 0
for i in range(m) :
  for j in range(d) :
    if j <11 :
      continue
    str_j = str(j)
    temp = int(str_j[0]) * int(str_j[1])
    if temp == i :
      count+=1
print(count)

Submission status: Runtime Error

Solution code:
MOD = 10**9 + 7

N,K = map(int,input().split())
A = list(map(int,input().split()))
B = A*2
d = []

for i in range(N*2):
  num = B[i]
  target = B[i+1:]
  d.append(len([n for n in target if num > n]))
  
d_each = sum(d[:N]) - sum(d[N:])
first = sum(d[N:])
print(int( K/2*((2*first)+((K-1)*d_each)) )%MOD)

Submission status: Runtime Error

Solution code:
a, b = input().strip()
print(a,b)

Submission status: Runtime Error

Solution code:
count=0
while M in 100:
  for i in range(2, D):
    MD=(D//10)*(D%10)
    if M=MD:
      count+=1
print(count)

Submission status: Runtime Error

Solution code:
m,d=map(int,input().split())
count=0
while M in 100:
  for i in D:
    MD=(D//10)*(D%10)
    if M=MD:
      count+=1
print(count)

Submission status: Runtime Error

Solution code:
M,D=input(,)
count=0
while M in 100:
  for i in D:
    MD=(D//10)*(D%10)
    if M=MD:
      count+=1
print(count)

Submission status: Runtime Error

Solution code:
M,D=input(,)
count=0
while M in 100:
  for i in D:
    MD=(D//10)*(D%10)
    if M=MD:
      count+=1

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(input().split())

#for i in range(1,K+1):
#    B = B + A
#print(B)
# Tentousuu
cnt = 0
for i in range(0 , N*K):
    for j in range(i, N*K):
        if (A[(i%N)] > A[(j%N)]):
            cnt = cnt + 1
#print('t=' + str(cnt))
print(cnt%(10**9+7))

Submission status: Runtime Error

Solution code:
import math
n=int(input())*2
S=list(input())
# Lを1、Rを0としてDP
dp=[0]*(n)
dp[0]=1
if S[0]=='W' or S[-1]=='W':
	print(0)
	exit()
for i in range(1,n):
	# print(S,i)
	if S[i]==S[i-1]:
		dp[i]=0 if dp[i-1] else 1
	else:
		dp[i]=1 if dp[i-1] else 0

count=1
counter=[0]*2
for i in range(n):
	if dp[i]==0:
		count*=counter[1]-counter[0]
		count%=10**9+7
	counter[dp[i]]+=1
if counter[0]!=counter[1]:
	print(0)
	exit()

print(count*math.factorial(n//2))
# print(dp)

Submission status: Runtime Error

Solution code:
def calendar():
    m, d = map(int, input().split())
    res = []

    for month in range(1, m + 1):
        for day in range(2, 9):
            for x in range(2, 9):
                if x * day == month:
                    temp = str(day) + str(x)
                    temp = int(temp)
                    if temp <= d:
                        res.append(temp)
    return len(res)


print(calendar('15 40'))

Submission status: Runtime Error

Solution code:
def calendar(x):
    m, d = map(int, x.split())
    res = []
    for month in range(1, m + 1):
        for day in range(2, d + 1):
            for x in range(2, d + 1):
                if x * day == month:
                    temp = str(day) + str(x)
                    temp = int(temp)
                    if temp <= d:
                        res.append(temp)
    return len(res)


calendar()

Submission status: Runtime Error

Solution code:
def calendar():
    m, d = map(int, x.split())
    res = []
    for month in range(1, m + 1):
        for day in range(2, d + 1):
            for x in range(2, d + 1):
                if x * day == month:
                    temp = str(day) + str(x)
                    temp = int(temp)
                    if temp <= d:
                        res.append(temp)
    print(len(res))


calendar()

Submission status: Runtime Error

Solution code:
def calendar():
    m, d = map(int, x.split())
    print(m)
    res = []
    for month in range(1, m + 1):
        for day in range(2, d + 1):
            for x in range(2, d + 1):
                if x * day == month:
                    temp = str(day) + str(x)
                    temp = int(temp)
                    if temp <= d:
                        res.append(temp)
    print(len(res))


calendar()