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: 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, 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 res


calendar(15, 40)

Submission status: Runtime Error

Solution code:
m,d = int(input().split())
f = []
d1,d10,cout = 0,0,0
for i in range(m):
  for j in range(d):
    if d+1 >= 10:
      f = list(str(d+1))
      d10 = int(f[0])
      d1 = int(f[1])
    if d1*d10 == i+1:
      cout += 1
print(cout)

Submission status: Runtime Error

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

int main() {
  long long N, K;
  vector<int> A;
  cin >> N >> K;
  A.resize(N);
  for(int i = 0; i < N; i++) cin >> A[i];

  long long left = 0, right = 0;
  for(int i = 0; i < N; i++)
    for(int j = i+1; j < N; j++)
      if(A[i] > A[j]) left++;

  for(int i = N-1; i >= 0; i--)
    for(int j = i-1; j >= 0; j--)
      if(A[i] > A[j]) right++;

  const long long MOD = 1000000007;

  long long ans = 0;
  ans += K * (K+1) / 2 % MOD;
  ans = ans * left % MOD;

  long long rans = 0;
  rans += K * (K-1) / 2 % MOD;
  rans = rans * right % MOD;

  cout << ((ans+rans)%MOD);
}

Submission status: Runtime Error

Solution code:
M,D = input().split()
ans = 0
for i in range(1, M+1):
  for j in range(1, D+1):
    if j < 22:
      continue
    else:
      j = str(j)
      if M == int(j[0]) * int(j[1]):
        ans += 1
print(ans)

Submission status: Runtime Error

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

tentosu_f = 0
tentosu_l = 0

for i in range(len(A)):
    for j in range(i+1, len(A)):
        if A[i] > A[j]:
            tentosu_f += 1
          
for i in range(len(A)):
    for j in range(len(A)):
        if A[i] > A[j]:
            tentosu_l += 1
            
ans = int(tentosu_f * k) + int(k*(k-1) / 2 * tentosu_l)
print(ans%(10**9+7))

Submission status: Runtime Error

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

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

for i in range(1,M+1):
  for r in range(22,D+1):
    d_tens,d_ones = divmod(r,10)
    
    if d_ones == 0 or d_ones == 1:
      continue
    elif i == d_tens*d_ones:
      ans+=1
    else:
      continue
      
print(ans)

Submission status: Runtime Error

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

if D <10:
  print("0")
  sys.exit()

for i in range(1,M+1):
  for r in range(10,D+1):
    d_tens,d_ones = divmod(r,10)
    
    if d_ones == 0 or d_ones == 1:
      continue
    elif i == d_tens*d_ones:
      ans+=1
    else:
      continue
      
print(ans)

Submission status: Runtime Error

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

if D <10:
  print("0")
  break

for i in range(1,M+1):
  for r in range(10,D+1):
    d_tens,d_ones = divmod(r,10)
    
    if i == d_tens*d_ones:
      ans+=1
    else:
      continue
      
print(ans)

Submission status: Runtime Error

Solution code:
#include <iostream>
using namespace std;

int main(){
    int M, D;
    cin >> M >> D;
    int ans = 0;
    for(int m = 1;m<=M;m++){
        for(int d=1;d<=D;d++){
            if(d % 10 >= 2 && d/10 >= 2 && (d%10)*(d/10) == m){
                ans += 1;
            }
        }
    }
    cout << ans << endl;
}

Submission status: Runtime Error

Solution code:
m,d=map(int,input().sprit())
count=0
for i in range(m):
  for j in range(d):
    d1=int(j/10)
	d2=int(j-d1)
    if(i+1==d1*d2):
      count+=1
      continue
print(count)

Submission status: Runtime Error

Solution code:
m,d=map(int,input().split())
count=0
for i in range(m):
  for j in range(d):
    d1=int(j/10)
	d2=int(j-d1)
    if(i+1==d1*d2):
      count+=1
      continue
print(count)

Submission status: Runtime Error

Solution code:


n=int(input())
s=list(input())
#前処理
for i in range(0,2*n,2):
    if s[i]=='W':
        s[i]='B'
    else:
        s[i]='W'

#Lの数を数えてRとマッチング
countL=0
ans=1
for i in range(2*n):
    if s[i]=='W':
        countL+=1
    else:
        ans*=countL
        if countL==0:
            print(0)
            exit()
        countL-=1
