Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys
sys.setrecursionlimit(500000) 
input = sys.stdin.readline
from collections import deque
from heapq import heapify, heappop, heappush
H,W = map(int,input().split())
C = list(map(int,input().split()))
C[0] -= 1; C[1] -= 1
D = list(map(int,input().split()))
D[0] -= 1; D[1] -= 1
S = []; INF = float("inf")
for i in range(H):
  temp = str(input());temp =list(temp)
  S.append(temp)
#print(S)
reach = [[INF]*W for _ in range(H)]
reach[C[0]][C[1]] = 0
dxdy = [(1,0),(-1,0),(0,1),(0,-1)]
Q = deque([])
Q.append([0,C])
while Q:
  score,z = heappop(Q)
  x = z[0];y=z[1]
 
  for i in range(4):
    nx = x + dxdy[i][0]
    ny = y + dxdy[i][1]
    #print(nx,ny)
    if 0<=nx<H and 0<=ny<W and S[nx][ny] == "." and reach[nx][ny] > score:
      reach[nx][ny] = min(score,reach[nx][ny])
      u = [nx,ny]
      heappush(Q,[score,u])
  #print(reach)
 
  for i in range(5): #0~4
    for j in range(5):
      mx = x-2 + i
      my = y-2 + j
      if i == 2 and j == 2:
        continue
      if mx < 0 or mx >= H or my < 0 or my >= W or S[mx][my] == "#":
        continue
      if reach[mx][my] <= score+1: #すでにこのスコア以下でいける。
        continue
      reach[mx][my] = min(score+1,reach[mx][my])
      p = [mx,my]
      #print(v,p,"X")
      heappush(Q,[score+1,p])
#dfs(C,0)
#print(reach)
#print(reach[D[0]][D[1]])
if reach[D[0]][D[1]] == INF:
  print(-1)
else:
  print(reach[D[0]][D[1]])

### FIXED CODE ###

import sys
sys.setrecursionlimit(500000) 
input = sys.stdin.readline
from collections import deque
H,W = map(int,input().split())
C = list(map(int,input().split()))
C[0] -= 1; C[1] -= 1
D = list(map(int,input().split()))
D[0] -= 1; D[1] -= 1
S = []; INF = float("inf")
for i in range(H):
  temp = str(input());temp =list(temp)
  S.append(temp)
#print(S)
reach = [[INF]*W for _ in range(H)]
reach[C[0]][C[1]] = 0
dxdy = [(1,0),(-1,0),(0,1),(0,-1)]
Q = deque([])
Q.append([C,0])
while Q:
  z, score = Q.popleft()
  x = z[0];y=z[1]
 
  for i in range(4):
    nx = x + dxdy[i][0]
    ny = y + dxdy[i][1]
    #print(nx,ny)
    if 0<=nx<H and 0<=ny<W and S[nx][ny] == "." and reach[nx][ny] > score:
      reach[nx][ny] = min(score,reach[nx][ny])
      u = [nx,ny]
      Q.appendleft([u,score])
  #print(reach)
 
  for i in range(5): #0~4
    for j in range(5):
      mx = x-2 + i
      my = y-2 + j
      if i == 2 and j == 2:
        continue
      if mx < 0 or mx >= H or my < 0 or my >= W or S[mx][my] == "#":
        continue
      if reach[mx][my] <= score+1: #すでにこのスコア以下でいける。
        continue
      reach[mx][my] = min(score+1,reach[mx][my])
      p = [mx,my]
      #print(v,p,"X")
      Q.append([p,score+1])
#dfs(C,0)
#print(reach)
#print(reach[D[0]][D[1]])
if reach[D[0]][D[1]] == INF:
  print(-1)
else:
  print(reach[D[0]][D[1]])
### BUGGY CODE ###

N = int(input())

A = []
B = []
for i in range(N):
    a,b=map(int, input().split()) 
    A.append(a)
    B.append(b)
    tasks = dict(zip(range(N),B))

