Harryxun/stf_run huggingface dataset:
# D
import numpy as np

N, C = map(int, input().split())

C_cost_mat = np.zeros((C, C), dtype="int32")
now_mat = np.zeros((3, C), dtype="int32")

for i in range(C):
    c_list = list(map(int, input().split()))
    for j in range(C):
        C_cost_mat[i][j] = c_list[j]
        
for i in range(N):
    c_list = list(map(int, input().split()))
    for j in range(N):
        now_mat[(i + j + 2) % 3, c_list[j] - 1] += 1
        
res_mat = np.matmul(now_mat, C_cost_mat)

res = 3000
for i1 in range(C):
    for i2 in range(C):
        for i3 in range(C):
            if i1 != i2 and i2 != i3 and i3 != i1:
                res = min(res, res_mat[0, i1] + res_mat[1, i2] + res_mat[2, i3])
print(res)

### FIXED CODE ###

# D
import numpy as np

N, C = map(int, input().split())

C_cost_mat = np.zeros((C, C), dtype="int32")
now_mat = np.zeros((3, C), dtype="int32")

for i in range(C):
    c_list = list(map(int, input().split()))
    for j in range(C):
        C_cost_mat[i][j] = c_list[j]
        
for i in range(N):
    c_list = list(map(int, input().split()))
    for j in range(N):
        now_mat[(i + j + 2) % 3, c_list[j] - 1] += 1
        
res_mat = np.dot(now_mat, C_cost_mat)

res = 1000*N*N
for i1 in range(C):
    for i2 in range(C):
        for i3 in range(C):
            if i1 != i2 and i2 != i3 and i3 != i1:
                res = min(res, res_mat[0, i1] + res_mat[1, i2] + res_mat[2, i3])
print(res)
# 解法は正しいはずだがコーナーケースに引っかかるらしくWAが1個出る

import itertools
import math

D, G = map(int, input().split())

p = {}
c = {}
s = {}
for i in range(1, D + 1):
    pi, ci = map(int, input().split())
    score = 100 * i * pi + ci
    s[i] = score
    p[i] = pi
    c[i] = ci


def complete(pset):
    score = 0
    solved = 0
    comped_max = 0
    for b in pset:
        if b:
            score += s[i]
            solved += p[i]
            comped_max = max(comped_max, i)
    return score, solved, comped_max


def left(norm, i):
    if norm <= 0:
        return 0
    res = int(math.floor(norm / (100 * i)))
    if res < p[i]:
        return res
    return float("inf")


ans = float("inf")
for pset in itertools.product((True, False), repeat=D):
    score, solved, comped_max = complete(pset)
    solved += left(G - score, comped_max)
    ans = min(ans, solved)

print(ans)


### FIXED CODE ###

import itertools
import math

D, G = map(int, input().split())

p = {}
c = {}
s = {}
for i in range(1, D + 1):
    pi, ci = map(int, input().split())
    score = 100 * i * pi + ci
    s[i] = score
    p[i] = pi
    c[i] = ci


def complete(pset):
    score = 0
    solved = 0
    comped = set()
    for i, b in zip(range(1, D + 1), pset):
        if b:
            score += s[i]
            solved += p[i]
            comped.add(i)
    leftset = set(list(range(1, D + 1))) - comped
    return score, solved, leftset


def left(norm, leftset):
    if norm <= 0 or len(leftset) == 0:
        return 0
    i = max(leftset)
    res = int(math.ceil(norm / (100 * i)))
    if res < p[i]:
        return res
    return float("inf")


ans = float("inf")
for pset in itertools.product((True, False), repeat=D):
    score, solved, leftset = complete(pset)
    solved += left(G - score, leftset)
    ans = min(ans, solved)

print(ans)
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def main():
    s = SI()
    t = SI()

    d = {}
    for i, c in enumerate(s):
        if c not in d.keys():
            d[c] = [i]
        else:
            d[c].append(i)

    def init_didx():
        didx = {}
        for k in d.keys():
            didx[k] = 0
        return didx

    didx = init_didx()
    for c in set(t):
        if c not in d.keys():
            print(-1)
            return

    i_loop = 0
    currentidx = 0
    for c in t:
        # 次の文字を読む
        pos = d[c][didx[c]]
        if pos > currentidx:
            # 同じループでいけるならいく
            currentidx = pos
            didx[c] += 1
        else:
            # いけないなら次のループに
            i_loop += 1
            didx = init_didx()
            currentidx = pos

        dprint(c, i_loop, pos)

    print(len(s)*i_loop + pos + 1)

