Harryxun/stf_run huggingface dataset:
import math

a, b, x = [int(x) for x in input().split()]

bootle_volume = a * a * b
half_bootle_volume = 0.5 * bootle_volume

res = 0
if half_bootle_volume == x:
    res = math.degrees(math.atan(1))
elif half_bootle_volume > x:
    y = a - ((2 * x) / (a * b))
    degree = math.degrees(math.atan((a - y) / b))
    res = 90 - degree
elif half_bootle_volume < x:
    if b == y:
        res == 0
    else:
        y = ((2 * x) / (a ** 2)) - b
        degree = math.degrees(math.atan(a / (b - y)))
        res = 90 - degree

print(res)


### FIXED CODE ###

import math

a, b, x = [int(x) for x in input().split()]

bootle_volume = a * a * b
half_bootle_volume = 0.5 * bootle_volume

res = 0
if half_bootle_volume == x:
    res = math.degrees(math.atan(1))
elif half_bootle_volume > x:
    y = a - ((2 * x) / (a * b))
    degree = math.degrees(math.atan((a - y) / b))
    res = 90 - degree
elif half_bootle_volume < x:
    y = ((2 * x) / (a ** 2)) - b
    if y == b:
        res = 0
    else:
        degree = math.degrees(math.atan(a / (b - y)))
        res = 90 - degree

print(res)
A,B = map(int,input().split())

l = [["."]*100]*50
ll = [["#"]*100]*50

a = 1
b = 1

for i in range(5):
    for j in range(50):
        l[i*2][j*2] = "."
        a += 1
        if a == B:
            break
            break
for i in range(5):
    for j in range(50):
        ll[i*2][j*2] = "#"
        b += 1
        if b == A:
            break
            break

print(100 100)
def l_to_str(l):
    s = ""
    for x in l:
        s+=x
    return s
for i in l:
    print(l_to_str(i))
for i in ll:
    print(l_to_str(i))

### FIXED CODE ###

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

d = {}
for i in range(50):
    d[i] = ["."]*100
for i in range(50,100):
    d[i] = ["#"]*100
a = 1
b = 1

for i in range(10):
    if a == B:
        break
    for j in range(50):
        if a == B:
            break
        else:
            d[i*2][j*2] = "#"
            a += 1
    
        
        
for i in range(10):
    if b == A:
        break
    for j in range(50):
        if b == A:
            break
        else:
            d[i*2+51][j*2] = "."
            b += 1
    

print("100 100")
def l_to_str(l):
    s = ""
    for x in l:
        s+=x
    return s
for i in range(100):
    print(l_to_str(d[i]))
import math
a, b, k = [int(i) for i in input().split() ]
x=math.gcd(a,b)
i = 1
for j in range(2, 101):
    if i == k:
        break
    if x % j == 0:
        x = int(x/j)
        i += 1
print(x)

### FIXED CODE ###

a, b, k = [int(i) for i in input().split() ]
i = 0
for j in range(100, 0, -1):
    if ((a%j == 0) and (b%j == 0)):
        i += 1
        if i == k:
            print(j)
            break
import time
from bisect import bisect_left
t = time.time()
H,W,m = map(int,input().split())
h = [0]*(H+1)
w = [0]*(W+1)
c = [[-1] for i in range(H+1)]
for i in range(m):
    a,b = map(int,input().split())
    h[a] += 1
    w[b] += 1
    c[a].append(b)
mh = max(h)
mw = max(w)
hkouho = []
wkouho = []
for i in range(H+1):
    if h[i] == mh:
        hkouho.append(i)
for i in range(W+1):
    if w[i] == mw:
        wkouho.append(i)
for i in range(H+1):
    c[i].sort()
# print(hkouho)
# print(wkouho)
for i in hkouho:
    for j in wkouho:
        print(i,j,bisect_left(c[i],j))
        if c[i][bisect_left(c[i],j)] != j:
        # if j not in c[i]:
            print(mh+mw)
            exit()
        if time.time()-t > 2.7:
            print(mh+mw-1)
            exit()
print(mh+mw-1)

### FIXED CODE ###

import time
from bisect import bisect_left
t = time.time()
H,W,m = map(int,input().split())
h = [0]*(H+1)
w = [0]*(W+1)
c = [[-1,10**6] for i in range(H+1)]
for i in range(m):
    a,b = map(int,input().split())
    h[a] += 1
    w[b] += 1
    c[a].append(b)
