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

n,m = map(int, input().split())
a_list = []
for i in range(m):
    a_list.append(int(input()))

# memo = [-1 for _ in range(n)]
step_now = 0
step_1   = 0
step_2   = 0
DIV_NUM = 1000000007
if 1 in a_list:
    step_now = 0
else:
    step_now = 1
for i in range(1, n):
    if i == 1:
        step_1 = step_now
        if i+1 in a_list:
            step_now = 0
        else:
#             memo[i] = (memo[0] + 1) % DIV_NUM
            step_now = step_1 + 1
    else:
        step_2 = step_1
        step_1 = step_now % DIV_NUM
        if i+1 in a_list:
            step_now = 0
        else:
#             memo[i] = (memo[i-1] + memo[i-2]) % DIV_NUM
            step_now = (step_1 + step_2) % DIV_NUM
    if step_now ==  step_1 == step_2 == 0:
        break

print(step_now)

### FIXED CODE ###

n,m = map(int, input().split())
a_list = []
for i in range(m):
    a_list.append(int(input()))

# memo = [-1 for _ in range(n)]
step_now = 0
step_1   = 0
step_2   = 0
DIV_NUM = 1000000007
if 1 in a_list:
    a_list.pop(0)
    step_now = 0
else:
    step_now = 1
for i in range(1, n):
    if i == 1:
        step_1 = step_now
        if i+1 in a_list:
            a_list.pop(0)
            step_now = 0
        else:
#             memo[i] = (memo[0] + 1) % DIV_NUM
            step_now = step_1 + 1
    else:
        step_2 = step_1
        step_1 = step_now
        if i+1 in a_list:
            a_list.pop(0)
            step_now = 0
        else:
#             memo[i] = (memo[i-1] + memo[i-2]) % DIV_NUM
            step_now = (step_1 + step_2) % DIV_NUM
    if step_now ==  step_1 == step_2 == 0:
        break

print(step_now)
### BUGGY CODE ###

# 考えると、隣り合う列は結局 2*H 回ずることになり、
# それぞれの列間について最適な沈め順を見つけると、
# その順序関係を崩さないように全体の順番も構築できる（トポロジカルソートみたいに）ので、
# 各列間の最適解を求めて総和をとればいい

from itertools import accumulate
inf = 2 * 10**9
H, W = map(int, input().split())
C = [input() for _ in range(H)]
C_T = list(zip(*C))
C_T = ["".join(s) for s in C_T]
ans = 0
for C1, C2 in zip(C_T[:-1], C_T[1:]):
    # Z[i][j] := i 個ずれてて沈んでない方が j 個沈んでる状態の連結個数
    Z1 = []  # 左を押したとき（右が上にあるとき）
    Z2 = []  # 右を押したとき（左が上にあるとき）
    z1 = list(accumulate([int(c1==c2) for c1, c2 in zip(C1, C2)]))
    z1.reverse();  z1.append(0)
    Z1.append(z1)
    Z2.append([])
    for j in range(1, H+1):
        z1 = list(accumulate([int(c1==c2) for c1, c2 in zip(C1, C2[j:])]))
        z1.reverse();  z1.append(0);  Z1.append(z1)
        z2 = list(accumulate([int(c1==c2) for c1, c2 in zip(C1[j:], C2)]))
        z2.reverse();  z2.append(0);  Z2.append(z2)
    # dp[i][j] := 左を i 個、右を j 個沈めるまでの最小コスト  # 逆かも（どっちでもいい）
    dp = [[inf] * (H+2) for _ in range(H+2)]
    dp[0][0] = 0
    for j in range(H+1):
        for k in range(H+1):
            cost = dp[j][k] + (Z1[j-k][k] if j>=k else Z2[k-j][j])
            dp[j+1][k] = min(dp[j+1][k], cost)
            dp[j][k+1] = min(dp[j][k+1], cost)
    ans += dp[H][H]
print(ans)


### FIXED CODE ###

# 考えると、隣り合う列は結局 2*H 回ずることになり、
# それぞれの列間について最適な沈め順を見つけると、
# その順序関係を崩さないように全体の順番も構築できる（トポロジカルソートみたいに）ので、
# 各列間の最適解を求めて総和をとればいい

