Harryxun/stf_run huggingface dataset:
a, b, k = map(int, input().split())
divisers = []

for i in range(1, max(a, b)):
    if a % i == 0 and b % i == 0:
        divisers.append(i)

print(divisers[-k])


### FIXED CODE ###

a, b, k = map(int, input().split())
divisers = []

for i in range(1, min(a, b) + 1):
    if a % i == 0 and b % i == 0:
        divisers.append(i)

print(divisers[-k])
n, k = map(int, input().split())
p = sorted(list(int, input().split()))

ans = 0
for i in range(k):
    ans += p[i]

print(ans)

### FIXED CODE ###

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

ans = 0
for i in range(k):
    ans += p[i]

print(ans)
N, K = map(int, input().split())
N = abs(N - K)
if N // 10 == 0:
    while N > 100:
        N = N / 100
while N > 0:
    N = (N - K) 
print(abs(N))

### FIXED CODE ###

a, b, c = map(int, input().split())
print(c, a, b)
def main():
    from collections import defaultdict
    import sys
    sys.setrecursionlimit(100000)
    n, *rem = map(int, open(0).read().split())
    t = 3 * (n - 1)
    abc = rem[:t]
    q, k = rem[t], rem[t + 1]
    xy = rem[t + 2:]

    m = [[] for _ in range(n + 1)]
    dist = defaultdict(dict)
    for a, b, c in zip(*[iter(abc)] * 3):
        m[a].append(b)
        m[b].append(a)

        dist[a].update({b: c})
        dist[b].update({a: c})

    vis = [False] * (n + 1)
    cost = [0] * (n + 1)
    vis[k] = True

    def dfs(frm, to):
        if vis[to]:
            return
        vis[to] = True
        cost[to] = cost[frm] + dist[frm][to]
        frm = to
        for to in m[frm]:
            dfs(frm, to)

    frm = k
    for to in m[frm]:
        dfs(frm, to)

    tmp = []
    for x, y in zip(*[iter(xy)] * 2):
        tmp.append(cost[x] + cost[y])

    ans = "\n".join(map(str, tmp))
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    from collections import defaultdict
    import sys
    sys.setrecursionlimit(1000000)
    n, *rem = map(int, open(0).read().split())
    t = 3 * (n - 1)
    abc = rem[:t]
    q, k = rem[t], rem[t + 1]
    xy = rem[t + 2:]

    m = [[] for _ in range(n + 1)]
    dist = defaultdict(dict)
    for a, b, c in zip(*[iter(abc)] * 3):
        m[a].append(b)
        m[b].append(a)

        dist[a].update({b: c})
        dist[b].update({a: c})

    vis = [False] * (n + 1)
    cost = [0] * (n + 1)
    vis[k] = True

    def dfs(frm, to):
        if vis[to]:
            return
        vis[to] = True
        cost[to] = cost[frm] + dist[frm][to]
        frm = to
        for to in m[frm]:
            dfs(frm, to)

    frm = k
    for to in m[frm]:
        dfs(frm, to)

    tmp = []
    for x, y in zip(*[iter(xy)] * 2):
        tmp.append(cost[x] + cost[y])

    ans = "\n".join(map(str, tmp))
    print(ans)


if __name__ == '__main__':
    main()
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n + 1)]
for i in range(n):
	b[i + 1] = b[i] + a[i]
# b[i] = sum(a[:i])

suma = sum(a)
border = suma / 4

def func1(start_index, bit):
	# bit: 0 -> border を超えない, 1 -> border を超える
	end_index = start_index + 1
	
	if bit == 0:
		while b[end_index] - b[start_index] < border:
			end_index += 1
		if end_index == start_index + 1:
			return end_index, b[end_index] - b[start_index]
		else:
			return end_index - 1, b[end_index - 1] - b[start_index]

	elif bit == 1:
		while b[end_index] - b[start_index] < border:
			end_index += 1
		return end_index, b[end_index] - b[start_index]