mh = max(h)
mw = max(w)
hkouho = []
wkouho = []
for i in range(H+1):
    if h[i] == mh:
        hkouho.append(i)
for i in range(W+1):
    if w[i] == mw:
        wkouho.append(i)
for i in range(H+1):
    c[i].sort()
# print(hkouho)
# print(wkouho)
for i in hkouho:
    for j in wkouho:
        # print(c[i],i,j,bisect_left(c[i],j))
        if c[i][bisect_left(c[i],j)] != j:
            print(mh+mw)
            exit()
        if time.time()-t > 2.7:
            print(mh+mw-1)
            exit()
print(mh+mw-1)
l=list(map(int,input().split()))
c=collections.Counter(l)
def j(n):
  judge=1
  for k  in c.keys():
      if n%k==0:
        if n!=k:
          judge=0
          break
  return judge
count=0
if len(list(c.keys()))==1:
       print(count)
else:
  for k in c.keys():
    if j(k)==1:
      count+=1
  print(count)
  

### FIXED CODE ###

l=list(map(int,input().split()))
for i in range(5):
  if l[i]==0:
    print(i+1)
    break
color = set(map(int, input().split))
print(len(color))

### FIXED CODE ###

color = list(map(int,input().split()))
print(len(set(color)))
a, b, c, d = map(int, input().split())
a = []
for i in range(a, b + 1):
    for j in range(c, d + 1):
        a += i * j
max(a)

### FIXED CODE ###

a, b, c, d = map(int, input().split())
e = []
for i in [a, b]:
    for j in [c, d]:
        e += [i * j]

print(max(e))
from functools import reduce
isstr=input()
n,m = [int(i) for i in isstr.split(' ')]
mini=-1
maxi=1000000000000000
for i in range(m):
    a,b=[int(i) for i in input().split(' ')]
	tmp_mini=max(mini,a)
    tmp_maxi=min(maxi,b)
    if(tmp_mini<tmp_maxi):
      mini=tmp_mini
      maxi=tmp_maxi
    elif(tmp_mini==tmp_maxi):
      if tmp_mini<=n:
        print(1)
        break
      else:
        print(0)
        break
    else:
      print(0)
      break
      
if n>=maxi:
  print(maxi-mini+1)
elif maxi>n>=mini:
  print(n-mini+1)
else:
  print(0)

  	

### FIXED CODE ###

isstr=input()
n,m = [int(i) for i in isstr.split(' ')]
l=[0]*m
r=[0]*m
for i in range(m):
    l[i],r[i]=[int(i) for i in input().split(' ')]
result=min(r)-max(l)+1
result=result if result>0 else 0
print(result)
X, A = map(int, input.()split())

if X < A:
  print(0)
else:
  print(10)

### FIXED CODE ###

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

if X < A:
    print(0)
else:
    print(10)
import math
(_,), a  = [list(map(int, s.split())) for s in open(0)]

def fast_prime_factorize(num):
    prime_factor_sets = [set() for _ in range(num+1)]
    for i in range(2, int(math.sqrt(num)) + 2):
        if len(prime_factor_sets[i]) == 0:
            for j in range(i, num+1, i):
                prime_factor_sets[j].add(i)
    return prime_factor_sets

prime_factor_sets = fast_prime_factorize(max(a))

g = prime_factor_sets[0].copy()
l = set()
s = 0
for x in a:
    y = prime_factor_sets[x]
    if len(y) == 0 and x != 1:
        y = {x}
    g &= y
    l |= y
    s += len(y)

if len(g) != 0:
    ans = 'not coprime'
elif len(l) != s:
    ans = 'setwise coprime'
else:
    ans = 'pairwise coprime'
print(ans)

### FIXED CODE ###

import math
(_,), a  = [list(map(int, s.split())) for s in open(0)]

def fast_factorize(num):
    min_factor_list = list(range(num + 1))
    for i in range(int(math.sqrt(num) + 1), 1, -1):
        for j in range(i, num+1, i):
            min_factor_list[j] = i
    return min_factor_list

min_factor_list = fast_factorize(max(a))

prime_factor_sets = []
for x in a:
    prime_factor_set = set()
    while min_factor_list[x] != 1:
        prime_factor_set.add(min_factor_list[x])
        x //= min_factor_list[x]
    prime_factor_sets.append(prime_factor_set)

g = prime_factor_sets[0].copy()
l = prime_factor_sets[0].copy()
s = 0
for x in prime_factor_sets:
    g &= x
    l |= x
    s += len(x)

if len(g) != 0:
    ans = 'not coprime'