sorted_tasks = sorted(tasks.items(), key=lambda x:x[1])

sum = 0
flg = False

for k, v in sorted_tasks:
    sum += A[k]
    if (sum > v):
        flg = True
        break

if (flg):
    print('No')
else:
    print('Yes')

### FIXED CODE ###

N = int(input())

W=[[int(_) for _ in input().split()] for __ in range(N)]  

W.sort(key=lambda x: x[1])

sum = 0
flg = False

for i in range(N):
    sum += W[i][0]
    if (sum > W[i][1]):
        flg = True
        break

if (flg):
    print('No')
else:
    print('Yes')
### BUGGY CODE ###

S = list(input())
P = 0
for i in range(len(S)-3):
    for j in range(i+4,len(S)+1):
        M = '0'
        for k in range(j-i):
            M += S[i+k]
        N = int(M)
        if N%2019 == 0:
            P += 1
print(P)

### FIXED CODE ###

def main():
  n, d, mods = 0, 1, [1]+[0]*2019
  for i in reversed(input()):
    n = (n+int(i)*d)%2019
    d = d*10%2019
    mods[n] += 1
  print(sum([i*(i-1)//2 for i in mods]))
main()
### BUGGY CODE ###

N = int(raw_input())
A = list(map(int,raw_input().split()))
ans = []
for i in range(0,N):
  ans.append(A.index(i+1)+1)
for i in ans:
  print i, 


### FIXED CODE ###

N = int(raw_input())
A = list(map(int,raw_input().split()))
ans = [0]*N
for (index,con) in enumerate(A):
  ans[con-1] = index+1
for i in ans:
  print i,
### BUGGY CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, M = map(int, input().split())
    A = [int(input()) for _ in range(M)]

    mod = 10**9 + 7
    dp = [0] * (N + 1)
    dp[0] = 1

    for i in range(1, N + 1):
        if i in A:
            continue

        if i == 1:
            dp[1] = dp[0]
            continue

        dp[i] = dp[i - 1] + dp[i - 2]
        dp[i] %= mod

    print(dp[N])


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, M = map(int, input().split())
    A = set([int(input()) for _ in range(M)])

    mod = 10**9 + 7
    dp = [0] * (N + 1)
    dp[0] = 1

    for i in range(1, N + 1):
        if i in A:
            continue

        if i == 1:
            dp[1] = dp[0]
            continue

        dp[i] = dp[i - 1] + dp[i - 2]
        dp[i] %= mod

    print(dp[N])


if __name__ == "__main__":
    main()
### BUGGY CODE ###

def popcount(n):
    return bin(n).count("1")


cache = [-1] * (2 * 10 ** 5 + 1)


def f(n):
    if cache[X] != -1:
        return cache[X]
    return f(n % popcount(n)) + 1


N = int(input())
X = int(input(), 2)

result = []
for i in range(N):
    n = X ^ (1 << (N - 1 - i))
    t = 0
    while n != 0:
        n %= popcount(n)
        t += 1
    result.append(t)
print(*result, sep='\n')


### FIXED CODE ###

def popcount(n):
    return bin(n).count("1")


def f(n):
    if n == 0:
        return 0
    return 1 + f(n % popcount(n))


N = int(input())
X = input()

c = X.count('1')
t1 = [0] * N
t1[0] = 1 % (c + 1)
for i in range(1, N):
    t1[i] = (t1[i - 1] << 1) % (c + 1)
x1 = 0
for i in range(N):
    if X[i] == '0':
        continue
    x1 += t1[N - 1 - i]

if c - 1 != 0:
    t2 = [0] * N
    t2[0] = 1 % (c - 1)
    for i in range(1, N):
        t2[i] = (t2[i - 1] << 1) % (c - 1)
    x2 = 0
    for i in range(N):
        if X[i] == '0':
            continue
        x2 += t2[N - 1 - i]

result = []
for i in range(N):
    if X[i] == '0':
        n = (x1 + t1[N - 1 - i]) % (c + 1)
    elif X[i] == '1':
        if c - 1 == 0:
            result.append(0)
            continue
        n = (x2 - t2[N - 1 - i]) % (c - 1)
    result.append(1 + f(n))
print(*result, sep='\n')
### BUGGY CODE ###

n=int(input())
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

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

ans=[]
for num,cnt in factorization(n):
  for _ in range(cnt):
    ans.append(num)
out=float('inf')
tmp=[]
for i in range(2**len(ans)//2):
  tmp1,tmp2=1,1
  for j in range(len(ans)):
    if i>>j&1:
      tmp1*=ans[j]
    else:
      tmp2*=ans[j]
  out=min(out,tmp1-1+tmp2-1)
print(out)

### FIXED CODE ###

import math
n=int(input())

def make_divisors(n):
  divisors=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      divisors.append(i)
      if i!=n//i:
        divisors.append(n//i)
  divisors.sort()
  return divisors
a=make_divisors(n)
if len(a)%2==1:
  print(2*int(math.sqrt(n))-2)
if len(a)%2==0:
  b=a[len(a)//2-1]
  c=a[len(a)//2]
  print(b+c-2)
### BUGGY CODE ###

import math
from collections import defaultdict
from itertools import product
from functools import reduce 
from operator import mul


def is_prime(num):
    if not isinstance(num, int):
        return False
    if num <= 1:
        return False
    if num == 2 or num == 3:
        return True
    if num % 6 in [0, 2, 3, 4]:
        return False
    div_max = int(math.sqrt(num))
    for div in range(5, div_max + 1, 2):
        if num % div == 0:
            return False
    return True

def factorint(x):
    factors = defaultdict(int)
    while not is_prime(x):
        div_max = int(math.sqrt(x))
        for div in range(2, div_max + 1):
            if x % div == 0:
                factors[div] += 1
                x = int(x / div)
                break
    factors[x] += 1
    return factors

ans = 0
n = int(input())
rn = math.sqrt(n+1) + 1
factor_dict = factorint(n)
ks = [range(k+1) for k in factor_dict.values()]
prs = product(*ks)
for pr in prs:
    s = reduce(mul, [factor**p for factor,p in zip(factor_dict.keys(), pr)])
    if s >= rn:
        ans += s -1
print(ans)


### FIXED CODE ###

import math
from collections import defaultdict
from itertools import product
from functools import reduce 
from operator import mul


def is_prime(num):
    if not isinstance(num, int):
        return False
    if num <= 1:
        return False
    if num == 2 or num == 3:
        return True
    if num % 6 in [0, 2, 3, 4]:
        return False
    div_max = int(math.sqrt(num))
    for div in range(5, div_max + 1, 2):
        if num % div == 0:
            return False
    return True

def factorint(x):
    factors = defaultdict(int)
    if x==1:
        factors[1] = 1
        return factors
    while not is_prime(x):
        div_max = int(math.sqrt(x))
        for div in range(2, div_max + 1):
            if x % div == 0:
                factors[div] += 1
                x = int(x / div)
                break
    factors[x] += 1
    return factors

ans = 0
n = int(input())
rn = math.sqrt(n+1) + 1
factor_dict = factorint(n)
ks = [range(k+1) for k in factor_dict.values()]
prs = product(*ks)
for pr in prs:
    s = reduce(mul, [factor**p for factor,p in zip(factor_dict.keys(), pr)])
    if s >= rn:
        ans += s -1
print(ans)
### BUGGY CODE ###

N,M=map(int,input().split())
ab=[list(map(int,input().split())) for l in range(N)]
ct=0
money=0
l=[]
for i in range(N):
    l.append(ab[i][0])
while ct<M:
    min_id=l.index(min(l))
    if ct+ab[min_id][1]<M:
        money+=ab[min_id][0]*ab[min_id][1]
        ct+=ab[min_id][1]
        l[min_id]=10000000000
    else:
        for i in range(ab[min_id][1]):
            money+=l[min_id]
            ct+=1
            if ct==M:
                break
        l[min_id]=100000000000
        if ct==M:
            break
print(money)



### FIXED CODE ###

N,M=map(int,input().split())
ab=[list(map(int,input().split())) for l in range(N)]
ct=0
ct1=0
ct2=0
money=0
l=[]
id=[]
for i in range(N):
    l.append(ab[i][0])
id=sorted(range(len(l)),key=lambda k: l[k])
l.sort()
while ct<M:
    while ct2<ab[id[ct1]][1]:##
        money+=l[ct1] #l[ct1]
        #print(money,l[ct1])
        ct+=1
        ct2+=1
        if ct==M:
            break
    ct1+=1
    ct2=0
print(money)
### BUGGY CODE ###

n,x,y=map(int,input().split())
x-=1
y-=1
D=[[0]*n for _ in range(n)]
for i in range(n-1):
    for j in range(i+1,n):
        D[i][j]=min(abs(j-i),abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))

K=[0]*(n-1)

for i in range(n-1):
    for j in range(i+1,n):
        K[D[i][j]-1]+=1

for k in K:
    print(k)

### FIXED CODE ###

n,x,y=map(int,input().split())
x-=1
y-=1
D=[[0]*n for _ in range(n)]
for i in range(n-1):
    for j in range(i+1,n):
        D[i][j]=min(abs(j-i),abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))

K=[0]*(n-1)

for i in range(n-1):
    for j in range(i+1,n):
        K[D[i][j]-1]+=1

for k in K:
    print(k)
### BUGGY CODE ###

n = input()
a = list(map(int, input().split()))
suma = 1
for i in a:
    suma *= i
if suma > 10**18:
    print(-1)
else:
    print(suma)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
suma = 1
if 0 in a:
    print(0)
    exit()
for i in a:
    suma *= i
    if suma > 10**18:
        print(-1)
        exit()
print(suma)
### BUGGY CODE ###

import math

H, N = map(int,input().split()) # 複数の数字を変数に格納
List = [list(map(int,input().split())) for i in range(N)] # [[1,2],[3,4],[5,6]]

for i in range(N):
    List[i].append(List[i][0] / List[i][1])
    
List.sort(key=lambda x: x[2], reverse=True)

table = [[0] * H for i in range(N)]

for i in range(H):
    table[0][i] = List[0][1] * (math.ceil((i+1) / List[0][0]))
    
for j in range(1,N):
    attack = List[j][0]
    MP = List[j][1]
    for i in range(H):
        if (i+1) < attack:
            table[j][i] = min(table[j-1][i], MP)
        else:
            table[j][i] = min(table[j-1][i], table[j][i-attack]+MP)
            
print(table[N-1][H-1])

### FIXED CODE ###

import math

H, N = map(int,input().split()) # 複数の数字を変数に格納
List = [list(map(int,input().split())) for i in range(N)] # [[1,2],[3,4],[5,6]]

#for i in range(N):
#    List[i].append(List[i][0] / List[i][1])
    
#List.sort(key=lambda x: x[2], reverse=True)

table = [[0] * H for i in range(N)]

for i in range(H):
    table[0][i] = List[0][1] * (math.ceil((i+1) / List[0][0]))
    
for j in range(1,N):
    attack = List[j][0]
    MP = List[j][1]
    for i in range(H):
        if (i+1) < attack:
            table[j][i] = min(table[j-1][i], MP)
        else:
            table[j][i] = min(table[j-1][i], table[j][i-attack]+MP)
            
print(table[N-1][H-1])
### BUGGY CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
now=[[0,0] for i in range(n)]
day=0

while 1:
    day+=1
    siaisuu=0
    for i in range(n):
        if now[i][0]==n-1 or now[i][1] == day:
            continue
        nex=a[i][now[i][0]]
        if i+1==a[nex-1][now[nex-1][0]] and now[nex-1][1] != day:
            siaisuu+=1
            now[i][0]+=1
            now[i][1],now[nex-1][1]=day,day
            now[nex-1][0]+=1
    if siaisuu==0:
        break

for i in range(n):
    if now[i][0]!=n-1:
        print(-1)
        quit()

print(day-1)

### FIXED CODE ###

from collections import deque

n=int(input())
a=[list(map(int,input().split())) for i in range(n)]

for i in range(n):
    for j in range(n-1):
        a[i][j]-=1
    a[i].reverse()
# print(a)
day=[0]*n
pair=[-1]*n

q=deque(range(n))

while q:
    me=q.popleft()
    if not a[me]:
        continue
    oppo=a[me].pop()
    if pair[oppo]==me:
        now=max(day[me],day[oppo])+1
        day[me]=now
        day[oppo]=now
        q.append(me)
        q.append(oppo)
    else:
        pair[me]=oppo


for i in range(n):
    if a[i]:
        print(-1)
        break
else:
    print(max(day))
### BUGGY CODE ###

def f(k,j): return max(M[k],j-C[k])
while 1:
  h,w = map(int, raw_input().split())
  if h==w==0: break
  H = range(h)
  C = [0]*(h+1)
  M = C[:]
  a=[0]*w
  for i in H:
    x = raw_input()
    b=[0]*w
    sp=-1
    C = [-1]*(h+1)
    for j in range(w):
      if x[j]=="*":
        c=0
      elif x[j]==".":
        c=a[j]+1
      b[j]=c
      if c>sp:
        C[sp+1:c+1]=[j]*(c-sp)
      elif c<sp:
        for k in range(c+1,sp+1):
          M[k]=f(k,j)
          C[k]=-1
      sp=c
    for k in range(1,sp+1):
      if C[k]>=0:
        M[k]=f(k,w)
    a=b
  s=max([a*b for a,b in zip(M, H+[h])])
  print s

### FIXED CODE ###

while 1:
  h,w = map(int, raw_input().split())
  if h==w==0: break
  M = [0]*(h+1)
  a=[0]*w
  for i in range(h):
    x = raw_input()
    b=[0]*w
    sp=-1
    C = [-1]*(h+1)
    for j in range(w):
      if x[j]=="*": c=0
      else: c=a[j]+1
      b[j]=c
      dw=c-sp
      if dw>0: C[sp+1:c+1]=[j]*dw
      elif dw<0:
        for k in range(c+1,sp+1): M[k]=max(M[k],j-C[k])
        C[c+1:sp+1]=[-1]*(-dw)
      sp=c
    for k in range(1,sp+1):
      if C[k]>=0: M[k]=max(M[k],w-C[k])
    a=b
  s=max([a*b for a,b in zip(M, range(h+1))])
  print s
### BUGGY CODE ###

# coding: utf-8
# Your code here!

S=list(input())
S=list(map(int,S))[::-1]


mod=[0]*2019
mod[0]+=1

ans=0
temp=0
for i in range(len(S)):
    temp+=S[i]*10**i
    temp%=2019
    ans+=mod[temp]
    mod[temp]+=1

print(ans)


### FIXED CODE ###

# coding: utf-8
# Your code here!

S=list(input())
S=list(map(int,S))[::-1]


mod=[0]*2019
mod[0]+=1

ans=0
temp=0
p=1
for i in range(len(S)):
    temp+=S[i]*p
    p=p*10%2019
    temp%=2019
    ans+=mod[temp]
    mod[temp]+=1

print(ans)
### BUGGY CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))

tmp = 1

for i in range(K):
    tmp = tmp * A[i]
    
for i in range(K,N):
    tmp2 = tmp*A[i]//A[i-K]
    if tmp2 > tmp:
        print("Yes")
    else:
        print("No")
    tmp = tmp2

### FIXED CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(K,N):
    if A[i] > A[i-K]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

N = int(input())
A = tuple(map(int,input().split()))

R = N
L = [True] * N
for i in range(1,N):
    L = [L[j] and L[j+1] and A[j]^A[i+j] == A[j]+A[i+j] for j in range(N-i)] + [False]*(i) 
    R += sum(L)
    if sum(L) == 0:
        break
print(R)

### FIXED CODE ###

N = int(input())
A = tuple(map(int,input().split()))

result = 0
Right = 0
tmp = 0
for left in range(N):
    for right in range(Right,N):
        if not (tmp & A[right]):
            tmp += A[right]
            Right = right + 1
        else:
            break
    tmp -= A[left]
    result += Right - left
print(result)
### BUGGY CODE ###

n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
ans = 0
 
for i in range(n-2):
    flag = 0
    for j in range(i+1,n-1):
        if l[i] < l[j] + l[n-1]:
            ans += n-j-1
        else:
            for k in range(j+1,n):
                if l[i] < l[j] + l[k]:
                    ans += 1
                elif k-j == 1:
                    flag = 1
                    break
                else:
                    break
        if flag:
            break
 
print(ans)

### FIXED CODE ###

import bisect

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

for i in range(n-2):
    for j in range(i+1,n-1):
        ind = bisect.bisect_left(l,l[i]+l[j])
        ans += ind-j-1

print(ans)
### BUGGY CODE ###

N,X,Y=map(int,input().split())

d=[[10**7 for _ in range(N)] for _ in range(N)]
for a in range(1,N):
    d[a-1][a]=1
    d[a][a-1]=1
d[X-1][Y-1]=1
d[Y-1][X-1]=1

for i in range(N):
    for j in range(N):
        for k in range(N):
            d[i][j]=min(d[i][k]+d[k][j],d[i][j])
for i in range(N):
    for j in range(N):
        for k in range(N):
            d[i][j]=min(d[i][k]+d[k][j],d[i][j])

ans=[0 for _ in range(N)]
for k in range(N):
    for l in range(k+1,N):
        if d[k][l]<N:
            ans[d[k][l]]+=1
    
for o in range(N-1):
    print(ans[o+1])

### FIXED CODE ###

N,X,Y=map(int,input().split())

d=[[0 for _ in range(N)] for _ in range(N)]

for i in range(N):
    for j in range(i+1,N):
        d[i][j]=min(abs(i-j),abs(X-1-i)+abs(Y-1-j)+1,abs(X-1-j)+abs(Y-1-i)+1)

ans=[0 for _ in range(N)]
for k in range(N):
    for l in range(k+1,N):
        if d[k][l]<N:
            ans[d[k][l]]+=1
    
for o in range(N-1):
    print(ans[o+1])
### BUGGY CODE ###

N,K,Q=map(int,input().split())

list_seikaisha =[]

for i in range(Q):
    list_seikaisha.append(int(input())-1)

list_pt=[K for i in range(N)]

for seikaisha in list_seikaisha:
    list_pt=[x-1 for x in list_pt]
    list_pt[seikaisha]=list_pt[seikaisha]+1

list_YN=[]
f=lambda pt:"Yes" if pt>=1 else "No"
for pt in list_pt:
    print(f(pt))

### FIXED CODE ###

N,K,Q=map(int,input().split())

list_seikaisha =[]

for i in range(Q):
    list_seikaisha.append(int(input())-1)

list_pt=[K for i in range(N)]

for seikaisha in list_seikaisha:
    list_pt[seikaisha]=list_pt[seikaisha]+1
list_pt=[x-Q for x in list_pt]

list_YN=[]
f=lambda pt:"Yes" if pt>=1 else "No"
for pt in list_pt:
    print(f(pt))
### BUGGY CODE ###

N = int(input())

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

res = A[0]

for i in range(N-1):
    res = res*A[i+1]

if res > 10**18:
    res = -1

print(res)

### FIXED CODE ###

N = int(input())

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

res = A[0]

if 0 in A:
    print(0)
    exit()

for i in range(N-1):
    res = res*A[i+1]
    if res > 10**18:
        res = -1
        break



print(res)
### BUGGY CODE ###

from functools import reduce
N = int(input())
A = map(int, input().split())

mul = reduce(lambda x, y: x*y, A)

if mul > 10**18:
    print('-1')
else:
    print(mul)

### FIXED CODE ###

from functools import reduce
from math import log10

N = int(input())
A = sorted(map(int, input().split()))

mul = 1

for a in A:
    mul *= a
    if mul > 10**18:
        print('-1')
        break
else:
    print(mul)
### BUGGY CODE ###

n = int(input())

ans = 0
for A in range(1, n):
  for B in range(1, n):
    if A * B >= n:
      break
    ans += 1

print(ans)

### FIXED CODE ###

import math

n = int(input())

ans = 0

for A in range(1, n):
  if n % A == 0:
    ans += n // A - 1
  else:
    ans += n // A

print(ans)
### BUGGY CODE ###

count=0
n=int(input())
l=list(map(str,input()))
i=0
while i<=n-3:
    j=i+1
    while i+1<=j and j<=n-2:
        if l[i]==l[j]:
            j+=1
        else:
            k=j+1
            while j+1<=k and k<=n-1:
                if l[i]!=l[j] and l[j]!=l[k] and l[i]!=l[k] and k-j!=j-i:
                    count+=1
                    k+=1
                else:
                    k+=1
            j+=1
    i+=1
print(count)

### FIXED CODE ###

n=int(input())
l=input()
a=l.count('R')
b=l.count('G')
c=l.count('B')
d=a*b*c
i=0
count=0
lis=list(l)
while i<=n-3:
    j=i+1
    while i+2*(j-i)<=n-1:
        if lis[i]!=lis[j] and lis[j]!=lis[i+2*(j-i)] and lis[i]!=lis[i+2*(j-i)]:
            count+=1
            j+=1
        else:
            j+=1
    i+=1
print(d-count)
### BUGGY CODE ###

a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]

s = sorted(s)
t = sorted(t)
st = []
(i, j) = (0, 0)
while i < len(s) or j < len(t):
    if j == len(t) or (i < len(s) and s[i] < t[j]):
        st.append((s[i], min(abs(s[i] - t[max(j - 1, 0)]),
                             abs(s[i] - t[min(j, len(t) - 1)]))))
        i += 1
    else:
        st.append((t[j], min(abs(t[j] - s[max(i - 1, 0)]),
                             abs(t[j] - s[min(i, len(s) - 1)]))))
        j += 1

def doit(x):
    lo, hi = 0, len(st) - 1
    while hi - lo > 1:
        mid = (lo + hi) // 2
        if st[mid][0] < x:
            lo = mid
        else:
            hi = mid
    mid = (lo + hi) // 2
    return min(abs(st[mid][0] - x) + st[mid][1], abs(st[mid + 1][0] - x) + st[mid + 1][1])

for _ in range(q):
    print(doit(int(input())))

### FIXED CODE ###

a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]

s = sorted(s)
t = sorted(t)
st = []
(i, j) = (0, 0)
while i < len(s) or j < len(t):
    if j == len(t) or (i < len(s) and s[i] < t[j]):
        st.append((s[i], min(abs(s[i] - t[max(j - 1, 0)]),
                             abs(s[i] - t[min(j, len(t) - 1)]))))
        i += 1
    else:
        st.append((t[j], min(abs(t[j] - s[max(i - 1, 0)]),
                             abs(t[j] - s[min(i, len(s) - 1)]))))
        j += 1

def doit(x):
    lo, hi = 0, len(st) - 1
    while hi - lo > 1:
        mid = (lo + hi) // 2
        if st[mid][0] < x:
            lo = mid
        else:
            hi = mid
    mid = (lo + hi) // 2
    return min(abs(st[mid][0] - x) + st[mid][1], abs(st[mid + 1][0] - x) + st[mid + 1][1])

for _ in range(q):
    print(doit(int(input())))