def func2(bits):
	# bits: 0~7
	starts = [0]
	sums = []

	for i in range(3):
		f = func1(starts[-1], bits % 2)
		bits = bits // 2
		starts.append(f[0])
		sums.append(f[1])

	sums.append(b[n] - b[f[0]])

	return max(sums) - min(sums)

candidates = []

for i in range(8):
	candidates.append(func2(i))

print(min(candidates))

### FIXED CODE ###

from bisect import bisect, bisect_left

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

ans = float("inf")
for j in range(2, n-1):
	c = []
	f = bisect(b, b[j]/2)
	f -= 1
	if f == 0 or j == 2:
		c += [b[1]-b[0], b[j]-b[1]]
	elif f == j-1:
		c += [b[j-1]-b[0], b[j]-b[j-1]]
	else:
		if abs(b[f]-b[0] - (b[j]-b[f])) <= abs(b[f+1]-b[0] - (b[j]-b[f+1])):
			c += [b[f]-b[0], b[j]-b[f]]
		else:
			c += [b[f+1]-b[0], b[j]-b[f+1]]

	l = bisect(b, b[j]+((b[n]-b[j])/2))
	l -= 1
	#print(l)
	if l == j or j == n-2:
		c += [b[j+1]-b[j], b[n]-b[j+1]]
	elif l == n-1:
		c += [b[n-1]-b[j], b[n]-b[n-1]]
	else:
		if abs(b[l]-b[j] - (b[n]-b[l])) <= abs(b[l+1]-b[j] - (b[n]-b[l+1])):
			c += [b[l]-b[j], b[n]-b[l]]
		else:
			c += [b[l+1]-b[j], b[n]-b[l+1]]

	ans = min(ans, max(c)-min(c))

print(ans)
import sys
 
args = sys.argv
prices = list(map(int, args[2:]))
min = prices[0]
max_profit = 0

for price in prices[1:]:
    max_profit = price - min
    if min > price:
        min = price

print(max_profit)


### FIXED CODE ###

n = input()
prices = list()
for idx in range(int(n)):
    tmp = input()
    prices.append(int(tmp))

minp = prices[0]
maxv = prices[1] - prices[0]

for price in prices[1:]:
    maxv = max(maxv, price - minp)
    minp = min(minp, price)

print(maxv)
n,m,x = map(int, input().split())
costs = [list(map(int, input().split())) for _ in range(n)]

'''
n,m,x = [int(i) for i in input().split()]
costs =[]

for i in range(n):
    a = [int(i) for i in input().split()]
    costs.append(a)
'''


INF = 1000000000000000000000000000
ans = INF

for i in range(1<<n):  #n bits all searches
    # 1<<n == 2**n
    c = 0
    sums = [0]*m
    for j in range(n):
        if i>>j & 1: #i>>j %2 == 1  is also fine.
            #apply this candidate. 
            c += costs[j][0]
            for k in range(m):
                sums[k] += costs[j][k+1]
    
'''
    cost = 0
    c = 0
    sums = [0] * m
    use_index=[]
    for j in range(n):
        if i%2==1:
            use_index.append(j)
        i >>= 1
    
    for v in use_index:
        c += costs[v][0]        
        for j in range(m):
            sums[j] += costs[v][j+1]
'''

    if min(sums) >= x:
        ans = min(ans, c)

'''            
    judge=True
    for j in range(m):
        if sums[j]<x:
            judge=False
            break
    
    if judge:
        ans = min(ans, c)
'''
ans = -1 if ans==INF 
print(ans)



### FIXED CODE ###

import numpy as np

n,m,x = [int(i) for i in input().split()]
costs =[]
maa = 1000000000000000000000000000
ans = maa

for i in range(n):
    a = [int(i) for i in input().split()]
    costs.append(a)
    
for i in range(1,2**n+1):
    cost = 0
    c = 0
    sums = [0] * m
    use_index=[]
    for j in range(n):
        if i%2==1:
            use_index.append(j)
        i >>= 1
    
    for v in use_index:
        c += costs[v][0]        
        for j in range(m):
            sums[j] += costs[v][j+1]
            
    judge=True
    for j in range(m):
        if sums[j]<x:
            judge=False
            break
    
    if judge:
        ans = min(ans, c)

