Harryxun/stf_run huggingface dataset:
import sys
h, w, k = map(int, input().split())
grid = [[int(v) for v in input()] for _ in range(h)]


def ass(v):
    if not v:
        print(-1)
        sys.exit(0)

ass(h > 0 and w > 0 and k > 0)
for row in grid:
    ass(len(row) == w)


def count_ones(i):
    cnt = 0
    while i:
        if i & 1:
            cnt += 1
        i >>= 1
    return cnt

ans = h + w

for state in range(1 << h):
    j = 0
    vcnt = 0
    counters = [0] * (h + 1)
    is_ok = True
    while j < w:
        hi = 0
        i = 0
        local_counters = [0] * (h + 1)
        while i < h:
            if (1 << i) & state:
                hi = i
            # print(hi, i, j)
            # print(grid[i])
            local_counters[hi] += grid[i][j]
            i += 1
        for i, v in enumerate(local_counters):
            if v > k:
                is_ok = False
                break
            counters[i] += local_counters[i]
        if not is_ok:
            break
        if max(counters) > k:
            counters = local_counters.copy()
            vcnt += 1

        j += 1


    if is_ok and ans > count_ones(state) + vcnt:
        ans = count_ones(state) + vcnt
print(ans)



### FIXED CODE ###

import sys
def ass(v):
    if not v:
        print(-1)
        sys.exit(0)

h, w, k = map(int, input().split())
grid = [[1 if v == '1' else 0 for v in input()] for _ in range(h)]


ass(h > 0 and w > 0 and k > 0)
for row in grid:
    ass(len(row) == w)


def count_ones(i):
    cnt = 0
    while i:
        if i & 1:
            cnt += 1
        i >>= 1
    return cnt

ans = h + w

for state in range(1 << h):
    j = 0
    vcnt = 0
    counters = [0] * (h + 1)
    is_ok = True
    while j < w:
        hi = 0
        i = 0
        local_counters = [0] * (h + 1)
        ass(len(counters) == len(local_counters))
        while i < h:
            if (1 << i) & state:
                hi = i
            # print(hi, i, j)
            # print(grid[i])
            ass(len(local_counters) > hi)
            ass(i < h and j < w)
            ass(len(grid) > i)
            ass(len(grid[i]) > j)
            local_counters[hi] += grid[i][j]
            i += 1
        for i, v in enumerate(local_counters):
            if v > k:
                is_ok = False
                break
            counters[i] += local_counters[i]
        if not is_ok:
            break
        # ass(len(counters))
        # ass(k)
        if max(counters) > k:
            counters = local_counters[:]
            vcnt += 1

        j += 1


    if is_ok and ans > count_ones(state) + vcnt:
        ans = count_ones(state) + vcnt
print(ans)
def inpl(): return [int(i) for i in input().split()]
class UnionFind():
    def __init__(self, num):
        self.par = [-1 for _ in range(num)]
        self.dist = [0 for _ in range(num)]
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            x = self.par[x]
            return self.find(x)
    
    def union(self, x, y, d):
        rx = self.find(x)
        ry = self.find(y)
        if rx != ry:
            self.par[ry] = rx
            self.dist[ry] = d + self.dist[x] - self.dist[y]
        elif self.dist[ry] != d + self.dist[x] - self.dist[y]:
            return False
        return True 
    
ans = 'Yes'
N, M = inpl()
X = UnionFind(N)
for _ in range(M):
    l, r, d = inpl()
    if not X.union(l-1, r-1, d):
        ans = 'No'

print(ans)


### FIXED CODE ###

def inpl(): return [int(i) for i in input().split()]
def find(x):
    if par[x] == x:
        return x
    else:
        par[x],dist[x] = find(par[x]),dist[x]+dist[par[x]]
        return par[x]
N, M = inpl()
par = list(range(N+1))
dist = [0 for _ in range(N+1)]

for _ in range(M):
    l, r, d = inpl()
    fl = find(l)
    fr = find(r)
    if fl == fr and d + dist[l] - dist[r] != 0:
        print('No')
        break
    else: 
        par[fr] = fl
        dist[fr] = d + dist[l] - dist[r]
else:
    print('Yes')