def accumulate_reverse(S1, S2):
    n = min(len(S1), len(S2))
    res = [0] * (n+1)
    c = 0
    for i in range(n):
        if S1[i] == S2[i]:
            c += 1
        res[n-i-1] = c
    return res

inf = 10**8
H, W = map(int, input().split())
C = [input() for _ in range(H)]
C_T = list(zip(*C))
C_T = ["".join(s) for s in C_T]
ans = 0
for C1, C2 in zip(C_T[:-1], C_T[1:]):
    # Z[i][j] := i 個ずれてて沈んでない方が j 個沈んでる状態の連結個数
    Z1 = []  # 左を押したとき（右が上にあるとき）
    Z2 = []  # 右を押したとき（左が上にあるとき）
    Z1.append(accumulate_reverse(C1, C2))
    for j in range(1, H+1):
        Z1.append(accumulate_reverse(C1, C2[j:]))
        Z2.append(accumulate_reverse(C1[j:], C2))
    Z1 += Z2[::-1]
    # dp[i][j] := 左を i 個、右を j 個沈めるまでの最小コスト  # 逆かも（どっちでもいい）
    dp = [[inf] * (H+2) for _ in range(H+2)]
    dp[0][0] = 0
    for j in range(H+1):
        for k in range(H+1):
            cost = dp[j][k] + Z1[j-k][min(j, k)]
            dp[j+1][k] = min(dp[j+1][k], cost)
            dp[j][k+1] = min(dp[j][k+1], cost)
    ans += dp[H][H]
print(ans)
### BUGGY CODE ###

N = int(input())
S = input()

r_list = []
g_list = []
b_list = []
for i, s in enumerate(S):
    if s == 'R':
        r_list.append(i)
    elif s == 'G':
        g_list.append(i)
    elif s == 'B':
        b_list.append(i)

count = 0
for a in r_list:
    for b in g_list:
        for c in b_list:
            i, j, k = sorted((a, b, c))
            if j - i != k - j:
                count += 1
print(count)

### FIXED CODE ###

N = int(input())
S = input()

rs = set()
gs = set()
bs = set()
for i, s in enumerate(S):
    if s == 'R':
        rs.add(i+1)
    elif s == 'G':
        gs.add(i+1)
    elif s == 'B':
        bs.add(i+1)