# 答えはansの階乗
ans=ans%(10**9+7)
for i in range(1,n+1):
    ans*=i
    ans%(10**9+7)
print(ans)

Submission status: Runtime Error

Solution code:
N,K= list(map(int, input().split()))
A= list(map(int, input().split()))
AA=sorted(A)
num=0
before=0
for i in A:
    num+=AA.index(i)
num2=0
for i in range(N-1):
    for j in range(i+1,N):
        if A[i]>A[j]:
            num2+=1
hoge=(K-1)*K//2%1000000007
hoge=hoge*num%1000000007
hoge2=num2*K%1000000007
hoge=(hoge+hoge2)%1000000007
print(hoge)

Submission status: Runtime Error

Solution code:

M = 10**9+7
N = int(input())
S = list(input())
s = []

#0ならW、1ならB
s_append = s.append
for i in range(2*N):
    if S[i] == "B":
        s_append(1)
    else:
        s_append(0)

#端が0なら0を返す
if s[0] == 0 or s[2*N-1] == 0:
    print(0)
    exit()

ans = 0
lis = [0] #0なら左、1なら右
#全て0にする
lis_append = lis.append
for j in range(1,2*N):
    j1 = lis[j-1]
    if s[j-1] != s[j]:
        lis_append(j1)
    elif j1 == 0:
        lis_append(1)
    else:
        lis_append(0)

#左と右の数が違ったら0を返す
if lis.count(0) != lis.count(1):
    print(0)
    exit()

#"右"が選べる"左"の選択肢を掛けていく
cnt = 1
ans = 1
for k in range(1,2*N):
    if lis[k] == 0:
        cnt += 1
    else:
        ans *= cnt
        cnt -= 1

#N!をかける
for l in range(1,N+1):
    ans *= l
    ans %= M
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
S = input()
count = 0
ans = 1
m = 10**9 + 7
 
for i in range(N):
  if S[2*i] == "W":
    ans = (ans * ((2*i) - (count*2)))%m
    count += 1
  if S[2*i + 1] == "B":
    ans = (ans * ((2*i + 1) - (count*2)))%m
    count += 1
 
if count != N:
  print(0)
else:
  for o in range(1, N+1):
    ans *= o
    ans %= m
  print(ans % m)

Submission status: Runtime Error

Solution code:
N = int(input())
S = input()
count = 0
ans = 1
m = 10**9 + 7
 
for i in range(N):
  if S[2*i] == "W":
    ans = ans * ((2*i) - (count*2))%m
    count += 1
  if S[2*i + 1] == "B":
    ans = ans * ((2*i + 1) - (count*2))%m
    count += 1
 
if count != N:
  print(0)
else:
  for o in range(1, N+1):
    ans *= o
    ans %= m
  print(ans % m)

Submission status: Runtime Error

Solution code:
N = int(input())
S = input()
count = 0
ans = 1
m = 10**9 + 7
 
for i in range(N):
  if S[2*i] == "W":
    ans *= ((2*i) - (count*2))%m
    count += 1
  if S[2*i + 1] == "B":
    ans *= ((2*i + 1) - (count*2))%m
    count += 1
 
if count != N:
  print(0)
else:
  for o in range(1, N+1):
    ans *= o
    ans %= m
  print(ans % m)

Submission status: Runtime Error

Solution code:
N, K = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
numc = 0
numf = 0

for i in range(0, N):
    for j in range(0,i):
        if A[j] > A[i]:
            numc += 1
        if A[i] > A[j]:
            numf += 1
numbers = numc*K*(K+1) % (10**9+7)+ numf*K*(K-1) % (10**9+7)
 
ans = int(numbers/2 % (10**9 + 7))
print(ans)

Submission status: Runtime Error

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
S = list(input())

if S[0]!='B' or S[-1]!='B':
    print(0)
    exit()

mod = 10**9 + 7
cnt_l = 1
cnt_r = 0
pre_s = 'B'
pre_d = 1 #1がleft
ans = 1

for i in range(1,N*2):
    s = S[i]

    if pre_s==s:
        if pre_d==1:
            d = 0
            ans *= cnt_l - cnt_r #ここまでに出てきたLeftの総数 - ここまでに出てきたrightの総数
            cnt_r += 1
        else:
            d = 1
            cnt_l += 1
    else:
        if pre_d==1:
            d = 1
            cnt_l += 1
        else:
            d = 0
            ans *= cnt_l - cnt_r #ここまでに出てきたLeftの総数 - ここまでに出てきたrightの総数
            cnt_r += 1
    pre_s = s
    pre_d = d

