Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
T = int(input())

L = []
for i in range(0,T):
    L = list(map(int, input().split()))
    A = L[0]
    B = L[1]
    C = L[2]
    D = L[3]

    ans = "Yes"
    if A < B: #前提条件
        ans = "No"
    elif D < B: #前提条件
        ans = "No"
    elif B - C <= 1: #BとCの差が1より小さければ何が来てもOK
        ans = "Yes"
    elif C < B-math.gcd(B,D)+(A%math.gcd(B,D)):
        ans = "No"


    print(ans)
    L = []



Fixed submission:
import fractions
T = int(input())

L = []
for i in range(0,T):
    L = list(map(int, input().split()))
    A = L[0]
    B = L[1]
    C = L[2]
    D = L[3]

    ans = "Yes"
    if A < B: #前提条件
        ans = "No"
    elif D < B: #前提条件
        ans = "No"
    elif B - C <= 1: #BとCの差が1より小さければ何が来てもOK
        ans = "Yes"
    elif C < B-fractions.gcd(B,D)+(A%fractions.gcd(B,D)):
        ans = "No"


    print(ans)
    L = []
Buggy python submission (verdict: Runtime Error):
import sys
import math
N = input()
AList = list(map(int, input().split()))
listnum = 1000000000

low = -1000000000
high = 1000000000

mode = 1
a1 = 0
a2 = 0
while(True):
    p1 = math.floor((abs(low) + abs(high))/3) + low
    p2 = high - math.floor((abs(low) + abs(high))/3) 

    for j in range(1,int(N)+1):
        a1 += abs(AList[j-1] -(p1 + j))
    for j in range(1,int(N)+1):
        a2 += abs(AList[j-1] -(p2 + j))

    if a1 == a2 or abs(a1-a2) == 1:
        print(min(a1,a2))
        sys.exit()
    elif a1 < a2:
        high = p2
    else:
        low = p1        
    a1 = 0
    a2 = 0

Fixed submission:
A = int(input())

if A % 2 == 0:
    print(A)
else:
    print(A*2)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
jisho = []
for i in range(1,len(s)+1):
    for j in range(0,len(s)-i+1):
        jisho.append(s[j:j+i])
jisho = list(set(jisho))
jisho.sort()

print(jisho[K-1])

Fixed submission:
s = input()
K = int(input())
jisho = []
for i in range(1,min(len(s)+1,6)):
    for j in range(0,len(s)-i+1):
        jisho.append(s[j:j+i])
jisho = list(set(jisho))
jisho.sort()

print(jisho[K-1])
Buggy python submission (verdict: Runtime Error):
H,W = input().split()
H,W = int(H),int(W)
nodes = [list(input()) for i in range(H)]


if H == 1 and W == 1 and nodes[0][0] == ".":
    print("No")
    quit()
if H == 1 and W == 1 and nodes[0][0] == "#":
    print("Yes")
    quit()


for i in range(H):
    for j in range(W):
        if nodes[i][j] == "#":
            flag = False
            if i - 1 >= 0:
                if nodes[i-1][j] == "#":
                    flag = True
            if i + 1 < H:
                if nodes[i+1][j] == "#":
                    flag = True
            if j - 1 >= 0:
                if nodes[i][j-1] == "#":
                    flag = True
            if j + 1 < W:
                if nodes[i][j+1] == "#":
                    flag = True

            if flag == False:
                print("No")
                quit()

print("Yes")

Fixed submission:
a,b = input().split()
a = int(a)
b = int(b)
ans = 0
if a <= b:
    ans = a
else:
    ans = a - 1
print(ans)
Buggy python submission (verdict: Runtime Error):
H,W = input().split()
H,W = int(H),int(W)
nodes = [list(input()) for i in range(H)]


if H == 1 and W == 1 and nodes[0][0] == ".":
    print("No")
    quit()

for i in range(len(nodes)):
    for j in range(len(nodes)):
        if nodes[i][j] == "#":
            flag = False
            if i - 1 >= 0:
                if nodes[i-1][j] == "#":
                    flag = True
            if i + 1 < H:
                if nodes[i+1][j] == "#":
                    flag = True
            if j - 1 >= 0:
                if nodes[i][j-1] == "#":
                    flag = True
            if j + 1 < W:
                if nodes[i][j+1] == "#":
                    flag = True

            if flag == False:
                print("No")
                quit()

