Harryxun/stf_run huggingface dataset:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    from itertools import accumulate

    N = int(input())  # len(A)
    A = list(map(int, input().split()))
    zenbu=sum(A)
    B = [0] + A
    B = list(accumulate(B))
    C = [zenbu]*N
    import numpy as np
    B=np.array(B[1:])
    C=np.array(C)
    D=C-B
    ans=10**18
    for i in range(1, N+1):
        ans = min(abs(B[i]-D[i]),ans)
    print(ans)
resolve()

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    from itertools import accumulate

    N = int(input())  # len(A)
    A = list(map(int, input().split()))
    zenbu=sum(A)
    B = [0] + A
    B = list(accumulate(B))  # 累積和を格納したリスト作成


    ans=10**18
    for i in range(1, N):
        ans = min(abs(B[i]-(zenbu-B[i])),ans)
    print(ans)

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

sorted_b = [i+1 for i in range(a)]

diff = [x-y for (x,y) in zip(sorted_b, b)]

if len([i for i in diff if i == 0]) == 2:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

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

sorted_b = [i+1 for i in range(a)]

diff = [x-y for (x,y) in zip(sorted_b, b)]

if len([i for i in diff if i != 0]) <= 2:
  print('YES')
else:
  print('NO')
n=int(input())
h=[list(map(int,input().split()))]
high=0
count=0
for i in range(n):
  if high<=h[i]:
    count=count+1
    high=h[i]
print(count)

### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
high=0
count=0
for i in range(n):
  if high<=h[i]:
    count=count+1
    high=h[i]
print(count)
import sys
sys.setrecursionlimit(2147483647)

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

#n,m<=10**5

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

uf = UnionFind(m+1) #初期化

lastcheck=set([])
klkl=[]
for _ in range(n):
    kl=list(map(int,input().split()))[1:]
    if len(kl)==1:
        lastcheck.add(kl[0])
    else:
        for item in kl[1:]:
            uf.union(kl[0]-1,item-1)
    klkl.append(kl)
uf_list=uf.members(item-1)    

flag=0
for kl in klkl:
    for item in kl:
        item-=1
        if item not in uf_list:
            flag=1
        else:
            break
if flag==1:
    print("NO")
else:
    print("YES")
    














### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)

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

#n,m<=10**5

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

uf = UnionFind(m+1) #初期化

lastcheck=set([])
klkl=[]
for _ in range(n):
    kl=list(map(int,input().split()))[1:]
    if len(kl)>1:
        for item in kl[1:]:
            uf.union(kl[0]-1,item-1)
    klkl.append(kl)
uf_list=uf.members(klkl[0][0]-1)
#print(uf_list)
flag=0
for kl in klkl:
    for item in kl:
        item-=1
        if item not in uf_list:
            flag=1
        else:
            break
if flag==1:
    print("NO")
else:
    print("YES")
def nCr(n,r):
  ret = 1
  for i in range(r):
    ret *= n-i
    ret /= i+1
  return ret

def top(N,K):
  if K == 0:
    return 1
  L = len(N)
  ans = 0
  if L < K:
    return 0
  else:
    ans += nCr(L-1,K) * 9 ** K

    u = int(N[0])
    if int(N) % u * 10 ** (L-1) != 0 or u != 1:
      ans += (u - 1) * nCr(L-1,K - 1) * 9 ** (K - 1)
      return ans + top(str(N[1:]),K - 1)
    else:
      return ans

N = str(input())
K = int(input())

print(int(top(N,K)))

### FIXED CODE ###

def nCr(n,r):
  ret = 1
  for i in range(r):
    ret *= n-i
    ret /= i+1
  return ret

