Problem:


				Max Score: $250$ Points 

Problem Statement

					Snuke has a very long calendar. It has a grid with $n$ rows and $7$ columns. One day, he noticed that calendar has a following regularity. 

The cell at the $i$-th row and $j$-th column contains the integer $7i+j-7$.

					A good sub-grid is a $3 \times 3$ sub-grid and the sum of integers in this sub-grid mod $11$ is $k$. 

					How many good sub-grid are there? Write a program and help him. 

Input

						The input is given from standard input in the following format. 

$n \quad k$

Output

Print the number of good sub-grid. If there are no solution exists, print 0.

Constraints

$1 \le n \le 10^9$

$0 \le k \le 10$

Subtasks

Subtask 1 [ $150$ points ]

The testcase in the subtask satisfies $1 \le n \le 100$.

Subtask 2 [ $100$ points ]

There are no additional constraints.

Sample Input 1

7 7

Sample Output 1

2

					In this case, the calendar likes this matrix.

Sun.
Mon.
Tue.
Wed.
Thu.
Fri.
Sat.

Week 1
1
2
3
4
5
6
7

Week 2
8
9
10
11
12
13
14

Week 3
15
16
17
18
19
20
21

Week 4
22
23
24
25
26
27
28

Week 5
29
30
31
32
33
34
35

Week 6
36
37
38
39
40
41
42

Week 7
43
44
45
46
47
48
49

					The cell at $i$-th row and $j$-th column is denoted $(i, j)$. 

If upper-left is $(1, 5)$, the sum of integers is $5+6+7+12+13+14+19+20+21=117$.

If upper-left is $(3, 2)$, the sum of integers is $16+17+18+23+24+25+30+31+32=216$.

					Therefore, there are 2 good sub-grids.

Sample Input 2

6 0

Sample Output 2

2

					If upper-left is $(1, 3)$ or $(4, 4)$, it is a good sub-grid.

Sample Input 3

18 10



Sample input:
7 7