print("Yes")

Fixed submission:
H,W = input().split()
H,W = int(H),int(W)
nodes = [list(input()) for i in range(H)]


if H == 1 and W == 1 and nodes[0][0] == ".":
    print("No")
    quit()
if H == 1 and W == 1 and nodes[0][0] == "#":
    print("Yes")
    quit()


for i in range(H):
    for j in range(W):
        if nodes[i][j] == "#":
            flag = False
            if i - 1 >= 0:
                if nodes[i-1][j] == "#":
                    flag = True
            if i + 1 < H:
                if nodes[i+1][j] == "#":
                    flag = True
            if j - 1 >= 0:
                if nodes[i][j-1] == "#":
                    flag = True
            if j + 1 < W:
                if nodes[i][j+1] == "#":
                    flag = True

            if flag == False:
                print("No")
                quit()

print("Yes")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = input().split()
B = input().split()

L = {}
for i in range(len(A)):
    for j in range(len(B)):
        c = int(A[i]) + int(B[j])
        if c in L:
            del L[c] 
        else:
            L[c] = c
a = 0
for i in L.values():
    a = a ^ i
print(a)

Fixed submission:
S = input().split()
A = int(S[0])
B = int(S[1])
C = int(S[2])
a = 'No'
if C <= A + B:
    a = 'Yes'
print(a)
Buggy python submission (verdict: Runtime Error):
T=0
X=1
Y=2
item = input()
tabiji = [[0,0,0]]
for i in range(1, int(item)+1):
    tabiji.append(input().split(' '))

a='Yes'
for i in range(0, len(tabiji)-1):
    time = int(tabiji[i+1][T]) - int(tabiji[i][T])
    dX = int(tabiji[i+1][X]) - int(tabiji[i][X])
    dY = int(tabiji[i+1][Y]) - int(tabiji[i][Y])
    for j in range(time):
        if dX > 0:
            dX -= 1
        elif dX < 0:
            dX += 1
        elif dY > 0:
            dY -= 1
        elif dY < 0:
            dY += 1
        if dX == 0 and dY == 0 and (time - j+1) % 2 == 1:
            a = 'No'
            break
        elif dX == 0 and dY == 0 and (time - j+1) % 2 == 0:
            break
    if dX != 0 or dY != 0:
        a = 'No'

print(a)

Fixed submission:
item = input().split(' ')
if ((int(item[0]) * int(item[1])) % 2) == 0:
    print('Even')
else:
    print('Odd')
Buggy python submission (verdict: Runtime Error):
S = input()
R = 0
S = list(S)
temp = []
if len(S)-1 == 0:
    R = int(S)
for i in range(2**(len(S)-1)):
    for m in range(len(S)-1):
        if i+1 & 2**(m) > 0:
            temp.append(S[m] + "+")
        else:
            temp.append(S[m])
    temp.append(S[len(S)-1])
    temp = "".join(temp)
    R += eval(temp)
    temp = []    
print(R)

Fixed submission:
S = input()
R = 0
S = list(S)
temp = []
for i in range(2**(len(S)-1)):
    for m in range(len(S)-1):
        if i+1 & 2**(m) > 0:
            temp.append(S[m] + "+")
        else:
            temp.append(S[m])
    temp.append(S[len(S)-1])
    temp = "".join(temp)
    R += eval(temp)
    temp = []    
print(R)
Buggy python submission (verdict: Time Limit Exceeded):
a=input().split()
N=int(a[0])
M=int(a[1])
first=[]
second=[]
i=0
while i<M:
	y=input().split()
	if int(y[0])==1:
		first.append(y[1])
	elif int(y[1])==N:
		second.append(y[0])
	i+=1

if any(i in first for i in second):
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Fixed submission:
a=input().split()
N=int(a[0])
M=int(a[1])
first=[]
second=[]
i=0
while i<M:
	y=input().split()
	if int(y[0])==1:
		first.append(y[1])
	elif int(y[1])==N:
		second.append(y[0])
	i+=1

first=set(first)
second=set(second)
if len(first.intersection(second))>0:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
a=input().split()
N=int(a[0])
M=int(a[1])
first=[]
second=[]
i=0
while i<M:
	y=input().split()
	if int(y[0])==1:
		first.append(y[1])
	elif int(y[1])==N:
		second.append(y[0])
	i+=1