for i in range(1,N+1):
    ans *= i
    ans %= mod
if cnt_l!=N:
    print(0)
    exit()

print(ans)

Submission status: Runtime Error

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
S = list(input())

if S[0]!='B' or S[-1]!='B':
    print(0)
    exit()

mod = 10**9 + 7
cnt_l = 1
cnt_r = 0
pre_s = 'B'
pre_d = 1 #1がleft
ans = 1

for i in range(1,N*2):
    s = S[i]

    if pre_s==s:
        if pre_d==1:
            d = 0
            ans *= cnt_l - cnt_r #ここまでに出てきたLeftの総数 - ここまでに出てきたrightの総数
            cnt_r += 1
        else:
            d = 1
            cnt_l += 1
    else:
        if pre_d==1:
            d = 1
            cnt_l += 1
        else:
            d = 0
            ans *= cnt_l - cnt_r #ここまでに出てきたLeftの総数 - ここまでに出てきたrightの総数
            cnt_r += 1
    pre_s = s
    pre_d = d

for i in range(1,N+1):
    ans *= i
    ans %= mod
if cnt_l!=N:
    print(0)
    exit()

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
time_ans = 0
A_sort = sorted(A)
before = -1
b = -1
for i in range(N):
        a_sorti = A_sort[i]
        if a_sorti == before:
                time_ans += b
                continue
        b = A_sort.index(a_sorti)
        time_ans += b
        before = a_sorti

for i in range(N):
        for j in range(i + 1,N):
                if A[i] > A[j]:
                        ans += 1
ans1 = int((time_ans * K * (K - 1)) / 2) - K * (time_ans - ans)
print(ans1 % (10 ** 9 + 7))

Submission status: Runtime Error

Solution code:
import math
import sys
from copy import copy
import numpy as np
from collections import defaultdict, deque, Counter 
from itertools import accumulate, product, permutations,combinations, combinations_with_replacement
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd

max_value = 1000000000
min_value = -1000000000
sys.setrecursionlimit(max_value)

n = int(input())
s = list(input())

count = 0


if s[0] == 'W' or s[-1] == 'W':
    print(0)
    sys.exit()

LR_list = ['' for i in range(2*n)]
LR_list[0] = 'L'

for i in range(1,len(LR_list)):
    if s[i] == s[i-1]:
        if LR_list[i-1] == 'R':
            LR_list[i] = 'L'
        else:
            LR_list[i] = 'R'
    else:
        if LR_list[i-1] == 'R':
            LR_list[i] = 'R'
        else:
            LR_list[i] = 'L'

values = []

if LR_list.count('L') != LR_list.count('R'):
    print(0)
    sys.exit()
for i in range(len(LR_list)):
    if LR_list[i] == 'R':
        li = LR_list[:i].count('L')
        ri = LR_list[:i].count('R')
        values.append(li-ri)
print(np.array(values).prod()*math.factorial(n))

Submission status: Runtime Error

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

D = int(D)
ans = 0

for i in range(1,M+1):
    for j in range(1,D+1):
        if len(j) == 2:
            j1 = j // 10
            j2 = j % 10
            if j1 >= 2 and j2 >= 2 and j1 * j2 == i:
                ans += 1


print(ans)

Submission status: Runtime Error

Solution code:
seki = 0
for m in range(1, M + 1):
    for d in range(1, D + 1):
        d10, d1 = divmod(d, 10)
        if d10 >= 2 and d1 >= 2 and d10 * d1 == m:
            seki += 1
print(seki)

Submission status: Runtime Error

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


li = []

for i in range(n):
    count=0
    for j in range(n):
        if List[i]>List[j]:
            count += 1
    li.append(count)

count2=0

for i in range(1,n):
    for j in range(i+1,n+1):
        if int(List[i-1]) > int(List[j-1]):
            count2 += 1

counted = k*count2 + sum(li)*k*(k-1)/2

ans = counted % 1000000007
print(int(ans))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

count=0
for i in range(4, M+1):
    for j in range(22, D+1):
        str_j = str(j)
        if str_j[0] <= 1:
            continue
        if (int(str_j[0]) * int(str_j[1])) == i:
            count += 1
print(count)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
N, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
T_A = 0
T_A_all = 0
for i,a in enumerate(A):
    T_A += len([1 for x in A[i+1:] if a > x])
    T_A_all += len([1 for x in A if a > x])