main()

### FIXED CODE ###

import sys
def SI(): return sys.stdin.readline().strip()

def main():
    s = SI()
    t = SI()

    import collections
    d = collections.defaultdict(list)
    for i, c in enumerate(s):
        d[c].append(i)

    keys = d.keys()
    for c in set(t):
        if c not in keys:
            print(-1)
            return

    import bisect

    i_loop = 0
    currentidx = -1
    for c in t:
        # 次の文字を読む
        poslist = d[c]

        # とり切っていない場合
        posidx = bisect.bisect_right(poslist, currentidx)

        if posidx >= len(poslist):
            # とれないなら次のループでとったことにする
            i_loop += 1
            currentidx = poslist[0]
        else:
            # 同じループでとれるなら取って、現在位置を更新
            pos = poslist[posidx]
            currentidx = pos

    print(len(s)*i_loop + currentidx + 1)

main()
n = int(input())
t, a = map(int, input().split())
hl = list(map(int, input().split()))
count = 1
ss = 1000000000
ans = 0
for h in hl:
    if t-h*0.006-a >= 0:
        if float(t-h*0.006-a) < ss:
            ans = count
            count+=1
        else:
            count+=1
    else:
        if float(-t+h*0.006+a) > -ss:
            ans = count
            count+=1
            count+=1
        else:

print(ans)


### FIXED CODE ###

n = int(input())
t, a = map(int, input().split())
hl = list(map(int, input().split()))
ll = [t-h*0.006-a for h in hl]
ans = 1
dd = 1000000000
for i in range(n):
    if ll[i] >= 0 and ll[i] < dd:
        ans = i+1
        dd = ll[i]
    elif ll[i] < 0 and -ll[i] < dd:
        ans = i+1
        dd = -ll[i]
    else:
        pass

print(ans)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy


def main():
  r, c = map(int, input().split())
  g = numpy.array([[1 if v == '.' else 0 for v in input().strip()] for _ in range(r)])
  g = numpy.stack([g, g])

  print(g[0])

  for x in range(1, c):
    g[0, :, x] += g[0, :, x] * g[0, :, x - 1]

  for x in range(c - 2, -1, -1):
    g[0, :, x] = (g[0, :, x] != 0) * numpy.maximum(g[0, :, x], g[0, :, x + 1])

  for y in range(1, r):
    g[1, y] += g[1, y] * g[1, y - 1]

  for y in range(r - 2, -1, -1):
    g[1, y] = (g[1, y] != 0) * numpy.maximum(g[1, y], g[1, y + 1])

  g = g[0] + g[1]

  print(numpy.max(g) - 1)


if __name__ == '__main__':
  main()



### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy


def main():
  r, c = map(int, input().split())
  g = numpy.array([[1 if v == '.' else 0 for v in input().strip()] for _ in range(r)])
  g = numpy.array([g, g])

  for x in range(1, c):
    g[0, :, x] += g[0, :, x] * g[0, :, x - 1]

  for x in range(c - 2, -1, -1):
    g[0, :, x] = (g[0, :, x] != 0) * numpy.maximum(g[0, :, x], g[0, :, x + 1])

  for y in range(1, r):
    g[1, y] += g[1, y] * g[1, y - 1]

  for y in range(r - 2, -1, -1):
    g[1, y] = (g[1, y] != 0) * numpy.maximum(g[1, y], g[1, y + 1])

  g = g[0] + g[1]

  print(numpy.max(g) - 1)


if __name__ == '__main__':
  main()
S = ['Sunny', 'Cloudy', 'Rainy']
today = input()
prnit(S[(S.index(today)+1)%3])

### FIXED CODE ###

S = ['Sunny', 'Cloudy', 'Rainy']
today = input()
print(S[(S.index(today)+1)%3])
from fractions import gcd
 