for i in second:
	if i in first:
		print("POSSIBLE")
		break
else:
	print("IMPOSSIBLE")

Fixed submission:
a=input().split()
N=int(a[0])
M=int(a[1])
first=[]
second=[]
i=0
while i<M:
	y=input().split()
	if int(y[0])==1:
		first.append(y[1])
	elif int(y[1])==N:
		second.append(y[0])
	i+=1

first=set(first)
second=set(second)
if len(first.intersection(second))>0:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
a=input().split()
N=int(a[0])
M=int(a[1])
first=[]
second=[]
i=0
while i<M:
	y=input().split()
	if int(y[0])==1:
		first.append(y[1])
	elif int(y[1])==N:
		second.append(y[0])
	i+=1

if len(first)==0 or len(second)==0:
	print("IMPOSSIBLE")
else:
	if any(i  in first for i in second)==True:
		print("POSSIBLE")
	else:
		print("IMPOSSIBLE")


Fixed submission:
a=input().split()
N=int(a[0])
M=int(a[1])
first=[]
second=[]
i=0
while i<M:
	y=input().split()
	if int(y[0])==1:
		first.append(y[1])
	elif int(y[1])==N:
		second.append(y[0])
	i+=1

first=set(first)
second=set(second)
if len(first.intersection(second))>0:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
a=input().split()
N=int(a[0])
M=int(a[1])
first=[]
second=[]
i=0
while i<M:
	y=input().split()
	if int(y[0])==1:
		first.append(y)
	elif int(y[1])==N:
		second.append(y)
	i+=1

if len(first)==0 or len(second)==0:
	print("IMPOSSIBLE")
else:
	i=0
	check=0
	while i<len(first):
		j=0
		while j<len(second):
			k=first[i]
			l=second[j]
			if k[1]==l[0]:
				print("POSSIBLE")
				check=1
				break
			else:
				j+=1
		i+=1
	else:
		if check==0:
			print("IMPOSSIBLE")

Fixed submission:
a=input().split()
N=int(a[0])
M=int(a[1])
first=[]
second=[]
i=0
while i<M:
	y=input().split()
	if int(y[0])==1:
		first.append(y[1])
	elif int(y[1])==N:
		second.append(y[0])
	i+=1

first=set(first)
second=set(second)
if len(first.intersection(second))>0:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
def sum_ans(data):
    if sum(data) == 15:
        print("+")


def main():
    inputs = input()
    data = inputs.split(" ")
    m = max(data)
    ans = 15
    if m > 15:
        print("x")
    else:
        sum_ans()
        if data[0] * data[1] == 15:
            print("*")
        elif data[0] * data[1] < 15:
            print("x")
        
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    inputs = input()
    data = inputs.split(" ")
    data = [int(d) for d in data]
    m = max(data)
    ans = 15
    if int(m) > 15:
        print("x")
    else:
        s = sum(data)
        if data[0] * data[1] == 15:
            print("*")
        elif s == 15:
            print("+")
        else:
            print("x")
        
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def sum_ans(data):
    if sum(data) == 15:
        print("+")