T_B = 0
for i in range(N):
    for j in range(i + 1, N):
        if A[i] > A[j]:
            T_B += 1
T_B_all = 0
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            T_B_all += 1
print(T_A,T_B)
print(T_A_all,T_B_all)

a = T_A
z = T_A + T_A_all * (K -1)
print(int((K*(a+z)//2)%((10**9)+7)))

Submission status: Runtime Error

Solution code:
_, K = map(int, input().split())
a = list(map(int, input().split()))
s = [sum([b > c for c in a]) for b in a]
r = [sum([b > c for c in a[i:]]) for i, b in enumerate(a)]
b = (sum(r) + sum(s)*(K-1)/2)*K + sum(r)
print(int(b%(1e9+7)))

Submission status: Runtime Error

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

count = 0
for i in range(n):
    for j in range(n-i-1):
        jj = j+1+i
        if la[i] > la[jj]:
            count += 1

count2 = 0
laa = sorted(la)
for i in range(n):
    for j in range(n-i-1):
        jj = j+1+i
      
        if laa[i] < laa[jj]:
            count2 += 1

a = count * k
b = count2 * ((1/2)*(k-1)*k)
result = int(a)+int(b)

print(result%(pow(10,9)+7))

Submission status: Runtime Error

Solution code:
m,d=map(int,input().split())
count=0
for i in range(1,m+1):
	for j in range(1,d+1):
		if d>=10:
			d1=int(str(d)[-1])
    		d2=int(str(d)[0])
    		if d1>=2 and d2>=2 and d1*d2==m:
      			count+=1
print(count)

Submission status: Runtime Error

Solution code:
m,d=map(int,input().split())
count=0
for i in range(1,m+1):
  for j in range(1,d+1):
    d1=int(str(d)[-1])
    d2>=2
    if d>=10 and d1>=2 and d2>=2 and d1*d2==m:
      count+=1
print(count)

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
lis_a = list(map(int, input().split()))
mod = 1000000007
ans = 0
temp = 0
for i in range(len(lis_a)-1):
    for j in range(len(lis_a)):
        if(lis_a[i] > lis_a[j]):
            temp += 1
ans = (k*(temp+temp*k)//2) % mod
    
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
M,D = map(int,input().split())
a = 0
for i in np.arange(1,D+1):
	d10 = int(i/10)
	d01 = i-d10*10
    if 0 < d10*d01 and d10*d01 <= M:
    	a += 1
print(a)

Submission status: Runtime Error

Solution code:
M, D = map(int, input().split())
m_list = {m for m in range(1, M + 1)}
ans = 0

for d in range(11, D+1):
  d_10 = int(d/10)
  d_1 = d - (d_10 * 10)
  if (d_10 < 2) or (d_1 < 2):
    continue
  elif:
    if (d_10 * d_1) in m_list:
      ans += 1
      
print(ans)

Submission status: Runtime Error

Solution code:
N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
mod = 10**9+7
B = A*2
c = 0
for i in range(len(B)):
  t = B[i]
  for j in range(1,len(B[i:])):
    if t > B[i+j]:
      c += 1
      #print(t,B[i+j])
#print(c)
s = sum(range(K))
print((c%mod*s%mod)%mod)

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
li = list(map(int,input().split()))
mod = 10**9 +7
 
ans_1 = 0
ans_2 = 0
for i in range(n):
  for j in range(i+1,n):
    if li[i] > li[j]:
      ans_1+= 1
for i in range(n):
  for j in range(n):
    if li[i] > li[j]:
      ans_2 += 1
ans = k*ans_1%mod + 0.5*k%mod*(k-1)%mod*ans_2%mod
print(int(ans%mod))

Submission status: Runtime Error

Solution code:
from numpy import array
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
div = 1000000007
na = array(A)
s = 0
s2 = 0
for i, n in enumerate(na[:-1]):
    tmp = na < n
    s += sum(tmp[i+1:])
    s2 += sum(tmp)
 
s = int(s)
s2 = int(s2)
print(int((s * K + s2 * (K-1) * K // 2 ) % div))

Submission status: Runtime Error

Solution code:
M,D = map(int,input().split())
​
count = 0
if M < 4 or D < 22:
    print(count)
else :
    for m in range(4,M+1):
        for da in range(2,10):
            if da > m:
                break
            db = int(m/da)
#             if m == M and da == int(D/10) and db > D%10:
#                 break
#             if db < 2:
#                 continue
            if da*10+db <= D and da*db == m:
                count += 1
​
print(count)

Submission status: Runtime Error

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


li = []

for i in range(n):
    count=0
    for j in range(n):
        if List[i]>List[j]:
            count += 1
    li.append(count)
print(str(sum(li))+"li")


count2=0

for i in range(1,n):
    for j in range(i+1,n+1):
        #print(i,j)
        if int(List[i-1]) > int(List[j-1]):
            count2 += 1
    #print(str(count2)+"count2")


for m in range(k-1,0,-1):
    counted=count2+count2*(m-1)




ans = counted % 1000000007
print(ans)

Submission status: Runtime Error

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


li = []

for i in range(n):
    count=0
    for j in range(n):
        if List[i]>List[j]:
            count += 1
    li.append(count)
print(str(sum(li))+"li")


count2=0

for i in range(1,n):
    for j in range(i+1,n+1):
        #print(i,j)
        if int(List[i-1]) > int(List[j-1]):
            count2 += 1
    #print(str(count2)+"count2")


for m in range(k,0,-1):
    counted=count2+count2*(m-1)




ans = counted % 1000000007
print(ans)

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split(" "))
A=list(map(int,input().split(" ")))
#N=3
#K=3
#A=[1,3,2]
A1=[set() for _ in range(N)]
cnt=0
cnt1=0
for n1 in range(N):
    for n2 in range(N):
        if n1!=n2 and A[n1]>A[n2]:
            cnt+=1
        if n1<n2 and A[n1]>A[n2]:
            cnt1+=1

#ten=int(cnt1+cnt*(K**2-K)/2+cnt1*(K-1))
k2=(K**2)%(10**9+7)
ten1=int((k2*cnt)%(10**9+7))
ten2=int((K*cnt)%(10**9+7))
ten3=int((cnt1*K)%(10**9+7))
if ten1-ten2<0:
    ten=((ten1-ten2+10**9+7)/2)%(10**9+7)
else:
    ten=((ten1-ten2))/2%(10**9+7)
ten=ten+ten3
print(int(ten%(10**9+7)))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import *
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    m, d = LI()
    ans = 0
    for i in range(1, m + 1):
        for j in range(10, d + 1):
            if int(str(j)[0]) < 2 or int(str(j)[1]) < 2:
                continue
            if i == int(str(j)[0]) * int(str(j)[1]):
                ans += 1
    print(ans)
    return

#B
def B():
    n, l = LI()
    a = LI()
    d0 = defaultdict(int)
    d1 = defaultdict(int)
    for i in a:
        d0[i] += 1
    for i in range(n):
        b = 0
        for k in range(i+1, n):
            if a[i] > a[k]:
                b += 1
        d1[i] = b
    ans = 0
    d2 = list(d0.items())
    d2.sort()
    d3 = defaultdict(int)
    d = 0
    for key, value in d2:
        d3[key] = d
        d += value
    print(d3,d1)
    for i in range(n):
        ans += d3[a[i]] * l * (l-1) // 2 + d1[i] * l
        ans %= mod
    print(ans % mod)
    return

#C
def C():
    n = II()
    s = itertools.product([1, 0], repeat=2 * n)
    a = list(itertools.combinations(range(2*n), 2))
    d = defaultdict(int)
    def dfs(a):
        if len(a) == n:
            lis.append(a)
            return True
        for i in range(n):
            if d[i] == 0:
                d[i] = 1
                for k in range(n):
                    if d[k] == 0:
                        d[k] = 1
                        a.append((i, k))
                        dfs(a)
                        a.remove((i, k))
    lis = []
    dfs([])
    for si in s:
        for di in lis:
            b = list(si[::1])
            for x, y in di:
                for i in range(x, y + 1):
                    b[i] ^= 1
            if sum(b) < 1:
                print(si, di)
                break

    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()

Submission status: Runtime Error

Solution code:
input()
sys.stdin.readline()
import sys 
open(0)
int()
.split()（+ map()）
S = input().split() 
print(s)

Submission status: Runtime Error

Solution code:
M,D = map(int, input().split())
if M < 4 or D < 22:
    print(0)
else:
    result=0
    for m in range(4,M+1):
        for d in range(22,D+1):
            if str(d)[0] >= 2 and str(d)[1] >= 2 and int(str(d)[0])*int(str(d)[1])==m:
                result += 1
    print(result)

Submission status: Runtime Error

Solution code:

from decimal import *
getcontext().prec = 28
n, k = map(int,input().split())
a = list(map(int,input().split()))
inner = Decimal(0)
outer = Decimal(0)
for i in range(0,n):
    for j in range(0,n):
        if a[i] > a[j]:
            outer += 1
            if i < j:
                inner += 1

b = (Decimal(Decimal(inner) * Decimal(k)) + Decimal(Decimal(outer) * Decimal(Decimal(k) * Decimal(k-1)) / 2))
print(Decimal(Decimal(b)%Decimal(1000000007)))

Submission status: Runtime Error

Solution code:
M = int(input())
D = int(input())
D_array = list(map(int, str(D)))

ans = 0
for i in range(2,M+1):
  for d10 in range(2,int(D_array[0])+1):
    for d1 in range(2,10):
      if int(str(d10)+str(d1)) <= D:
        if int(d1)*int(d10) == i:
          ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
M = int(imput())
D = int(imput())
D_array = list(map(int, str(D)))

ans = 0
for i in range(2,M+1):
  for d10 in range(2,int(D_array[0])+1):
    for d1 in range(2,10):
      if int(str(d10)+str(d1)) <= D:
        if int(d1)*int(d10) == i:
          ans += 1
print(ans)

Submission status: Runtime Error

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

count_base =0
for i in range(N*K):
    for j in range(i, N*K):
        if As[i] > As[j]:
            count_base += 1
print(int(count_base % (pow(10, 9) + 7)))

Submission status: Runtime Error

Solution code:
import sys
n, k = map(int,input().split())
a = list(map(int,input().split()))
inner = float(0)
outer = float(0)
for i in range(0,n):
    for j in range(0,n):
        if a[i] > a[j]:
            outer += 1
            if i < j:
                inner += 1

b = (int(inner * int(k)) + int(outer * int(k) * int(k-1) / 2))
print(int(b%int(1000000007)))

Submission status: Runtime Error

Solution code:
n,k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
count = [0]*2000
A = (10**9)+7
c_in = 0
for i in range(n):
  for j, t in enumerate(a[:i]):
    c_in += int(t > a[i])
  count[a[i]-1] += 1
c_out = 0
for i in range(n):
  c_out += sum(count[:a[i]-1])
N = (c_in*k)%A + (k*(k-1)//2)*c_out%A
print(N)

Submission status: Runtime Error

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

N = A[0]
K = A[1]
count = 0
 
list = []
 
for i in range(N):
  for j in range(i,N):
    if B[i] > B[j]:
      count+=1


for sabun in range(1,K):
    count = count*sabun + count
    
count = count%(10**9 + 7)
print(count)

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
li = list(map(int,input().split()))
mod = 10**9 +7

ans_1 = 0
ans_2 = 0
for i in range(n-1):
  for j in range(i+1,n):
    if li[i] > li[j]:
      ans_1+= 1
for i in range(n):
  for j in range(n):
    if li[i] < li[j]:
      ans_2 += 1
ans = k*ans_1 + 0.5*k*(k-1)%mod*ans_2
print(ans_1)
print(ans_2)
print(ans%mod)

Submission status: Runtime Error

Solution code:
def count_inversion(sequence):
    return sum(sum(m<n for m in sequence[i+1:]) for i,n in enumerate(sequence))
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k-1):
    a+=a

 
 
print(count_inversion(a)%100000007)

Submission status: Runtime Error

Solution code:
m,d=map(int,input().split())
if 22>d:
    print(0)
else:
    a=22
    ans=0
    while d>=a:
        b=str(a)
        if 2>int(b[0]) or 2>int(b[1]):
            a+=1
        else:
            if m >= int(b[0])*int(b[1]):
                ans+=1
                a+=1
            else:
                a+=1
print(ans)

Submission status: Runtime Error

Solution code:
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
N = A[0]
K = A[1]
count = 0
 
list = []

for i in range(N):
  for j in range(i,N):
    if B[i] > B[j]:
      count+=1

count = count*K
  
count = count%(10**9 + 7)
print(count)

Submission status: Runtime Error

Solution code:
while True:
    try:
        M, D = map(int, input().split())
        result = 0
        if D >= 22:
            for i in range(22, D+1):
                i = str(i)
                mm = MAPS[i] if i in MAPS else None
                if mm is not None and mm <= M:
                    result += 1
        print(result)

    except EOFError:
        break

Submission status: Runtime Error

Solution code:
M,D=(int(x) for x in input())
ans=0
for i in range(4,M+1):
    for j in range(22,D+1):
        if j[-1]*j[-2]==i:
            ans+=1
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

b = []

for i in range(nk[1]):
    b += a

def bubble_sort(A):
    cnt = 0
    for j in range(len(A)):
        for l in range(len(A)-1, j, -1):
            if A[l] < A[l-1]:
                A[l], A[l-1] = A[l-1], A[l]

                cnt += 1
    return int(cnt)

ans = bubble_sort(b) % 1000000007
print(ans)

Submission status: Runtime Error

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

b = []

for i in range(nk[1]):
    b += a

def bubble_sort(A):
    cnt = 0
    for j in range(len(A)):
        for l in range(len(A)-1, j, -1):
            if A[l] < A[l-1]:
                A[l], A[l-1] = A[l-1], A[l]

                cnt += 1
    return int(cnt)

ans = bubble_sort(b)
ans = ans % 1000000007
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
M,D=map(int,input().split())
ans=0
for i in range(4,M+1):
  for j in range(22,D+1):
    if j[-1]*j[-2]==i:
      ans+=1
print(ans)

Submission status: Runtime Error

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

count = 0
for i in range(2,int(D)+1):
    if len(str(i)) == 2:
        x = str(i)
        y = x[0:1]
        z = x[1:2]
        for j in range(2,int(M) + 1):
            if int(y) * int(z) == j and int(z) != 1 and int(y) != 1:
                count += 1
print(count)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env pypy3


M = 10 ** 9 + 7


def naive_inv_num(xs):
    n = len(xs)
    res = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            if xs[i] > xs[j]:
                res += 1
    return res


def rep_inv_num(k, xs, mod=M):
    c1 = naive_inv_num(xs)
    c2 = naive_inv_num(xs * 2)
    c3 = naive_inv_num(xs * 3)
    d1 = c2 - c1
    f = c3 - 2 * c2 + c1
    res = c1
    res += (k - 1) * d1
    res %= mod
    res += f * (k - 1) * k // 2
    res %= mod
    res -= f * (k - 1)
    res %= mod
    return res


def main():
    _, k = (int(z) for z in input().split())
    xs = [int(x) for x in input().split()]
    res = rep_inv_num(k, xs)
    print(res)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

count = 0
for i in range(2,int(D)+1):
    if len(str(i)) == 2:
        x = str(i)
        y = x[0:1]
        z = x[1:2]
        for j in range(2,int(M) + 1):
            if (int(y) * int(z) == j) and (int(z) != 1) and (int(y) != 1):
                count += 1
print(count)

Submission status: Runtime Error

Solution code:
M = int(input('Please enter the number of month: '))
D = int(input('Please enter the number of days in a month: ))

count = 0
for m in range(1,M+1):
    for d in range(1,D+1):
        d1 = d % 10
        d10 = d // 10
        if d1 * d10 == m:
            count += 1
print(count)

Submission status: Runtime Error

Solution code:
M = input()#5
D = input()#30


caM = []
for i in range(1,int(M)+1):
    caM.append(i)
count = 0
for i in range(2,int(D)+1):
    if len(str(i)) == 2:
        x = str(i)
        y = x[0:1]
        z = x[1:2]
        for j in range(2,int(M) + 1):
            if (int(y) * int(z) == j) and (int(z) != 1) and (int(y) != 1):
                count += 1
print(count)

Submission status: Runtime Error

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

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

c=0
for m in range(1,M+1):
    for d in range(1,D+1):
        if d>=10:
            t=str(d)
            if int(t[0])>1 and int(t[1])>1 and int(t[0])*int(t[1]) == m:
                c+=1

print(c)

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

Submission status: Runtime Error

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

if M < 4 or D < 22:
  print(0)
else :
  count = 0
  for m in range(4,M):
    for d in range(22,D):
      d1 = d%10
      d10 = int(d/10)
      if d10*d1 == m:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
M,D=(int(input()) for _ in range(2))
# print(M,D)

count = 0
for ii in range(1,M+1):
    
    for i in range (22, D + 1):
        #print(i)
        d1 = i % 10
        d2 = i // 10
        
        if d1 < 2 or d2 < 2:
            continue
        
        if ii == d1 * d2:
            count = count + 1
        
        

print(count)