c,d = [int(i) for i in readline().split()]
 
print(c*d//gcd(c,d))

### FIXED CODE ###

a,b = input().split()
a,b = int(a), int(b)
x = max(a,b)
y = min(a,b)
t = 0
if x % y == 0:
    t = y
else:
    while x % y != 0:
        z = x%y
        x = y
        y = z
    t = z

glm = a * b /t
print(round(glm))
s = list(input())

a = int(s[0]+s[1])
b = int(s[2]+s[3])

if  1<=a<=12 and 1<=b<=12:
  print('AMBIGUOUS')
elif a>12 and 1<=b<=12:
  print('YYMM')
elif b>12 and 1<=a<=12:
  print('MMYY')
elif a>12 and b>12:
  print('NA')
elof a<0 and b<0:
  print('NA')

### FIXED CODE ###

s = list(input())

a = int(s[0]+s[1])
b = int(s[2]+s[3])

if  1<=a<=12 and 1<=b<=12:
  print('AMBIGUOUS')
elif (a>12 or a==0) and 1<=b<=12:
  print('YYMM')
elif (b>12 or b==0) and 1<=a<=12:
  print('MMYY')
elif (a>12 or a==0) and (b>12 or b==0):
  print('NA')
a, b = input(), input()
if (int(a) * int(b)) % 2 == 0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

a, b = input().split()
if (int(a) * int(b)) % 2 == 0:
  print("Even")
else:
  print("Odd")
MOD = 10 ** 9 + 7
N, M = list(map(int, input().split()))
A = sorted(map(int, input().split()), reverse=True) + [-1]
B = sorted(map(int, input().split()), reverse=True) + [-1]

def solve():
    su = 1
    h, w = 0, 0
    for i, n in enumerate(range(N*M, 0, -1)):
        #print("h={}, w={}, i={}, n={}, su={}".format(h, w, i, n, su))
        if su == 0:
            return su
        if A[h] >= n:
            nh = h + 1
        if B[w] >= n:
            nw = w + 1
        if A[h] == B[w] and B[w] == n:
            #print(1)
            pass
        elif A[h] == n:
            #print(2)
            su = (su * nw) % MOD
        elif B[w] == n:
            #print(3)
            su = (su * nh) % MOD
        else:
            #print(4)
            su = (su * (nh * nw - i)) % MOD
        h = nh
        w = nw
    return su
        
            
if any(any(x1 == x2 for x1, x2 in zip(X, X[1:])) for X in [A, B]):
    print(0)
else:
    print(solve())


### FIXED CODE ###

MOD = 10 ** 9 + 7
N, M = list(map(int, input().split()))
A = sorted(map(int, input().split()), reverse=True) + [-1]
B = sorted(map(int, input().split()), reverse=True) + [-1]

def solve():
    su = 1
    h, w = 0, 0
    for i, n in enumerate(range(N*M, 0, -1)):
        #print("h={}, w={}, i={}, n={}, su={}".format(h, w, i, n, su))
        if su == 0:
            return su
        nh, nw = h, w
        if A[h] >= n:
            nh = h + 1
        if B[w] >= n:
            nw = w + 1
        if A[h] == B[w] and B[w] == n:
            #print(1)
            pass
        elif A[h] == n:
            #print(2)
            su = (su * nw) % MOD
        elif B[w] == n:
            #print(3)
            su = (su * nh) % MOD
        else:
            #print(4)
            su = (su * ((nh * nw - i) % MOD)) % MOD
        h = nh
        w = nw
    return su
        
            
if any(any(x1 == x2 for x1, x2 in zip(X, X[1:])) for X in [A, B]):
    print(0)
else:
    print(solve())
n=int(input())
a=list(map(int,input().split()))
mx=0
for i in a:
  mx=max(mx, i)
  if mx-i>1:
    print('No')
    return
print('Yes')

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
mx=0
for i in a:
  mx=max(mx, i)
  if mx-i>1:
    print('No')
    exit()
print('Yes')
from collections import Counter
n, m, k = map(int, input().split())

fgraph = [list() for _ in range(n)]  # 隣接行列のリスト版
bgraph = [list() for _ in range(n)]  # brock関係のグラフ
cgraph = [list() for _ in range(n)]  # 友達候補のグラフ
rks = [None]*n


def dfs(graph, s, r):  # 深さ優先探索
    if rks[s] is None:
        rks[s] = r
    for j in range(len(graph[s])):
        if rks[graph[s][j] - 1] is not None:
            continue
        dfs(graph, graph[s][j]-1, r)


for i in range(m):
    a, b = map(int, input().split())
    fgraph[a-1].append(b)
    fgraph[b-1].append(a)

 # fgraphの連結成分を調べる
c = -1
for i in range(n):
    if rks[i] is None:
        c += 1
        dfs(fgraph, i, c)  # iから始めるDFS。ｃが同じなら同じ連結成分にいる

for i in range(k):
    c, d = map(int, input().split())
    if rks[c-1] == rks[d-1]:  # 同一連結成分の中でのブロック関係のみ注目
        bgraph[c-1].append(d)
        bgraph[d-1].append(c)

counter = Counter(rks)
for i in range(n):
    print(counter[rks[i]] - len(fgraph[i]) - len(bgraph[i]) - 1)

### FIXED CODE ###

import sys
from collections import Counter
input = lambda: sys.stdin.readline().rstrip()
n, m, k = map(int, input().split())

fgraph = [list() for _ in range(n)]  # 隣接行列のリスト版
bgraph = [list() for _ in range(n)]  # brock関係のグラフ
cgraph = [list() for _ in range(n)]  # 友達候補のグラフ
sys.setrecursionlimit(10**9)
rks = [None]*n


def dfs(graph, s, r):  # 深さ優先探索
    if rks[s] is None:
        rks[s] = r
    for j in range(len(graph[s])):
        if rks[graph[s][j] - 1] is not None:
            continue
        dfs(graph, graph[s][j]-1, r)


for i in range(m):
    a, b = map(int, input().split())
    fgraph[a-1].append(b)
    fgraph[b-1].append(a)

 # fgraphの連結成分を調べる
c = -1
for i in range(n):
    if rks[i] is None:
        c += 1
        dfs(fgraph, i, c)  # iから始めるDFS。ｃが同じなら同じ連結成分にいる

for i in range(k):
    c, d = map(int, input().split())
    if rks[c-1] == rks[d-1]:  # 同一連結成分の中でのブロック関係のみ注目
        bgraph[c-1].append(d)
        bgraph[d-1].append(c)

counter = Counter(rks)
for i in range(n):
    print(counter[rks[i]] - len(fgraph[i]) - len(bgraph[i]) - 1)
w, h, x, y = map(int, input().split())

if x > w / 2:
    x = w - x
if y > h / 2:
    y = h - y


if x / w > y / h:
    a = []
    a.append(w * w * y / x / 2)
    a.append(h * h * x / (h - y) / 2)
    a.append(w * w * y / (w - x) / 2)
    a.append(h * h  * (w - x) / (h - y) / 2)
    a.append(x * h)
    a.append(y * w)
else:
    a = []
    a.append(h * h * x / y / 2)
    a.append(h * (h - y) * x / y / 2)
    a.append(w * w * y / (w - x) / 2)
    a.append(w * w * (h - y) / (w - x) / 2)
    a.append(x * h)
    a.append(y * w)

m = max(a)

counter = 0
for i in range(6):
    if a[i] == m:
        counter += 1
if counter >= 2:
    flag = 1
else:
    flag = 0

print(m, flag)


### FIXED CODE ###

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

m = w * h / 2
if x == w / 2 and y == h / 2:
    flag = 1
else:
    flag = 0
print(m, flag)
n, k = map(int, input().split())
x = list(map(int, input().split()))

if 0 in x:
    x.remove(0)
    k -= 1

if k==0:
    print(0)

else:
    flag01 = 0
    flag02 = 0
    
    i=0
    if x[0]>=0:
        print(x[k-1])
    else:
        while(x[i]<0 and i+k-1<n):
            xtmp = x[i:i+k]
            if flag01==1:
                MIN = min(MIN, abs(xtmp[-1]))
                break

            if xtmp[0]<0 and xtmp[1]>0:
                flag01 = 1
            if i<n-k:
                if x[i+k]>0 and x[i+k-1]<0:
                    flag02=1

            if flag02==1:
                MIN = min(MIN, abs(xtmp[0]))             

            if i==0:
                MIN = abs(xtmp[0])+2*abs(xtmp[-1])

            MIN = min(MIN, abs(xtmp[0])+2*abs(xtmp[-1]))
            MIN = min(MIN, 2*abs(xtmp[0])+abs(xtmp[-1]))

            i+=1

        print(MIN)

### FIXED CODE ###

# -*- coding: utf-8 -*-

n, k = map(int, input().split())
X = list(map(int, input().split()))
ans = 10**10
for i in range(n-k+1):
    left = X[i]
    right = X[i+k-1]
    ans = min(ans, abs(left)+abs(left-right), abs(right)+abs(right-left))
print(ans)
import sys
input = sys.stdin.readline
N = int(input())
d = 0
for a in range(1,N):
  for b in range(1,N):
    for c in range(1,N):
      if a*b+c == N:
        d += 1
print(d)

### FIXED CODE ###

S = input("")
if S[-1] == "s":
  print(S+"es")
else:
  print(S+"s")
n=int(input())
a=int(input))
print(n*n-a)

