Harryxun/stf_run huggingface dataset:
A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
x = [int(input()) for _ in range(Q)]
inf = 10 ** 18

s = [-inf] + s + [inf]
t = [-inf] + t + [inf]

# def binsearch_l(seq, l, r, tar):
#     if r - l < 2: return l
#     #
#     m = l + (r - l + 1) // 2
#     # print("##", l, r, (m, seq[m]), tar)
#     if seq[m] <= tar:
#         return binsearch_l(seq, m, r, tar)
#     else:
#         return binsearch_l(seq, l, m, tar)

ans_Q = [None] * Q
i_last = j_last = 0
for idx, x_tmp in sorted(enumerate(x), key=lambda x: x[1]):
    i_l, i_r = 0, A + 2
    while i_r - i_l > 1:
        m = i_l + (i_r - i_l) // 2
        # print("##", i_l, i_r, (m, s[m]), x_tmp)
        if s[m] <= x_tmp:
            i_l = m
        else:
            i_r = m
    #
    j_l, j_r = 0, A + 2
    while j_r - j_l > 1:
        m = j_l + (j_r - j_l) // 2
        # print("##", j_l, j_r, (m, t[m]), x_tmp)
        if t[m] <= x_tmp:
            j_l = m
        else:
            j_r = m
    #
    ans = inf
    for i, j in ((i_l, j_l), (i_l + 1, j_l), (i_l, j_l + 1), (i_l + 1, j_l + 1)):
        if i < 1 or A < i: continue
        if j < 1 or B < j: continue
        ans_tmp_s = abs(x_tmp - s[i]) + abs(s[i] - t[j])
        ans_tmp_t = abs(x_tmp - t[j]) + abs(s[i] - t[j])
        ans_tmp = min(ans_tmp_s, ans_tmp_t)
        # print("#", x_tmp, s[i], t[j], ans_tmp)
        if ans > ans_tmp:
            ans = ans_tmp
    #
    i_last, j_last = i_l, j_l
    ans_Q[idx] = ans

for ansi in ans_Q: print(ansi)

### FIXED CODE ###

import sys, bisect
input = sys.stdin.readline
A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
x = [int(input()) for _ in range(Q)]
inf = 10 ** 18

s = [-inf] + s + [inf]
t = [-inf] + t + [inf]

ans_Q = [None] * Q
i_last = j_last = 0
for idx, x_tmp in sorted(enumerate(x), key=lambda x: x[1]):
    i_l = max(0, bisect.bisect_left(s, x_tmp, lo=i_last) - 1)
    j_l = max(0, bisect.bisect_left(t, x_tmp, lo=j_last) - 1)
    # print("#", x_tmp, (i_l, s[i_l]), (j_l, t[j_l]))
    #
    ans = inf
    for i, j in ((i_l, j_l), (i_l + 1, j_l), (i_l, j_l + 1), (i_l + 1, j_l + 1)):
        if i < 1 or A < i: continue
        if j < 1 or B < j: continue
        ans_tmp_s = abs(x_tmp - s[i]) + abs(s[i] - t[j])
        ans_tmp_t = abs(x_tmp - t[j]) + abs(s[i] - t[j])
        ans_tmp = min(ans_tmp_s, ans_tmp_t)
        # print("#", x_tmp, s[i], t[j], ans_tmp)
        if ans > ans_tmp:
            ans = ans_tmp
    #
    i_last, j_last = i_l, j_l
    ans_Q[idx] = ans

for ansi in ans_Q: print(ansi)
g = a - 1
d, r = divmod(b - 1, g)
if r == 0:
    print(d)
else:
    print(d + 1)

### FIXED CODE ###

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

g = a - 1
d, r = divmod(b - 1, g)
if r == 0:
    print(d)
else:
    print(d + 1)
n=int(input())
a=list(map(int,input().split()))
b=set(a)
print("YES" if n == len(b), else "NO")


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=set(a)
print("YES" if n == len(b) else "NO")
s = input()
if s = "Sunny":
  print("Cloudy")
elif s = "Cloudy":
  print("Rainly")
else:
  print("Sunny")
  
 


### FIXED CODE ###

s = input()
if s == "Sunny":
  print("Cloudy")
