Harryxun/stf_run huggingface dataset:
import copy

s = input()
X, Y = list(map(int, input().split()))

#少なくとも、右にx,↑にy進まなきゃいけない
# Fはくっつけられる
# s < 8000 よって N^2くらいならok
# Tが1回→左右 2回→前か後ろ 3回→左右
# この性質から、左右は左右のみで考えればいい
# x方向の数字N個をつかって、xを作成する 足し引きのみ 2^N xを加えて0にできるかどうか

s += "T"

now = 1
# 1はx方向、-1はy方向とする
go = 0
x = []
y = []
for i in s:
    if i == "T":
        if go != 0:
            if now == 1:
                x.append(go)
            else:
                y.append(go)
            go = 0
        now *= -1
    if i == "F":
        go += 1

X = abs(X)
Y = abs(Y)
x_use = sum(x) - X
y_use = sum(y) - Y
if x_use % 2 == 1 or y_use % 2 == 1 or x_use < 0 or y_use < 0:
    print("No")
    exit()
x_use = x_use//2
y_use = y_use//2


def solve(integer_list, target_sum,  i=0, sum=0):
    if sum > target_sum:
        False
    if i == len(integer_list):
        return sum == target_sum
    if (solve(integer_list, target_sum, i + 1, sum)):
        return True
    if (solve(integer_list, target_sum, i + 1, sum + integer_list[i])):
        return True
    return False

if solve(x, x_use) and solve(y, y_use):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

import copy

s = input()
X, Y = list(map(int, input().split()))

#少なくとも、右にx,↑にy進まなきゃいけない
# Fはくっつけられる
# s < 8000 よって N^2くらいならok
# Tが1回→左右 2回→前か後ろ 3回→左右
# この性質から、左右は左右のみで考えればいい
# x方向の数字N個をつかって、xを作成する 足し引きのみ 2^N xを加えて0にできるかどうか

s += "T"

now = 1
# 1はx方向、-1はy方向とする
start = 0
go = 0
x = []
y = []
for i in s:
    if i == "T":
        if start == 0:
            X = X - go
            go = 0
            start = 1
        else:
            if go != 0:
                if now == 1:
                    x.append(go)
                else:
                    y.append(go)
                go = 0
        now *= -1
    if i == "F":
        go += 1
x.sort()
y.sort()
x = x[::-1]
y = y[::-1]
X = abs(X)
Y = abs(Y)
x_use = sum(x) - X
y_use = sum(y) - Y
if x_use % 2 == 1 or y_use % 2 == 1 or x_use < 0 or y_use < 0:
    print("No")
    exit()
x_use = x_use//2
y_use = y_use//2


def solve(integer_list, target_sum,  i=0, sum=0):
    if sum > target_sum:
        return False
    if sum == target_sum:
        return True
    if i == len(integer_list):
        return sum == target_sum
    if (solve(integer_list, target_sum, i + 1, sum)):
        return True
    if (solve(integer_list, target_sum, i + 1, sum + integer_list[i])):
        return True
    return False

#if solve(x, x_use) and solve(y, y_use):
#    print("Yes")
#else:
#    print("No")


def part_sum0(a,A):
    #初期化
    N=len(a)
    dp=[[0 for i in range(A+1)] for j in range(N+1)]
    dp[0][0]=1

    #DP
    for i in range(N):
        for j in range(A+1):
            if a[i]<=j: #i+1番目の数字a[i]を足せるかも
                dp[i+1][j]=dp[i][j-a[i]] or dp[i][j]
            else: #入る可能性はない
                dp[i+1][j]=dp[i][j]
    return dp[N][A]
 
if part_sum0(x,x_use) and part_sum0(y, y_use):
    print("Yes")
else:
    print("No")
a = list(map(int,input().split()))
N = a[0]
L = a[1]

taste = 0

def if_test(N,L):
    if L > 0:
     for i in range(N):
      taste = taste + L + i
       
     taste = taste - L
     print(taste)
      
    elif L+N-1 < 0:
     for i in range(N):
      taste = taste + L + i 
          
     taste = taste - (L + N - 1)   
     print(taste)
        
    else:
     for i in range(N):
      taste = taste + L + i
      
     print(taste)
    