if ans ==maa:
    print(-1)
else:
    print(ans)
# ABC088D - Grid Repainting
import sys

input = sys.stdin.readline


def dfs(x: int, y: int, cur: int) -> None:
    D[x][y] = cur
    for dx, dy in dxy:
        a, b = x + dx, y + dy
        if a < H and b < W and S[a][b] == "." and D[a][b] == 0:
            dfs(a, b, cur + 1)


def main():
    global H, W, S, D, dxy
    H, W = tuple(map(int, input().split()))
    S = tuple(input().rstrip() for _ in range(H))
    D = [[0] * W for _ in range(H)]  # distance
    dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    dfs(0, 0, 1)
    white, x = sum(s.count(".") for s in S), D[-1][-1]
    ans = white - x if x else -1
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC088D - Grid Repainting
import sys
input = sys.stdin.readline

from collections import deque

def bfs() -> None:
    q = deque([(0, 0)])
    while q:
        x, y = q.popleft()
        for dx, dy in dxy:
            nx, ny = x + dx, y + dy  # next x, y
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == "." and dist[nx][ny] == 0:
                q.append((nx, ny))
                dist[nx][ny] = dist[x][y] + 1


def main():
    global H, W, S, dist, dxy
    H, W = tuple(map(int, input().split()))
    S = tuple(input().rstrip() for _ in range(H))
    dist = [[0] * W for _ in range(H)]  # distance from (0, 0) to (x, y)
    dist[0][0] = 1
    dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    bfs()
    white, x = sum(s.count(".") for s in S), dist[-1][-1]
    ans = white - x if x else -1
    print(ans)


if __name__ == "__main__":
    main()
#coding:utf-8
import numpy as np
c = np.array(list(map(int, input().split())))
if np.sum(c)/3 == c[0]+c[4]+c[8]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

#coding:utf-8
n = int(input())
a = int(input())
if n%500 <= a:
    print("Yes")
else:
    print("No")
from collections import defaultdict
from numba import njit, b1, i4, i8, f8
import numpy as np

@njit
def get_prime_factors(x):
    out = set()
    if x < 1:
        return out
    while not x%2:
        out.add(2)
        x //= 2
    i = 3
    while i*i <= x:
        if not x%i:
            out.add(i)
            x //= i
        else:
            i += 2
    if x != 1:
        out.add(x)
    return out

@njit
def main():
    n = int(input())
    a = list(map(int, input().split()))
    df = defaultdict(lambda : 0)
    
    
    for ai in a:
        primes = get_prime_factors(ai)
        for prime in primes:
            df[prime] += 1
    if df.values():
        val = max(df.values())
        if val == 1:
            print("pairwise coprime")
        elif val == n:
            print("not coprime")
        else:
            print("setwise coprime")
    else:
        print("pairwise coprime")


main()


### FIXED CODE ###

from collections import defaultdict


def get_prime_factors(x):
    out = set()
    if x < 1:
        return out
    while not x%2:
        out.add(2)
        x //= 2
    i = 3
    while i*i <= x:
        if not x%i:
            out.add(i)
            x //= i
        else:
            i += 2
    if x != 1:
        out.add(x)
    return out


def main():
    n = int(input())
    a = list(map(int, input().split()))
    df = defaultdict(lambda : 0)
    for ai in a:
        primes = get_prime_factors(ai)
        for prime in primes:
            df[prime] += 1
    if df.values():
        val = max(df.values())
        if val == 1:
            print("pairwise coprime")
        elif val == n:
            print("not coprime")
        else:
            print("setwise coprime")
    else:
        print("pairwise coprime")

if __name__ == "__main__":
    main()
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	A,B = inputMap()

	ans = 0
	to = 0
	flg = False
	while True:
		ans += 1
		if flg == False:
			to += A
			flg = True
		else:
			to = (tp-1) + A
		if to >= B:
			break

	print(ans)