elif s == "Cloudy":
  print("Rainy")
else:
  print("Sunny")
a, b, x = map(int, input().split())
print(b//x - (a-1)//x

### FIXED CODE ###

a, b, x = map(int, input().split())
print(b//x - (a-1)//x)
s = list(input())
if s[0] == '?':
  s[0] = "D"
for i in range(1, len(s)):
  if s[i] == '?':
    if s[i-1]== 'D' and (s[i+1] == 'D' or s[i+1] == '?'):
      s[i] = 'P'
    else: 
      s[i] = 'D'
print("".join(s))

### FIXED CODE ###

s = list(input())
if s[0] == '?':
  s[0] = "D"
for i in range(1, len(s)-1):
  if s[i] == '?':
    if s[i-1]== 'D' and (s[i+1] == 'D' or s[i+1] == '?'):
      s[i] = 'P'
    else: 
      s[i] = 'D'
if s[len(s)-1] == '?':
  s[len(s)-1] = 'D'
print("".join(s))
N = int(input())
A = list(map(int, input().split()))
if len(A) & 1:
  A.append(0)
A.sort()
print(sum([A[i+1]-A[i] for i in range(0, A, 2)]))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
if len(A) & 1:
  A.append(0)
A.sort()
print(sum([A[i+1]-A[i] for i in range(0, len(A), 2)]))
A, B, M = map(int, input().split())
F = list(map(int, input().split()))
M = list(map(int, input().split()))
C = []

for _ in range(M):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    C.append((x,y,c))

minF = min(F)
minM = min(M)
ans = minF + minM

for x, y, z in C:
    tmp = F[x] + F[y] - z
    if tmp < ans:
        ans = tmp

print(ans)

### FIXED CODE ###

A, B, M = map(int, input().split())
Frz = list(map(int, input().split()))
Mic = list(map(int, input().split()))
C = []

for _ in range(M):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    C.append((x,y,c))

minF = min(Frz)
minM = min(Mic)
ans = minF + minM

for x, y, z in C:
    tmp = Frz[x] + Mic[y] - z
    if tmp < ans:
        ans = tmp

print(ans)
import math
n , k = map(int, input().split())
a = list(map(int,input().split()))
a1=[0]*(n+1)
k = min(k,int(math.log2(n)*2.5))
for i in range(k):
    for j in range(n):
        st=j-a[j]
        gl=j+a[j]
        if st<0:
            st=0
        if gl>=n:
            gl=n-1
        a1[st]+=1
        a1[gl+1]-=1
    for k in range(1,n):
        a1[k]=a1[k-1]+a1[k]
    a=a1[:n]
    a1=[0]*n
print(' '.join([str(n) for n in a]))


### FIXED CODE ###

import math
n , k = map(int, input().split())
a = list(map(int,input().split()))
a1=[0]*(n+1)
k = min(k,int(math.log2(n)*2.5))
for i in range(k):
    for j in range(n):
        st=j-a[j]
        gl=j+a[j]
        if st<0:
            st=0
        if gl>=n:
            gl=n-1
        a1[st]+=1
        a1[gl+1]-=1
    for k in range(1,n):
        a1[k]=a1[k-1]+a1[k]
    a=a1[:n]
    a1=[0]*(n+1)
print(' '.join([str(n) for n in a]))
N, R = map(int, input().split())
if N < 10:
    print(100*(10-K) + R)
else:
    print(R)


### FIXED CODE ###

N, R = map(int, input().split())
if N < 10:
    print(100*(10-N) + R)
else:
    print(R)
import string

S = list(map(str, input()))

s = sorted(set(S))

alphabet = string.ascii_lowercase

if len(s) == len(alphabet):
    print("None")
else:

    for i in range(53):
        if s[i] != alphabet[i]:
            print(alphabet[i])
            break


### FIXED CODE ###

import string

S = list(map(str, input()))
s = sorted(set(S))
count = 0

alphabet = string.ascii_lowercase

if len(s) == len(alphabet):
    print("None")

else:
    for i in range(len(s)):
        if s[i] != alphabet[i]:
            print(alphabet[i])
            break
        else:
            count += 1

if count == len(s):
    print(alphabet[len(s)])
from functools import reduce
from math import gcd

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

print(reduce(gcd, a))


### FIXED CODE ###

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


def gcd(x, y):
    while y != 0:
        x, y = y, x % y

    return x


ret = gcd(a[0], a[1])

for e in a[2:]:
    ret = gcd(ret, e)

print(ret)
a b c = map(int, input().split())

if a<=c and c<=b:
    print("Yes")
else:
    print(”No”)

### FIXED CODE ###

a, b, c = map(int, input().split())
 
if a<=c and c<=b:
    print("Yes")
else:
    print("No")
all = list(map(int, input().split()))

N = all[0]
Y = all[1]

for i in range(N):
    for j in range(N-i):
        if N!=i+j+abs(N-(i+j)):
            yu = -1
            hi = -1
            no = -1
            break
        else:
            total = 10000*i + 5000*j + 1000*(N-(i+j))
            if Y!=total:
                continue
            else:
                yu = i
                hi = j
                no = (N-(i+j))
    else:
        continue
    break

print(str(yu) + " " + str(hi) + " " + str(no))



### FIXED CODE ###

all = list(map(int, input().split()))

N = all[0]
Y = all[1]

yu = -1
hi = -1
no = -1
for i in range(N+1):
    for j in range((N+1)-i):
        c = (N-(i+j))
        total = 10000*i + 5000*j + 1000*c
        if Y==total:
            yu = i
            hi = j
            no = c
            break
        else:
            continue
    else:
        continue 
    break

print(str(yu) + " " + str(hi) + " " + str(no))
import sys
sys.setrecursionlimit(10 ** 9)

n, m = map(int, input().split())
root = [-1] * n
def find(x):
    if root[x] < 0:
        return x
    else:
        x = find(x)
        return x
    

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x
        

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    unite(a, b)

ans = len([i for i in root if i < 0]) - 1
print(ans)



### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

n, m = map(int, input().split())
root = [-1] * n
def find(x):
    if root[x] < 0:
        return x
    else:
        root[x] = find(root[x])
        return root[x]
    

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x
        

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    unite(a, b)

ans = len([i for i in root if i < 0]) - 1
print(ans)
import sys
import numpy as np
N = int(input())
D = list(map(int,input().split()))
M = max(D)
countlist=[0] * (M + 1)
ans=1

for i in D:
    countlist[i]+=1

if countlist[0]!=1 :
    print(0)
    sys.exit()
elif M<2:
    print(1)
    sys.exit()

if D[0]!=0 :
    print(0)
    sys.exit()

for i in range(2,M+1):
        ans *= countlist[i-1]**countlist[i]

print(ans%998244353) 

### FIXED CODE ###

N = int(input())
ans=0
if N%2==0:
    ans=N/2-1
elif N!=1:
    ans=N/2
print(int(ans))
s=input()
cnt=0;a=0
res = []
for i in s:
    if i not in res:
        res.append(i)
for i in s:
    if res[0]==i:
        cnt+=1
    if res[1]==i:
        a+=1
if a==2 and cnt==2:
    print("Yes")
else:print("No")


### FIXED CODE ###

S = input()
c = 0
for i in S:
  if S.count(i) == 2:
    c = c + 1
if (c == 4):
  print("Yes")
else:
  print("No")
X = input()

ans = []
for i in range(len(X)):
    if X[i] == '?' and X[i-1] != 'P' and X[i+1] != 'P':
        ans.append('P')
    elif X[i] == '?':
        ans.append('D')
    else:
        ans.append(X[i])

print(ans)

for i in ans:
    print(i, end = "")

### FIXED CODE ###

X = input()
ans = []

for i in range(len(X)):
    if X[i] == '?':
        ans.append('D')
    else:
        ans.append(X[i])

for i in ans:
    print(i, end = "")
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range(n):
  suf += b[i]
  if a[i]  + 1 == a[i+1]:
    suf += c[i]
print(suf)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range (n):
  suf += b[i]
  if i >= 1 and a[i - 1]  + 1 == a[i]:
    suf += c[a[i - 1] - 1]
print(suf)
s,w=map(int,input().split())
 
if s>w:
	return("safe")
else:
	return("unsafe")

### FIXED CODE ###

s,w=map(int,input().split())
 
if s>w:
	print("safe")
else:
	print("unsafe")
a,b = map(int, raw_input().split())
op = f.read()

while(1):
  if op == "+":
    print "%d" %(a+b)
  elif op == "-":
    print "%d" %(a-b)
  elif op == "*":
    print "%d" %(a*b)
  elif op == "/":
    print "%d" %(a/b)
  elif op == "?":
    break

### FIXED CODE ###

while(1):
  a,op,b = raw_input().split()
  a = int(a)
  b = int(b)
  if op == "+":
    print (a+b)
  elif op == "-":
    print (a-b)
  elif op == "*":
    print (a*b)
  elif op == "/":
    print (a/b)
  elif op == "?":
    break
L = int(input())
print((L/3)**3)


### FIXED CODE ###

N, M = input().split()
N, M = int(N), int(M)
if N < 2:
  print(int(M*(M-1)/2))
elif M < 2:
  print(int(N*(N-1)/2))
else:
  print(int(N*(N-1)/2 + M*(M-1)/2))
n = int(input())
h= list(map(int, input().split())) 

count = 0
ans = 0
def dfs(s):
    if s + 1 < len(h):
        if h[s] >= h[s+1]:
            global count 
            count = count + 1
            return dfs(s+1)
    

for i in reversed(range(len(h))):
    count = 0
    aaa = dfs(i)
    if count > ans :
        ans = count
        
print(ans)
    

### FIXED CODE ###

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

count = 0
ans = 0

for i in range(len(h)):
    if i + 1 < len(h):
        if h[i] >= h[i+1]:
            count = count + 1
        else:
            count = 0
    if count > ans :
        ans = count
        
print(ans)
def l(a, b):
  if a > b:
    a, b = b, a
  return l(a, b % a) if b % a else a

def g(a, b):
  return a * b // l(a, b)

N = int(input())
res = 1
for n in range(N):
  res = g(res, int(input())

print(res)

### FIXED CODE ###

def l(a, b):
  if a > b:
    a, b = b, a
  return l(a, b % a) if b % a else a

def g(a, b):
  return a * b // l(a, b)

N = int(input())
res = 1
for n in range(N):
  res = g(res, int(input()))

print(res)
X = int(input())
c = 1
for b in range(1,X):
    for p in range(2,X):
        if b**p <= X:
            c = max(c, b**p)
        else:
            break
print(c)

### FIXED CODE ###

a,b,c,d = map(int, input().split())
 
if abs(b-a) <= d and abs(c-b) <= d :
  print('Yes')
elif abs(a-c) <= d :
  print('Yes')
else:
  print('No')
def main():
  size = int(input())
  for i in range(size):
    array[i] = list(map(int, input().split())
                    
  flg = "Yes"           
  pre_time = 0
  pos = [0, 0] 
  for i in range (size):
    time = array[i][0] - pre_time
    distance = abs(array[i][1]-pos[0]) + abs(array[i][2]-pos[1])
    
    if time == distance or ((distance<time) and (time-distance)%2 == 0):
      pre_time = time
      pos = array[i][1:]
    else:
      flg = "No"
                    
  print(flg)
                    
main()

### FIXED CODE ###

def main():
  size = int(input())
  array = []
  for i in range(size):
    array.append(list(map(int, input().split())))
                    
  flg = "Yes"           
  pre_time = 0
  pos = [0, 0] 
  for i in range (size):
    time = array[i][0] - pre_time
    distance = abs(array[i][1]-pos[0]) + abs(array[i][2]-pos[1])
    
    if time == distance or ((distance<time) and (time-distance)%2 == 0):
      pre_time = array[i][0]
      pos = array[i][1:]
    else:
      flg = "No"
                    
  print(flg)
                    
main()
from copy import deepcopy
n = int(input())
lista = [[] for i in range(n + 1)]
ans = 10000000
for i in range(n):
    a = int(input())
    lista[i + 1].append(a)
def dfs(now, ignore):
    global ans
    if now == 2:
        ans = min(ans, len(ignore) - 1)
    for i in lista[now]:
        if i in ignore:
            continue
        nignore = deepcopy(ignore)
        nignore.append(i)
        dfs(i, nignore)
dfs(1, [1])
print(-1 if ans == 10000000 else ans)

### FIXED CODE ###

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()
A = getArray(N)
for i in range(N):
    A[i] -= 1
ignore = [0] * N
ignore[0] = 1

now = 0
cnt = 0
while True:
    now = A[now]
    cnt += 1
    if ignore[now] == 1:
        print(-1)
        break
    ignore[now] = 1
    if now == 1:
        print(cnt)
        break
N, Q = map(int, input().split())


class Tree(object):
    def __init__(self, num):
        self.num = num
        self.childs = []
        self.count = 0


def dfs(p, x):
    """
    add x to all elements which have p as parent
    :param p: root of subtree, Tree class
    :param x: numbers to add, int
    """
    # add x to p.count
    p.count += x

    # recurrsive call for direct children of p
    for child in p.childs:
        dfs(child, x)


trees = [Tree(num) for num in range(N)]

for _ in range(N-1):
    a, b = map(int, input().split())
    a = a - 1
    b = b - 1
    trees[a].childs.append(trees[b])


for _ in range(Q):
    p, x = map(int, input().split())
    p = p - 1
    dfs(trees[p], x)


for tree in trees:
    print(tree.count, end="")

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

 
N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
 
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
 
value = [0] * (N+1)
for p,x in PX:
    value[p] += x
 
def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])
 
dfs(1,0,0)
 
answer = ' '.join(map(str,value[1:]))
print(answer)
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()

def solve():
    N, Q = map(int, line_input())
    event = []
    for i in range(N):
        s, t, x = map(int, line_input())
        event.append((max(s-x, 0), 1, x))
        event.append((max(t-x, 0), -1, x))
    for i in range(Q):
        d = int(single_input())
        event.append((d, 2, 0))
    event.sort()
    stop = []
    heapq.heapify(stop)
    ans = ""
    for time, parameter, co in event:
        if parameter == 1: heapq.heappush(stop, co)
        elif parameter == -1: stop.remove(co)
        else:
            if stop: ans += str(stop[0]) + "\n"
            else: ans += "-1\n"
    print(ans)

    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import sys, collections, heapq
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()

def solve():
    N, Q = map(int, line_input())
    event = []
    for i in range(N):
        s, t, x = map(int, line_input())
        event.append((s-x, 1, x))
        event.append((t-x,-1, x))
    for i in range(Q):
        d = int(single_input())
        event.append((d, 2, d))
    event.sort()
    candidate = []
    heapq.heapify(candidate)
    stop = collections.defaultdict(int)
    ans = ""
    for time, parameter, co in event:
        if parameter == 1:
            heapq.heappush(candidate, co)
            stop[co] += 1
        elif parameter == -1:
            stop[co] -= 1
        else:
            while candidate:
                x = heapq.heappop(candidate)
                if stop[x] > 0:
                    heapq.heappush(candidate, x)
                    ans += str(x) + "\n"
                    break
            else: ans += "-1\n"
    print(ans)

    return 0

if __name__ == "__main__":
    solve()
import sys
N,M = map(int,input().split())
ls_1 = []
ls_2 = []
ls_3 = []
for i in range(M):
    s,c = map(int,input().split())
    if s == 1:
        ls_1.append(c)
    elif s == 2:
        ls_2.append(c)
    else:
        ls_3.append(c)
if len(set(ls_1)) > 1 or len(set(ls_2)) > 1 or len(set(ls_3)) > 1 or ls_1[0] == 0:
    print(-1)
    sys.exit()
if len(ls_1) == 0:
    ls_1.append(1)
if len(ls_2) == 0:
    ls_2.append(0)
if len(ls_3) == 0:
    ls_3.append(0)
    
ans = 100 * ls_1[0] + 10 * ls_2[0] + ls_3[0]
print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
ls_1 = []
ls_2 = []
ls_3 = []
for i in range(M):
    s,c = map(int,input().split())
    if s == 1:
        ls_1.append(c)
    elif s == 2:
        ls_2.append(c)
    else:
        ls_3.append(c)
if len(set(ls_1)) > 1 or len(set(ls_2)) > 1 or len(set(ls_3)) > 1 or (N > 1 and len(ls_1) > 0 and sum(ls_1)==0):
    print(-1)
else:
    if len(ls_1) == 0:
        if N > 1:
            ls_1.append(1)
        else:
            ls_1.append(0)
    if len(ls_2) == 0:
        ls_2.append(0)
    if len(ls_3) == 0:
        ls_3.append(0)
    
    ans = (10 **(N-1)) * ls_1[0] + (10**((N-2)*(N-1)// 2)) * ls_2[0] + ((N-2)*(N-1) // 2) * ls_3[0]
    print(ans)
N = int(input())
Tlist = list(map(int, input().split()))
M = int(input())
PX = [list(map(int, input().split())) for i in range(M)]

for i in range(M):
    print(sum(Tlist)-Tlist[i]+PX[i][1])

### FIXED CODE ###

N = int(input())
Tlist = list(map(int, input().split()))
M = int(input())
PX = [list(map(int, input().split())) for i in range(M)]

for i in range(M):
    print(sum(Tlist)-Tlist[PX[i][0]-1]+PX[i][1])
def wheel(a,b):
    if a>=13:
        return b
    if a>=6 and a<=12:
        return b/2
    if a<6:
    return 0   
a,b = map(int, input().split())
print(wheel(a,b))

### FIXED CODE ###

def wheel(a,b):
    if a>=13:
        return b
    if a>=6 and a<=12:
        return int(b/2)
    if a<=5:
        return 0   
a,b = map(int, input().split())
print(wheel(a,b))
n, k = map(int, input().split())
s = list(input().split())

print(s[k-1].swapcase)

### FIXED CODE ###

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

s[k-1] = s[k-1].swapcase()
print("".join(s))
n = input()
f_x=0
for i in range(len(n)):
    f_x+=int(n[i])
if int(n)%f_n==0:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

n = input()
f_x=0
for i in range(len(n)):
    f_x+=int(n[i])
if int(n)%f_x==0:
    print('Yes')
else:
    print('No')
A, B = map(int, raw_input().split())

result = A + B

while True:
    if 24 <= result:
        result -= 24
    else:
        break

print(result)

### FIXED CODE ###

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

result = A + B

while True:
    if 24 <= result:
        result -= 24
    else:
        break

print(result)
A,B=input().strip().split()
if A>=1 and A<=100 and B>=1 and B<=100:
    A*B

### FIXED CODE ###

A,B=input().strip().split()
A,B=[int(A),int(B)]    
if A>=1 and A<=100:
    if B>=1 and B<=100:
        print(A*B)
n,k=map(int, input().split())
an=[int(i) for i in input().split()]
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 10 ** 9 + 7
N = 10 ** 5
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

an=sorted(an)
r_an=list(reversed(an))

max1=0
min1=0
for i in range(1,n-k+2):
    c=cmb(n-i,k-1,mod)
    max1=max1 + an[-i]*c%p
    min1=min1 + r_an[-i]*c%p
print((max1-min1)%p)

### FIXED CODE ###

from collections import deque

h,w=map(int, input().split())
S = [input() for _ in range(h)]

move=((1,0),(-1,0),(0,1),(0,-1))

def bfs(i,j): # 幅優先探索、マス i,j から始まる時の最長経路
    if S[i][j] == '#': # そのマスが壁ならスタート地点にならないのでパス
        return 0
    
    visited=[[0]*w for _ in range(h)] # 探索済のリスト
    visited[i][j]=1 # 最初のマスは探索済へ
    
    que=deque([(i,j,0)]) # キューの作成（queueは待ち行列）
    
    while len(que)>0:
        ci,cj,d = que.popleft() #キューの左側から取り出してキューから削除

        for mi,mj in move: #moveで定義したそれぞれの動きについて
            ni,nj = ci+mi,cj+mj # 移動先の座標をni,njとしている。
            if 0 <= ni < h and 0 <= nj < w and visited[ni][nj]==0:
                if S[ni][nj] == '.':
                    visited[ni][nj] = 1
                    que.append((ni, nj, d+1))
    return d
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, bfs(i, j))
print(ans)