Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]
 
n , q = map(int,input().split())
point = [0] * n
edge = [[] for i in range(n)]
 
for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
 
for _ in range(q):
    a , b = map(int,input().split())
    point[a-1] += b
 
def dfs(now, last=-1):
    for nxt in edge[now]:
        if nxt==last: continue
        point[nxt] += point[now]
        dfs(nxt, now)
dfs(0)
print(*point)
import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]

n , q = map(int,input().split())
point = [0] * n
edge = [[] for i in range(n)]

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

for _ in range(q):
    a , b = map(int,input().split())
    point[a-1] += b

def dfs(now, last=-1):
    for nxt in edge[now]:
        if nxt==last: continue
        point[nxt] += point[now]
        dfs(nxt, now)
dfs(0)
print(*point)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]
 
n , q = map(int,input().split())
point = [0] * n
edge = [[] for i in range(n)]
 
for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
 
for _ in range(q):
    a , b = map(int,input().split())
    point[a-1] += b
 
def dfs(now, last=-1):
    for nxt in edge[now]:
        if nxt==last: continue
        point[nxt] += point[now]
        dfs(nxt, now)
dfs(0)
print(*point)
from functools import reduce
k=int(input())
m=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for p in range(1,k+1):
            l=[i,j,p]
            m+=reduce(fractions.gcd,l)
print(m)

### FIXED CODE ###

from functools import reduce
import fractions
import math
k=int(input())
m=0
for i in range(1,k+1):
    for j in range(i,k+1):
        for p in range(j,k+1):
            l=[i,j,p]
            if i==j==p:
                m+=reduce(math.gcd,l)
            elif (i==j and i!=p) or (i==p and i!=j) or (j==p and i!=p):
                m+=3*reduce(math.gcd,l)
            else:
                m+=6*reduce(math.gcd,l)
print(m)
n, z, w = map(int, input().split())
a = list(map(int, input().split()))

score = []

# only X
score.append(abs(a[-1] - w))

if n > 1:
    # X -> Y
    score.append(abs(a[i] - a[-1]))

print(max(score))


### FIXED CODE ###

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

score = []

# only X
score.append(abs(a[-1] - w))

if n > 1:
    # X -> Y
    score.append(abs(a[-2] - a[-1]))