elif len(l) != s:
    ans = 'setwise coprime'
else:
    ans = 'pairwise coprime'
print(ans)
a=input().split()
b=input()
c=[int(i) for i in a]
d=0
for j in c:
  d+=j
d=d-max(c)
d=d+(max(c))*(2**b)

### FIXED CODE ###

a=input().split()
b=int(input())
c=[int(i) for i in a]
d=0
for j in c:
  d+=j
d=d-max(c)
d=d+(max(c))*(2**b)
print(d)
import sys

# sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


a = None


def dfs(root, parent):
    res = 0
    for i in a[root]:
        if i != parent:
            res ^= 1 + dfs(i, root)
    return res


def solve():
    n = read_int()
    global a
    a = [[] for _ in range(n)]
    for i in range(n - 1):
        x, y = read_int_list()
        x -= 1
        y -= 1
        a[x].append(y)
        a[y].append(x)
    return ['Bob', 'Alice'][dfs(0, -1) > 0]


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import random


sys.setrecursionlimit(10 ** 5 + 5)
random.seed = 1

# sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


a = None


def dfs(root, parent):
    res = 0
    for i in a[root]:
        if i != parent:
            res ^= 1 + dfs(i, root)
    return res


def read_tree(check=False):

    if check:
        n, p = gen()
    else:
        n = read_int()
        p = [read_int_list() for i in range(n - 1)]

    global a
    a = [[] for _ in range(n)]
    for x, y in p:
        x -= 1
        y -= 1
        a[x].append(y)
        a[y].append(x)


def gen():
    n = random.randint(5, 30)

    inside = [1]
    outside = list(range(2, n + 1))
    p = []
    for i in range(n - 1):
        x = random.choice(inside)
        y = random.choice(outside)
        p.append([x, y])
        outside.remove(y)
        inside.append(y)
    return n, p


def solve():
    read_tree(check=False)
    return ['Bob', 'Alice'][dfs(0, -1) > 0]


def check():
    for i in range(1000):
        res = solve()
        print(i, res)


def main():
    # check()
    res = solve()
    print(res)


if __name__ == '__main__':
    main()
S=input()
K=int(input())

end=0
if K!=1:
    S_old = S
    i=0
    while S_old[-1] == S_old[i]:
        S= S + S[i]
        i+=1
ans = 0
i=0
while i<len(S)-1:
    renzoku=1
    x=i
    while S[x] == S[i+1]:
        renzoku+=1
        if i+2 < len(S):
            i=i+1
        else:
            break
    if renzoku >1:
        ans+=renzoku//2
    i+=1
if K== 1:
    print(ans)
else:
    S=S_old
    ans = ans*(K-1)
    i=0
    while S[i] == S[0]:
        i+=1
    S=S[i:]
    i=0
    while i<len(S)-1:
        renzoku=1
        x=i
        while S[x] == S[i+1]:
            renzoku+=1
            if i+2 < len(S):
                i=i+1
            else:
                break
        if renzoku >1:
            ans+=renzoku//2
        i+=1
    print(ans)

### FIXED CODE ###

S=input()
K=int(input())
flg=False
for s in S:
    if S[0] != s:
        flg=True
        break