from franctions import gcd
a,b,c = map(int, input().split())
if c % gcd(a, b) == 0:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

a,b,c = map(int, input().split())
cnt = 0
for i in range(b+1):
    if i*a%b == c:
        cnt =+ 1
        break
    else:
        continue
print("YES" if cnt == 1 else "NO")
n = int(input())
a = tuple(map(int,input().split()))

a = sorted(a)

print(a[n//2+1]-a[n//2])

### FIXED CODE ###

n = int(input())
a = tuple(map(int,input().split()))

a = sorted(a)

print(a[n//2]-a[n//2-1])
a,b=map(int,input().split())
if a>8 or b8:
  print(":(")
else:
  print("Yay!")

### FIXED CODE ###

a,b=map(int,input().split())
if a>8 or b>8:
  print(":(")
else:
  print("Yay!")
A,B = input().split(" ")
if A+B >= 10:
    print("error")
else:
    print(A+B)

### FIXED CODE ###

A,B = map(int, input().split(" "))
if A+B >= 10:
    print("error")
else:
    print(A+B)
import random, math


A, B = [int(str) for str in input().split()]

def is_prime(q,k=4):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし(但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


if A < B:
    A, B = B, A

div_list = [i for i in make_divisors(B) if A % i == 0]
prime_list = [1] + [i for i in range(1, math.gcd(A, B) + 1) if is_prime(i)]
print(len([i for i in prime_list if i in div_list]))

### FIXED CODE ###

A, B = [int(str) for str in input().split()]

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


print(len(set(prime_factorize(gcd(A, B)))) + 1)
n=int(input())
l=list(map(int,input().split()))
m=l.pop(max(l))
print("Yes" if m>sum(l) else "No")

### FIXED CODE ###

n=int(input())
l=sorted(list(map(int,input().split())))
m=l.pop(-1)
print("Yes" if m<sum(l) else "No")
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= 1

cnt = [0]*(10**5)#何回出たか
cnt2 = [0]*(10**5)#何回目に出てきたか
t = []
nxt = 0
loop = 0

for i in range(10**5):
    cnt[nxt] += 1
    if cnt[nxt] >= 2:
        # print("i: " + str(i))
        # print("nxt: " + str(nxt))
        loop = i - cnt2[nxt]
        modC = cnt2[nxt]
        break
    cnt2[nxt] = i
    t.append(nxt)
    nxt = a[nxt]

modK = (k-modC)%loop
# print("-------")
# print(t)
# print("modC: " + str(modC))
# print("modK: " + str(modK))
# print("loop: " + str(loop))
# print(modK)
# print(loop)
# print("-------")

if k < modC:
    print(t[k] + 1)
else:
    print(t[modC + modK] + 1)

"""
発想はあってる
テストケース公開されたら試してみる！
"""

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= 1

cnt = [0]*(2*10**5)#何回出たか
cnt2 = [0]*(2*10**5)#何回目に出てきたか
t = []
nxt = 0
loop = 0

for i in range(2*10**5):
    cnt[nxt] += 1
    if cnt[nxt] >= 2:
        # print("i: " + str(i))
        # print("nxt: " + str(nxt))
        loop = i - cnt2[nxt]
        modC = cnt2[nxt]
        break
    cnt2[nxt] = i
    t.append(nxt)
    nxt = a[nxt]

modK = (k-modC)%loop
# print("-------")
# print(t)
# print("modC: " + str(modC))
# print("modK: " + str(modK))
# print("loop: " + str(loop))
# print(modK)
# print(loop)
# print("-------")

if k < modC:
    print(t[k] + 1)
else:
    print(t[modC + modK] + 1)

"""
発想はあってる
テストケース公開されたら試してみる！
"""
N = int(input())
A = int(input())
B = int(input())

if N == 1:
    print("Hello World")
if N == 2:
    print(A + B)

### FIXED CODE ###

N = int(input())

if N == 1:
    print("Hello World")
if N == 2:
    A = int(input())
    B = int(input())
    print(A + B)
# C - pushpush
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
    if n % 2 == 0:
        if i % 2 ==0:
            b.append(a[i])
        else:
            b.insert(0,a[i])
    else:
        if i % 2 !=0:
            b.append(a[i])
        else:
            b.insert(0,a[i])


print(' '.join(map(int, b)))

### FIXED CODE ###

# C - pushpush
from collections import deque
n = int(input())
a = list(map(int, input().split()))
b = deque()
for i in range(n):
    if n % 2 == 0:
        if i % 2 ==0:
            b.append(a[i])
        else:
            b.appendleft(a[i])
    else:
        if i % 2 !=0:
            b.append(a[i])
        else:
            b.appendleft(a[i])

print(*b, end=" ")
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    l = list(map(int, input().split()))
    l.sort()

    l_c = [0] * 1001

    for li in l:
        l_c[li] += 1
    for i in range(1000):
        l_c[i + 1] += l_c[i]

    ans = 0

    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            ans += l_c[l[i] + l[j] - 1] - j - 1

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


### FIXED CODE ###

from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    l = list(map(int, input().split()))
    l.sort()

    l_c = [0] * 2001

    for li in l:
        l_c[li] += 1
    for i in range(2000):
        l_c[i + 1] += l_c[i]

    ans = 0

    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            ans += l_c[l[i] + l[j] - 1] - j - 1

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
import sys

x = int(str(sys.stdin.readline()))
y = 1
for i in range(1, x):
	y2 = i * i
	if x < y2:
		break
	y = y2
print(y)



### FIXED CODE ###

import sys


xs = list(sys.stdin.readline().split(' '))
a,b,c,d = [int(x) for x in xs]

f = (lambda x,y: abs(x - y) <= d)
g = (lambda x,y,z: f(x,y) or (f(x,z) and f(y,z)))

if g(a,c, b):
	print("Yes")
else:
	print("No")
import math

def LI():
	return [ int(s) for s in input().split() ]
  
a,b,c = LI()

check = c-b-a 
print('Yes') if check > 0 and 4*a*b < check**2 print('No')

### FIXED CODE ###

import math

def LI():
	return [ int(s) for s in input().split() ]
  
a,b,c = LI()
check = c-b-a 

print('Yes') if check > 0 and 4*a*b < check**2 else print('No')
a = map(int, input().split())
if a.endswith('e'):
 print(a+'s')
elif  a.endswith('s'):
 print(a+'es')
else:
 print(a)

### FIXED CODE ###

S = input()
if S.endswith('s'):
  print(S+'es')
else:
 print(S+'s')
N = int(input())
ac, tle, wa, re = 0

for i in range(n):
    s[i-1] = input()
    
    
    if s[i-1] =="AC":
        ac = ac+1
    elif s[i-1] =="TLE"
        tle = tle+1
    elif s[i-1] =="WA"
        wa = wa+1
    elif s[i-1] =="RE"
        re = re+1

print("AC x "+ac)
print("WA x "+wa)
print("TLE x "+tle)
print("RE x "+re)

### FIXED CODE ###

n = int(input())
s = ""
ac=0
wa=0
tle=0
re=0

for i in range(n):
    s = input()

    if s == 'AC':
        ac = ac+1
    elif s == 'TLE':
        tle = tle+1
    elif s == 'WA':
        wa = wa+1
    elif s == 'RE':
        re = re+1

print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))
n=int(input)
p = list(map(int, input().split()))
ans=0
x=0
for i in range(n+1):
	if p[x] < p[x+1]:
		ans+=1
		x+=1
print(ans)

### FIXED CODE ###

n=int(input())
p = list(map(int, input().split()))
ans=0

for i in range(1,n-1):
  if p[i-1]<p[i]<p[i+1] or p[i+1]<p[i]<p[i-1]:
    ans+=1
print(ans)
a,b = map(int,input().split())
s = list(input())
if s[a] == "-" and len(s) == a+b+1:
  s.remove(s[a])
  for i in range(a+b):
    if i.is_integer() == False:
      print("No")
      break
  else:
    print("Yes")
else:
  print("No")

### FIXED CODE ###

a,b = map(int,input().split())
s = input()
if s[a] == "-" and len(s) == a+b+1 and str.isdecimal(s[:a]) == True and str.isdecimal(s[a+1:]) == True:
    print("Yes")
else:
  print("No")
S = input()
S.sort()
if S[0]==S[1] and S[2]==S[3] and S[1] !=S[2]:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

S = list(input())
S.sort()
if S[0]==S[1] and S[2]==S[3] and S[1] !=S[2]:
  print("Yes")
else:
  print("No")
x, y = map(int, input().split())

print(x+y//c)

### FIXED CODE ###

x,y = map(int,input().split())

print(x+y//2)
s = input()

alp = [0]*26
a_int = ord('a')

if s == "zyxwvutsrqponmlkjihgfedcba":
    ans = -1
else:
    for c in s:
        alp[ord(c)-a_int] = 1

    for i in range(26):
        if alp[i] == 0:
            ans = s+chr(i+a_int)
            break
print(ans)


### FIXED CODE ###

s = input()

alp = [0]*26
a_int = ord('a')

ans = -1
cand = []
if len(s) == 26:
    for i in reversed(range(1, 26)):
        if s[i] < s[i-1]:
            cand.append(s[i])
            continue
        else:
            cand.append(s[i])
            cand = sorted(cand, reverse=True)
            c = min(list(filter(lambda x: x > s[i-1], cand)))
            ans = s[0:i-1]+c
            break

else:
    for c in s:
        alp[ord(c)-a_int] = 1

    for i in range(26):
        if alp[i] == 0:
            ans = s+chr(i+a_int)
            break
print(ans)
print((int(input())/3)^3)


### FIXED CODE ###

s = int(input())
side = s/3
ans = pow(side,3)
print(ans)
from math import pi
r = int(input())
a=r*r*pi
b=(r+r)*pi
print("{0:.6f} {1:.6f}".format( a, b) )


### FIXED CODE ###

from math import pi
r = float(input())
a=r*r*pi
b=(r+r)*pi
print("{0:.6f} {1:.6f}".format( a, b) )
pi = 3.14159265
r = int(input())
print(round(r * r * pi, 6), round(2 * pi * r, 6))

### FIXED CODE ###

from math import pi
r = float(input())
print(round(r * r * pi, 7), round(2 * pi * r, 7))
ia = input()
a = int(ia)
ib = input()
b = int(ib)

ansP = a+b
ansS = a-b
ansM = a*b

max1 = max(ansP,ansS)
max2 = max(max1, ansM)
print(max2)

### FIXED CODE ###

a,b= map(int, input().split())

print(max(a+b,a-b,a*b))
num = input().split(" ")
a = int(num[0])
b = int(num[1])

if a > b:
    print("a > b")
elif a < b:
    print("a > b)
else:
    print("a == b")

### FIXED CODE ###

num = input().split(" ")
a = int(num[0])
b = int(num[1])

if a > b:
    print("a > b")
elif a < b:
    print("a < b")
else:
    print("a == b")
print(48-int(open(0)))

### FIXED CODE ###

print(48-int(input()))
from numba import njit
N = int(input())
a = list(map(int, input().split()))

@njit
def fnc(N,a):
    a.sort(reverse = True)
    p=0
    ppl = [a[0]]*2
    best_index = 1
    best_point = a[0]
    for i in a[1:]:
        p += best_point
        ppl = ppl[:best_index]+[i]+ppl[best_index:]
        #print(ppl)
        point_list = [min(ppl[i],ppl[i+1]) for i in range(0,len(ppl)-1)]
        #print(point_list)
        best_point = max(point_list)
        for j,q  in enumerate(point_list):
            if q == best_point:
                best_index = j+1
                continue
    return p     

print(fnc(N,a))

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))

a.sort(reverse = True)
p = a[0]
for i in range(N-2): #-1は上記a[0]分、もう-1は最初の要素挿入は加点されないため。
    p += a[(i//2)+1]

print(p)
import numpy as np 

np.arange(1, 100, 1)


### FIXED CODE ###

N = int(input())

print(int(N*(N+1)/2))
from decilmal import Decimal as D
mi1,mi2,sa1,sa2,houwa,lim=map(int,input().split())
slim=lim*houwa//100
ws=set(mi1*i+mi2*j for i in range(lim//(100*mi1)+2) for j in range(lim//(100*mi2)+2) if 100*(mi1*i+mi2*j)<=lim)
ss=set(sa1*i+sa2*j for i in range(slim//sa1+2) for j in range(slim//sa2+2) if (sa1*i+sa2*j)<=slim)
ans=D("0")
iw,isa=mi1*100,0
for s in ss:
  for w in ws:
    if s>houwa*w or s==w==0:continue
    if ans<D(str(10000*s))/D(str(s+100*w)) and s+100*w<=lim:
      ans=D(str(10000*s))/D(str(s+100*w))
      isa,iw=s,w
print(100*iw+isa,isa)


### FIXED CODE ###

from decimal import Decimal as D
mi1,mi2,sa1,sa2,houwa,lim=map(int,input().split())
slim=houwa*lim//(100+houwa)
ws=set(mi1*i+mi2*j for i in range(lim//(100*mi1)+2) for j in range(lim//(100*mi2)+2) if 100*(mi1*i+mi2*j)<=lim)
ss=set(sa1*i+sa2*j for i in range(slim//sa1+2) for j in range(slim//sa2+2) if (sa1*i+sa2*j)<=slim)
ans=D("0")
iw,isa=mi1,0
for s in ss:
  for w in ws:
    if s>houwa*w or w==0:continue
    if ans<D(str(10000*s))/D(str(s+100*w)) and s+100*w<=lim:
      ans=D(str(10000*s))/D(str(s+100*w))
      isa,iw=s,w
print(100*iw+isa,isa)
n, k = map(int, input().split())
a = list(map(int, input().split()))
x=bin(k)[2:]

ans=0
flag=True

for i in range(50):
    count=0
    for j in range(n):
        if (a[j]>>(50-i-1))&1==1:
            count+=1

    if 50-i>len(x):
        ans+=（2**(50-i-1)）*count

    elif not flag:
        ans+=（2**(50-i-1)）*max(count, n-count)
    else:
        if 2*count>=n:
            if int(x[-(50 - i)]) == 1:
                ans+=（2**(50-i-1)）*count
                flag=False
            else:
                ans +=（ 2 ** (50 - i - 1)） * count

        else:
            if int(x[-(50-i)])==1:
                ans+=（2**(50-i-1)）*(n-count)
            else:
                ans+=（2**(50-i-1)）*count
      

print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
x=bin(k)[2:]

ans=0
flag=True

for i in range(50):
    count=0
    for j in range(n):
        if (a[j]>>(50-i-1))&1==1:
            count+=1

    if 50-i-1>len(x)-1:
        ans+=2**(50-i-1)*count

    elif not flag:
        ans+=2**(50-i-1)*max(count, n-count)
    else:
        if 2*count>=n:
            if int(x[-(50 - i)]) == 1:
                ans+=2**(50-i-1)*count
                flag=False
            else:
                ans += 2 ** (50 - i - 1) * count
        
        else:
            if int(x[-(50-i)])==1:
                ans+=2**(50-i-1)*(n-count)
            else:
                ans+=2**(50-i-1)*count

print(ans)
import sys

def check(operate_list, num_list):
    res = num_list[0]
    for i, op in enumerate(operate_list):
        if op == "+":
            res += num_list[i+1]
        elif op == "-":
            res -= num_list[i+1]
    return res == 7

def concat(operate_list, num_list):
    string = num_list[0]
    for op, num in zip(operate_list, num_list[1:]):
        # it is beautiful!
        string += op
        string =+ num
    string += "=7"
    return string

def main():
    line = sys.stdin.readline().strip()
    num_list = []
    for s in line:
        num_list.append(int(s))
    result = ""
    stack = []
    stack.append([])
    N = len(num_list)
    while(len(stack) != 0):
        l = stack.pop()
        if len(l) == N-1:
            if check(l, num_list):
                result = concat(l, num_list)
                break
        else:
            stack.append(l + ["+"]) # careful code
            stack.append(l + ["-"])

    print(result)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys

def check(operate_list, num_list):
    res = num_list[0]
    for i, op in enumerate(operate_list):
        if op == "+":
            res += num_list[i+1]
        elif op == "-":
            res -= num_list[i+1]
    return res == 7

def concat(operate_list, num_list):
    num_list = list(map(str, num_list))
    string = num_list[0]
    for op, num in zip(operate_list, num_list[1:]):
        # it is beautiful!
        string += op
        string += num
    string += "=7"
    return string

def main():
    line = sys.stdin.readline().strip()
    num_list = []
    for s in line:
        num_list.append(int(s))
    result = ""
    stack = []
    stack.append([])
    N = len(num_list)
    while(len(stack) != 0):
        l = stack.pop()
        if len(l) == N-1:
            if check(l, num_list):
                result = concat(l, num_list)
                break
        else:
            stack.append(l + ["+"]) # careful code
            stack.append(l + ["-"])

    print(result)

if __name__ == "__main__":
    main()
n,m,k=map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
result = 0
count = 0
while True:
  if not a and not b:
    print(count)
  if result > k:
    print(count-1)
    break
  if not a:
    result += b.pop()
    count += 1
  elif not b:
    result += a.pop()
    count += 1
  elif a[0] < b[0]:
    result += a.pop(0)
    count += 1
  else:
    result += b.pop(0)
    count += 1

### FIXED CODE ###

n,m,k=map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a, b = [0], [0]

for i in range(n):
  a.append(a[i] + A[i])
for i in range(m):
  b.append(b[i] + B[i])
  
ans, j = 0, m

for i in range(n+1):
  if a[i] > k:
    break
  while b[j] > k - a[i]:
    j -= 1
  ans = max(ans, i + j)
  
print(ans)
n, d = map(int, input().split())
count = 0
x_list = (list(map(int, input().split())) for _ in range(n)))

for i in range(n-1):
    for j in range(i+1, n):
        count += (sum((a-b)**2 for a,b in zip(x_list[i], x_list[j]))**0.5).is_integer
print(count)

### FIXED CODE ###

import math

n, d = map(int, input().split())
x_list = []
count = 0

for i in range(n):
    x_list.append([int(i) for i in input().split()])

for i in range(len(x_list)-1):
    for j in range(i+1, len(x_list)):
        cal = 0
        for k in range(d):
            cal += (x_list[i][k] - x_list[j][k])**2
        if math.sqrt(cal) == int(math.sqrt(cal)):
            count += 1

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

fromLeft = [-1]*n

for i in range(n):
    fromLeft[i] = a[i] - i

ans = 0

ldList = [0]*(3*10**5)

for i in reversed(range(n)):
    if -1*fromLeft[i] < 3*10**5-10:
        ldList[-1*fromLeft[i]] += 1
    if a[i]+i < 3*10**5-10:
        ans += ldList[a[i]+i]

print(ans)

### FIXED CODE ###

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

fromLeft = [-1]*n

for i in range(n):
    fromLeft[i] = a[i] - i

ans = 0

ldList = [0]*(n*2+5)

for i in reversed(range(n)):
    if 0 <= fromLeft[i]+n+1 and fromLeft[i]+n+1 < n*2+5:
        ldList[fromLeft[i]+n+1] += 1
    if 0 <= -1*a[i]-i+n+1 and -1*a[i]-i+n+1 < n*2+5:
        ans += ldList[-1*a[i]-i+n+1]

print(ans)
x, y = list(map(int, input().split()))
if y - x >= 0:
    ans = y - x
if y + x >= 0:
    ans = min(ans, y + x + 1)
if -y - x >= 0:
    ans = min(ans, -y - x + 1)
if -y + x >= 0:
    ans = min(ans, -y + x + 2)
print(ans)


### FIXED CODE ###

x, y = list(map(int, input().split()))
ans = []
if y - x >= 0:
    ans.append(y - x)
if y + x >= 0:
    ans.append(y + x + 1)
if -1 * y - x >= 0:
    ans.append(-1 * y - x + 1)
if -1 * y + x >= 0:
    ans.append(-1 * y + x + 2)
print(min(ans))
a,b=map(int, input().split())
print a>10?b:b+800

### FIXED CODE ###

a,b=map(int, input().split())
x = b if a>10 else b+((10-a)*100)
print(x)
while True:
    x = input().split()
    H = x[0]
    W = x[1]
    if H == 0 and W == 0:
        break
    for i in range(0,H):
        print "#"*W

### FIXED CODE ###

while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    a = [["#" for j in range(W)] for i in range(H)]
    b = ["".join(a[i]) for i in range(H)]
    for i in range(H):
        print(b[i])
    print()