if_test(L,N)


### FIXED CODE ###

a = list(map(int,input().split()))
N = a[0]
L = a[1]
  

 
def if_test(N,L):
  taste = 0
  if L > 0:
     for i in range(N):
      taste += (L + i)
#      print("L>0"+str(taste))
       
     taste = taste - L
     print(taste)
      
  elif (L+N-1) < 0:
     for i in range(N):
      taste = taste + L + i 
#      print("<0"+str(taste))
          
     taste = taste - (L + N - 1)   
     print(taste)
        
  else:
     for i in range(N):
      taste = taste + L + i
#      print(taste)
     print(taste)
    
if_test(N,L)
h,w,d=map(int,input().split())
l={}
for i in range(h):
  l1=list(map(int,input().split()))
  for j in l1:
    l[j]=[l1.index(j)+1,i+1]
li=[]
for i in range(1,d+1):
  l11=[]
  c=0
  x=l[i][0]
  y=l[i][1]
  while i<=h*w:
    c+=abs(x-l[i][0])+abs(y-l[i][1])
    l11.append(c)
    x=l[i][0]
    y=l[i][1]
    i+=d
  li.append(l11)
q=int(input())
for i in range(q):
  a,b=map(int,input().split())
  r=a%d
  if r==0:
    print(li[d][b//d-1]-li[d][a//d-1])
  else:
    print(li[r-1][b//d]-li[r-1][a//d])

### FIXED CODE ###

h,w,d=map(int,input().split())
l={}
for i in range(h):
  l1=list(map(int,input().split()))
  for j in l1:
    l[j]=[l1.index(j)+1,i+1]
li=[]
for i in range(1,d+1):
  l11=[]
  c=0
  x=l[i][0]
  y=l[i][1]
  while i<=h*w:
    c+=abs(x-l[i][0])+abs(y-l[i][1])
    l11.append(c)
    x=l[i][0]
    y=l[i][1]
    i+=d
  li.append(l11)
q=int(input())
for i in range(q):
  a,b=map(int,input().split())
  r=a%d
  if r==0:
    print(li[d-1][b//d-1]-li[d-1][a//d-1])
  else:
    print(li[r-1][b//d]-li[r-1][a//d])
a = int(input().split())
print(round((a[0]+a[1])/2))

### FIXED CODE ###

S=((input())).split(' ')
print((int)(((int)(S[0])+(int)(S[1]))/2+0.5))
from collections import Counter
 
M = 998244353
n = int(input())
a = map(int, input().split())
x, c = next(a), Counter(a)
r = 0
if x == c[0] == 0:
  r = p = i = 1
  x = c.get(i)
  while x and i < n:
    r = r * pow(p, x, M) % M
    p = x; i += 1; x = c.get(i); n -= x
print((r, 0)[n > 1])

### FIXED CODE ###

from collections import Counter

M = 998244353
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
if a[0] == 0 and c[0] == 1:
    r = i = 1
    while c[i]:
        r = r * pow(c[i - 1], c[i], M) % M
        n -= c[i]
        i += 1
print(r if n == 1 else 0)
#-*- coding:utf-8 -*-
a,b = int(input()),int(input())

if a*b %2 == 0:
    print("Even")
else: print("Odd")

### FIXED CODE ###

#-*- coding:utf-8 -*-
a = list(map(int,input().split()))


if a[0]*a[1] %2 == 0:
    print("Even")
else: print("Odd")
s = int(input())

for i in range(4):
    if s[i] == s[i+1]:
        print("Bad")
    else:
        print("Good")

### FIXED CODE ###

a = input()
for i in range(3):
    if a[i] == a[i+1]:
        print("Bad")
        quit()
print("Good")
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*(n+1)
cnt=[0]*m
s=set()
for i in range(1,n+1):
  b[i]=b[i-1]+a[i-1]
for i in range(n+1):
  cnt[b[i]%m]+=1
  s.add(b[i]%m)
ans=0
for i in s:
  ans+=cnt[i]*(cnt[i]-1)//2
print(ans)


### FIXED CODE ###

from collections import Counter
import numpy as np
n,m=map(int,input().split())
a=[0]+list(map(int,input().split()))
d=Counter(np.cumsum(a)%m)
ans=0
for v in d.values():
  ans+=v*(v-1)//2
print(ans)
n,m=map(int,input().split())
pem=1
if m==1:
    print(1)
    pem=-1
def fctr2(n): #それぞれの素因数の指数だけ出力
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append(c)
            c=0
    if n!=1:
        f.append(1)
    return f

mod=10**9+7
fuc=[1]
def fucfun(n):
    for i in range(1,n):
        e=fuc[i-1]*i
        fuc.append(e%mod)
def com(n,k):
    com=(fuc[n]%mod)*pow(fuc[k],mod-2,mod)*pow(fuc[n-k],mod-2,mod)
    return com
f=fctr2(m)
a=max(f)+n
fucfun(a)
s=1
for i in range(len(f)):
    t=com(f[i]+n-1,f[i])
    s=(s*t)%mod
if pem==1:
    print(s)

### FIXED CODE ###

n,m=map(int,input().split())
pem=1
if m==1:
    print(1)
def fctr2(n): #それぞれの素因数の指数だけ出力
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append(c)
            c=0
    if n!=1:
        f.append(1)
    return f

mod=10**9+7
fuc=[1]
def fucfun(n):
    for i in range(1,n):
        e=fuc[i-1]*i
        fuc.append(e%mod)
def com(n,k):
    com=(fuc[n]%mod)*pow(fuc[k],mod-2,mod)*pow(fuc[n-k],mod-2,mod)
    return com
f=fctr2(m)
if m!=1:
    a=max(f)+n
    fucfun(a)
    s=1
    for i in range(len(f)):
        t=com(f[i]+n-1,f[i])
        s=(s*t)%mod
    print(s)
a,b = [int(i) for i in input().split]

if   (a < b):
    print(a < b)

elif (a > b):
    print(a > b)

else 
    print(a == b)

### FIXED CODE ###

a, b = [int(i) for i in input().split()]
 
if a < b:
    print("a < b")
 
elif a > b:
    print("a > b")
 
else:
    print("a == b")
n = int(raw_input())
A = map(int, raw_input().split())
q = int(raw_input())
M = map(int, raw_input().split())
  
def solve(i,m):
  if m == 0:
    return True
  if i >= n or m - sum(A) > 0:
    return False
  res = solve(i+1,m) or solve(i+1, m-A[i]
  return res

for j in range(q):
   if solve(0,m[j]):
      print "yes"
   else:
      print "no"
 

### FIXED CODE ###

n = int(raw_input())
A = map(int, raw_input().split())
q = int(raw_input())
M = map(int, raw_input().split())
  
def solve(i,m):
  if m == 0:
    return True
  if i >= n or m - sum(A) > 0:
    return False
  res = solve(i+1,m) or solve(i+1, m-A[i])
  return res

for j in range(q):
   if solve(0,M[j]):
      print "yes"
   else:
      print "no"
n = int(input())
for i in range(n):
    left = right = []
    arr = map(int, input().split())
    for a in arr:
        if len(left) == 0 or left[-1] < a:
            left.append(a)
        elif len(right) == 0 or right[-1] < a:
            right.append(a)
        else:
            break
    if len(arr) == len(left) + len(right):
        print("YES")
    else:
        print("NO")

### FIXED CODE ###

n = int(input())
for i in range(n):
    left, right = [], []
    arr = map(int, input().split())
    for a in arr:
        if len(left) == 0 or left[-1] < a:
            left.append(a)
        elif len(right) == 0 or right[-1] < a:
            right.append(a)
        else:
            break
    if len(left) + len(right) == 10:
        print("YES")
    else:
        print("NO")
N=int(input())
count=1
size=1
p=list(map(int,input().split()))
q=[p[0]]
for i in range (1,N):
  if p[i]!=p[i-1]:
    q.append(p[i])
    size+=1
j=0
while True:
  if j>=size-3:
    break
  while (q[j]-q[j+1])*(q[j+1]-q[j+2])>=0:
    j+=1
  count+=1
  j+=2
print(count)

### FIXED CODE ###

N=int(input())
count=1
size=1
p=list(map(int,input().split()))
q=[p[0]]
for i in range (1,N):
  if p[i]!=p[i-1]:
    q.append(p[i])
    size+=1
j=0
while True:
  if j>=size-2:
    break
  while (q[j]-q[j+1])*(q[j+1]-q[j+2])>=0:
    if j>=size-3:
      count-=1
      break
    j+=1    
  count+=1
  j+=2
print(count)
# -*- coding: utf-8 -*-
# 文字列の入力
S = str(input())

ans=0

if len(S)==1:
  ans=0
elif len(S)==2:
  if S[0]==S[1]:
    ans=1
  else:
    ans=0
else: #3枚以上はちゃんと読み込む
  strint=[]
  original_string=[]
  
  for i in range(len(S)):
    string.append(S[i])
    original_string.append(S[i])
    
  for i in range(len(S)-2):
    gramed = str(string[i])+str(string[i+1])+str(string[i+2])
    
    if gramed=="000":
      string[i+1]="1"
    if gramed=="001":
      string[i]="1"
    if gramed=="011":
      string[i+2]="0"
    if gramed=="110":
      string[i]="0"
    if gramed=="100":
      string[i+2]="1"
    if gramed=="111":
      string[i+1]="1"
  
  #print(string)
  #print(original_string)
  
  for i in range(len(S)):
    if original_string[i]!=string[i]:
      ans=ans+1
  
print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
# スペース区切りの整数の入力
A, B = map(int, input().split())

ans=max((A)+(A-1),A+B,B+(B-1))

print(ans)
import fractions
import bisect
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
N, M = map(int, input().split())
S = input()
T = input()
L = lcm(N,M)
S_arr = [0]*N
T_arr = [0]*M
for i in range(1,N):
    S_arr[i] = i*(L//N)
for i in range(1,M):
    T_arr[i] = i*(L//M)
for i in range(M):
    index = bisect.bisect_left(S_arr,T_arr[i])
    if S_arr[index] == T_arr[i] and S[index] != T[i]:
        print(-1)
        exit()
print(L)

### FIXED CODE ###

import fractions
import bisect
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
N, M = map(int, input().split())
S = input()
T = input()
L = lcm(N,M)
S_arr = [0]*N
T_arr = [0]*M
for i in range(1,N):
    S_arr[i] = i*(L//N)
for i in range(1,M):
    T_arr[i] = i*(L//M)
if M <= N:
    for i in range(M):
        index = bisect.bisect_left(S_arr,T_arr[i])
        if S_arr[index] == T_arr[i] and S[index] != T[i]:
            print(-1)
            exit()
else:
    for i in range(N):
        index = bisect.bisect_left(T_arr,S_arr[i])
        if T_arr[index] == S_arr[i] and T[index] != S[i]:
            print(-1)
            exit()

print(L)
s=input()
s1=int(s[0]+s[1])
s2=int(s[2]+s[3])
if 1 <= s1 <= 12 and 1 <= s2 <= 12:
    print("AMBIGUOUS")
elif 1 <= s1 <= 12:
    print("MMYY")
elif 1 <= s2 <= 12:
    print("YYMM")
else:
    print("NA")

### FIXED CODE ###

N,K = map(int, input().split())
S = input()
S_list =list(S)
l ={"A":"a","B":"b","C":"c"}
ans=S_list[K-1]
S_list[K-1]=l[ans]
print("".join(S_list))
a = input()
l = list(a)
num = len(l)
TorF = True

if num % 2 == 0:
    b = num/2
    for i in range(b):
        if not a(2*i ) == 'h' and a(2*i + 1) == 'i':
            TorF = False
            break
else:
    TorF = False

if TorF == True:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

a = input()
l = list(a)
num = len(l)
TorF = True

if num % 2 == 0:
    b = int(num/2)
    for i in range(b):
        if not (a[2*i] == 'h' and a[2*i + 1] == 'i'):
            TorF = False
            break
else:
    TorF = False

if TorF == True:
    print('Yes')
else:
    print('No')
import heapq
n , m = map(int,input().split())
kouho = [[] for i in range(m)]
hosyu = [0 for i in range(m)]
for i in range(n):
    a , b = map(int,input().split())
    kouho[a-1].append(-b)
for i in range(m):
    now = i
    p = 0
    heapq.heapify(kouho[i])
    while kouho[i]:
        if now == m:
            break
        if p == 0:
            p = heapq.heappop(kouho[i])
        if hosyu[now] > p:
            hosyu[now] = p
            p = 0
        now += 1
print(abs(sum(hosyu)))

### FIXED CODE ###

import heapq
n , m = map(int,input().split())
kouho = [[] for i in range(m)]
for i in range(n):
    a , b = map(int,input().split())
    if a <= m:
        kouho[a-1].append(-b)
ans = 0
p = []
heapq.heapify(p)

for i in range(m):

    for j in kouho[i]:
        heapq.heappush(p,j)
    if p:
        ans -= heapq.heappop(p)
print(ans)
a, b, n = map(int(input().split()))
x = min(b-1, n)
print(floor(a*x/b) - a * floor(x/b))

### FIXED CODE ###

from math import floor
a, b, n = map(int, input().split())
if b == 1:
	print(0)
else:
	x = min(b-1, n)
	print(floor(a*x/b) - a * floor(x/b))
i=input()
l=map(int,input().split())
ans=min(l[1],l[3])-max(l[0],l[2])
print(ans if ans>0 else 0)

### FIXED CODE ###

l=list(map(int,input().split()))
ans=min(l[1],l[3])-max(l[0],l[2])
print(ans if ans>0 else 0)
right_list=[] #右に進む
left_list=[] #左に進む
diff_list=[] #差分

right_list.append(l[0])
left_list.append(l[n-1])

for i in range(1,n):
    right_list.append(right_list[i-1]+l[i])
    left_list.append(left_list[i-1]+l[n-1-i])

left_list.reverse()

for i in range(0,n-1):
    diff_list.append(abs(right_list[i]-left_list[i+1]))

print(min(diff_list))

### FIXED CODE ###

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

right_list=[] #右に進む
left_list=[] #左に進む
diff_list=[] #差分

right_list.append(l[0])
left_list.append(l[n-1])

for i in range(1,n):
    right_list.append(right_list[i-1]+l[i])
    left_list.append(left_list[i-1]+l[n-1-i])

left_list.reverse()

for i in range(0,n-1):
    diff_list.append(abs(right_list[i]-left_list[i+1]))

print(min(diff_list))
a, b, c = map(int, input().split())
k = int(input())

for i in range(k):
    maxnum = max(a, b, c)
    if maxnum == a:
        a *= 2
    elif maxnum == b:
        b *= 2
    elif maxnum == c:
        c *= 2
print(sum(a, b, c))

### FIXED CODE ###

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

for i in range(k):
    maxnum = max(a, b, c)
    if maxnum == a:
        a *= 2
    elif maxnum == b:
        b *= 2
    elif maxnum == c:
        c *= 2
print(a + b + c)
a = int(input())
b = int(input())
print((a + b) * 2)


### FIXED CODE ###

a , b = map(int, input().split())
print(a * b, (a + b) * 2)
a = input()

if a(:1) = 's':
  print(a end='es')
else:
  print(a end='s')

### FIXED CODE ###

a = input()
 
if a[-1] == 's':
  print(a, end='es')
else:
  print(a, end='s')
N = int(input())
min = 999999
A = 0
B = 0
def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

for i in range(1, N/2):
    a = i
    b = N - i
    if min > digitSum(a) + digitSum(b):
        min = digitSum(a) + digitSum(b)   

print(min)

### FIXED CODE ###

N = int(input())
min = 999999

A = 0
B = 0

def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

for i in range(1, N/2+1):
    a = i
    b = N - i

    if min > digitSum(a) + digitSum(b):
        min = digitSum(a) + digitSum(b)   

print(min)
N,Y = map(int,input().split())
for i in range(int(N)):
	for n in range(int(N-i)):
		m = N-i-n
		if i*10000+n*5000+m*1000 ==Y:
			print(i,n,m)
        else:
	break
if 10000*i+5000*n+1000*m != Y:
	print(-1,-1,-1)

### FIXED CODE ###

N,Y = map(int,input().split())
for i in range(N+1):
    for n in range(N-i+1):
        if 10000*i+5000*n+1000*(N-i-n) == Y:
            print(i,n,N-i-n)
            break
    else:
        continue
    break
else:
    print(-1,-1,-1)
def main():
    h,w = map(int, input().split())

    A = []
    grid = []
    for i in range(h):
        A.append(input())
    gird = []

    for i in range(h):
        if A[i] != '.'*w:
            grid.append(A[i])

    A = grid.copy()
    w_tmp = len(A[0])
    h_tmp = len(A)
    grid = ['' for _ in range(h_tmp)]
    for i in range(w_tmp):
        tmp = 0
        for j in range(h_tmp):
            if A[j][i] == '.':
                tmp += 1
        if tmp != h_tmp:
            for j in range(h_tmp):
                grid[j] += A[j][i]
    for i in range(len(grid)):
        print(grid[i])


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    h,w = map(int, input().split())

    A = []
    grid = []
    for i in range(h):
        A.append(input())
    gird = []

    for i in range(h):
        if A[i] != '.'*w:
            grid.append(A[i])

    A = grid.copy()
    w_tmp = len(A[0])
    h_tmp = len(A)
    grid = ['' for _ in range(h_tmp)]
    for i in range(w_tmp):
        tmp = 0
        for j in range(h_tmp):
            if A[j][i] == '.':
                tmp += 1
        if tmp != h_tmp:
            for j in range(h_tmp):
                grid[j] += A[j][i]
    for i in range(len(grid)):
        print(grid[i])


if __name__ == '__main__':
    main()
import numpy as np
n = int(input())
a_list = np.array(list(map(int, input().split())))

status = True
counter = 0
while status:
    if np.sum(a_list % 2) > 0:
        break
    counter += 1
    a_list = a_list / 2
print(counter)


### FIXED CODE ###

s = input()
counter = 0

for i in range(len(s)):
    if s[i] == '1':
        counter += 1
print(counter)
a,b,c = map(int,input())
ave = int((a+b+c)/2)
if a == ave or b == ave or c == ave:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a,b,c = map(int,input().split())
if a+b == c or b+c == a or c+a == b:
  print("Yes")
else:
  print("No")
n = int(input())
a = [int(input()) for i in range(n)]
b = sorted(a)

for A in a:
    if A == b[n - 1]:
        print(b[n - 2])
    else:
        print(b[n - 1])

### FIXED CODE ###

r = int(input())

print(3 * r * r)
read = input
read = Read(False, """
1 1 3
1
10000000000
2
9999999999
5000000000
""").read
A,B,Q = list(map(int, read().split(' ')))
arrA = list(map(int, [read() for i in range(A)]))
arrB = list(map(int, [read() for i in range(B)]))
arrQ = list(map(int, [read() for i in range(Q)]))
arrA.sort()
arrB.sort()
import bisect
def cs(x, arr):
    al = bisect.bisect_left(arr, x)
    return list(map(lambda i: arr[i], filter(lambda i:i>=0 and i< len(arr), range(al-1, al + 2))))
def same_s(da,db):
    da = da / abs(da)
    db = db / abs(db)
    return da*db>0
    
def t(q,a,b):
    da = q - a
    db = q - b
    if(min(abs(da), abs(db)) == 0):
        return max(abs(da), abs(db))
    if same_s(da, db):
        return max(abs(da), abs(db))
    else :
        return 2*min(abs(da), abs(db)) + max(abs(da), abs(db))
for q in arrQ:
    optA = cs(q, arrA)
    optB = cs(q, arrB)
    ret = 10 ** 11
    for a in optA:
        for b in optB:
            ret = min(ret, t(q, a,b))
    print(ret)

### FIXED CODE ###

import bisect
read = input
bisect_right = bisect.bisect_right
# @ see https://docs.python.org/zh-cn/3/library/bisect.html
a ,b , q = map(int, read().split())
INF = 10**18
A =[-INF] + [int(read()) for i in range(a)] +[INF]
B =[-INF] + [int(read()) for i in range(b)] +[INF]
A.sort()
B.sort()
try:
    for i in range(q):
        x = int(read())
        sa = bisect_right(A, x)
        sb = bisect_right(B, x)
        ans = INF
        for pa in [A[sa - 1 ], A[sa]]:
            for pb in [B[sb - 1 ], B[sb]]:
                d1 = abs(x - pa) + abs(pa - pb)
                d2 = abs(x - pb) + abs(pb - pa)
                ans = min(ans, d1, d2)
        print(ans)
except:
    print(x, sa, sb)
s=input()
aa=int(s[:2])
bb=int(s[3:])
if 0<aa<=12 and 0<bb<=12: ans='AMBIGUOUS'
elif 0<bb<=12: ans='YYMM'
elif 0<aa<=12: ans='MMYY'
else: ans='NA'
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
s=list(input())
s[k-1]=s[k-1].lower()
print(''.join(s))
S = sorted(list(set(input())))

alphabet = list('abcdefghijklmnopqrstuvwxyz')

if alphabet == S:
    print('None')
    exit()
elif len(S) == 1 and S[0] == 'a':
    print('b')
    exit()

for i in range(len(alphabet)):
    if S[i] == alphabet[i]:
        continue
    else:
        print(alphabet[i])
        exit()


### FIXED CODE ###

S = sorted(list(set(input())))

alphabet = list('abcdefghijklmnopqrstuvwxyz')

for i in range(len(alphabet)):
    if alphabet[i] not in S:
        print(alphabet[i])
        exit()

print('None')
a,b=input().split()
print(int(a-b+1))

### FIXED CODE ###

a,b=input().split()
a=int(a)
b=int(b)
print(int(a-b+1))
N, M = map(int, input().split())
for i in range(1, M):
    if M / i < N:
        break
    if M % i == 0:
        ans = i
print(ans)


### FIXED CODE ###

N, M = map(int, input().split())
ans = 1

S = M / N
S = int(S)
#print(S)
import math
if N == 1:
    ans = M
else:
    not_sosu = -1
    for i in range(2, int(math.sqrt(M)) + 1):
        if M % i == 0:
            not_sosu = 1
            if M / i >= N and M % i == 0:
                ans = max(ans, i)
            j = M // i
            if M / j >= N and M % j == 0:
                ans = max(ans, j)
            #print(i)
    if not_sosu == -1:
        ans = 1


if N == 1:
    ans = M

print(ans)
INF = 9999999999999999999
d = [INF for i in range(v)]
d[r] = 0
heapq.heappush(v_q,(0,r))
while(len(v_q) != 0):
    cost,u = heapq.heappop(v_q)
    if(cost > d[u]):
        continue
    for j in range(e):
        if(u == e_1[j]):
            alt = cost+e_w[j]
            if(d[e_2[j]] > alt):
                d[e_2[j]] = alt
                heapq.heappush(v_q,(alt,e_2[j]))

for i in range(v):
    if(d[i] != INF):
        print(d[i])
    else:
        print("INF")


### FIXED CODE ###

import sys
from collections import deque

v,e,r=map(int, input().split());

edge_info=[0]*v;
for i in range(v):
    edge_info[i] = []

for i in range(e):
    e1, e2, w = map(int, input().split());
    edge_info[e1].append((e2,w))

v_q=deque();

INF = 9999999999999999999
d = [INF for i in range(v)]
d[r] = 0
v_q.append((0,r))
while(len(v_q) != 0):
    cost,u = v_q.popleft()
    if(cost > d[u]):
        continue
    for j in range(len(edge_info[u])):
        e2,w = edge_info[u][j]
        alt = cost+w
        if(d[e2] > alt):
            d[e2] = alt
            v_q.append((alt,e2))

for i in range(v):
    if(d[i] != INF):
        print(d[i])
    else:
        print("INF")