Sample output:
2

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
cnt = [(n - 2) // 11 for _ in range(11)]
for i in range(1, (n - 2) % 11 + 1):
  cnt[i] += 1
ans = 0
for i in range(11):
  j = ((5 * k - 1 - 7 * i) % 11 + 11) % 11
  ans += cnt[i] * cnt[j]
print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
cnt = [(n - 2) // 11 for _ in range(11)]
for i in range(1, (n - 2) % 11):
  cnt[i] += 1
ans = 0
for i in range(11):
  j = ((5 * k - 1 - 7 * i) % 11 + 11) % 11
  ans += cnt[i] * cnt[j]
print(ans)

Submission status: Wrong Answer

Solution code:
n, k = [ int(v) for v in input().split() ]
mod_list = [6,4,2,0,9,7,5,3,1,10,8]
g = mod_list.index(k)
corumn_list = [ None for i in range(5) ]

for i in range(11):
    for j in range(1,6):
        if (7*i+j) % 11 == g and corumn_list[j-1] is None:
            corumn_list[j-1] = i

m = (n-2)%11
ans = (5*((n-2)//11)+sum([m >= i  for i in corumn_list]))
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split())

    part1(n, k)


def part1(n, k):
    ans = 0

    for i in range(1, n-3+2):
        for j in range(1, n-3+2):
            s = 0
            for x in range(3):
                for y in range(3):
                    s += 7*(i+x) + (j+y) - 7
            # print(i, j, s, sep="\t")
            if s % 11 == k:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split())

    part1(n, k)


def part1(n, k):
    ans = 0

    for i in range(1, n-3+2):
        for j in range(1, n-3+2):
            s = 0
            for x in range(3):
                for y in range(3):
                    s += 7*(i+x) + (j+y) - 7
            print(i, j, s, sep="\t")
            if s % 11 == k:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
if N < 3:
    print(0)
    exit()

mem = [0] * 11
for i in range(11):
    for j in range(2,7):
        n = i*7 + j
        if (9*n)%11 == K: mem[i] += 1

ans = sum(mem) * (N//11)
ans -= mem[0]
if N%11 == 0:
    ans -= mem[-1]
else:
    ans += sum(mem[:N%11])
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
count=0

if n > 15:
    count+=5*n//11
    n = n%11

for i in range(n-2):
    for i2 in range(5):
        if ((9*(i*7+i2+1)+6)%11) == k:
            count+=1
print(count)

Submission status: Wrong Answer

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

loop_no=n//11
remain=n%11
ans=loop_no*5
if remain<=2:
    print(ans)
    exit()
   
else:
    for i in range(1,remain-1):
        for j in range(1,6):
            q=63*i+9*j+9
            if q%11==k:
                ans += 1

print(ans)

Submission status: Wrong Answer

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

loop_no=n//11
remain=n%11
ans=loop_no*5
if remain==0:
    print(ans)
    exit()
elif remain==1:
    for j in range(1,6):
        q=63*1+9*j+9
        if q%11==k:
            ans += 1    
else:
    for i in range(1,remain-1):
        for j in range(1,6):
            q=63*i+9*j+9
            if q%11==k:
                ans += 1

print(ans)

Submission status: Wrong Answer

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

loop_no=n//11
remain=n%11
ans=loop_no*5
for i in range(1,remain-1):
    for j in range(1,6):
        q=63*i+9*j+9
        if q%11==k:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
c = 0
s = 4
for i in range(n-2):
    for j in range(5):
        if (s % 11 == k):
            c += 1
        s -= 2
        if s < 0:
            s = 11 - s
    s -= 3
    if s < 0:
        s = 11 - s
print(c)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
c = 0
s = 4
for i in range(n-2):
    for j in range(5):
        if (s % 11 == k):
            c += 1
        s -= 2
    s -= 3
print(c)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split());n-=2;h=[sum(k==(i*63+i*9+81)%11for j in range(5))for i in range(min(n,11))];print(sum(h[:n%11]+h*(n//11)))

Submission status: Wrong Answer

Solution code:
n,k=map(int,raw_input().split())
ans=5*(n/11)
inv=(5*k)%11
for i in range(1,max(8,(n%11-1)*7+1)):
    if i%7 not in (1,0) and i%11==inv:ans+=1
for i in range(1,8):
    if i%7 not in (1,0) and i%11==inv:ans-=1
print ans

Submission status: Wrong Answer

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

n, k = map(int, input().split())
M = [[7*i+j-7 for j in range(1, 7+1)] for i in range(1, min(n+1, 14))]
cnt = 0
f = lambda i, j : sum(M[i+y][j+x] for y in range(3) for x in range(3)) % 11 == k
h = [0] * 11
for i in range(min(max(0, n-2), 11)):
    for j in range(7-2):
        if f(i, j) :
            h[i] += 1
cnt = sum(h) * (n // 11)
for i in range(max(0, n % 11 - 2)):
    cnt += h[i]
print(cnt - (0 if n % 11 else 1))

Submission status: Wrong Answer

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

n, k = map(int, input().split())
M = [[(7*i+j-7) for j in range(1, 7+1)] for i in range(1, min(n+1, 14))]
cnt = 0
f = lambda i, j : sum(M[i+y][j+x] for y in range(3) for x in range(3)) % 11 == k
h = [0] * 11
for i in range(max(0, min(n-2, 11))):
    for j in range(7-2):
        if f(i, j) :
            h[i] += 1
cnt = sum(h) * (n // 11)
for i in range(max(0, n % 11 - 2)):
    cnt += h[i]
print(cnt)

Submission status: Wrong Answer

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

n, k = map(int, input().split())
M = [[(7*i+j-7) for j in range(1, 7+1)] for i in range(1, min(n+1, 14))]
cnt = 0
f = lambda i, j : sum(M[i+y][j+x] for y in range(3) for x in range(3)) % 11 == k
h = [0] * 11
for i in range(max(0, min(n-2, 11))):
    for j in range(7-2):
        if f(i, j) :
            h[i] += 1
cnt = sum(h) * (n // 11)
for i in range(min(0, n % 11 - 2)):
    cnt += h[i]
print(cnt)

Submission status: Wrong Answer

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

n, k = map(int, input().split())
M = [[(7*i+j-7) for j in range(1, 7+1)] for i in range(1, min(n+1, 14))]
cnt = 0
f = lambda i, j : sum(M[i+y][j+x] for y in range(3) for x in range(3)) % 11 == k
h = [0] * 11
for i in range(max(0, min(n-2, 11))):
    for j in range(7-2):
        if f(i, j) :
            h[i] += 1
cnt = sum(h) * (n // 11)
for i in range(n % 11 - 2):
    cnt += h[i]
print(cnt)

Submission status: Wrong Answer

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

n, k = map(int, input().split())
M = [[(7*i+j-7) for j in range(1, 7+1)] for i in range(1, min(n+1, 14))]
cnt = 0
f = lambda i, j : sum(M[i+y][j+x] for y in range(3) for x in range(3)) % 11 == k
h = [0] * 11
for i in range(min(n-2, 11)):
    for j in range(7-2):
        if f(i, j) :
            h[i] += 1
cnt = sum(h) * (n // 11)
for i in range(n % 11 - 2):
    cnt += h[i]
print(cnt)

Submission status: Wrong Answer

Solution code:
#
# 1 <= i < i+2 <= n
# 1 <= j < j+2 <= 7
#
#  7*(i+0)+(j+0)-7, 7*(i+0)+(j+1)-7, 7*(i+0)+(j+2)-7
#  7*(i+1)+(j+0)-7, 7*(i+1)+(j+1)-7, 7*(i+1)+(j+2)-7
#  7*(i+2)+(j+0)-7, 7*(i+2)+(j+1)-7, 7*(i+2)+(j+2)-7
#
# sum(j,i) = 9*(7*i+j+1)
#
# sum(j,i)%11 = k
#
# sum(1,i) = 9*(7*i+1+1) = 9*(7*i+2) = 63*i+18
# sum(2,i) = 9*(7*i+2+1) = 9*(7*i+3) = 63*i+27
# sum(3,i) = 9*(7*i+3+1) = 9*(7*i+4) = 63*i+36
# sum(4,i) = 9*(7*i+4+1) = 9*(7*i+5) = 63*i+45
# sum(5,i) = 9*(7*i+5+1) = 9*(7*i+6) = 63*i+54
#
# sum(1,i)%11 = (63*i+18)%11 = (8*(i%11)+7)%11
# sum(2,i)%11 = (63*i+27)%11 = (8*(i%11)+5)%11
# sum(3,i)%11 = (63*i+36)%11 = (8*(i%11)+3)%11
# sum(4,i)%11 = (63*i+45)%11 = (8*(i%11)+1)%11
# sum(5,i)%11 = (63*i+54)%11 = (8*(i%11)+10)%11
#

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

tmp = [0] * 13

for i in range(1, 13):
    for j in range(1, 6):
        sum9 = 9 * (7 * i + j + 1)
        if sum9 % 11 == k:
            tmp[i % 11] += 1

ans = 0
for i in range(1, n + 1):
    ans += tmp[i % 11]
    
print(ans)

Submission status: Wrong Answer

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

n, k = map(int, input().split())
M = [[(7*i+j-7) for j in range(1, 7+1)] for i in range(1, 14)]
cnt = 0
f = lambda i, j : sum(M[i+y][j+x] for y in range(3) for x in range(3)) % 11 == k
h = [0] * 11
for i in range(min(n-2, 11)):
    for j in range(7-2):
        if f(i, j) :
            h[i] += 1
cnt = sum(h) * (n // 11)
for i in range(n % 11 - 2):
    cnt += h[i]
print(cnt)

Submission status: Wrong Answer

Solution code:
#
# 1 <= i < i+2 <= n
# 1 <= j < j+2 <= 7
#
#  7*(i+0)+(j+0)-7, 7*(i+0)+(j+1)-7, 7*(i+0)+(j+2)-7
#  7*(i+1)+(j+0)-7, 7*(i+1)+(j+1)-7, 7*(i+1)+(j+2)-7
#  7*(i+2)+(j+0)-7, 7*(i+2)+(j+1)-7, 7*(i+2)+(j+2)-7
#
# sum(j,i) = 9*(7*i+j+1)
#
# sum(j,i)%11 = k
#
# sum(1,i) = 9*(7*i+1+1) = 9*(7*i+2) = 63*i+18
# sum(2,i) = 9*(7*i+2+1) = 9*(7*i+3) = 63*i+27
# sum(3,i) = 9*(7*i+3+1) = 9*(7*i+4) = 63*i+36
# sum(4,i) = 9*(7*i+4+1) = 9*(7*i+5) = 63*i+45
# sum(5,i) = 9*(7*i+5+1) = 9*(7*i+6) = 63*i+54
#
# sum(1,i)%11 = (63*i+18)%11 = (8*(i%11)+7)%11
# sum(2,i)%11 = (63*i+27)%11 = (8*(i%11)+5)%11
# sum(3,i)%11 = (63*i+36)%11 = (8*(i%11)+3)%11
# sum(4,i)%11 = (63*i+45)%11 = (8*(i%11)+1)%11
# sum(5,i)%11 = (63*i+54)%11 = (8*(i%11)+10)%11
#

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

tmp = [0] * 13

for i in range(1, 13):
    for j in range(1, 6):
        sum9 = 9 * (7 * i + j + 1)
        if sum9 % 11 == k:
            tmp[i % 11] += 1

ans = 0
for i in range(1, n - 1):
    ans += tmp[i % 11]
    
print(ans)

Submission status: Wrong Answer

Solution code:
#
# 1 <= i < i+2 <= n
# 1 <= j < j+2 <= 7
#
#  7*(i+0)+(j+0)-7, 7*(i+0)+(j+1)-7, 7*(i+0)+(j+2)-7
#  7*(i+1)+(j+0)-7, 7*(i+1)+(j+1)-7, 7*(i+1)+(j+2)-7
#  7*(i+2)+(j+0)-7, 7*(i+2)+(j+1)-7, 7*(i+2)+(j+2)-7
#
# sum(j,i) = 9*(7*i+j+1)
#
# sum(j,i)%11 = k
#
# sum(1,i) = 9*(7*i+1+1) = 9*(7*i+2) = 63*i+18
# sum(2,i) = 9*(7*i+2+1) = 9*(7*i+3) = 63*i+27
# sum(3,i) = 9*(7*i+3+1) = 9*(7*i+4) = 63*i+36
# sum(4,i) = 9*(7*i+4+1) = 9*(7*i+5) = 63*i+45
# sum(5,i) = 9*(7*i+5+1) = 9*(7*i+6) = 63*i+54
#
# sum(1,i)%11 = (63*i+18)%11 = (8*(i%11)+7)%11
# sum(2,i)%11 = (63*i+27)%11 = (8*(i%11)+5)%11
# sum(3,i)%11 = (63*i+36)%11 = (8*(i%11)+3)%11
# sum(4,i)%11 = (63*i+45)%11 = (8*(i%11)+1)%11
# sum(5,i)%11 = (63*i+54)%11 = (8*(i%11)+10)%11
#

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

tmp = [0] * 13

for i in range(1, 13):
    for j in range(1, 6):
        sum9 = 9 * (7 * i + j + 1)
        if sum9 % 11 == k:
            tmp[i % 11] += 1

ans = 0
if n - 2 <= 12:
    for i in range(1, n - 1):
        ans += tmp[i % 11]
else:
    ans = sum(tmp) * ((n - 3) // 11)
    z =  ((n - 3) // 11) * 11 + 1
    for i in range(z, n - 1):
        ans += tmp[i % 11]
    
print(ans)

Submission status: Wrong Answer

Solution code:
#
# 1 <= i < i+2 <= n
# 1 <= j < j+2 <= 7
#
#  7*(i+0)+(j+0)-7, 7*(i+0)+(j+1)-7, 7*(i+0)+(j+2)-7
#  7*(i+1)+(j+0)-7, 7*(i+1)+(j+1)-7, 7*(i+1)+(j+2)-7
#  7*(i+2)+(j+0)-7, 7*(i+2)+(j+1)-7, 7*(i+2)+(j+2)-7
#
# sum(j,i) = 9*(7*i+j+1)
#
# sum(j,i)%11 = k
#
# sum(1,i) = 9*(7*i+1+1) = 9*(7*i+2) = 63*i+18
# sum(2,i) = 9*(7*i+2+1) = 9*(7*i+3) = 63*i+27
# sum(3,i) = 9*(7*i+3+1) = 9*(7*i+4) = 63*i+36
# sum(4,i) = 9*(7*i+4+1) = 9*(7*i+5) = 63*i+45
# sum(5,i) = 9*(7*i+5+1) = 9*(7*i+6) = 63*i+54
#
# sum(1,i)%11 = (63*i+18)%11 = (8*(i%11)+7)%11
# sum(2,i)%11 = (63*i+27)%11 = (8*(i%11)+5)%11
# sum(3,i)%11 = (63*i+36)%11 = (8*(i%11)+3)%11
# sum(4,i)%11 = (63*i+45)%11 = (8*(i%11)+1)%11
# sum(5,i)%11 = (63*i+54)%11 = (8*(i%11)+10)%11
#

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

tmp = [0] * 13

for i in range(1, 13):
    for j in range(1, 6):
        sum9 = 9 * (7 * i + j + 1)
        if sum9 % 11 == k:
            tmp[i % 11] += 1

ans = 0
if n - 2 <= 12:
    for i in range(1, n - 1):
        ans += tmp[i % 11]
else:
    ans = sum(tmp) * ((n - 3) // 11)
    z =  ((n - 3) // 11) * 11
    for i in range(1, n - z - 1):
        ans += tmp[(z + i) % 11]
    
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,raw_input().split())
ans=0
inv=(5*k)%11
if n>=11:
    for i in range(8,78):
        if i%7 not in (1,0) and i%11==inv:ans+=1
ans+=5*(max(0,n/11-1))
for i in range(1,(n%11-1)*7+1):
    if i%7 not in (1,0) and i%11==inv:ans+=1
print ans

Submission status: Wrong Answer

Solution code:
n,k=map(int,raw_input().split())
ans=0
inv=(5*k)%11
if n>=11:
    for i in range(8,50):
        if i%7 not in (1,0) and i%11==inv:ans+=1
ans+=5*(max(0,n/11-1))
for i in range(1,(n%11-1)*7+1):
    if i%7 not in (1,0) and i%11==inv:ans+=1
print ans

Submission status: Wrong Answer

Solution code:
#
# 1 <= i < i+2 <= n
# 1 <= j < j+2 <= 7
#
#  7*(i+0)+(j+0)-7, 7*(i+0)+(j+1)-7, 7*(i+0)+(j+2)-7
#  7*(i+1)+(j+0)-7, 7*(i+1)+(j+1)-7, 7*(i+1)+(j+2)-7
#  7*(i+2)+(j+0)-7, 7*(i+2)+(j+1)-7, 7*(i+2)+(j+2)-7
#
# sum(j,i) = 9*(7*i+j+1)
#
# sum(j,i)%11 = k
#
# sum(1,i) = 9*(7*i+1+1) = 9*(7*i+2) = 63*i+18
# sum(2,i) = 9*(7*i+2+1) = 9*(7*i+3) = 63*i+27
# sum(3,i) = 9*(7*i+3+1) = 9*(7*i+4) = 63*i+36
# sum(4,i) = 9*(7*i+4+1) = 9*(7*i+5) = 63*i+45
# sum(5,i) = 9*(7*i+5+1) = 9*(7*i+6) = 63*i+54
#
# sum(1,i)%11 = (63*i+18)%11 = (8*(i%11)+7)%11
# sum(2,i)%11 = (63*i+27)%11 = (8*(i%11)+5)%11
# sum(3,i)%11 = (63*i+36)%11 = (8*(i%11)+3)%11
# sum(4,i)%11 = (63*i+45)%11 = (8*(i%11)+1)%11
# sum(5,i)%11 = (63*i+54)%11 = (8*(i%11)+10)%11
#

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

tmp = [0] * 13

for i in range(1, 13):
    for j in range(1, 6):
        sum9 = 9 * (7 * i + j + 1)
        if sum9 % 11 == k:
            tmp[i % 11] += 1

ans = 0
if n - 2 <= 12:
    for i in range(1, n - 1):
        ans += tmp[i % 11]
else:
    ans = sum(tmp) * ((n - 3) // 11)
    z =  ((n - 3) // 11) * 11
    for i in range(1, n - z):
        ans += tmp[(z + i) % 11]
    
print(ans)

Submission status: Wrong Answer

Solution code:
#
# 1 <= i < i+2 <= n
# 1 <= j < j+2 <= 7
#
#  7*(i+0)+(j+0)-7, 7*(i+0)+(j+1)-7, 7*(i+0)+(j+2)-7
#  7*(i+1)+(j+0)-7, 7*(i+1)+(j+1)-7, 7*(i+1)+(j+2)-7
#  7*(i+2)+(j+0)-7, 7*(i+2)+(j+1)-7, 7*(i+2)+(j+2)-7
#
# sum(j,i) = 9*(7*i+j+1)
#
# sum(j,i)%11 = k
#
# sum(1,i) = 9*(7*i+1+1) = 9*(7*i+2) = 63*i+18
# sum(2,i) = 9*(7*i+2+1) = 9*(7*i+3) = 63*i+27
# sum(3,i) = 9*(7*i+3+1) = 9*(7*i+4) = 63*i+36
# sum(4,i) = 9*(7*i+4+1) = 9*(7*i+5) = 63*i+45
# sum(5,i) = 9*(7*i+5+1) = 9*(7*i+6) = 63*i+54
#
# sum(1,i)%11 = (63*i+18)%11 = (8*(i%11)+7)%11
# sum(2,i)%11 = (63*i+27)%11 = (8*(i%11)+5)%11
# sum(3,i)%11 = (63*i+36)%11 = (8*(i%11)+3)%11
# sum(4,i)%11 = (63*i+45)%11 = (8*(i%11)+1)%11
# sum(5,i)%11 = (63*i+54)%11 = (8*(i%11)+10)%11
#

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

tmp = [0] * 13

for i in range(1, 13):
    for j in range(1, 6):
        sum9 = 9 * (7 * i + j + 1)
        if sum9 % 11 == k:
            tmp[i] += 1

ans = 0
if n - 2 <= 12:
    for i in range(1, n - 1):
        ans += tmp[i]
else:
    ans = sum(tmp) * ((n - 3) // 11)
    z = ((n - 3) // 11) * 11 + 1
    for i in range(1, n - z):
        ans += tmp[i]
    
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,raw_input().split())
ans=5*(n/11)
inv=(5*k)%11
for i in range(8,max(8,(n%11-1)*7+1)):
    if i%7 not in (1,0) and i%11==inv:ans+=1
print ans

Submission status: Wrong Answer

Solution code:
n,k=map(int,raw_input().split())
ans=5*(n/11)
inv=(5*k)%11
for i in range(8,min(8,(n%11-1)*7+1)):
    if i%7 not in (1,0) and i%11==inv:ans+=1
print ans

Submission status: Wrong Answer

Solution code:
#
# 1 <= i < i+2 <= n
# 1 <= j < j+2 <= 7
#
#  7*(i+0)+(j+0)-7, 7*(i+0)+(j+1)-7, 7*(i+0)+(j+2)-7
#  7*(i+1)+(j+0)-7, 7*(i+1)+(j+1)-7, 7*(i+1)+(j+2)-7
#  7*(i+2)+(j+0)-7, 7*(i+2)+(j+1)-7, 7*(i+2)+(j+2)-7
#
# sum(j,i) = 9*(7*i+j+1)
#
# sum(j,i)%11 = k
#
# sum(1,i) = 9*(7*i+1+1) = 9*(7*i+2) = 63*i+18
# sum(2,i) = 9*(7*i+2+1) = 9*(7*i+3) = 63*i+27
# sum(3,i) = 9*(7*i+3+1) = 9*(7*i+4) = 63*i+36
# sum(4,i) = 9*(7*i+4+1) = 9*(7*i+5) = 63*i+45
# sum(5,i) = 9*(7*i+5+1) = 9*(7*i+6) = 63*i+54
#
# sum(1,i)%11 = (63*i+18)%11 = (8*(i%11)+7)%11
# sum(2,i)%11 = (63*i+27)%11 = (8*(i%11)+5)%11
# sum(3,i)%11 = (63*i+36)%11 = (8*(i%11)+3)%11
# sum(4,i)%11 = (63*i+45)%11 = (8*(i%11)+1)%11
# sum(5,i)%11 = (63*i+54)%11 = (8*(i%11)+10)%11
#

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

tmp = [0] * 13

for i in range(1, 13):
    for j in range(1, 6):
        sum9 = 9 * (7 * i + j + 1)
        if sum9 % 11 == k:
            tmp[i] += 1

ans = 0
if n - 2 <= 12:
    for i in range(1, n - 1):
        ans += tmp[i]
else:
    ans = sum(tmp) * ((n - 3) // 11)
    z = ((n - 3) // 11) * 11 + 1
    for i in range(1, n - z + 1):
        ans += tmp[i]
    
print(ans)

Submission status: Wrong Answer

Solution code:
#
# 1 <= i < i+2 <= n
# 1 <= j < j+2 <= 7
#
#  7*(i+0)+(j+0)-7, 7*(i+0)+(j+1)-7, 7*(i+0)+(j+2)-7
#  7*(i+1)+(j+0)-7, 7*(i+1)+(j+1)-7, 7*(i+1)+(j+2)-7
#  7*(i+2)+(j+0)-7, 7*(i+2)+(j+1)-7, 7*(i+2)+(j+2)-7
#
# sum(j,i) = 9*(7*i+j+1)
#
# sum(j,i)%11 = k
#
# sum(1,i) = 9*(7*i+1+1) = 9*(7*i+2) = 63*i+18
# sum(2,i) = 9*(7*i+2+1) = 9*(7*i+3) = 63*i+27
# sum(3,i) = 9*(7*i+3+1) = 9*(7*i+4) = 63*i+36
# sum(4,i) = 9*(7*i+4+1) = 9*(7*i+5) = 63*i+45
# sum(5,i) = 9*(7*i+5+1) = 9*(7*i+6) = 63*i+54
#
# sum(1,i)%11 = (63*i+18)%11 = (8*(i%11)+7)%11
# sum(2,i)%11 = (63*i+27)%11 = (8*(i%11)+5)%11
# sum(3,i)%11 = (63*i+36)%11 = (8*(i%11)+3)%11
# sum(4,i)%11 = (63*i+45)%11 = (8*(i%11)+1)%11
# sum(5,i)%11 = (63*i+54)%11 = (8*(i%11)+10)%11
#

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

tmp = [0] * 13

for i in range(1, 13):
    for j in range(1, 6):
        sum9 = 9 * (7 * i + j + 1)
        if sum9 % 11 == k:
            tmp[i] += 1

ans = 0
if n - 2 <= 12:
    for i in range(1, n - 1):
        ans += tmp[i]
else:
    ans = sum(tmp) * ((n - 1) // 11)
    for i in range(1, (n - 1) % 11 + 2):
        ans += tmp[i]
    
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,raw_input().split())
ans=5*(n/11)
inv=(5*k)%11
for i in range(8,(n%11-1)*7+1):
    if i%7 not in (1,0) and i%11==inv:ans+=1
print ans

Submission status: Wrong Answer

Solution code:
#
# 1 <= i < i+2 <= n
# 1 <= j < j+2 <= 7
#
#  7*(i+0)+(j+0)-7, 7*(i+0)+(j+1)-7, 7*(i+0)+(j+2)-7
#  7*(i+1)+(j+0)-7, 7*(i+1)+(j+1)-7, 7*(i+1)+(j+2)-7
#  7*(i+2)+(j+0)-7, 7*(i+2)+(j+1)-7, 7*(i+2)+(j+2)-7
#
# sum(j,i) = 9*(7*i+j+1)
#
# sum(j,i)%11 = k
#
# sum(1,i) = 9*(7*i+1+1) = 9*(7*i+2) = 63*i+18
# sum(2,i) = 9*(7*i+2+1) = 9*(7*i+3) = 63*i+27
# sum(3,i) = 9*(7*i+3+1) = 9*(7*i+4) = 63*i+36
# sum(4,i) = 9*(7*i+4+1) = 9*(7*i+5) = 63*i+45
# sum(5,i) = 9*(7*i+5+1) = 9*(7*i+6) = 63*i+54
#
# sum(1,i)%11 = (63*i+18)%11 = (8*(i%11)+7)%11
# sum(2,i)%11 = (63*i+27)%11 = (8*(i%11)+5)%11
# sum(3,i)%11 = (63*i+36)%11 = (8*(i%11)+3)%11
# sum(4,i)%11 = (63*i+45)%11 = (8*(i%11)+1)%11
# sum(5,i)%11 = (63*i+54)%11 = (8*(i%11)+10)%11
#

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

tmp = [0] * 13

for i in range(1, 13):
    for j in range(1, 6):
        sum9 = 9 * (7 * i + j + 1)
        if sum9 % 11 == k:
            tmp[i] += 1

ans = 0
if n - 2 <= 12:
    for i in range(1, n - 1):
        ans += tmp[i]
else:
    ans = sum(tmp) * ((n - 2) // 11)
    for i in range(1, (n - 2) % 11 + 2):
        ans += tmp[i]
    
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,raw_input().split())
ans=17*(n/11)
inv=(5*k)%11
for i in range(8,(n%11-1)*7+1):
    if i%7 not in (1,0) and i%11==inv:ans+=1
print ans

Submission status: Wrong Answer

Solution code:
#
# 1 <= i < i+2 <= n
# 1 <= j < j+2 <= 7
#
#  7*(i+0)+(j+0)-7, 7*(i+0)+(j+1)-7, 7*(i+0)+(j+2)-7
#  7*(i+1)+(j+0)-7, 7*(i+1)+(j+1)-7, 7*(i+1)+(j+2)-7
#  7*(i+2)+(j+0)-7, 7*(i+2)+(j+1)-7, 7*(i+2)+(j+2)-7
#
# sum(j,i) = 9*(7*i+j+1)
#
# sum(j,i)%11 = k
#
# sum(1,i) = 9*(7*i+1+1) = 9*(7*i+2) = 63*i+18
# sum(2,i) = 9*(7*i+2+1) = 9*(7*i+3) = 63*i+27
# sum(3,i) = 9*(7*i+3+1) = 9*(7*i+4) = 63*i+36
# sum(4,i) = 9*(7*i+4+1) = 9*(7*i+5) = 63*i+45
# sum(5,i) = 9*(7*i+5+1) = 9*(7*i+6) = 63*i+54
#
# sum(1,i)%11 = (63*i+18)%11 = (8*(i%11)+7)%11
# sum(2,i)%11 = (63*i+27)%11 = (8*(i%11)+5)%11
# sum(3,i)%11 = (63*i+36)%11 = (8*(i%11)+3)%11
# sum(4,i)%11 = (63*i+45)%11 = (8*(i%11)+1)%11
# sum(5,i)%11 = (63*i+54)%11 = (8*(i%11)+10)%11
#

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

ans = 0

if n > 12:
    for j in range(1, 6):
        for i in range(1, 13):
            sum = 9 * (7 * i + j + 1)
            if sum % 11 == k:
                ans += 1
    ans *= (n + 1) // 11

for j in range(1, 6):
    for i in range(1, (n % 11) - 1):
        sum = 9 * (7 * i + j + 1)
        if sum % 11 == k:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
#
# 1 <= i < i+2 <= n
# 1 <= j < j+2 <= 7
#
#  7*(i+0)+(j+0)-7, 7*(i+0)+(j+1)-7, 7*(i+0)+(j+2)-7
#  7*(i+1)+(j+0)-7, 7*(i+1)+(j+1)-7, 7*(i+1)+(j+2)-7
#  7*(i+2)+(j+0)-7, 7*(i+2)+(j+1)-7, 7*(i+2)+(j+2)-7
#
# sum(j,i) = 9*(7*i+j+1)
#
# sum(j,i)%11 = k
#
# sum(1,i) = 9*(7*i+1+1) = 9*(7*i+2) = 63*i+18
# sum(2,i) = 9*(7*i+2+1) = 9*(7*i+3) = 63*i+27
# sum(3,i) = 9*(7*i+3+1) = 9*(7*i+4) = 63*i+36
# sum(4,i) = 9*(7*i+4+1) = 9*(7*i+5) = 63*i+45
# sum(5,i) = 9*(7*i+5+1) = 9*(7*i+6) = 63*i+54
#
# sum(1,i)%11 = (63*i+18)%11 = (8*(i%11)+7)%11
# sum(2,i)%11 = (63*i+27)%11 = (8*(i%11)+5)%11
# sum(3,i)%11 = (63*i+36)%11 = (8*(i%11)+3)%11
# sum(4,i)%11 = (63*i+45)%11 = (8*(i%11)+1)%11
# sum(5,i)%11 = (63*i+54)%11 = (8*(i%11)+10)%11
#

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

ans = 0

if n > 11:
    for j in range(1, 6):
        for i in range(1, 13):
            sum = 9 * (7 * i + j + 1)
            if sum % 11 == k:
                ans += 1
    ans *= (n + 1) // 11

for j in range(1, 6):
    for i in range(1, (n % 11) - 1):
        sum = 9 * (7 * i + j + 1)
        if sum % 11 == k:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
#
# 1 <= i < i+2 <= n
# 1 <= j < j+2 <= 7
#
#  7*(i+0)+(j+0)-7, 7*(i+0)+(j+1)-7, 7*(i+0)+(j+2)-7
#  7*(i+1)+(j+0)-7, 7*(i+1)+(j+1)-7, 7*(i+1)+(j+2)-7
#  7*(i+2)+(j+0)-7, 7*(i+2)+(j+1)-7, 7*(i+2)+(j+2)-7
#
# sum(j,i) = 9*(7*i+j+1)
#
# sum(j,i)%11 = k
#
# sum(1,i) = 9*(7*i+1+1) = 9*(7*i+2) = 63*i+18
# sum(2,i) = 9*(7*i+2+1) = 9*(7*i+3) = 63*i+27
# sum(3,i) = 9*(7*i+3+1) = 9*(7*i+4) = 63*i+36
# sum(4,i) = 9*(7*i+4+1) = 9*(7*i+5) = 63*i+45
# sum(5,i) = 9*(7*i+5+1) = 9*(7*i+6) = 63*i+54
#
# sum(1,i)%11 = (63*i+18)%11 = (8*(i%11)+7)%11
# sum(2,i)%11 = (63*i+27)%11 = (8*(i%11)+5)%11
# sum(3,i)%11 = (63*i+36)%11 = (8*(i%11)+3)%11
# sum(4,i)%11 = (63*i+45)%11 = (8*(i%11)+1)%11
# sum(5,i)%11 = (63*i+54)%11 = (8*(i%11)+10)%11
#

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

ans = 0

if n > 13:
    for j in range(1, 6):
        for i in range(1, 13):
            sum = 9 * (7 * i + j + 1)
            if sum % 11 == k:
                ans += 1
    ans *= (n + 1) // 11

for j in range(1, 6):
    for i in range(1, (n % 11) - 1):
        sum = 9 * (7 * i + j + 1)
        if sum % 11 == k:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
a = [0,5,10,4,9,3,8,2,7,1,6]
r = a[k]
s = 0
for i in range(2,n):
  for j in [2,3,4,5,6]:
    if (7*i + j - 7 - r)%11 == 0:
      s += 1
print(s)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
#(i,j)=7i+j-7
x=0
for i in range(11):
    if (9*i)%11==k:
        x=i
        break
ans=0
for i in range((7*n)//11+1):
    s=11*i+x
    if s>7*n-7:
        continue
    if s<=7:
        continue
    if s%7==0 or s%7==1:
        continue
    else:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main(): 
    """
    カレンダーらしいもの: 7列…
    """
    n, k = map(int, input().split())

    part1(n, k)


def part1(n, k):
    ans = 0

    for i in range(1, n-3+2):
        for j in range(1, 5+1):
            s = 0
            for y in range(3):
                for x in range(3):
                    s += 7*(i+y) + (j+x) - 7
            # print(i, j, s, sep="\t")
            if s % 11 == k:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

count = 0

for i in range(1,6):
	for j in range(1,n-1):
		if (9*i+9+63*j)%11 == k:
			count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
count=0
for i in range(n-2):
    for i2 in range(5):
        if ((9*(i*7+i2+1)+6)%11) == k:
            count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
count=0
for i in range(n-2):
    for i2 in range(5):
        if ((9*(7*i+i2+8+1))%11) == k:
            count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, raw_input().split(' '))

ans = 0
for i in xrange(n-2):
    i += 1
    for j in xrange(7-2):
        j += 1
        s = 9*(7*i+j+1)

        if ((s % 11) == k):
            ans +=1
print ans

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
c = 0
s = 81
for i in range(n-2):
    for j in range(5):
        if (s + j * 9) % 11 == k:
            c += 1
    s += 63
print(c)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int, input().split(" "))
 
vl = []
rl = []
for v in range(n):
    kari_value = []
    for v2 in range(v*7+1, v*7+1+7):
        kari_value.append(v2)
    vl.append(kari_value)
   
for v in range(len(vl)-2):  # 縦の繰り返し
  for v2 in range(len(vl[0])-2):  # 横の繰り返し
    s = vl[v][v2] + vl[v][v2+1] + vl[v][v2+2] + vl[v+1][v2] + vl[v+1][v2+1] + vl[v+1][v2+2] + vl[v+2][v2] + vl[v+2][v2+1] + vl[v+2][v2+2]
    if (s % 11 == k) :
      rl.append(1)
    
print(sum(rl))

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
d = [11, 16, 10, 25, 9, 24, 19, 13, 18, 12, 17]
print(len([x for x in range(d[k], 7 * (n - 1), 11) if x % 7 > 1]))

Submission status: Time Limit Exceeded

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

sq1 = sum([1,2,3,8,9,10,15,16,17])
sq2 = sq1 + 9
sq3 = sq1 + 18
sq4 = sq1 + 27
sq5 = sq1 + 36
square = [sq1, sq2, sq3, sq4, sq5]

i = 0
c = 0
while i <= n-3:
    a = i * 63
    for j in square:
        b = (j + a) % 11
        if (b == k):
            c += 1
    i += 1

print(str(c))

Submission status: Time Limit Exceeded

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

n, k = map(int, input().split())
M = [[(7*i+j-7)%11 for j in range(1, 7+1)] for i in range(1, n+1)]
cnt = 0
f = lambda i, j : sum(M[i+y][j+x] for y in range(3) for x in range(3)) % 11 == k
h = [0] * 11
for i in range(min(n-2, 11)):
    for j in range(7-2):
        if f(i, j) :
            h[i] += 1
cnt = sum(h) * (n // 11)
for i in range(n % 11 - 2):
    cnt += h[i%11]
print(cnt)

Submission status: Time Limit Exceeded

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

n, k = map(int, input().split())
M = [[(7*i+j-7)%11 for j in range(1, 7+1)] for i in range(1, n+1)]
cnt = 0
f = lambda i, j : sum(M[i+y][j+x] for y in range(3) for x in range(3)) % 11 == k
h = [0] * 11
for i in range(min(n-2, 11)):
    for j in range(7-2):
        if f(i, j) :
            h[i] += 1
for i in range(n-2):
    cnt += h[i%11]
print(cnt)

Submission status: Time Limit Exceeded

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

n, k = map(int, input().split())
M = [[7*i+j-7 for j in range(1, 7+1)] for i in range(1, n+1)]
cnt = 0
f = lambda i, j : sum(M[i+y][j+x] for y in range(3) for x in range(3)) % 11 == k
for i in range(n-2):
    for j in range(7-2):
        if f(i, j) :
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

c = 0
for i in range(2, n):
    for j in range(2, 7):
        if (7 * i + j - 7) * 9 % 11 == k:
            c += 1

print(c)

Submission status: Time Limit Exceeded

Solution code:
#
# 1 <= i < i+2 <= n
# 1 <= j < j+2 <= 7
#
#  7*(i+0)+(j+0)-7, 7*(i+0)+(j+1)-7, 7*(i+0)+(j+2)-7
#  7*(i+1)+(j+0)-7, 7*(i+1)+(j+1)-7, 7*(i+1)+(j+2)-7
#  7*(i+2)+(j+0)-7, 7*(i+2)+(j+1)-7, 7*(i+2)+(j+2)-7
#
# sum = 9*(7*i+j+1)
#
# sum%11 = k
#

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

ans = 0

for j in range(1,6):
    for i in range(1, n - 1):
        sum = 9 * (7 * i + j + 1)
        if sum % 11 == k:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

cnt = 0
for i in range(1, n - 1):
    for j in range(1, 6):
        if 9 * (7 * i + j + 1) % 11 == k:
            cnt += 1
        #print(i, j, ":", 9 * (7 * i + j + 1), 9 * (7 * i + j + 1) % 11)

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, raw_input().split(' '))

ans = 0
for i in xrange(n-2):
    i += 1
    for j in xrange(7-2):
        j += 1
        s = 0
        for ii in xrange(3):
            for jj in xrange(3):
                s += 7*(i+ii) + (j+jj) -7

        if ((s % 11) == k):
            ans +=1
print ans

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, raw_input().split(' '))

ans = 0
for i in range(n-2):
    i += 1
    for j in range(7-2):
        j += 1
        s = 0
        for ii in range(3):
            for jj in range(3):
                s += 7*(i+ii) + (j+jj) -7

        if ((s % 11) == k):
            ans +=1
print ans

Submission status: Memory Limit Exceeded

Solution code:
n,k=map(int,input().split());n-=2;h=[sum(k==(63*i+9*j+81)%11for j in range(5))for i in range(min(n,11))];print(sum(h*(n//11)+h[:n%11]))

Submission status: Memory Limit Exceeded

Solution code:
n,k=map(int,input().split());n-=2;print(sum(([sum(k==(63*i+9*j+81)%11for j in range(5))for i in range(11)]*(n//11+1))[:n]))

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
if n < 3:
    print(0)
    exit()

table = [[0] * 5 for i in range(11)]
for i in range(11):
    for j in range(5):
        t = 9 * (j + 2 + 7 * (i + 1))
        table[i][j] = t % 11

c = [0]
for row in table:
    c.append(c[-1] + row.count(k))

d, m = divmod(n - 2, 11)
ans = c[m] + c[-1] * d
print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
p = max(0, n//11-1)
q = n-11*p
#print(p, q)
r = 0
for i in range(11):
  for j in range(5):
    s = (7*(i+1)+(j+1)-7)*9+0+1+2+7+8+9+14+15+16
    if s%11 == k:
      r += 1
r = r*p
for i in range(q-2):
  for j in range(5):
    s = (7*(i+1)+(j+1)-7)*9+0+1+2+7+8+9+14+15+16
    if s%11 == k:
      r += 1
print(r)