def main():
    inputs = input()
    data = inputs.split(" ")
    m = max(data
    ans = 15
    if m > 15:
        print("x")
    else:
        sum_ans()
        if data[0] * data[1] == 15:
            print("*")
        elif data[0] * data[1] < 15:
            print("x")
        
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    inputs = input()
    data = inputs.split(" ")
    data = [int(d) for d in data]
    m = max(data)
    ans = 15
    if int(m) > 15:
        print("x")
    else:
        s = sum(data)
        if data[0] * data[1] == 15:
            print("*")
        elif s == 15:
            print("+")
        else:
            print("x")
        
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def sum_ans = (data):
    if sum(data) == 15:
        print("+")


def main():
    inputs = input()
    data = inputs.split(" ")
    m = max(data
    ans = 15
    if m > 15:
        print("x")
    else:
        sum_ans()
        if data[0] * data[1] == 15:
            print("*")
        elif data[0] * data[1] < 15:
            print("x")
        
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    inputs = input()
    data = inputs.split(" ")
    data = [int(d) for d in data]
    m = max(data)
    ans = 15
    if int(m) > 15:
        print("x")
    else:
        s = sum(data)
        if data[0] * data[1] == 15:
            print("*")
        elif s == 15:
            print("+")
        else:
            print("x")
        
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
count = 0

if N != 2:
    for i in range(1,N):
        if a[i] == a[i-1]:
            a[i] = a[i+1] + 1
            count = count + 1
else:
    if a[0] == a[1]:
        count = count + 1


print(count)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
count = 0

if N != 2:
    for i in range(1,N-1):
        if a[i] == a[i-1]:
            a[i] = a[i+1] + 1
            count = count + 1
else:
    if a[0] == a[1]:
        a[0] = a[1]+1
        count = count + 1

if a[N-2] == a[N-1]:
    count = count + 1

print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
count = 0
a = []
b = input()
c = b.split()
for i in range(N):
    a.append(int(c[i]))

for i in range(1,N):
    if a[i] == a[i-1]:
        a[i] = a[i+1] + 1
        count = count + 1

print(count)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
count = 0

if N != 2:
    for i in range(1,N-1):
        if a[i] == a[i-1]:
            a[i] = a[i+1] + 1
            count = count + 1
else:
    if a[0] == a[1]:
        a[0] = a[1]+1
        count = count + 1

if a[N-2] == a[N-1]:
    count = count + 1

print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
count = 0
a = list(map(int,input().split()))


for i in range(1,N):
    if a[i] == a[i-1]:
        a[i] = a[i+1] + 1
        count = count + 1

print(count)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
count = 0

if N != 2:
    for i in range(1,N-1):
        if a[i] == a[i-1]:
            a[i] = a[i+1] + 1
            count = count + 1
else:
    if a[0] == a[1]:
        a[0] = a[1]+1
        count = count + 1

if a[N-2] == a[N-1]:
    count = count + 1

print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
count = 0
a = list(map(int,input().split()))


for i in range(1,N):
    if a[i] == a[i-1]:
        a[i] = a[i+1] + 1
        count = count + 1

print(count)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
count = 0

if N != 2:
    for i in range(1,N-1):
        if a[i] == a[i-1]:
            a[i] = a[i+1] + 1
            count = count + 1
else:
    if a[0] == a[1]:
        a[0] = a[1]+1
        count = count + 1

if a[N-2] == a[N-1]:
    count = count + 1

print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = input()
b = A.split(" ")
c = []
for i in range(0,N):
    c.append(abs(int(b[i])))
c.sort

print(c[-1]-c[0])

Fixed submission:
N = int(input())
if N%2 == 0:
    print(N)
else:
    print(N*2)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = input()
b = A.split(" ")
c = []
for i in range(0,N):
    c.append(abs(int(b[i])))

c.sort

print(int(c[-1])-int(c[0]))

Fixed submission:
N = int(input())
if N%2 == 0:
    print(N)
else:
    print(N*2)
Buggy python submission (verdict: Runtime Error):

a = 0
s = input()
n = len(S)

for i in range(0,n):
    if s[i] == "+":
        a = a+1
    if s[i] == "-":
        a = a-1
        
print(a)

Fixed submission:
a = 0
s = input()

for i in range(0,4):
    if s[i] == "+":
        a = a+1
    if s[i] == "-":
        a = a-1
        
print(int(a))
Buggy python submission (verdict: Runtime Error):
c = 0
A = input()
B = A.split(" ")
a,b = int(B[0]),int(B[1])
for i in range(1,a-b):
    c = c + i
print(c - a)


Fixed submission:
i = int(input())
if i <= 999:
    print("ABC")
else:
    print("ABD")

Buggy python submission (verdict: Runtime Error):
c = 0
a,b = map(int,input())
for i in range(1,a-b):
    c = c + i
print(a-c)


Fixed submission:
i = int(input())
if i <= 999:
    print("ABC")
else:
    print("ABD")
Buggy python submission (verdict: Runtime Error):
c = 0
A =input().split(" ")
a,b = A[0],A[1]
for i in range(1,a-b):
    c = c + i
print(a-c)


Fixed submission:
a,b = map(int, input().split())
c = b-a
d = 0

for i in range(1,c):
    d = i + d

print(d - a)
Buggy python submission (verdict: Runtime Error):
A,B,K =map(int,input().split())
for i in range(A,B+1):
    if i < (A + K) :
        print(i)
    elif i > (B - K):
        print(i)

Fixed submission:
S = input().replace("a","",1).replace("b","",1).replace("c","",1)
if S:
    print("No")
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
A,B,K =map(int,input().split())
for i in range(A,B+1):
    if i < (A + K) or i > (B - K):
        print(i)

Fixed submission:
S = input().replace("a","",1).replace("b","",1).replace("c","",1)
if S:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n,m,d = (int(i) for i in input().split())
step = n-d
if d != 0:
  step =step*2
print('{:.10f}'.format(step*n**(m-2)*(m-1)/n**m))


Fixed submission:
n,m,d = (int(i) for i in input().split())
step = n-d
if d != 0:
  step =step*2
print('{:.10f}'.format(step*(m-1)/n**2))
Buggy python submission (verdict: Runtime Error):
S=list(input())
counter = 0
for i in range(len(S):
    if S[i] == '+':
        counter += 1
    else:
        counter -= 1

print(counter)

Fixed submission:
S=list(input())
counter = 0
for i in range(len(S)):
    if S[i] == '+':
        counter += 1
    elif S[i] == '-':
        counter -= 1

print(counter)

Buggy python submission (verdict: Runtime Error):
S=list(input())
counter = 0
for i in len(S):
    if S[i] == '+':
        counter += 1
    else:
        counter -= 1

print(counter)

Fixed submission:
S=list(input())
counter = 0
for i in range(len(S)):
    if S[i] == '+':
        counter += 1
    elif S[i] == '-':
        counter -= 1

print(counter)

Buggy python submission (verdict: Runtime Error):
S=input()
counter = 0
for i in len(S):
    if S[i] == '+':
        counter += 1
    else:
        counter -= 1

print(counter)

Fixed submission:
S=list(input())
counter = 0
for i in range(len(S)):
    if S[i] == '+':
        counter += 1
    elif S[i] == '-':
        counter -= 1

print(counter)

Buggy python submission (verdict: Runtime Error):
S=input()
counter
for i in len(S):
    if S[i] == '+':
        counter += 1
    else:
        counter -= 1

print(counter)

Fixed submission:
S=list(input())
counter = 0
for i in range(len(S)):
    if S[i] == '+':
        counter += 1
    elif S[i] == '-':
        counter -= 1

print(counter)
Buggy python submission (verdict: Runtime Error):
N0 = int(input())
N1 = list(map(int,str(N0)))
S_N = 0

for i in range(len(N)):
    S_N += N1[i]

if N0 % S_N == 0:
    print('Yes')
else:
    print('No')

Fixed submission:
N0 = int(input())
N1 = list(map(int,str(N0)))
S_N = 0

for i in range(len(N1)):
    S_N += N1[i]

if N0 % S_N == 0:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
N0 = int(input())
N1 = list(map,N0)
S_N = 0

for i in range(len(N1)):
    S_N += N1[i]

if N0 % S_N == 0:
    print('Yes')
else:
    print('No')

Fixed submission:
N0 = int(input())
N1 = list(map(int,str(N0)))
S_N = 0

for i in range(len(N1)):
    S_N += N1[i]

if N0 % S_N == 0:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
N0 = int(input())
N1 = list(map,N0)
S_N = 0

for i in range(len(N)):
    S_N += N[i]

if N % S_N == 0:
    print('Yes')
else:
    print('No')

Fixed submission:
N0 = int(input())
N1 = list(map(int,str(N0)))
S_N = 0

for i in range(len(N1)):
    S_N += N1[i]

if N0 % S_N == 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import sys,time
X, Y = map(int,input().split())
time.sleep((X%7)/5)


Fixed submission:
n = int(input())
ar = list(map(int,input().split()))
su = [0]*n
su[0]=ar[0]
for i in range(1,n):
    su[i] = ar[i] + su[i-1]

# +
ans1,off = 0,0
for i in range(0,n):
    if i%2 == 0:
        if su[i] + off <= 0:
            ans1 += 1-(su[i]+off)
            off += 1-(su[i]+off)
    else:
        if su[i] + off >= 0:
            ans1 += (su[i]+off+1)
            off -= (su[i]+off+1)

# -
ans2,off = 0,0
for i in range(0,n):
    if i%2 != 0:
        if su[i] + off <= 0:
            ans2 += 1-(su[i]+off)
            off += 1-(su[i]+off)
    else:
        if su[i] + off >= 0:
            ans2 += (su[i]+off+1)
            off -= (su[i]+off+1)
print(min(ans1,ans2))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

s = []
for i in range(n):
    s.append(input())

result = 0
for offset in range(n):
    is_symmetry = True
    for i in range(n):
        for j in range(i+1, n):
            if s[i][(j+offset)%n] != s[j][(i+offset)%n]:
                is_symmetry = False
                break
        if not is_symmetry:
            break
    if is_symmetry:
        result += n

print(result)

Fixed submission:
n = int(input())

s = []
for i in range(n):
    s.append(input())

result = 0

def judge(board):
    for i in range(n):
        for j in range(i+1, n):
            if board[i][j] != board[j][i]:
                return 0
    return 1

result = 0
for i in range(n):
    board = s[i:] + s[:i]
    result += n * judge(board)

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

s = []
for i in range(n):
    s.append(list(input()))

result = 0
for offset in range(n):
    # print('offset: %i' % offset)
    is_symmetry = True
    for i in range(n):
        for j in range(i+1, n):
            # print('s[%i][%i] = %c' % (i, (j+offset)%n, s[i][(j+offset)%n]))
            # print('s[%i][%i] = %c' % (j, (i+offset)%n, s[j][(i+offset)%n]))
            # print('--')
            if s[i][(j+offset)%n] != s[j][(i+offset)%n]:
                is_symmetry = False
                break
        if not is_symmetry:
            break
    if is_symmetry:
        result += n
        # print('offset: %i' % offset)

print(result)

Fixed submission:
n = int(input())

s = []
for i in range(n):
    s.append(input())

result = 0

def judge(board):
    for i in range(n):
        for j in range(i+1, n):
            if board[i][j] != board[j][i]:
                return 0
    return 1

result = 0
for i in range(n):
    board = s[i:] + s[:i]
    result += n * judge(board)

print(result)
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
for _ in range(n):
    a,b,c,d=map(int,input().split())
    if d<b:
        print("No")
        continue
    elif a<b:
        print("No")
        continue
    g=math.gcd(b,d)
    h=1
    if 1+h>c:
        print("No")
        continue
    print("Yes")

Fixed submission:
import fractions 
n=int(input())
for _ in range(n):
    a,b,c,d=map(int,input().split())
    if d<b:
        print("No")
        continue
    elif a<b:
        print("No")
        continue
    elif c>=b:
        print("Yes")
        continue
    g=fractions.gcd(b,d)
    h=((b-1-a%b)//g)*g
    if a%b+h>c:
        print("No")
        continue
    print("Yes")

Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
for _ in range(n):
    a,b,c,d=map(int,input().split())
    if d<b:
        print("No")
        continue
    elif a<b:
        print("No")
        continue
    g=math.gcd(b,d)
    h=int((b-1-1)/g)*g
    if a%b+h>c:
        print("No")
        continue
    print("Yes")

Fixed submission:
import fractions 
n=int(input())
for _ in range(n):
    a,b,c,d=map(int,input().split())
    if d<b:
        print("No")
        continue
    elif a<b:
        print("No")
        continue
    elif c>=b:
        print("Yes")
        continue
    g=fractions.gcd(b,d)
    h=((b-1-a%b)//g)*g
    if a%b+h>c:
        print("No")
        continue
    print("Yes")

Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
for _ in range(n):
    a,b,c,d=map(int,input().split())
    if d<b:
        print("No")
        continue
    elif a<b:
        print("No")
        continue
    g=math.gcd(b,d)
    h=1
    if a%b+h>c:
        print("No")
        continue
    print("Yes")

Fixed submission:
import fractions 
n=int(input())
for _ in range(n):
    a,b,c,d=map(int,input().split())
    if d<b:
        print("No")
        continue
    elif a<b:
        print("No")
        continue
    elif c>=b:
        print("Yes")
        continue
    g=fractions.gcd(b,d)
    h=((b-1-a%b)//g)*g
    if a%b+h>c:
        print("No")
        continue
    print("Yes")