if __name__ == "__main__":
	main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	A,B = inputMap()

	if B == 1:
		print(0)
		sys.exit()

	ans = 0
	to = 0
	flg = False
	while True:
		ans += 1
		if flg == False:
			to += A
			flg = True
		else:
			to = (to-1) + A

		if to >= B:
			break

	print(ans)

if __name__ == "__main__":
	main()
m1,d1 = map(int,input().split())
m2,d2 = map(int,input().split())

if mi == m2:
    print(0)
else:
    print(1)

### FIXED CODE ###

m1,d1 = map(int,input().split())
m2,d2 = map(int,input().split())

if m1 == m2:
    print(0)
else:
    print(1)
age= int(input())
if age=7 or 5 or 3:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

age= int(input())
if age== 7:
  print('YES')
elif age== 5:
  print('YES')
elif age== 3:
  print('YES')
else:
  print('NO')
import math
A, B = map(int,input().split())

GCD = fractions.gcd(A,B)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

l = factorization(GCD)
if len(l) == 1:
    print(len(l))
else:
    print(len(l)+1)



### FIXED CODE ###

import fractions
import sys
A, B = map(int,input().split())

GCD = fractions.gcd(A,B)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

l = factorization(GCD)
if len(l) == 1 and l[0][0] == 1:
    print(len(l))
else:
    print(len(l)+1)
import math
s = int(input())
m = int(s**0.5)

l = s - m*m
if l<0:
    m = m-1
    l = s - m*m



if l < 1000000000 and m < 1000000000:
    print(0,1,m,0,l,m+1)
    #print(m*m + l)
elif m = 1000000000:
    print(0,0,m,0,0,m)

    


### FIXED CODE ###

s = int(input())
m = int(s**0.5)

l = s - m*m
if l<0:
    m = m-1
    l = s - m*m



if l < 1000000000 and m < 1000000000:
    print(0,1,m,0,l,m+1)
    #print(m*m + l)
elif m == 1000000000:
    print(0,0,m,0,0,m)