### FIXED CODE ###

n=int(input())
a=int(input())
print(n*n-a)
n, k = map(int,input().split())
al = list(map(int,input().split()))
dics = {}

for i in range(n):
    if al[i] in dics:
        dics[al[i]] = dics[al[i]] + 1
    else:
        dics.update({al[i]:1})
        
counts = len(dics.keys())
kesu = 0
sortv = list(sorted(dics.values()))

if len(sortv) > k:
    for i in range(n-k-1):
        kesu = kesu + sortv[i]
print(kesu)

### FIXED CODE ###

n, k = map(int,input().split())
al = list(map(int,input().split()))
dics = {}
 
for i in range(n):
    if al[i] in dics:
        dics[al[i]] = dics[al[i]] + 1
    else:
        dics.update({al[i]:1})
        
counts = len(dics.values())
kesu = 0
sortv = list(sorted(list((dics.values()))))

i = counts
j = 0
while i > k:
    kesu = kesu + sortv[j]
    i = i - 1
    j = j + 1
print(kesu)
import math
x = input().split()
a,b,c,d = int(x[0]),int(x[1]),int(x[2]),int(x[3])

cn=0
if a%c==0:
    cn+=1
cn+=int(b/c)-int(a/c)
dn=0
if a%d==0:
    dn+=1