def top(N,K):
  if K == 0:
    return 1
  L = len(N)
  ans = 0
  if L < K:
    return 0
  else:
    ans += nCr(L-1,K) * 9 ** K

    u = int(N[0])
    z = N.count('0')
    o = N.count('1')
    f = 0
    if z + o == L:
      f = 1
    if f == 0:
      ans += (u - 1) * nCr(L-1,K - 1) * 9 ** (K - 1)
      if L == 1:
        return ans + 1
      else:
        return ans + top(str(int(N[1:])),K - 1)
    else:
      if len(str(int(N[1:]))) != 1:
        return ans + top(str(int(N[1:])),K - 1)
      else:
        if o >= K:
          return ans + 1
        else:
          return ans

N = str(input())
K = int(input())

print(int(top(N,K)))
#!/usr/bin/env python3
import sys

def solve(N: int, M: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    import numpy as np    
    from scipy.sparse import csr_matrix    
    from scipy.sparse.csgraph import floyd_warshall
    omat = csr_matrix((c, (a, b)), shape=(N+1, N+1), dtype=np.int32, directed=False)
    smat = floyd_warshall(omat)
    return ((omat-smat) > 0).sum() // 2


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]"
    b = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    print(solve(N, M, a, b, c))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

def solve(N: int, M: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    import numpy as np    
    from scipy.sparse import csr_matrix    
    from scipy.sparse.csgraph import floyd_warshall
    omat = csr_matrix((c+c, (a+b, b+a)), shape=(N+1, N+1), dtype=np.int32)
    smat = floyd_warshall(omat)
    return ((omat-smat) > 0).sum() // 2


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]"
    b = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    print(solve(N, M, a, b, c))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()
N = int(input())
S = input()

ans = 0
while 'ABC' in S:
    ans += 1
    S.remove('ABC')

print(ans)


### FIXED CODE ###

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

ans = S.count('ABC')
print(ans)
a,b,c,k=map(int,input().split())
if a>=k:
  print(a)
else:
  s=k-a
  if a+b>=s:
    print(a)
  else:
    c=k-a-b
    print(a-c)

### FIXED CODE ###

s=input()
t=input()
if t[:-1]==s:
  print("Yes")
else:
  print("No")