count = 0
for i in rs:
    for j in gs:
        a = min(i, j)
        b = max(i, j)
        d = b - a
        e = 0
        if (a - d) in bs:
            e += 1
        if (b + d) in bs:
            e += 1
        if d % 2 == 0 and (b - (d // 2)) in bs:
            e += 1
        count += (len(bs) - e)
print(count)
### BUGGY CODE ###

from scipy.sparse.csgraph import csgraph_from_dense,dijkstra
import sys

input = sys.stdin.readline

n, m = map(int, input().split())
edges = [[float('INF')]*n for _ in range(n)]

for _ in range(m):
    _from, to, dist = map(int, input().split())
    edges[_from-1][to-1] = dist

for i in range(1, n):
    edges[i][i-1] = 0

G = csgraph_from_dense(edges, null_value=float('INF'))
D = dijkstra(G, directed=True, indices=0)
ans = D[-1]
if ans == float('INF'):
    ans = -1
print(int(ans))

### FIXED CODE ###

import heapq
import sys
input = sys.stdin.readline

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

edges = [[] for _ in range(n)]
for i in range(1, n):
    _from, to, dist = i, i-1, 0
    edges[_from].append([to, dist])

for _ in range(m):
    _from, to, dist = map(int, input().split())
    edges[_from-1].append([to-1, dist])


D = [float('INF')]*n
D[0] = 0
todo = []
for to, dist in edges[0]:
    heapq.heappush(todo, [dist, to])
    D[to] = dist

while todo:
    total_dist, node = heapq.heappop(todo)

    for to, dist in edges[node]:
        if total_dist + dist < D[to]:
            heapq.heappush(todo, [total_dist+dist, to])
            D[to] = total_dist + dist
        else:
            continue

ans = D[n-1]
if ans == float('INF'):
    ans = -1

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

x, op, y = input().split()
x = int(x)
y = int(y)
while not (x == 0 and y == 0 and op == "?") :
 if op == "+" :
  print(x + y)
 elif op == "-":
  print(x - y)
 elif op == "*":
  print(x * y)
 elif op == "/":
  print(x // y)

### FIXED CODE ###

x, op, y = input().split()
x = int(x)
y = int(y)
while op != "?" :
 if op == "+" :
  print(x + y)
 elif op == "-":
  print(x - y)
 elif op == "*":
  print(x * y)
 elif op == "/":
  print(x // y)
 x, op, y = input().split()
 x = int(x)
 y = int(y)
### BUGGY CODE ###

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

A.sort()
F.sort(reverse = True)

M = 0
for i in range(N):
    M=max(F[i]*A[i],M)

def judge(n):
    score = 0
    for i in range(N):
        score += max(A[i] - n//F[i],0)
    return score<=K

def bisect(l,r):
    while r-l>1:
        if judge((l+r)//2):
            r = (l+r)//2
        else:
            l = (l+r)//2
    return r

if judge(0):
    print(0)
else:
    print(bisect(0,M))


### FIXED CODE ###

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

A.sort()
F.sort(reverse = True)

M = 0
for i in range(N):
    M=max(F[i]*A[i],M)

def judge(n):
    score = 0
    for i in range(N):
        score += max(A[i] - n//F[i],0)
    return score<=K

def bisect(l,r):
    while r-l>1:
        if judge((l+r)//2):
            r = (l+r)//2
        else:
            l = (l+r)//2
    return r

if judge(0):
    print(0)
else:
    print(bisect(0,M))
### BUGGY CODE ###

nk = list(map(int,input().split()))
p = list(map(int,input().split()))
ans = [0] * (nk[0] + nk[1])

zeros = [0] * nk[1]

seq4search = zeros + p

for i in range(nk[1], nk[0] + nk[1]):
    seq4search[i] = (seq4search[i] + 1) / 2
    ans[i] = sum(seq4search[i - nk[1] + 1:i + 1])

print(max(ans))

### FIXED CODE ###

nk = list(map(int,input().split()))
p = list(map(int,input().split()))
ans = [0] * (nk[0] + nk[1])
 
zeros = [0] * nk[1]
 
seq4search = zeros + p
 
for i in range(nk[1], nk[0] + nk[1]):
    seq4search[i] = (seq4search[i] + 1) / 2
    ans[i] = ans[i-1] + seq4search[i] - seq4search[i - nk[1]] 
 
print(max(ans))
### BUGGY CODE ###

N=int(input())
x=1
z=10**9+7
for n in range(1,N+1):
  x*=n
print(x%z)

### FIXED CODE ###

N=int(input())
x=1
z=10**9+7
for n in range(1,N+1):
  x*=n
  x%=z
print(x)
### BUGGY CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
def main():
    # dp:=上からi桁目まで払える最小の枚数
    S = list(map(int, '0'+input()))
    l = len(S)
    dp = [[1e18]*2 for _ in range(1001001)]
    dp[0][0]=0
    for i in range(l):
        k = S[i]
        dp[i+1][0] = min(dp[i+1][0], dp[i][0]+k)
        dp[i+1][1] = min(dp[i+1][1], dp[i][0]+k+1)
        dp[i+1][0] = min(dp[i+1][0], dp[i][1]+10-k)
        dp[i+1][1] = min(dp[i+1][1], dp[i][1]+10-k-1)
    print(dp[l][0])

    
if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
def main():
    # dp:=上からi桁目まで払える最小の枚数
    S = list(map(int, '0'+input()))
    l = len(S)
    dp = [[1e18]*2 for _ in range(1001001)]
    dp[0][0]=0
    for i in range(l):
        k = S[i]
        dp[i+1][0] = min(dp[i+1][0], dp[i][0]+k)
        dp[i+1][1] = min(dp[i+1][1], dp[i][0]+k+1)
        dp[i+1][0] = min(dp[i+1][0], dp[i][1]+10-k)
        dp[i+1][1] = min(dp[i+1][1], dp[i][1]+10-k-1)
    print(dp[l][0])

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

N = int(input())
H = list(map(int,input().split()))
ans = 0
for i in range(N):
    k = 0
    for j in range(i+1,N):
        if H[j-1]>=H[j]:
            k+=1
        else:break
    ans = max(ans,k)
print(ans)

### FIXED CODE ###

N = int(input())
H = list(map(int,input().split()))
ans = 0
k = 0
for i in range(N-1):
    if H[i]>=H[i+1]:
        k+=1
    else:
        ans = max(ans,k)
        k=0
print(max(ans,k))
### BUGGY CODE ###

n,k,l=map(int,input().split())
def maketree(n,k,target):
    from collections import defaultdict
    road=defaultdict(set)
    roadidx=[-1 for _ in range(n)]
    for i in range(len(target)):
        p=target[i][0]
        q=target[i][1]
        pidx=roadidx[p]
        qidx=roadidx[q]
        if pidx==-1 and qidx==-1:
            road[p]={p,q}
            roadidx[p]=p
            roadidx[q]=p
        elif pidx==-1 and qidx!=-1:
            road[qidx]|={p,}
            roadidx[p]=qidx
        elif pidx!=-1 and qidx==-1:
            road[pidx]|={q,}
            roadidx[q]=pidx
        elif pidx!=qidx:
            x=road[pidx]|road[qidx]
            y=min(pidx,qidx)
            z=max(pidx,qidx)
            road[y]=x
            road.pop(z)
            for j in x:
                roadidx[j]=y
    resroad=[]
    idx=[-1 for _ in range(n)]
    count=0
    for i in road:
        resroad.append(road[i])
        for j in road[i]:
            idx[j]=count
        count+=1
    return resroad,idx

road = []
for i in range(k):
        p,q=map(int,input().split())
        p-=1
        q-=1
        road.append([p,q])
metro=[]
for i in range(l):
        r,s=map(int,input().split())
        r-=1
        s-=1
        metro.append([r,s])
roadtree,roadidx=maketree(n,k,road)
metrotree,metroidx=maketree(n,l,metro)

result=[1 for i in range(n)]
for i in roadtree:
    check=i.copy()
    while len(check)>0:
        now=check.pop()
        if metroidx[now]!=-1:
            x=i & metrotree[metroidx[now]]
            if len(x)!=0:
                for j in x:
                    result[j]=len(x)
        else:x={now,}
        check-=x

res=''
for i in range(n):
    res=res+str(result[i])+' '
print(res)

### FIXED CODE ###

import sys
input=sys.stdin.readline
N,K,L=map(int,input().split())
road=[tuple(map(int,input().split())) for _ in range(K)]
metro=[tuple(map(int,input().split())) for _ in range(L)]
inf=float('inf')
def Find(root,x):
    if root[x]<0:
        return x
    if root[x]>=0:
        root[x]=Find(root,root[x])
        return root[x]

def UnionFind(N,branch):
    root=[-1]*(N+1)
    for a,b in branch:
        aroot=Find(root,a)
        broot=Find(root,b)
        if aroot==broot:continue
        elif root[aroot]<=root[broot]:
            root[aroot]+=root[broot]
            root[broot]=aroot
        elif root[aroot]>root[broot]:
            root[broot]+=root[aroot]
            root[aroot]=broot
    return root
r_root=UnionFind(N,road)
m_root=UnionFind(N,metro)
from collections import defaultdict
data=[]
cnt=defaultdict(int)
for i in range(1,N+1):
    ri=Find(r_root,i)
    mi=Find(m_root,i)
    data.append((ri,mi))
    cnt[(ri,mi)]+=1
ans=''
for d in data:
    ans+=str(cnt[d])+' '
print(ans[:-1])
### BUGGY CODE ###

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

a = 1
for i in x:
  a *= i

if a > pow(10,18):
  print(-1)
else:
  print(a)
  

### FIXED CODE ###

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

a = 1
if 0 in x:
  print(0)
else:
  for i in x:
    a *= i
    if a > pow(10,18):
      print(-1)
      break
  else:
    print(a)
### BUGGY CODE ###

# s1 = input()
# len_s = len(s1)
# s2 = s1
# while True:
#     len_1 = len(s2)
#     s2 = s2.replace("01", "").replace("10", "")
#     len_2 = len(s2)
#     if len_1 == len_2:
#         break
#
# print(len_s - len(s2))

s = input()
s2 = s
# for i in range(len(s) // 2, 0, -1):
#     # print("i", i)
#     # print("s2", s2)
#     m1 = "1" * i + "0" * i
#     m2 = "0" * i + "1" * i
#     s2 = s2.replace(m1, "").replace(m2, "")

while True:
    len_1 = len(s2)
    s2 = s2.replace("0000011111", "").replace("1111100000", "")
    s2 = s2.replace("000111", "").replace("111000", "")
    s2 = s2.replace("01", "").replace("10", "")
    len_2 = len(s2)
    if len_1 == len_2:
        break
print(len(s) - len(s2))


### FIXED CODE ###

s = input()
ans = min(s.count('0'), s.count('1'))
print(ans * 2)
### BUGGY CODE ###

n=int(input())
ab=[list(map(int,input().split())) for _ in range(n-1)]
mod=pow(10,9)+7
ki=[[] for _ in range(n)]
todo=[]
for a,b in ab:
  ki[a-1].append(b-1)
  ki[b-1].append(a-1)
import sys
sys.setrecursionlimit(100000)
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1]
for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
memo={}
def dfs(i,pare):#根がi、親がpareの部分木についての値を返す。[サイズ,整数の書き方の場合の数]
  if (i,pare) in memo:
    return memo[(i,pare)]
  l=ki[i]
  ret=0
  sizes=[]
  pats=[]
  sum_size=0
  ret=1
  for li in l:
    if li==pare:
      continue
    size,pat=dfs(li,i)
    sizes.append(size)
    sum_size+=size
    ret*=cmb(sum_size,size,mod)
    ret*=pat
  memo[(i,pare)]=(sum_size+1,ret)
  return (sum_size+1,ret)
for i in range(n):
  print(dfs(i,-1)[1])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
def main():
    n=int(input())
    def cmb(n, r, mod):
        if ( r<0 or r>n ):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod
    mod = 10**9+7 #出力の制限
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
    for i in range( 2, n + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )

    ki=[[] for _ in range(n)]
    for _ in range(n-1):
        a,b=map(int,input().split())
        a,b=a-1,b-1
        ki[a].append(b)
        ki[b].append(a)
    memo={} # memo[(p,v)]:p->vの部分木のサイズ、整数の書き方
    def dfs(p,v):
        if (p,v) in memo:return memo[(p,v)]
        size,pat=0,1
        tmps,tmpp=1,1
        deg=len(ki[v])
        for nv in ki[v]:
            if nv==p:continue
            si,pi=dfs(v,nv)
            size+=si
            tmps*=g2[si]
            tmps%=mod
            tmpp*=pi
            tmpp%=mod
        pat=(g1[size]*tmps*tmpp)%mod
        memo[(p,v)]=(size+1,pat)
        return (size+1,pat)
    ans=[0]*n
    def bfs(p,v,res):
        if p!=-1:memo[(v,p)]=res
        deg=len(ki[v])
        tmps,tmpp=1,1
        for i in range(deg):
            si,pi=memo[(v,ki[v][i])]
            tmps*=g2[si]
            tmpp*=pi
            tmps%=mod
            tmpp%=mod

        ans[v]=g1[n-1]*tmps*tmpp
        ans[v]%=mod

        dpl=[1]*(deg+1)
        dpr=[1]*(deg+1)
        tmp=1
        for i in range(deg):
            si,pi=memo[(v,ki[v][i])]
            tmp*=pi*g2[si]
            tmp%=mod
            dpl[i+1]=tmp
        tmp=1
        for i in range(deg-1,-1,-1):
            si,pi=memo[(v,ki[v][i])]
            tmp*=pi*g2[si]
            tmp%=mod
            dpr[i]=tmp
        for i in range(deg):
            nv=ki[v][i]
            if p==nv:continue
            bfs(v,nv,(n-memo[(v,nv)][0],(g1[n-1-memo[(v,nv)][0]]*dpl[i]*dpr[i+1])%mod))
    dfs(-1,0)
    #print(memo)
    bfs(-1,0,0)
    print(*ans,sep='\n')
    #print(memo)

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

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    x = I()
    i = 0
    while True:
        t = x - i**5
        if t >= 0:
            u = int(t**0.2)
            for j in range(u-1, u+2):
                if j**5 - i**5 == x:
                    return JA([j,i], " ")

        t = x + i**5
        u = int(t**0.2)
        for j in range(u-1, u+2):
            if j**5 + i**5 == x:
                return JA([j,-i], " ")
        i += 1

    return -1


print(main())





### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    x = I()
    for a in range(1,1000):
        a5 = a**5
        for b in range(a+1):
            b5 = b**5
            if a5 + b5 == x:
                return JA([a,-b], " ")
            if a5 - b5 == x:
                return JA([a,b], " ")

    return -1


print(main())
### BUGGY CODE ###

from bisect import bisect_left
A, B, Q = map(int, input().split())
BIG = 10**10 + 1
S = [-BIG] + sorted([int(input()) for _ in range(A)]) + [BIG*2]
T = [-BIG] + sorted([int(input()) for _ in range(B)]) + [BIG*2]
for _ in range(Q):
  x = int(input())
  shrine_b = bisect_left(S, x)
  shrine_l = S[shrine_b-1]
  shrine_r = S[shrine_b]
  dsl = x-shrine_l
  dsr = shrine_r-x

  temple_b = bisect_left(T, x)
  temple_l = T[temple_b-1]
  temple_r = T[temple_b]
  dtl = x-temple_l
  dtr = temple_r-x

  ans = float('inf')
  tmp = dsl if shrine_l < temple_l else dtl
  ans = ans if ans < tmp else tmp
  tmp = dsr if shrine_r > temple_r else dtr
  ans = ans if ans < tmp else tmp
  tmp = dsl * 2 + dtr
  ans = ans if ans < tmp else tmp
  tmp = dsl + dtr * 2
  ans = ans if ans < tmp else tmp
  tmp = dsr * 2 + dtl
  ans = ans if ans < tmp else tmp
  tmp = dsr + dtl * 2
  ans = ans if ans < tmp else tmp
  print(ans)

### FIXED CODE ###

from bisect import bisect_right
A, B, Q = map(int, input().split())
BIG = 10**10 + 1
S = [-BIG] + [int(input()) for _ in range(A)] + [BIG*2]
T = [-BIG] + [int(input()) for _ in range(B)] + [BIG*2]
for _ in range(Q):
  x = int(input())
  shrine_b = bisect_right(S, x)
  dsl = x-S[shrine_b-1]
  dsr = S[shrine_b]-x
  temple_b = bisect_right(T, x)
  dtl = x-T[temple_b-1]
  dtr = T[temple_b]-x

  print(min(
    dsl if dsl > dtl else dtl,
    dsr if dsr > dtr else dtr,
    dsl * 2 + dtr,
    dsl + dtr * 2,
    dsr * 2 + dtl,
    dsr + dtl * 2
  ))
### BUGGY CODE ###

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

for i in range(n):
  if P[i] == min(P[0:i+1]):
    ans += 1
  else:
    ans += 0
    
print(ans)

### FIXED CODE ###

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

ans = 0
tmp = P[0]
for i in range(n):
  if P[i] <= tmp:
    ans += 1
    tmp = P[i]
  else:
    pass
print(ans)
### BUGGY CODE ###

X = input()

while X.find("ST") != -1:
    X = X.replace("ST", "")

print(len(X))

### FIXED CODE ###

X = input()

count = 0
t_count = 0
for x in X:
    if x == "S":
        count += 1
    if x == "T":
        count -= 1
        if count < 0:
            count = 0
            t_count += 1


print(t_count + count)
### BUGGY CODE ###

import itertools

n=int(input())
li=[]
ans=0

for i in range(n):
    s=input()
    if s[0]=="M" or s[0]=="A" or s[0]=="R" or s[0]=="C" or s[0]=="H":
        li.append(s)

tm=(list(itertools.combinations(li,3)))

for j in tm:
    if j[0][0]!=j[1][0] and j[1][0]!=j[2][0] and j[2][0]!=j[0][0]:
        ans+=1

print(ans)

### FIXED CODE ###

import itertools

n=int(input())
li=[]

for i in range(n):
    li.append(input()[0])

tm=list(itertools.combinations(["M","A","R","C","H"],3))
ans=0

for j1,j2,j3 in tm:
    ans+=li.count(j1)*li.count(j2)*li.count(j3)

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

import math
k=int(input())
a=[]
for i in range(1,k+1):
  for j in range(1,k+1):
    for k in range(1,k+1):
      a.append(math.gcd(math.gcd(i,j),k))
print(sum(a))

### FIXED CODE ###

import math 
k=int(input())
ans=0
for i in range(1,k+1):
  for j in range(1,k+1):
    for k in range(1,k+1):
      ans+=(math.gcd(math.gcd(i,j),k))
print(ans)