else:
    l = (m+1)*(m+1)-s
    if l < 1000000000:
        print(0,0,m+1,1,l,m+1)
    else:
        for i in range(2,int(l**0.5) +1):
            if l%i == 0:
                t =i
                break
        print(0,0,m+1,t,l//t,m+1)
import math

class Point:
    def __init__(self, num_x, num_y):
        self.x = num_x
        self.y = num_y

def kock(n, p1, p2):
    if n == 0:
        return
    
    s = Point((2 * p1.x + 1 * p2.x) / 3.0, (2 * p1.y + 1 * p2.y) / 3.0)
    t = Point((1 * p1.x + 2 * p2.x) / 3.0, (1 * p1.y + 2 * p2.y) / 3.0)
    u = Point(0, 0)
    u.x = (t.x - s.x) * math.cos(math.pi / 3) - (t.y - s.y) * math.cos(math.pi / 3) + s.x
    u.y = (t.x - s.x) * math.sin(math.pi / 3) - (t.y - s.y) * math.cos(math.pi / 3) + s.y

    kock(n - 1, p1, s)
    print "%f %f" % (s.x, s.y)
    kock(n - 1, s, u)
    print "%f %f" % (u.x, u.y)
    kock(n - 1, u, t)
    print "%f %f" % (t.x, t.y)
    kock(n - 1, t, p2)
    
n = input()

p1 = Point(0, 0)
p2 = Point(100, 0)

print "%f %f" % (p1.x, p1.y)
kock(n, p1, p2)
print "%f %f" % (p2.x, p2.y

### FIXED CODE ###

import math

class Point:
    def __init__(self, num_x, num_y):
        self.x = num_x
        self.y = num_y

def kock(n, p1, p2):
    if n == 0:
        return

    s = Point(0, 0)
    t = Point(0, 0)
    u = Point(0, 0)

    s.x = (2 * p1.x + p2.x) / 3.0
    s.y = (2 * p1.y + p2.y) / 3.0
    t.x = (p1.x + p2.x * 2) / 3.0
    t.y = (p1.y + p2.y * 2) / 3.0
    u.x = (t.x - s.x) * math.cos(math.pi / 3) - (t.y - s.y) * math.sin(math.pi / 3) + s.x
    u.y = (t.x - s.x) * math.sin(math.pi / 3) + (t.y - s.y) * math.cos(math.pi / 3) + s.y

    kock(n - 1, p1, s)
    print "%.8f %.8f" % (s.x, s.y)
    kock(n - 1, s, u)
    print "%.8f %.8f" % (u.x, u.y)
    kock(n - 1, u, t)
    print "%.8f %.8f" % (t.x, t.y)
    kock(n - 1, t, p2)

n = input()

p1 = Point(0, 0)
p2 = Point(100, 0)

print "%.8f %.8f" % (p1.x, p1.y)
kock(n, p1, p2)
print "%.8f %.8f" % (p2.x, p2.y)
z = list(map(int, input().split()))
x = z[0]
if z[1] == 0:
  print(z[0])
else:
  p = list(map(int, input().split()))
  count = 0
  l = []
  for i in range(-150, 150):
    l.append(i)
  for i in p:
    l.remove(i)
  t = 200
  for i in l:
    e = abs(x-i)
    if e >= t:
      break
    t = e
    ans = i
  print(ans)

### FIXED CODE ###

z = list(map(int, input().split()))
x = z[0]
if z[1] == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  l = []
  for i in range(-1, 102):
    l.append(i)
  for i in p:
    l.remove(i)
  t = 200
  for i in l:
    e = abs(x-i)
    if e >= t:
      break
    t = e
    ans = i
  print(ans)
a=input()
b=input()
dic={}
def findout(i,j):
    if (i,j) in dic:
        return dic[(i,j)]
    
    if i==0 and j==0:
        if a[i]==b[j]:
            return a[i]
        else:
            return ""
    
    elif i==0 and j>0:
        if a[i]==b[j]:
            
            return a[i]
        else:
            
            dic[(i,j)] = findout(i,j-1)
            return dic[(i,j)]
    
    elif i>0 and j==0:
        if a[i]==b[j]:
            return b[j]
        else:
            dic[(i,j)]=findout(i-1,j)
            return dic[(i,j)]
    else:
        if a[i]==b[j]:
            dic[(i,j)]=findout(i-1,j-1)+a[i]
            return dic[(i,j)]
        else:
            temp1=findout(i,j-1)
            temp2=findout(i-1,j)
            if len(temp1)>len(temp2):
                dic[(i,j)]=temp1
            else:
                dic[(i,j)]=temp2
            return dic[(i,j)]
print(findout(len(a)-1,len(b)-1))

### FIXED CODE ###

a="0"+input()
b="1"+input()
dp=[[0]*len(b) for i in range(len(a))]
for i in range(len(a)):
    for j in range(len(b)):
        if a[i]==b[j]:
            if i>0 and j>0:
                dp[i][j]=dp[i-1][j-1]+1
            else:
                dp[i][j]=1
        else:
            if i>0 and j>0:
                dp[i][j]=max(dp[i-1][j],dp[i][j-1])
            elif i==0 and j>0:
                dp[i][j]=dp[i][j-1]
            elif i>0 and j==0:
                dp[i][j]=dp[i-1][j]
            else:
                dp[i][j]=0

ans = []
x,y=len(a)-1,len(b)-1
lcs = dp[x][y]
while x > 0 or y > 0:
    if x-1 >= 0 and dp[x-1][y] == lcs:
        x -= 1
    elif y-1 >= 0 and dp[x][y-1] == lcs:
        y -= 1
    else:
        ans.append(a[x])
        y -= 1
        x -= 1
        
        lcs -= 1
print("".join(ans[::-1]))
N, R, G, B = map(int, input().split())
ans = 0
for i in range(R):
    for j in range(G):
        if 0 <= N-i-j <= b:
            ans += 1
print(ans)


### FIXED CODE ###

R, G, B, N = map(int, input().split())
ans = 0
r=0
while r*R <= N:
    g=0
    while r*R + g*G <= N:
        if (N - r*R - g*G) % B == 0:
            ans += 1
        g += 1
    r += 1
print(ans)
W, H, x, y, r = map(int, input().split())
if x >= r and x + r <= W and y >= r and y + r <=
print("Yes")
else:
print("No")


### FIXED CODE ###

W, H, x, y, r = map(int, input().split())
if x >= r and x + r <= W and y >= r and y + r <= H:
  print("Yes")
else:
  print("No")
N,M = [int(c) for c in input().split()]
ab = [list(map(int,input().split())) for c in range(N)]
cd = [list(map(int,input().split())) for c in range(M)]
for i in range(N):
    mi = 2*10**8
    for j in range(M):
        tmp = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if mi > tmp:
            mi = tmp
            ans = j+1
    print(ans)


### FIXED CODE ###

N,M = [int(c) for c in input().split()]
ab = [list(map(int,input().split())) for c in range(N)]
cd = [list(map(int,input().split())) for c in range(M)]
for i in range(N):
    mi = 2*10**9
    for j in range(M):
        tmp = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if mi > tmp:
            mi = tmp
            ans = j+1
    print(ans)
N, K = [int(x) for x in input().split(" ")]
 
placed = 0
elm = []
for i in range(N):
  a, b = input().split(" ")
  elm.append({
    "order": i + 1,
    "element": int(a),
    "count": int(b)
  })

elm.sort(key=lambda e: (e["element"], e["order"]))
for i in range(len(elm)):
  placed = e["count"]
  if placed >= K:
    print(e["element"])
    break


### FIXED CODE ###

N, K = [int(x) for x in input().split(" ")]
 
placed = 0
elm = []
for i in range(N):
  a, b = input().split(" ")
  elm.append({
    "order": i + 1,
    "element": int(a),
    "count": int(b)
  })

elm.sort(key=lambda e: (e["element"], e["order"]))
for i in range(len(elm)):
  e = elm[i]
  placed += e["count"]
  if placed >= K:
    print(e["element"])
    break
a,b=map(int, input().split())
if a<=5:
  b=0
elif 6<=a<=12:
  b=b/2
  
 print(b)

### FIXED CODE ###

a,b=map(int, input().split())
if a<=5:
    b=0
elif 6<=a<=12:
    b=b/2
print(int(b))
a, b = input().split()
a= int(a)
b = int(b)
if not len(a) ==2;
 if not len(b) == 2;
  print(a*b)
else:
  print("-1")


### FIXED CODE ###

import sys
a, b = map(int, input().split())
k = range(1,10)
if a in k:
 if b in k:
  print(a*b)
  sys.exit()
 else:
  pass
print("-1")
N = int(input())

cnt = 0
strdit = {1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0}
for i in input().split():
    strdit[int(i)] += 1

for i in strdit.keys():
    if strdit[i] != 0:
        cnt += abs(i-strdit[i])

print(cnt)



### FIXED CODE ###

N = input()

cnt = 0
strdit = {}
for i in input().split():
    i = int(i)
    if i not in strdit.keys():
        strdit[i] = 0
    strdit[i] += 1

for i in strdit.keys():
    if i > strdit[i]:
        cnt += strdit[i]
    else:
        cnt += strdit[i] - i

print(cnt)
せっかimport sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
A = l()
L = []
L2 = []
for i in range(N):
    L.append(i+A[i]+1)
    L2.append(i-A[i]+1)
ans = 0
for l in L:
    c = L2.count(l)
    ans += c
print(ans)

### FIXED CODE ###

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
A = l()
L = []
L2 = [0]*(10**6)
for i in range(N):
    if i+A[i]+1 < 10**6:
        L.append(i+A[i]+1)
    if i-A[i]+1 >= 0 and i-A[i]+1 < 10**6:
        L2[i-A[i]+1] += 1
ans = 0
for l in L:
    ans += L2[l]
print(ans)