n = int(input())
import math as ms
dic = []
for i in range(1,ms.floor(n / 2) + 1):
    if n % i == 0:
        dic.append([i,n // i])
    
f = []
for i in range(len(dic)):
    a = ms.floor(ms.log10(dic[i][0])) + 1
    b = ms.floor(ms.log10(dic[i][1])) + 1
    f.append(max(a,b))
    
print(min(f))
    

### FIXED CODE ###

n = int(input())
import math as ms
dic = []
for i in range(1,ms.floor(ms.sqrt(n)) + 1):
    if n % i == 0:
        dic.append([i,n // i]) 
f = []
for i in range(len(dic)):
    a = ms.floor(ms.log10(dic[i][0])) + 1
    b = ms.floor(ms.log10(dic[i][1])) + 1
    f.append(max(a,b))
    
print(min(f))
import java.util.Scanner;
class Rp1ABC093{
  static public void main(String args[]){
    String S;
    Scanner sc = new Scanner(System.in);
    
  if (S=="abc") or (S=="bca") or (S=="cba") or (S=="acb") or (S=="bac") or (S=="cab")
    System.out.println("Yes");
  else
    System.out.println("No");
  }
}

### FIXED CODE ###

S = input()
if (S=="abc") or (S=="acb") or (S=="bca") or (S=="cba") or (S=="bac") or (S=="cab"):
  print("Yes")
else:
  print("No")
n, u, v = int(input())
print(n, u, v)

### FIXED CODE ###

#読み込み部
N, u, v = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N-1)]

#グラフ作成部
graph = [[] for i in range(N+1)]
for i,j in AB:
    graph[i].append(j)
    graph[j].append(i)

#深さ優先探索
def dfs(v):
    dist = [-1] * (N+1)
    stack = [v]
    dist[v] = 0
    while stack:
        v = stack.pop()
        dw = dist[v] + 1
        for w in graph[v]:
            if dist[w] >= 0:
                continue
            dist[w] = dw
            stack.append(w)
    return dist

DU,DV = dfs(u),dfs(v)
 
answer = 0
for u,v in zip(DU[1:],DV[1:]):
    if u < v:
        x = v - 1
        if answer < x:
            answer = x

print(answer)
package main

import "fmt"

func main() {
	var a, b int

	fmt.Scan(&a, &b)

	if (a * b)%2 == 1 {
		fmt.Println("Odd")
	} else {
		fmt.Println("Even")
	}
}

### FIXED CODE ###

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

if (a*b)%2 == 0:
    print('Even')

else:
    print('Odd')
print(len(set(int(input()) for _ in range(int(input()))))

### FIXED CODE ###

print(len(set(int(input()) for _ in range(int(input())))))
from math import inf
from collections import deque

N, A, B, C = map(int, input().split())
ls = [0]
for _ in range(N):
    ls.append(int(input()))
ls.sort()

q = deque()
q.append((0, -30, 0, 0, 0))
minmp = inf
while len(q):
    n, mp, a, b, c = q.pop()
    if n == N:
        if min(a, b, c) == 0:
            continue
        minmp = min(minmp, mp + abs(a - A) + abs(b - B) + abs(c - C))
    else:
        q.append((n + 1, mp, a, b, c))
        q.append((n + 1, mp + 10, a + ls[n + 1], b, c))
        q.append((n + 1, mp + 10, a, b + ls[n + 1], c))
        q.append((n + 1, mp + 10, a, b, c + ls[n + 1]))

print(minmp)


### FIXED CODE ###

try:
    from math import inf
except:
    inf = float("inf")
from collections import deque

N, A, B, C = map(int, input().split())
ls = [0]
for _ in range(N):
    ls.append(int(input()))
ls.sort()

q = deque()
q.append((0, -30, 0, 0, 0))
minmp = inf
while len(q):
    n, mp, a, b, c = q.pop()
    if n == N:
        if min(a, b, c) == 0:
            continue
        minmp = min(minmp, mp + abs(a - A) + abs(b - B) + abs(c - C))
    else:
        q.append((n + 1, mp, a, b, c))
        q.append((n + 1, mp + 10, a + ls[n + 1], b, c))
        q.append((n + 1, mp + 10, a, b + ls[n + 1], c))
        q.append((n + 1, mp + 10, a, b, c + ls[n + 1]))

print(minmp)
n = int(input())
if n >= 30:
  l = 'Yes'
 else:
  l = 'No'
 print(l)

### FIXED CODE ###

n = int(input())
if n >= 30:
  l = 'Yes'
else:
  l = 'No'
print(l)
a,b,c,d = map(int,input().split())
while(a>0 or c>0):
  c-=b
  a-=d
if a<=0 and c>0:
  print("No")
elif c<=0 and a>0: 
  print("Yes")
elif a<=0 and c<=0:
  print("Yes")

### FIXED CODE ###

import math
a,b,c,d = map(int,input().split())
x=c/b
y=a/d
x=math.ceil(x)
y=math.ceil(y)
if x<=y:
  print("Yes")
else:
  print("No")
from heapq import*
from copy import*
n,k=map(int,input().split())
*v,=map(int,input().split())
v2=deepcopy(v)
motimono=[]
ans=[]
if k>=n:
    v*=2
    for j in range(1,k+1):
        try:
            for i in range(n-j,n+1):
                motimono=v[i:i+j]
                ans.append(sum(motimono))
                heapify(motimono)
                for i in range(k-j):
                    if len(motimono)>0:
                        heappop(motimono)
                    ans.append(sum(motimono))
        except:
            continue
    motimono=deepcopy(d2)
    k-=n
    for i in range(k):
        heappop(motimono)
        ans.append(sum(motimono))
    print(max(ans))
else:
    v*=2
    for j in range(1,k+1):
        try:
            for i in range(n-j,n+1):
                motimono=v[i:i+j]
                ans.append(sum(motimono))
                heapify(motimono)
                for i in range(k-j):
                    if len(motimono)>0:
                        heappop(motimono)
                    ans.append(sum(motimono))
        except:
            continue
    print(max(ans))

### FIXED CODE ###

from heapq import*
n,k=map(int,input().split())
*v,=map(int,input().split())
motimono=[]
ans=[]
if k>=n:
    k-=n
    heapify(v)
    ans.append(sum(v))
    for i in range(k):
        if len(v)>0:
            heappop(v)
        ans.append(sum(v))
    print(max(ans))
else:
    v*=2
    for j in range(1,k+1):
        for i in range(n-j,n+1):
            motimono=v[i:i+j]
            ans.append(sum(motimono))
            heapify(motimono)
            for i in range(k-j):
                if len(motimono)>0:
                    heappop(motimono)
                ans.append(sum(motimono))
    print(max(ans))
str = input()
num = list(map(int,str.split(' ')))
if (num[0]%2)*(num[1]%2)*(num[2])==1:
	num.sort()
        print(num[0]*num[1])
else:
        print(0)


### FIXED CODE ###

str = input()
num = list(map(int,str.split(' ')))
if ((num[0]%2)and(num[1]%2)and(num[2]%2))==0:
	print(0)
else:
	num.sort()
	print(num[0]*num[1])
N, K = list(map(int, input().split()))

if N >= K:
    print(N % K)
else:
    print(K % N)


### FIXED CODE ###

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

print(min(N % K, K - (N % K)))
n=int(input())
    a=list(map(int,input().split()))
     
    sum=0
    for i in range(n):
        sum=sum+a[i]
     
    for j in range(1,n,2):
        sum=sum-a[j]*2
     
    ans=[sum]
    ch=sum
    for i in range(0,n-1):
        ch=a[i]*2-ch
        ans.append(ch)
     
     
    aaa=str(ans[0])
    for i in range(1,n):
        ccd=str(ans[i])
        aaa=aaa+' '+ccd
    print(aaa)

### FIXED CODE ###

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

sum=0
for i in range(n):
    sum=sum+a[i]

for j in range(1,n,2):
    sum=sum-a[j]*2

ans=[sum]
ch=sum
for i in range(0,n-1):
    ch=a[i]*2-ch
    ans.append(ch)

print(' '.join(map(str, ans)))
x=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F",]
a,b=input().split();a,b=x.index(a),x.index(b)
if a>b:print(">")
elif a<b:print("<")
else;print("=")

### FIXED CODE ###

x=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F",]
a,b=input().split();a,b=x.index(a),x.index(b)
if a>b:print(">")
elif a<b:print("<")
else:print("=")
n,x,m = list(map(int,input().split()))

ans = x % m
dicNum = dict()
dicSum = dict()
dicNum[x] = 1
dicSum[1] = x

for i in range(2,n+1):
    b = x
    x = x**2 % m
    if x in dicNum.keys():
        t = i - dicNum[x]
        zan = n - i + 1
        k = zan // t
        ans += (dicSum[i-1] - dicSum[dicNum[x]-1]) * k
        if zan% t != 0:
            zan = zan % t
            ans += dicSum[dicNum[x] - 1 + zan] - dicSum[dicNum[x]-1]
        break
    else:
        ans += x
        dicSum[i] = ans
        dicNum[x] = i

print(ans)

### FIXED CODE ###

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

if x == 0:
    ans = 0
else:
    ans = x % m
dicNum = dict()
dicSum = dict()
dicNum[x] = 1
dicSum[1] = x
dicSum[0] = 0

for i in range(2,n+1):
    b = x
    x = x**2 % m
    if x in dicNum.keys():
        t = i - dicNum[x]
        zan = n - i + 1
        k = zan // t
        ans += (dicSum[i-1] - dicSum[dicNum[x]-1]) * k
        if zan% t != 0:
            zan = zan % t
            ans += dicSum[dicNum[x] - 1 + zan] - dicSum[dicNum[x]-1]
        break
    else:
        ans += x
        dicSum[i] = ans
        dicNum[x] = i

print(ans)
S = input()
sl = []
ans = 'AC'

for i in S:
    sl.append(i)
if sl[0] != 'A':
    ans = 'WA'
if sl[2:-1].count('C') != 1:
    ans = 'WA'
sl.pop(0)
sl.pop(sl.index('C'))
s = "".join(sl)
#print(s)
if s.islower() == False:
    ans = 'WA'
#print(sl)
print(ans)

### FIXED CODE ###

S = input()
sl = []
ans = 'AC'

for i in S:
    sl.append(i)
if S[0] != 'A':
    ans = 'WA'
if S[2:-1].count('C') != 1:
    ans = 'WA'

if S[1:].replace("C","c",1).islower() == False:
    ans = 'WA'
#print(sl)
print(ans)
answer = 0
for i in range(1, n+1, 2):
    num_of_divisor = 0
    for j in range(1, i+1):
        if i % j == 0:
            num_of_divisor += 1
    if num_of_divisor == 8:
        answer += 1
print(answer)

### FIXED CODE ###

n = int(input())
answer = 0
for i in range(1, n+1, 2):
    num_of_divisor = 0
    for j in range(1, i+1):
        if i % j == 0:
            num_of_divisor += 1
    if num_of_divisor == 8:
        answer += 1
print(answer)
L,R = map(int,input().split())
 
if R - L >=2019:
  print(0)
else:
  ans = 2019
  for i in range(L,R):
    for j in range(i+1,R):
      a = (i*j)%2019
    ans = min(ans,a)
  print(a)

### FIXED CODE ###

L,R = map(int,input().split())
ans = float('inf')
for i in range(L,R):
  for j in range(i+1,R+1):
    if (i*j)%2019==0:
      print(0)
      exit()
    ans = min(ans,(i*j)%2019)
print(ans)
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    h, w = map(int, input().split())
    col = [[0, w + 1] for _ in range(h)]
    row = [[0, h + 1] for _ in range(w)]
    for i in range(h):
        s = list(input()[:-1].decode())
        for j in range(w):
            if s[j] == '#':
                col[i].append(j + 1)
                row[j].append(i + 1)

    cc = [[0] * (w + 2) for _ in range(h)]
    rc = [[0] * (h + 2) for _ in range(w)]

    for i in range(h):
        col[i].sort()
        for j in range(len(col[i]) - 1):
            cc[i][col[i][j] + 1:col[i][j + 1]] = [col[i][j + 1] - col[i][j] - 1] * (col[i][j + 1] - col[i][j] - 1)

    for i in range(w):
        row[i].sort()
        for j in range(len(row[i]) - 1):
            rc[i][row[i][j] + 1:row[i][j + 1]] = [row[i][j + 1] - row[i][j] - 1] * (row[i][j + 1] - row[i][j] - 1)

    ans = 0
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            ans = max(ans, cc[i][j] + rc[j][i] - 1)

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


### FIXED CODE ###

from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    h, w = map(int, input().split())
    col = [[0, w + 1] for _ in range(h)]
    row = [[0, h + 1] for _ in range(w)]
    for i in range(h):
        s = list(input()[:-1].decode())
        for j in range(w):
            if s[j] == '#':
                col[i].append(j + 1)
                row[j].append(i + 1)

    cc = [[0] * (w + 2) for _ in range(h)]
    rc = [[0] * (h + 2) for _ in range(w)]

    for i in range(h):
        col[i].sort()
        for j in range(len(col[i]) - 1):
            cc[i][col[i][j] + 1:col[i][j + 1]] = [col[i][j + 1] - col[i][j] - 1] * (col[i][j + 1] - col[i][j] - 1)

    for i in range(w):
        row[i].sort()
        for j in range(len(row[i]) - 1):
            rc[i][row[i][j] + 1:row[i][j + 1]] = [row[i][j + 1] - row[i][j] - 1] * (row[i][j + 1] - row[i][j] - 1)

    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(ans, cc[i][j + 1] + rc[j][i + 1] - 1)

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
N = int(input())
print(sum(list(range(N))))

### FIXED CODE ###

N = int(input())
print(((N-1)*N)//2)
def prime(p):
  if p == 2:
    return True
  else:
    flg = False
    count = 0
    for i in range(1, int(p ** 0.5)):
      if p % i == 0:
        count += 1
    if count == 1:
      flg = True
    return flg
N = int(input())
if N == 1:
  print(1)
else:
  p_list = []
  for j in range(2, N + 1):
    if prime(j):
      p_list.append(j)
  l = []
  for p in p_list:
    k = 1
    add = 0
    while N // (p ** k):
      add += N // (p ** k)
      k += 1
    l.append(add + 1)
  for r in l:
    ans *= r % (10 ** 9 + 7)
  print(ans)


### FIXED CODE ###

def prim(p):
  if p == 2:
    return True
  else:
    flg = False
    count = 0
    for i in range(1, int(p ** 0.5) + 1):
      if p % i == 0:
        count += 1
    if count == 1:
      flg = True
    return flg
N = int(input())
if N == 1:
  print(1)
else:
  p_list = []
  for j in range(2, N + 1):
    if prim(j):
      p_list.append(j)
  l = []
  for p in p_list:
    k = 1
    add = 0
    while N // (p ** k):
      add += N // (p ** k)
      k += 1
    l.append(add + 1)
  ans = 1
  for r in l:
    ans *= r
    ans = ans % (10 ** 9 + 7)
  print(ans)
import numpy as np
A, B, Q, *L = map(int, open('0').read().split())
s = L[:A]
t = L[A:A+B]
x = L[A+B:]

s = [-float('inf')]+s+[float('inf')]
t = [-float('inf')]+t+[float('inf')]
sls = np.searchsorted(s,x)
tls = np.searchsorted(t,x)
for ar, br, c in zip(sls,tls,x):
  bl = br-1
  al = ar-1
  n = s[ar]-t[bl]+min(s[ar]-c,c-t[bl])
  m = t[br]-s[al]+min(t[br]-c,c-s[al])
  p = c-min(t[bl],s[al])
  q = max(s[ar],t[br])-c
  print(min(n,m,p,q))

### FIXED CODE ###

from bisect import bisect_left
INF = 10**18
A, B, Q = map(int, input().split())
als = [int(input()) for i in range(A)]
bls = [int(input()) for i in range(B)]
als = [-INF]+als+[INF]
bls = [-INF]+bls+[INF]

for i in range(Q):
  x = int(input())
  ai = bisect_left(als,x)
  bi = bisect_left(bls,x)
  res = INF
  for S in [als[ai], als[ai-1]]:
    for T in [bls[bi], bls[bi-1]]:
      d1, d2 = abs(S-x)+abs(T-S), abs(T-x)+abs(S-T)
      res = min(res,d1,d2)
  print(res)
h = int(input())

count = 0

def cal(h):
  if h = 1:
    count = count + 1
    return 0
  
  return count + cal(int(h/2))) + 1

print(cal(h))

### FIXED CODE ###

h = int(input())
 

def cal(h):
  if h == 1:
    return 1
  
  return 2*cal(int(h/2)) + 1
 
print(cal(h))
n = input()
s = list(map(int, input().split()))

if 'Y' in s:
    print('Four')
else:
    print('Three')


### FIXED CODE ###

n = input()
s = list(input().split())

if 'Y' in s:
    print('Four')
else:
    print('Three')
import fractions
from functools import reduce

def gcd_list(numbers):
	return reduce(fractions.gcd,numbers)

n=int(input())
hp=list(map(int,input().split()))
print(gcd_list(hp))

### FIXED CODE ###

a,b=map(int,input().split())
if b%a:
  print(b-a)
else:
  print(b+a)