print(max(score))
import math
#[N,K] = list(map(int,input().split()))
#A = list(map(int,input().split()))
#[A,B,C,D] = list(map(int,input().split()))
[A,B,C,D] = list(map(int,input().split()))
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
x_c = (B//C) - ((A-1)//C)
x_d = (B//D) - ((A-1)//D)
x_cd = (B//lcm(C,D)) - ((A-1)//lcm(C,D))
ans = (B - A + 1) - (x_c + x_d -x_cd)
print(ans)

### FIXED CODE ###

from fractions import gcd
#[N,K] = list(map(int,input().split()))
#A = list(map(int,input().split()))
#[A,B,C,D] = list(map(int,input().split()))
[A,B,C,D] = list(map(int,input().split()))
def lcm(x, y):
    return (x * y) // gcd(x, y)
x_c = (B//C) - ((A-1)//C)
x_d = (B//D) - ((A-1)//D)
x_cd = (B//lcm(C,D)) - ((A-1)//lcm(C,D))
ans = (B - A + 1) - (x_c + x_d -x_cd)
print(ans)
"""
=int(input())
=map(int,input().split())
=list(map(int,input().split()))

# アレイ import numpy as np =np.array(list(map(float,input().split())))

# 文字列 =list(str(input()).split(" " or ","))

# 一文字＆連番(縦横可能) =map(int, open(0).read().split())

# 2-d list
lis=[[] for _ in range(M)]
for i in range(M):
    lis[i] = list(map(int,input().split()[0:]))

# Each list
N = int(input())
a = [0] * N
b = [0] * N
c = [0] * N
for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())
"""
import numpy as np


n = int(input())
x=n
pf={}
for i in range(2,int(n**0.5)+1):
    while n % i == 0:
        pf[i] = pf.get(i,0)+1
        n//= i
if n > 1 : pf[n] = 1

from decimal import Decimal
# print((list(pf.keys()))[0]) #素因数分解したときの最小の因数取得
lis=[]
for b in range(-1000,1000):
    a=b+int(list(pf.keys())[0])
    siki=Decimal(a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4)
    if siki==Decimal(x/int(list(pf.keys())[0])):
        lis.append((a,b))
print(*lis[0])

### FIXED CODE ###


x=int(input())
A=0
B=0
for a in range(-500,500):
    for b in range(-500,500):
        if a**5-b**5==x:
            A=a
            B=b
            break
print(A,B)
import collections
N=int(input())
s=[int(input()) for i jn range(N)]
M=int(input())
t=[int(input()) for i in range(M)]

table=collections.defaultdict(int)
for x in s:
  table[x]+=1
for x in t:
  table[t]+=1
table=table.values()
table=[x for x in table if x >= 0]
print(sum(table))

### FIXED CODE ###

import collections
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for i in range(M)]

table=collections.defaultdict(int)
for x in s:
  table[x]+=1
for x in t:
  table[x]-=1
table=table.values()
table=[x for x in table if x >= 0]
table.append(0)
print(max(table))
N = int(input())
lst_a = [int(input()) for _ in range(N)]
lst_ans = [0] * (10**5)
lst_a.sort()


for a in lst_a:
    lst_ans[a] += 1
ans = sum(1 for i in lst_ans if i % 2 == 1)


print(ans)

### FIXED CODE ###

from collections import Counter


N = int(input())
lst_number = [int(input()) for _ in range(N)]
set_number = set(lst_number)
cnt_number = Counter(lst_number)
ans = 0


for key in set_number:
    if cnt_number[key] % 2 == 1:
        ans += 1


print(ans)
a, b, c = map(int, input().split(' '))
if a + b + c != 17:
  print 'NO'
else if a * b * c != 175:
  print 'NO'
else:
  print 'YES'

### FIXED CODE ###

a, b, c = map(int, input().split(' '))
if a + b + c != 17:
  print('NO')
elif a * b * c != 175:
  print('NO')
else:
  print('YES')
# -*- coding:utf-8 -*-
"""
.....A
B.....
を連結させればABは一個増える
"""
def solve():
    N = int(input())

    ans = 0
    b_start = 0
    a_end = 0
    ryouhou = 0
    for i in range(N):
        s = input()
        ans += s.count("AB")
        
        if s[0] == "B" and S[-1] == "A":
            ryouhou += 1
        elif s[0] == "B":
            b_start += 1
        elif s[-1] == "A":
            a_end += 1
    
    add_ab_num = min(b_start, a_end)
    ans += add_ab_num

    rest_katahou = (max(b_start, a_end) - add_ab_num)

    if ryouhou >= rest_katahou:
        ans += rest_katahou
        rest_ryouhou = (ryouhou - rest_katahou)
        ans += rest_ryouhou//2
    else:
        ans += ryouhou
    
    print(ans)
   
        

if __name__ == "__main__":
    solve()


### FIXED CODE ###

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

def solve():
    N = int(input())
    ans = 0
    endA = 0
    startB = 0
    ryouhou = 0
    # Aで終わるs1と、Bで始まるs2を連結させれば1個増える
    for i in range(N):
        s = input()
        if s[-1]=="A" and s[0]=="B":
            ryouhou += 1
        elif s[-1]=="A":
            endA += 1
        elif s[0]=="B":
            startB += 1
        
        ans += s.count("AB")
    

    if endA>=1 and startB>=1 and ryouhou>=1:
        ans += min(endA-1, startB-1)
        ans += ryouhou + 1
        print(ans)
        return
    elif ((endA>=1 and startB==0 and ryouhou>=1) or
          (endA==0 and startB>=1 and ryouhou>=1)):
        ans += ryouhou
        print(ans)
        return
    elif endA==0 and startB==0 and ryouhou>=1:
        ans += ryouhou-1
        print(ans)
        return
    else:
        # ryouhou==0のとき
        ans += min(endA, startB)
        rest = abs(max(endA, startB) - min(endA, startB))
        
        ans += min(rest, ryouhou)
        rest = ryouhou - rest
        if rest <= 0:
            print(ans)
            return
        else:
            ans += rest//2
            print(ans)
            return

if __name__ == "__main__":
    solve()
N=int(input())
ans = [0 for _ in range(10001)]
for i in range(101):
  for j in range(101):
    for k in range(101):
      v = i*i + j*j + k*k + i*j + j*k + k*i
      if v < 10001:
        ans[v] += 1

for i in range(n):
  print(ans[i+1])

### FIXED CODE ###

n=int(input())
ans = [0 for _ in range(10001)]
for i in range(1, 101):
  for j in range(1, 101):
    for k in range(1, 101):
      v = i*i + j*j + k*k + i*j + j*k + k*i
      if v < 10001:
        ans[v] += 1

for i in range(n):
  print(ans[i+1])
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
  a, b, c, d = map(int, input().split())
  a -= 1
  lc = (c*d)//fractions.gcd(c,d)
  ans = (b-a)-(b//c-a//c)-(b//d-a//d)+(b//lc-a//lc)
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()


### FIXED CODE ###

def solve():
  n = int(input())
  works = [list(map(int, input().split())) for i in range(n)]
  works = sorted(works, key=lambda x:x[1])
  if works[0][0] > works[0][1]:
    print("No")
    exit()
  sum = 0
  for i in works:
    sum += i[0]
    if sum > i[1]:
      print("No")
      exit()
  print("Yes")
  return 0
 
if __name__ == "__main__":
  solve()
N = int(input())
A = []
B = []
C = {}
m = 1000000007

def mypow(dummy, num):

    ans = 1
    for i in range(num):
        ans = (ans*2)%1000000007
    return ans

for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    if a/b in C.keys():
        C[a/b] +=1
    else: C[a/b] = 1
    
used = set()
ans = 1
for c in C.keys():
    if c in used: continue
    if -1/c in C.keys():
        used.add(-1/c)
        
        score = mypow(2, C[c]) + mypow(2, C[-1/c])- 1
        
        ans = (ans * score)%m

    else:
        
        ans = (ans*mypow(2, C[c]))%m

print(ans-1)






### FIXED CODE ###

import math
N = int(input())
A = 0
B = 0
Z = 0
C = {}
m = 1000000007

def mypow(dummy, num):
    ans = 1
    for i in range(num):
        ans = (ans*2)%1000000007
    return ans

def rNum(a, b):
    g = math.gcd(a, b)
    if a <0 and b<0:
        a *= -1
        b *= -1
    if a >0 and b <0:
        return (-1*(a//g), -1*(b//g))
    else:
        return (a//g, b//g)


for i in range(N):
    a, b = map(int, input().split())
    
    if a == 0 and b==0:
        Z += 1
        continue
    elif a==0:
        A += 1
        continue
    elif b==0:
        B +=1
        continue
    
    r = rNum(a, b)
    if r in C.keys():
        C[r] +=1
    else: C[r] = 1


used = set()
ans = 1
ans *= (mypow(2, A) + mypow(2, B) -1)%m


for c in C.keys():
    if c in used: continue
    a, b = c
    r = rNum(b, -1*a)
    if r in C.keys():
        if c == r: continue
        used.add(r)
        score = (mypow(2, C[c]) + mypow(2, C[r])- 1)
        ans *= score

    else:
        ans *= mypow(2, C[c])

ans += Z

print((ans-1)%m)
for i in range(min(math.ceil(math.sqrt(M)), M//N), 0, -1):
  if M % i == 0:
    print(i)
    break


### FIXED CODE ###

import math
N, M = [int(i) for i in input().split()]
for i in range(math.ceil(M/N), 0, -1):
  if M % i == 0:
    print(i)
    break
A = input()
B = input()
result = False
Amin = int(round(A * 12.5)) 
Amax = int(round((A+1) * 12.5)-1)
Bmin = B * 10
Bmax = (B+1) * 10


for i in range(Amin,Amax+1):
    for j in range(Bmin,Bmax+1):
        
        if(i == j):
            print(i)
            result = True
            break

    if(result):

        break



if(result==False):
    print(-1)        
       
    


### FIXED CODE ###


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

result = False
Amin = int(round(A * 12.5)) 
Amax = int(round((A+1) * 12.5)-1)
Bmin = B * 10
Bmax = (B+1) * 10 - 1


for i in range(Amin,Amax+1):
    for j in range(Bmin,Bmax+1):
        if(i == j):
            print(i)
            result = True
            break

    if(result):

        break



if(result==False):
    print(-1)
x=int(input())
print(x/3600, ':', (x-x/3600)/60, ':', x-{(x-x/3600)/60}, sep='')



### FIXED CODE ###

a, b=map(int, input().split())
print(a*b, a+a+b+b)
A=int(input())
B=int(input())
C=int(input())
if A==B and A!=C:
  print('Yes')
if A==C and A!=B: 
  print('Yes')
if B==C and B!=A: 
  print('Yes')
else: 
  print('No')

### FIXED CODE ###

A,B,C = input().split()
if A==B and A!=C or B==C and B!=A or C==A and C!=B:
    print("Yes")
else:
    print("No")
import sys
l = int(input())
s = list(map(int, input().split()))

while l > 0:
    for i in range(l-1):
        count = 1
        ss = s[i:i+l-2]
        for j in range(len(ss)-2):
            if ss[j] == ss[j+1]:
                count *= 1
            else:
                count *= 0
        if count == 1:
            print(i)
            sys.exit()
        l -= 1


### FIXED CODE ###

S = input()
T = input()
count = 0
if S[0] == T[0]:
    count += 1

if S[1] == T[1]:
    count += 1

if S[2] == T[2]:
    count += 1
    
print(count)
import sys
from collections import deque
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
n, m = map(int, input().split())
memo = set(list(range(n)))
E = [[] for i in range(n)]
for i in range(m):
    x, y, z = map(int, input().split())
    E[x-1].append(y-1)
    E[y-1].append(x-1)
def dfs(cur, pre):
    stack = deque([[cur, pre]])
    while stack:
        cur, pre = stack.pop()
        memo.discard(cur)
        for e in E[cur]:
            if e != pre and e in memo:
                stack.append([e, cur])
ans = 0
for i in range(n):
    if i in memo:
        dfs(cur, -1)
        ans += 1
print(ans)


### FIXED CODE ###

import sys
from collections import deque
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
n, m = map(int, input().split())
memo = set(list(range(n)))
E = [[] for i in range(n)]
for i in range(m):
    x, y, z = map(int, input().split())
    E[x-1].append(y-1)
    E[y-1].append(x-1)
def dfs(cur, pre):
    stack = deque([[cur, pre]])
    while stack:
        cur, pre = stack.pop()
        if pre != -1:
            memo.discard(cur)
        for e in E[cur]:
            if e != pre and e in memo:
                stack.append([e, cur])
ans = 0
while len(memo):
    cur = memo.pop()
    dfs(cur, -1)
    ans += 1
print(ans)
# -*- coding: utf-8 -*-
S = str(input())
T = str(input())

counter = 0
for i in range(S):
    if S[i] == T[i]:
        counter += 1

print(counter)

### FIXED CODE ###

# -*- coding: utf-8 -*-
S = str(input())
T = str(input())

counter = 0
for i in range(len(S)):
    if S[i] == T[i]:
        counter += 1

print(counter)
n,T = map(int,input().split())
ct = [[map(int,input().split())] for _ in range(n)]
cost = 9999
for i in range(n):
    c,t = ct[i][0],ct[i][1]
    if t<=T:
        cost = min(cost,c)
print(cost if cost != 9999 else 'TLE')

### FIXED CODE ###

n,T = map(int,input().split())
ct = [list(map(int,input().split())) for _ in range(n)]
cost = 9999
for i in range(n):
    c,t = ct[i][0],ct[i][1]
    if t<=T:
        cost = min(cost,c)
print(cost if cost != 9999 else 'TLE')
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
#print(n,m,l)
def bin_search(a,li):
    max_len=len(li)
    min_len=0
    while max_len>min_len:
        mid=(max_len+min_len)//2
        if li[mid]==a:
            return True
        elif abs(min_len-max_len)==1 and li[mid]!=a and li[mid+1]!=a and li[mid-1]!=a:
            break
        elif li[mid]<a:
            min_len=mid
        else:
            max_len=mid
s=[]
g=[]
for i in l:
    if i[0]==1:
        s.append(i[1])
    if i[1]==n:
        g.append(i[0])
g.sort
for i in s:
    if bin_search(i,g):
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')

### FIXED CODE ###

n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
#print(n,m,l)
def bin_search(a,li):
    max_len=len(li)-1
    min_len=0
    while max_len>=min_len:
        mid=(max_len+min_len)//2
        if li[mid]==a:
            return True
        elif li[mid]<a:
            min_len=mid+1
        else:
            max_len=mid-1
s=[]
g=[]
for i in l:
    if i[0]==1:
        s.append(i[1])
    if i[1]==n:
        g.append(i[0])
g.sort()
for i in s:
    if bin_search(i,g):
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')
while True:
    a, op, b = map(int, input().split(" "))
    if a == 0 and b == 0:
        break
    
    if op == "+":
        c = a + b
    elif op == "-":
        c = a - b
    elif op == "*":
        c = a * b
    else
        c = a / b
    print(c)


### FIXED CODE ###

while True:
    a, op, b = map(str, input().split(" "))
    if op == "?":
        break
    a, b = int(a), int(b)
    if op == "+":
        c = a + b
    elif op == "-":
        c = a - b
    elif op == "*":
        c = a * b
    else:
        c = a // b
    print(c)
def main():
    a = int(input())
    b = int(input())

    print((a-1) * (b-1))

        
if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    a, b = [int(x) for x in input().rstrip().split()]

    print((a-1) * (b-1))
        
if __name__ == '__main__':
    main()
import math
N, M = map(int, input().split())
x = M//N
mid = int(math.sqrt(M))
if x >= mid:
    ans = []
    for i in range(1, mid+1):
        ans.append(i)
        if M%i == 0:
            ans.append(i)
            if M//i <= x:
                ans.append(M//i)
    print(max(ans))
else:
    for i in rreversed(range(1, x+1)):
        if M%i == 0:
            print(i)
            break

### FIXED CODE ###

N, M = map(int, input().split())
x = M//N
max = 1
for i in range(x, 0, -1):
    mod = M - (N-1)*i
    if mod%i == 0:
        max = i
        break
print(max)
n, k = input().split(" ")
h = input().split(" ")

count = 0
for i in range(n):
  if h[i]>=k:
    count+=1
print(count)

### FIXED CODE ###

n, k = input().split(" ")
h = input().split(" ")

count = 0
for i in range(int(n)):
  if int(h[i])>=int(k):
    count+=1
print(count)
input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):
        
        if serial >= sqrt:
            return input_list

        if input_list[serial] is True:
            for s in range(serial ** 2, num, serial):
                input_list[s] = False

### FIXED CODE ###

a = [True for i in range(1000000)]
i = 3
while i * i < 1000000:
    for j in range(3 * i, 1000000, 2 * i): a[j] = False
    i += 2
 
while True:
    try:
        n = int(input())
    except:
        break
 
    count = int(n >= 2) + sum(a[i] for i in range(3, n + 1, 2))
    print(count)
def solve():
 seq1 = raw_input()
 seq2 = raw_input()
 a, b = len(seq1), len(seq2)
 x1 = [0 for i in range(b+1)]
  for i in range(a):
   e1 = seq1[i]
   x2 = x1+[]
   for j in range(b):
    if e1 == seq2[j]:
     x1[j+1] = x2[j] + 1
    elif x1[j+1]<x1[j]:
     x1[j+1] = x1[j]
  return x1[-1]
  
n = input()
for i2 in range(n):
 print solve()

### FIXED CODE ###

def solve():
 seq1 = raw_input()
 seq2 = raw_input()
 a, b = len(seq1), len(seq2)
 x1 = [0 for i in range(b+1)]
 for i in range(a):
  e1 = seq1[i]
  x2 = x1+[]
  for j in range(b):
   if e1 == seq2[j]:
    x1[j+1] = x2[j] + 1
   elif x1[j+1]<x1[j]:
    x1[j+1] = x1[j]
 return x1[-1]
n = input()
for i2 in range(n):
 print solve()
a, b, k = map(int, input().split())
l = list(range(a,b+1))
ans = sorted(set(l[:k] + l[len(l)-k:]))

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

### FIXED CODE ###

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

l = [i for i in range(a, b+1) if (i < a+k) or (i > b-k)]

print(*l, sep="\n", end="")
a,b,x = map(int,input().split())
l = 1
r = 10**9
num = 0
b_num = 0
if 10**9*a + b*9 <= x:
  print(10**9)
elif a+b > x:
  print(0)
else:
  while 1:
    num = (l+r)//2
    if r - l == 1:
      c = [l*a+len(str(l))*b,r*a+len(str(r))*b]
      print(r if c[1]<=x else l)
      break
    cost = a*num+b*len(str(num))
    if cost < x:
      l = num
    else:
      r = num
    b_num = num
  




### FIXED CODE ###

s = input()
target =  ["MON","TUE","WED","THU","FRI","SAT","SUN"]
print(7 if s=="SUN" else 7-(target.index(s)+1))
n=int(input())
n1=[int(i) for i in str(n)]
n2=len(n1)

x=0
if n1=1:
  x=n
elif n1=2:
  x=9
elif n1=3:
  x=9+(n-99)
elif n1=4:
  x=9+900
elif n1=5:
  x=9+900+(n-999)
  
print(x)

### FIXED CODE ###

n=int(input())

if n<100:
  print(min(n,9))
elif n<10000:
  print(min(n-90,909))
else:
  print(min(n-9090,90909))
while True:
    s = raw_input()
    if s.split() [1] == "?" : 
    break
    print eval(s)

### FIXED CODE ###

while True:
    s = raw_input()
    if s.split() [1] == "?" : break
    print eval(s)
N, M = map(int, input().strip().split())

a_b = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    a_b.append(array)

c_d = []
for i in range(M):
    array = list(map(int, input().strip().split()))
    c_d.append(array)

for n in range(N):
    mind = 2 * 10^8 + 1
    for m in range(M):
        dist = abs(a_b[n][0] - c_d[m][0]) + abs(a_b[n][1] - c_d[m][1])
        if dist < mind:
            mind = dist
            checkpoint = m + 1
    print(checkpoint)


### FIXED CODE ###

N, M = map(int, input().strip().split())

a_b = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    a_b.append(array)

c_d = []
for i in range(M):
    array = list(map(int, input().strip().split()))
    c_d.append(array)

for n in range(N):
    mind = 1000000007
    for m in range(M):
        dist = abs(a_b[n][0] - c_d[m][0]) + abs(a_b[n][1] - c_d[m][1])
        if dist < mind:
            mind = dist
            checkpoint = m + 1
    print(checkpoint)
import sys
lines = sys.stsin.readlines()
K, N = list(map(int, lines[0].srtip().split()))
As = list(map(int, lines[1].strip().split()))
 
diffs =[]
for base, switch in zip(arr[:-1], arr[1:]):
  diffs.append(switch-base)

diffs.append(arr[0]+K-arr[-1])
 
print(K-max(diffs))

### FIXED CODE ###

K, N = list(map(int, input().split()))
As = list(map(int, input().split()))
diffs =[]
for base, switch in zip(As[:-1], As[1:]):
  diffs.append(switch-base)
diffs.append(As[0]+K-As[-1])
print(K-max(diffs))
n, k = map(int, input().split())

li = [0]
li.extend(list(map(int, input().split())))
tuita = [0]*(n+1)
cnt = 0
town = 1

def search(town, times):
  if times == 0:
    return town
  newTown = li[town]
  newTimes = times - 1 
  return search(newTown, newTimes)

while True:
  town = li[town]
  cnt += 1
  if tuita[town] == 0:
    tuita[town] = cnt
  else:
    if k < tuita[town]:
      print(search(1, k))
    elif k == tuita[town]:
      print(town)
    else:
      print(search(town, (k - tuita[town]) % (cnt - tuita[town])))
    break
 

  
    

### FIXED CODE ###

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

li = [0]
li.extend(list(map(int, input().split())))
tuita = [0]*(n+1)
cnt = 0
town = 1

lastTown = 1
while True:
  town = li[town]
  cnt += 1
  if tuita[town] == 0:
    tuita[town] = cnt
  else:
    if k < tuita[town]:
      lastTown = 1
      times = k
    elif k == tuita[town]:
      lastTown = town
      times = 0
    else:
      lastTown = town
      times = (k - tuita[town]) % (cnt - tuita[town])
    break

town = lastTown
while times > 0:
  if times <= 0:
    break
  times -= 1
  town = li[town]
print(town)
N,K=(int(i) for i in input().split())
hlist=[int(input()) for l in range(N)]
hlist.sort()
for j in range(N-K+2):
    dif=[hlist[j+k]-hlist[j]]
print(min(dif))

### FIXED CODE ###

N,K=(int(i) for i in input().split())
hlist=[int(input()) for i in range(N)]
hlist.sort()
dif=[]
for j in range(N-K+1):
    dif.append(hlist[j+K-1]-hlist[j])
print(min(dif))
import math
a,b,n=map(int,input().split())
max=-2
if b<n:
    n=b
for i in range(1,n+1):
    if i<b:
        s=math.floor(a*i/b)
    if s>max:
        max=s
print(int(max))


### FIXED CODE ###

import math
a,b,n=map(int,input().split())
max=-2
if n<b:
    max=math.floor(a*n/b)
else:
    #b<=n
    max=math.floor(a*(b-1)/b)
    

print(max)