dn+=int(b/d)-int(a/d)

cdn=0
cd = c*d/math.gcd(c,d)
if a%cd==0:
    cdn+=1
cdn+=int(b/cd)-int(a/cd)

print((b-a+1)-(cn+dn-cdn))

### FIXED CODE ###

import fractions
x = input().split()
a,b,c,d = int(x[0]),int(x[1]),int(x[2]),int(x[3])

cd = int(c*d/fractions.gcd(c,d))

cn = b // c - (a-1) // c
dn = b // d - (a-1) // d
cdn = b // cd - (a-1) // cd

print((b-a+1)-(cn+dn-cdn))
inputData1 = int(input())
inputData2 = int(input())
ans = 0
if inputData2 % inputData1 ==0:
    ans = inputData1 + inputData2
else:
    ans = inputData2 - inputData1
print(ans)

### FIXED CODE ###

inputData = input().split(' ')
ans = 0

if int(inputData[1]) % int(inputData[0]) ==0:
    ans = int(inputData[0]) + int(inputData[1])
else:
    ans = int(inputData[1]) - int(inputData[0])
print(ans)
N,A,B,C,D=map(int,input().split())
A=A-1
B=B-1
C=C-1
D=D-1

s=input()

if C<D:
    if not "##" in s[A:D+1]:
        ans="Yes"
    else:
        ans="No"
elif D<C:
    if not "##" in s[A:C+1]:
        if "..." in s[B-1:D+1]:
            ans="Yes"
    else:
        ans="No"

print(ans)



### FIXED CODE ###

N,A,B,C,D=map(int,input().split())
A=A-1
B=B-1
C=C-1
D=D-1