if not flg:
    print(len(S)*K//2)
    exit()
ans = 0
i=0
while i<len(S)-1:
    renzoku=1
    x=i
    while S[x] == S[i+1]:
        renzoku+=1
        if i+2 < len(S):
            i=i+1
        else:
            break

    if renzoku >1:
        ans+=renzoku//2
    i+=1

if S[0] == S[-1]:
    s=S[0]
    top=0
    bottom=0
    i=0
    while S[i] == s:
        top+=1
        i+=1
    i=-1
    while S[i] == s:
        bottom+=1
        i-=1
    if (top%2) + (bottom%2) == 2:
        print((ans+1)*K-1)
        exit()
    
print(ans*K)
S = input()
N = len(S)
n = 0
i = 0

while i < (N-1) / 2
  if S[i] != S[N-1]:
    break
  elif i == (N-1)/2:
    n += 1
    break
  else:
    i += 1
    
s = S[:(N-3)/2]
l = len(s)
i = 0

while i < (l-1) / 2
  if s[i] != s[l-1]:
    break
  elif i == (N-1)/2:
    n += 1
    break
  else:
    i += 1
    
S = S[(N+1)/2:]
i = 0
while i < (l-1) / 2
  if S[i] != S[l-1]:
    break
  elif i == (l-1)/2:
    n += 1
    break
  else:
    i += 1

if n == 3:
  print("Yes")

### FIXED CODE ###

import sys
s = sys.stdin.readline().rstrip()
i = 0
l = len(s)
flag = True
while flag and i <= l:
  if s[i] != s[l-1]:
    flag = False
  i += 1
  l -= 1
l = len(s)
a = s[0:-(-(l-1)//2)]
i = 0
l = len(a)
while flag and i <= l:
  if a[i] != a[l-1]:
    flag = False
  i += 1
  l -= 1
b = s[(len(s) + 3)//2 - 1:]
i = 0
l = len(b)
while flag and i <= l:
  if b[i] != b[l-1]:
    flag = False
  i += 1
  l -= 1
if flag:
  print('Yes')
else:
  print('No')
s = input()
if s[0] == 'Y' and s[1] == 'A' and s[2] == 'K' and s[3] == 'I':
    print('Yes')
else:
    print('No')


### FIXED CODE ###

s = input()
s_list = []
ans = ['Y', 'A', 'K', 'I']
for i in s:
    s_list.append(i)
s_list = s_list[:4]
if s_list == ans:
    print('Yes')
else:
    print('No')
import numpy as np
s = np.array(list(input()))
if s[0] == s[1] and s[1] == s[2]:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

s = list(input())
if s[0] == s[1] and s[1] == s[2]:
    print("No")
else:
    print("Yes")
N = int(input())
I = list(map(int, input().split()))
minX = 1000000
for i in range(1, len(I)):
  minX = min(minX, abs(sum(I[:-i]) - sum(I[-i:]) ) )
  
  
print(minX)

### FIXED CODE ###

A, B = map(int, input().split())
print("Possible" if ((A) % 3 == 0 or (B) % 3 == 0 or (A + B) % 3 == 0) else "Impossible")
n,k = map(int,input().split())
a = list(map(int,input().split()))

hyouten = []


for i in range(n-k+1):

    
    if i>0:
        score_old = a[i-1]
        score = a[i+k-1]
#        print(score_old,score)
        if score >score_old:
            print("Yes")
        else:
            print("No")
    hyouten.append(score)

### FIXED CODE ###

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

#hyouten = []


for i in range(n-k+1):

    
    if i>0:
        score_old = a[i-1]
        score = a[i+k-1]
#        print(score_old,score)
        if score >score_old:
            print("Yes")
        else:
            print("No")
import sys
from fractions import gcd

input = sys.stdin.readline

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
diff = []
ans = []

for i in range(N-1):
    diff.append(x[i+1] - x[i])

for i in range(N-2):
    ans.append(gcd(diff[i], diff[i+1]))

print(min(ans))

### FIXED CODE ###

import sys
from fractions import gcd

input = sys.stdin.readline

N, X = map(int, input().split())
x = list(map(int, input().split()))

if N == 1:
    print(abs(X - x[0]))
    exit()

x.append(X)
x.sort()
diff = []
ans = []

for i in range(N):
    diff.append(x[i+1] - x[i])

for i in range(N-1):
    ans.append(gcd(diff[i], diff[i+1]))

print(min(ans))
s=input()

tmp=0
length=[]

for i in range(len(s)):
    if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
        tmp+=1
    else:
        length.append(tmp)
        tmp=0
print(max(length))

### FIXED CODE ###

s=input()

tmp=0
length=[]

for i in range(len(s)):
    if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
        tmp+=1
        if i==len(s)-1:
            length.append(tmp)
    else:
        length.append(tmp)
        tmp=0
print(max(length))
def solve(a, m): 
    if m < 0 or m > sumA:
        return False
    if m == 0:
        return True
    if len(a) == 0:
        return False
    return solve(a[1:], m - a[0]) or solve(a[1:], m)

n = int(input())
tmp = input().split()
a = []
for i in range(n):
    a.append(int(tmp[i]))
q = int(input())
tmp = input().split()
m = []
for i in range(q):
    m.append(int(tmp[i]))

for i in range(q):
    if solve(a, m[i]):
        print("yes")
    else:
        print("no")



### FIXED CODE ###

def solve(a, m, sumA):
    if m < 0 or m > sumA:
        return False
    if m == 0:
        return True
    if len(a) == 0:
        return False
    return solve(a[1:], m - a[0], sumA) or solve(a[1:], m, sumA)

n = int(input())
tmp = input().split()
a = []
for i in range(n):
    a.append(int(tmp[i]))
q = int(input())
tmp = input().split()
m = []
for i in range(q):
    m.append(int(tmp[i]))

sumA = sum(a)

for i in range(q):
    if solve(a, m[i], sumA):
        print("yes")
    else:
        print("no")
import sys
sys.setrecursionlimit(1000000000)
def popcount(x):
    '''xの立っているビット数をカウントする関数
    (xは64bit整数)'''

    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)

    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
    x = x + (x >> 8) # 16bitごと
    x = x + (x >> 16) # 32bitごと
    x = x + (x >> 32) # 64bitごと = 全部の合計
    return x & 0x0000007f
def main():
    N = int(input())
    X = input()
    d = {}
    dd = {}
    x1 = X.count('1')
    xn = int(X, 2)
    dd[0] = 0
    def hoge(i):
        if i in dd:
            return dd[i]
        if i not in d:
            j = popcount(i)
            d[i] = i % j
            if d[i] == 0:
                dd[i] = 1
            else:
                dd[i] = 1 + hoge(d[i])
        return dd[i]
    if xn == 1:
        xn1 = 0
    else:
        xn1 = xn % (x1-1)
    xn2 = xn % (x1 + 1)
    for i in range(N):
        if X[i] == '1':
            t = xn1
            if xn1 == 0:
                print(0)
                continue
            t -= pow(2, N-1-i, x1-1)
            t %= (x1-1)
        else:
            t = xn2
            t += pow(2, N-1-i, x1+1)
            t %= (x1 + 1)
        if t == 0:
            print(1)
        else:
            print(1 + hoge(t))
main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000000)
def popcount(x):
    '''xの立っているビット数をカウントする関数
    (xは64bit整数)'''

    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)

    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
    x = x + (x >> 8) # 16bitごと
    x = x + (x >> 16) # 32bitごと
    x = x + (x >> 32) # 64bitごと = 全部の合計
    return x & 0x0000007f
def main():
    N = int(input())
    X = input()
    d = {}
    dd = {}
    x1 = X.count('1')
    xn = int(X, 2)
    def hoge(i):
        if i in dd:
            return dd[i]
        if i not in d:
            j = popcount(i)
            d[i] = i % j
            if d[i] == 0:
                dd[i] = 1
            else:
                dd[i] = 1 + hoge(d[i])
        return dd[i]
    if N == 1:
        if X == '1':
            print(0)
            return 0
        else:
            print(1)
            return 1
    if x1 == 1:
        xn1 = 0
    else:
        xn1 = xn % (x1-1)
    xn2 = xn % (x1 + 1)
    for i in range(N):
        if X[i] == '1':
            t = xn1
            if x1-1 == 0:
                print(0)
                continue
            t -= pow(2, N-1-i, x1-1)
            t %= (x1-1)
        else:
            t = xn2
            t += pow(2, N-1-i, x1+1)
            t %= (x1 + 1)
        if t == 0:
            print(1)
        else:
            print(1 + hoge(t))
main()
def main():
    n,q=map(int,input().split())
    s=input()
    td=[list(input().split()) for _ in [0]*q]
    l=0
    r=n-1
    for t,d in td[::-1]:
        if d=="R":
            if r<=n-1:
                if s[r]==t:
                    r-=1
            if l>=1:
                if s[l-1]==t:
                    l-=1
        else:
            if l>=0:
                if s[l]==t:
                    l+=1
            if r<=n-2:
                if s[r+1]==t:
                    r+=1
    print(r-l+1)
main()

### FIXED CODE ###

def main():
    n,q=map(int,input().split())
    s=input()
    td=[list(input().split()) for _ in [0]*q]
    l=0
    r=n-1
    for t,d in td[::-1]:
        if d=="R":
            if 0<=r<=n-1:
                if s[r]==t:
                    r-=1
            if n-1>=l>=1:
                if s[l-1]==t:
                    l-=1
        else:
            if n-1>=l>=0:
                if s[l]==t:
                    l+=1
            if 0<=r<=n-2:
                if s[r+1]==t:
                    r+=1
    print(max(r-l+1,0))
main()
a = input()
print(a**3)

### FIXED CODE ###

x=int(input())
print(x**3)
# Mo's algorithm
# 言ったり来たりバージョン
import sys
from math import sqrt

input = sys.stdin.buffer.readline
n, q = map(int, input().split())
C = list(map(int, input().split()))
bucket_size = int(sqrt(n))
LR = [[] for _ in range(n // bucket_size)]
for i in range(q):
    l, r = map(int, input().split())
    LR[l // bucket_size].append((r, l, i))

# print(LR)

num = 0
count = [0] * (n + 1)


def add_num(idx):
    global num
    c = C[idx]
    if not count[c]:
        num += 1
    count[c] += 1


def del_num(idx):
    global num
    c = C[idx]
    count[c] -= 1
    if not count[c]:
        num -= 1


# 開区間[nl,nr)で考える
nl, nr = 0, 0
ans = [0] * (q)
preb = -1
for i in range(n // bucket_size):
    query = LR[i]
    if not query:
        continue
    query.sort(reverse=(i % 2 == 1))
    for r, l, idx in query:
        l -= 1
        # print(nl, nr, l, r)
        # 区間を広げる時
        while nl > l:
            nl -= 1
            add_num(nl)
        while nr < r:
            add_num(nr)
            nr += 1
        # 区間を狭める時
        while nl < l:
            del_num(nl)
            nl += 1
        while nr > r:
            nr -= 1
            del_num(nr)
        # print("a", num, "idx", idx, "LR", (l, r))
        # print("c", count)
        ans[idx] = num


print(*ans, sep="\n")



### FIXED CODE ###

import sys

input = sys.stdin.buffer.readline
n, q = map(int, input().split())
C = list(map(int, input().split()))
LR = []
for i in range(q):
    l, r = map(int, input().split())
    LR.append((l, r, i))
LR.sort(key=lambda x: x[1])


BIT = [0] * (n + 1)


def update(idx, val):
    while idx <= n:
        BIT[idx] += val
        idx += idx & (-idx)


def query(idx):
    res = 0
    while idx > 0:
        res += BIT[idx]
        idx -= idx & (-idx)
    return res


pos = [-1] * (n + 1)


def func(idx):
    temp = C[idx]
    if pos[temp] == -1:
        pos[temp] = idx + 1
        update(idx + 1, 1)
    else:
        pre = pos[temp]
        pos[temp] = idx + 1
        update(pre, -1)
        update(idx + 1, 1)


ans = [0] * (q)
idx = 0
for i in range(q):
    l, r, ans_num = LR[i]
    # l,rは0-indexに戻す
    l -= 1
    r -= 1
    while idx < r + 1:  # rになるまで増やす
        if idx < n:  # n超えないように注意
            func(idx)
            idx += 1
        else:
            break
    res = 0
    res += query(r + 1)
    if l > 0:
        res -= query(l)
    ans[ans_num] = res

print(*ans, sep="\n")
s=input()
print(A+""+C.join(s[8]))

### FIXED CODE ###

print("A"+input()[8]+"C")
import sys
n,m=map(int,input().split())
S=list(map(int,list(input())))

idx = n
ans=[]
while idx > 0:
    for i in range(1,m+1)[::-1]:
        #print(i,idx,idx-i,S[idx-i])
        if S[idx-i] == 0 and idx-i>=0:
            idx -= i
            ans.append(i)
            break
    else:
        print(-1)
        sys.exit()
print(*ans[::-1])

### FIXED CODE ###

import sys
n,m=map(int,input().split())
S=list(map(int,list(input())))
if m > n:
    m = n
idx = n
ans=[]
while idx > 0:
    for i in range(1,m+1)[::-1]:
        #print(i,idx,idx-i,S[idx-i])
        if S[idx-i] == 0 and idx-i>=0:
            idx -= i
            ans.append(i)
            break
    else:
        print(-1)
        sys.exit()
print(*ans[::-1])
a,b,c=input()
print('YES' if a[-1]==b[0] and b[-1] == c[0] else 'NO')

### FIXED CODE ###

a,b,c=input().split()
print('YES' if a[-1]==b[0] and b[-1] == c[0] else 'NO')
n = int(input())
s = [input() for i in range(n)]

cnt = 0

def is_symmetry():
    for k in range(n):
        for l in range(k+1, n):
            if s_[k][l] != s_[l][k]:
                return false
    return true

for i in range(n):
    i_ = (n+i)%n
    s_ = s[i_:] + s[:i_]
    if is_symmetry()
        cnt += 1

print(cnt*n)

### FIXED CODE ###

n = int(input())
s = [input() for i in range(n)]

cnt = 0

def is_symmetry(s_):
    for k in range(n):
        for l in range(k+1, n):
            if s_[k][l] != s_[l][k]:
                return False
    return True

for i in range(n):
    i_ = (n+i)%n
    s_ = s[i_:] + s[:i_]
    if is_symmetry(s_):
        cnt += 1

print(cnt*n)