Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
fs = []
for _ in range(n):
    r = list(input())
    r = [ord(s) - ord("a") for s in r]    
    fs.append(r)
fs = np.array(fs)
sym = np.zeros((n,n))
cnt = 0
# di,dj とdi+1,dj+1が同値
# dj側は0で固定して良い
for di in range(n):
    for i in range(n):
        for j in range(n):
            sym[(i+di)%n][j] = fs[i][j]
    flg = True
    for i in range(n):
        for j in range(i+1,n):
            if sym[i][j] != sym[j][i]:
                flg = False
                break
    if flg:
        cnt += n
print(cnt)


Fixed submission:
n = int(input())
fs = []
for _ in range(n):
    r = list(input())
    r = [ord(s) - ord("a") for s in r]    
    fs.append(r)
sym = [[0]*n for i in range(n)]
cnt = 0
# di,dj とdi+1,dj+1が同値
# dj側は0で固定して良い
for di in range(n):
    for i in range(n):
        for j in range(n):
            sym[(i+di)%n][j] = fs[i][j]
    flg = True
    for i in range(n):
        for j in range(i+1,n):
            if sym[i][j] != sym[j][i]:
                flg = False
                break
    if flg:
        cnt += n
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
fs = []
for _ in range(n):
    r = list(input())
    r = [ord(s) - ord("a") for s in r]    
    fs.append(r)
fs = np.array(fs)
sym = np.zeros((n,n))
cnt = 0
# di,dj とdi+1,dj+1が同値
# dj側は0で固定して良い
for di in range(n):
    for i in range(n):
        for j in range(n):
            sym[(i+di)%n][j] = fs[i][j]
    if (sym == sym.T).all():
        cnt += n
print(cnt)


Fixed submission:
n = int(input())
fs = []
for _ in range(n):
    r = list(input())
    r = [ord(s) - ord("a") for s in r]    
    fs.append(r)
sym = [[0]*n for i in range(n)]
cnt = 0
# di,dj とdi+1,dj+1が同値
# dj側は0で固定して良い
for di in range(n):
    for i in range(n):
        for j in range(n):
            sym[(i+di)%n][j] = fs[i][j]
    flg = True
    for i in range(n):
        for j in range(i+1,n):
            if sym[i][j] != sym[j][i]:
                flg = False
                break
    if flg:
        cnt += n
print(cnt)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
fs = []
for _ in range(n):
    r = list(input())
    r = [ord(s) - ord("a") for s in r]    
    fs.append(r)
fs = np.array(fs)
sym = np.zeros((n,n))
cnt = 0
# di,dj とdi+1,dj+1が同値
# dj側は0で固定して良い
for di in range(n):
    for i in range(n):
        for j in range(n):
            sym[(i+di)%n][j] = fs[i][j]
    if (sym == sym.T).all():
        cnt += n
print(cnt)


Fixed submission:
n = int(input())
fs = []
for _ in range(n):
    r = list(input())
    r = [ord(s) - ord("a") for s in r]    
    fs.append(r)
sym = [[0]*n for i in range(n)]
cnt = 0
# di,dj とdi+1,dj+1が同値
# dj側は0で固定して良い
for di in range(n):
    for i in range(n):
        for j in range(n):
            sym[(i+di)%n][j] = fs[i][j]
    flg = True
    for i in range(n):
        for j in range(i+1,n):
            if sym[i][j] != sym[j][i]:
                flg = False
                break
    if flg:
        cnt += n
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
# 愚
import numpy as np
n = int(input())
fs = []
for _ in range(n):
    r = list(input())
    r = [ord(s) - ord("a") for s in r]    
    fs.append(r)
fs = np.array(fs)
sym = np.zeros((n,n))
cnt = 0
for di in range(n):
    for dj in range(n):
        for i in range(n):
            for j in range(n):
                sym[(i+di)%n][(j+dj)%n] = fs[i][j]
        if (sym == sym.T).all():
            cnt += 1
print(cnt)

Fixed submission:
n = int(input())
fs = []
for _ in range(n):
    r = list(input())
    r = [ord(s) - ord("a") for s in r]    
    fs.append(r)
sym = [[0]*n for i in range(n)]
cnt = 0
# di,dj とdi+1,dj+1が同値
# dj側は0で固定して良い
for di in range(n):
    for i in range(n):
        for j in range(n):
            sym[(i+di)%n][j] = fs[i][j]
    flg = True
    for i in range(n):
        for j in range(i+1,n):
            if sym[i][j] != sym[j][i]:
                flg = False
                break
    if flg:
        cnt += n
print(cnt)