s=input()

if A<B<C<D:
    if not "##" in s[B:D+1]:
        if not "##" in s[A:C+1]:
            ans="Yes"
        else:
            ans="No"
    else:
        ans="No"
elif A<B<D<C:
    if not "##" in s[A:C+1]:
        if s[B-1]!="#" and s[B+1]!="#":
            ans="Yes"
        elif "..." in s[B:D+1]:
            ans="Yes"
        elif s[D-1]!="#" and s[D+1]!="#":
            ans="Yes"
        else:
            ans="No"
    else:
        ans="No"
elif A<C<B<D:
    if "##" in s[A:C+1] or "##" in s[B:D+1]:
        ans="No"
    else:
        ans="Yes"
print(ans)
# coding:UTF-8
import math
work = input().split(" ")
a = int(work[0])
b = int(wokr[1])
print(math.ceil((a+b)/2))


### FIXED CODE ###

# coding:UTF-8
import math
work = input().split(" ")
a = int(work[0])
b = int(work[1])
print(math.ceil((a+b)/2))
a, b, n = map(int, input().split())

answer = 0
if b-1 > n:
    x = n
else:
    x = (n // (b-1)) * (b-1)
answer = (a*x)//b - a*(x//b)

print(answer)


### FIXED CODE ###

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

if b > n:
    x = n
else:
    x = n // b * b - 1
answer = max(0, (a*x)//b - a*(x//b))

print(answer)
N = int(input())
ary = []
d2 = []
max = 0
sin_max = 0
for _ in range(N):
  ball = list(map(int, input().split()))
  ary.append(ball)
for i in range(N):
    for j in range(N):
        x = ary[i][0] - ary[j][0]
        y = ary[i][1] - ary[j][1]
        tmp = str(x) + str(y)
        d2.append(tmp)
        max = d2.count(d2[0])
        for i in range(1,N-1):
            if max < d2.count(d2[i]):
                max = d2.count(d2[i])
        sin_max = max
    d2 = []
    max = 0
    sin_max = 0

print(N - sin_max)


### FIXED CODE ###

n=int(input())
if n==1:
	print(1)
	exit()
xy = sorted([list(map(int,input().split())) for i in range(n)])
p=q=0
ans=0
dic={}
for i in range(n-1):
	for j in range(i+1,n):
		p = xy[i][0]-xy[j][0]
		q = xy[i][1]-xy[j][1]
		if (p,q) in dic:
			dic[(p,q)]+=1
		else:
			dic[(p,q)]=1
print(n-max(dic.values()))
def main():
    N = int(input())

    td = {}
    for _ in range(N):
        str = [ci for ci in input()]
        str.sort()
        t = ''.join(str)
        if t not in td.keys():
            td[t] = 0
        else:
            if td[t] == 0:
                td[t] = 1
            else:
                td[t] += td[t] * 2
    count = 0
    for v in td.values():
        count += v
    print(count)


m

### FIXED CODE ###


def main():
    N = int(input())

    A = []
    for _ in range(N):
        a = sorted(list(input()))
        A.append(''.join(a))
    td = {}
    for t in A:
        if t not in td.keys():
            td[t] = 1
        else:
            td[t] += 1
    count = 0
    for v in td.values():
        count += v * (v - 1) // 2
    print(count)


main()
import math

w = input()
total = 0
x = 0
y = 0


n = w[0]
d = w[2]
n = int(n)
d = float(d)


for x in range(n):
    w = input()

    i = w.index(' ')
    y = w[0:i]
    x = w[(i+1):]

    x = int(x)
    y = int(y)

    if math.sqrt((x*x)+(y*y)) <= d:
        total = total+1

print (total)

### FIXED CODE ###

import math

w = input()
total = 0
x = 0
y = 0


i = w.index(' ')
n = w[0:i]
d = w[(i+1):]
n = int(n)
d = float(d)


for x in range(n):
    w = input()

    i = w.index(' ')
    y = w[0:i]
    x = w[(i+1):]

    x = int(x)
    y = int(y)

    if math.sqrt((x*x)+(y*y)) <= d:
        total = total+1

print (total)
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,m = (int(x) for x in input().split())

if n==1:
  if m==1:
    print(0)
  else:
    print(comb(m, 2))
elif m==1:
  print(comb(n, 2))
else:
  print(comb(n, 2)+comb(m, 2))

### FIXED CODE ###

import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,m = (int(x) for x in input().split())

if n<=1:
  if m<=1:
    print(0)
  else:
    print(comb(m, 2))
elif m<=1:
  print(comb(n, 2))
else:
  print(comb(n, 2)+comb(m, 2))
p = str(input())
s = list(p)
k = int(input())

zisyo = []
for i in range(len(s)):
    count = 0
    st = s[i]
    zisyo.append(st)
    while count <= n:
        count = count + 1
        try:
            st = st + s[i + count]
            zisyo.append(st)
        except:
            pass
    
zisyosort = list(sorted(list(set(zisyo))))
print(zisyosort[k-1])

### FIXED CODE ###


s = str(input())
k = int(input())
kouho = [s]

for i in range(len(s)):
    for plus in range(k+1):
        st = s[i:i + plus]
        kouho.append(st)
so = list(sorted(set(kouho)))
if '' in so:
    so.remove('')
    
print(so[k-1])
turn=int(input())
ten=[0,0]

for _ in range(turn):
    hikaku = input().split()
    if hikaku[0] < hikaku[1]:
        ten[1] +=3

    elif hikaku[0]) > hikaku[1]:
        ten[0] +=3

    else:
        ten[0]+=1
        ten[1]+=1

print(" ".join(map(str,ten)))

### FIXED CODE ###

turn=int(input())
ten=[0,0]

for _ in range(turn):
    hikaku = input().split()
    if hikaku[0] < hikaku[1]:
        ten[1] +=3

    elif hikaku[0] > hikaku[1]:
        ten[0] +=3

    else:
        ten[0]+=1
        ten[1]+=1

print(" ".join(map(str,ten)))
import math

x1, y1, x2, y2 = map(int, input().split())

print("{a:5f}".format(
    a=math.sqrt(math.pow(x2 - x1, 2) + math.pow(y2 - y1, 2))))



### FIXED CODE ###

import math

x1, y1, x2, y2 = map(float, input().split())

print(math.sqrt(math.pow(x2 - x1, 2) + math.pow(y2 - y1, 2)))
N = int(input() )
for i in range(N):
  C[i] = (map(int, input().split() ) )
 
C.sort(key=lambda s:s[1] )
 
judge = "Yes"
time = 0
for i in range(N):
  time += C[i][0]
  if time > C[i][1]:
    judge = "No"
    break
print(judge)

### FIXED CODE ###

N = int(input() )
C = []
for i in range(N):
  A, B = map(int, input().split() )
  C.append([A, B])
C.sort(key=lambda s:s[1] )
 
judge = "Yes"
time = 0
for i in range(N):
  time += C[i][0]
  if time > C[i][1]:
    judge = "No"
    break
print(judge)
import collections
N, *A = [int(_) for _ in open(0).read().split()]
win_lose = {i: set() for i in range(1, N + 1)}
for win, lose in zip(A, range(2, N + 1)):
    win_lose[win].add(lose)

memo = [-1] * (N + 1)


def rec(x):
    if memo[x] == -1:
        if win_lose[x] == set():
            memo[x] = 0
        else:
            memo[x] = max(rec(y) for y in win_lose[x]) + len(win_lose[x])
    return memo[x]


for x in win_lose[1]:
    rec(x)
print(1 + max(memo[2:]))


### FIXED CODE ###

import collections
N, *A = [int(_) for _ in open(0).read().split()]
win_lose = {i: set() for i in range(1, N + 1)}
for win, lose in zip(A, range(2, N + 1)):
    win_lose[win].add(lose)

s1 = [1]
s2 = []
while s1:
    a = s1.pop()
    s2 += [a]
    for b in win_lose[a]:
        s1 += [b]
memo = [0] * (N + 1)
for x in s2[::-1]:
    if win_lose[x] == set():
        memo[x] = 0
    else:
        memo[x] = max(a + b for a, b in zip(
            sorted(memo[y] for y in win_lose[x])[::-1], range(1, N + 1)))
print(memo[1])