Harryxun/stf_run huggingface dataset:
A = list(map(int, input().split()))

if B % 2 == 0:
    if A[0] >= 13 and A[0] <= 100:
        print(A[1])
    elif 6 <= A[0] and A[0] <= 12:
        print(A[1]/2)
    elif 0 <= A[0] and A[0] <= 5:
        print(0)

### FIXED CODE ###

def main():
    i = list(map(int, input().split()))
    a = i[0]
    b = i[1]

    #if isinstance(a, int) == False or isinstance(b, int) == False or a < 0 or 100 < a or b < 2 or 1000 < b or b % 2 != 0:
    #    return

    if 13 <= a and a <= 100:
        print(b)
    elif 6 <= a and a <= 12:
        print(b//2)
    elif 0 <= a and a <= 5:
        print(0)

if __name__ == "__main__":
    main()
A,B,C = map(int, input().split())
if (A=B or B=C or C=A)and not(A=B=C):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

A,B,C = map(int, input().split())
if A==B==C:
  print('No')
elif A==B or B==C or C==A:
  print('Yes')
else:
  print('No')
N, M = map(int, input().split())
dict = {i+1:[] for i in range(M)}
for _ in range(M):
    a, b = map(int, input().split())
    dict[a].append(b)
    dict[b].append(a)
    
def DFS(visited, sight, cnt):
    if(len(visited) == N):
        return cnt+1
    for num in dict[sight]:
        if num in visited:
            continue
        cnt = DFS(visited+[num], num, cnt)
    return cnt

print(DFS([1], 1, 0))

### FIXED CODE ###

N, M = map(int, input().split())
graph ={i+1:[] for i in range(N)}
for _ in range(M):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)
    
def dfs(path, n, cnt):
    if(len(path) == N):
        return cnt+1
    for j in graph[n]:
        if(j in path):
            continue
        cnt = dfs(path+[j], j, cnt)
    return cnt
print(dfs([1], 1, 0))
S, W = map(int, input().split())
if S <= W:
    print("unsafe")
else:
    print("safe")

### FIXED CODE ###

N = int(input())

items = set()
for i in range(N):
    item = input()
    items.add(item)
print(len(items))
# coding: utf-8
# Your code here!
def dfs(num,cost):
    visited[num]=cost
    for item in way[num]:
        if visited[item[0]]==-1:
            dfs(item[0],cost+item[1])
    return
    
N=int(input())

way=[[] for i in range(N)]
visited=[-1]*N
for _ in range(N-1):
    a,b,c=map(int,input().split())
    way[a-1].append([b-1,c])
    way[b-1].append([a-1,c])


Q,K=map(int,input().split())
dfs(K-1,0)
for _ in range(Q):
    x,y=map(int,input().split())
    print(visited[x-1]+visited[y-1])


### FIXED CODE ###

# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**9)

def dfs(num,cost):
    visited[num]=cost
    for item in way[num]:
        if visited[item[0]]==-1:
            dfs(item[0],cost+item[1])
    return
    
N=int(input())

way=[[] for i in range(N)]
visited=[-1]*N
for _ in range(N-1):
    a,b,c=map(int,input().split())
    way[a-1].append([b-1,c])
    way[b-1].append([a-1,c])


Q,K=map(int,input().split())
dfs(K-1,0)
for _ in range(Q):
    x,y=map(int,input().split())
    print(visited[x-1]+visited[y-1])
a =  input().split()

if a[1] = "+":
    print(int(a[0]) + int(a[2]))
    
if a[1] = "-":
    print(int(a[0]) - int(a[2]))

### FIXED CODE ###

print(eval(input()))
from bisect import bisect_left

n = int(input())
a = tuple(sorted(map(int, input().split())))
j = bisect_left(a, 0)

p = a[j:]
m = a[:j]

if len(m) % 2 == 0:
    print(sum(p) - sum(m))
else:
    print(sum(p[1:]) - sum(m[:-1]) + abs(p[0] + m[-1]))


### FIXED CODE ###

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

sa = 0
min_v = float('inf')
minus_count = 0
for aa in a:
    if aa < 0:
        minus_count += 1
        aa = abs(aa)
    min_v = min(min_v, aa)
    sa += aa

if minus_count % 2 == 0:
    print(sa)
else:
    print(sa - min_v * 2)
# coding: utf-8
# Here your code !
import math

def calculate_minkowski_distances():
    _ = input()
    data = []
    for i in range(2):
        data.append([float(value) for value in input().rstrip().split()])

    for exponent in (1, 2, 3, math.inf):
        print(minkowski_distance(*data, exponent))

def minkowski_distance(vector_x, vector_y, exponent):
    abs_xy = [ abs(pair[0] - pair[1]) for pair in zip(vector_x, vector_y) ]

    m_dis = 0
    if math.isinf(exponent) :
        m_dis = max(abs_xy)
    elif exponent == 0 :
        m_dis = nan
    else :
        m_dis = ( sum([ elem**exponent for elem in abs_xy ])**(1/exponent) )
    
    return m_dis

if __name__ == "__main__" :
    calculate_minkowski_distances()
    
    

### FIXED CODE ###

# coding: utf-8
# Here your code !

def calculate_minkowski_distances():
    _ = input()
    data = []
    for i in range(2):
        data.append([float(value) for value in input().rstrip().split()])

    for exponent in (1, 2, 3, float("inf")):
        print(minkowski_distance(data[0],data[1], exponent))
#        print("{0:.8f}".format(minkowski_distance(*data, exponent)))

def minkowski_distance(vector_x, vector_y, exponent):
#    abs_xy = [ abs(pair[0] - pair[1]) for pair in zip(vector_x, vector_y) ]
    abs_xy = [abs(vector_x[i] - vector_y[i]) for i in range(len(vector_x))]
    
    m_dis = 0
    if exponent == float("inf") :
        m_dis = max(abs_xy)
    elif exponent == 0 :
        m_dis = nan
    else :
        m_dis = sum([ elem**exponent for elem in abs_xy ])**(1/exponent)
    
    return m_dis

if __name__ == "__main__" :
    calculate_minkowski_distances()
def get_next_int():
    return int(float(input()))
def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])
def main():
    n = get_next_int()
    
    a = get_next_ints()
    b = get_next_ints()
    
    a_offsets = []
    b_offsets = []
    for i in range(n):
        a_offsets.append(str(a[i] ^ a[i-1]))
        b_offsets.append(str(b[i] ^ b[i-1]))
    #print(a_offsets)
    #print(b_offsets)
    a_text = " ".join(a_offsets)
    b_text = " ".join(b_offsets)
    target_text = a_text + " " + a_text
    
    start = 0
    while target_text.find(b_text, start) >= 0 and start <= len(a_text):
        start = target_text.find(b_text, start)
        #print(start)
        pos_diff = s[:start].count(" ")
        xor_diff = b[0] ^ a[pos_diff]
        print(pos_diff, xor_diff)        
        start = start + 2
    
    

if __name__ == '__main__':
    main()
if __name__ == '__jupyter__':
    import doctest
    print(doctest.testmod())

### FIXED CODE ###

def get_next_int():
    return int(input().rstrip("\n"))


def get_next_ints(delim=" "):
    return tuple([int(x) for x in input().rstrip("\n").split(delim)])


def main():
    n = get_next_int()

    a = get_next_ints()
    b = get_next_ints()

    a_offsets = []
    b_offsets = []
    for i in range(n):
        a_offsets.append(str(a[i] ^ a[i - 1]))
        b_offsets.append(str(b[i] ^ b[i - 1]))
    #print(a_offsets)
    #print(b_offsets)
    a_text = " ".join(a_offsets)
    b_text = " ".join(b_offsets)
    target_text = a_text + " " + a_text
    start_pos = 0
    if target_text.find(b_text, start_pos) >= 0:
        fisrt_pos = target_text.find(b_text, start_pos)
        fisrt_pos_diff = target_text[:fisrt_pos].count(" ")
        fisrt_xor_diff = b[0] ^ a[fisrt_pos_diff]
        print(fisrt_pos_diff, fisrt_xor_diff)
        if target_text.find(b_text, fisrt_pos+1) >= 0:
            second_pos = target_text.find(b_text, fisrt_pos+1)
            second_pos_diff = target_text[:second_pos].count(" ")
            if second_pos_diff < len(a):
                second_xor_diff = b[0] ^ a[second_pos_diff]
                print(second_pos_diff, second_xor_diff)
                interval = (second_pos_diff - fisrt_pos_diff)
                remain = (n - second_pos_diff - 1) // (second_pos_diff - fisrt_pos_diff)
                for i in range(remain):
                    print(second_pos_diff + interval * (i + 1), [fisrt_xor_diff,second_xor_diff ][i % 2])

if __name__ == '__main__':
    main()
s = input()
sa = s.index("A")
sc = s.index("C")
scr = s.rindex("C")
if sa == 1 and sc == scr and 2 <= sc <= len(s) - 3

### FIXED CODE ###

s = input()
if s[0] == "A" and s[2:-1].count("C") == 1:
  i = s.index("C")
  ss = s[1:i] + s[i+1:]
  if ss.islower() == True:
    print("AC")
  else:
    print("WA")
else:
  print("WA")
N = list(input())
if N in '7':
	print('Yes')
else:
	print('No')

### FIXED CODE ###

N = list(input())
if '7' in N:
	print('Yes')
else:
	print('No')
print(degrees(atan(2 * (a ** 2 * b - x) / a ** 3)) if x >= a ** 2 * b / 2 else degrees(atan(a * b ** 2 / x / 2)))


### FIXED CODE ###

from math import atan, degrees
a, b, x = map(int, input().split())
print(degrees(atan(2 * (a ** 2 * b - x) / a ** 3)) if x >= a ** 2 * b / 2 else degrees(atan(a * b ** 2 / x / 2)))
N = int(input())
A = list(map(int, input().split()))
if all(A[0]==a for a in A):
    print(A[0])
else:
    B = []
    D = []
    for a in A:
        for i in range(len(A)):
            if A[i]%a != 0:
                B = append(A[i]%a)
                C = list(set(B))
    for i in range(len(C)-1):
        D.append(abs(C[i]-C[i+1]))
    print(min(min(C),min(D)))

### FIXED CODE ###

import fractions
N = int(input())
A = list(map(int, input().split()))
a = 0
for i in range(N):
    a = fractions.gcd(a, A[i])
print(a)
a,b=map(int,input().split());print('DH'[a==b])

### FIXED CODE ###

a,b=input().split();print('DH'[a==b])
import math
a,b,x = map(int,input().split())
h = x/(a**2)
if b//2 >= h:

    d = 2*h*a/b

    sin = math.degrees(math.acos(d/((d**2+b**2)**0.5)))
    print(sin)
else:
    d = 2*(b-h)*a/a
    sin = math.degrees(math.acos(d/((d**2+a**2)**0.5)))
    print(90-sin)


### FIXED CODE ###

a,b = map(int,input().split())
if a > 9 or b > 9:
  print(-1)
else:
  print(a*b)
x=input().split(" ")
print(f"{x[0]*x[1}} {(x[0]+x[1])*2}")

### FIXED CODE ###

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

### FIXED CODE ###

inf = 10 ** 18
P = 10 ** 9 + 7

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

A_all = sum(A)

xi = min(A[0], B[0])
A[0] -= xi
B[0] -= xi
for i in range(N):
    yi = min(B[i], A[i + 1])
    A[1 + i] -= yi
    B[i] -= yi
    #
    if i < N - 1:
        xi = min(A[1 + i], B[1 + i])
        A[1 + i] -= xi
        B[1 + i] -= xi
    #
    # print("#", A, B, A_all - sum(A))
    
A_r = list(reversed(A))
B_r = list(reversed(B))


xi = min(A_r[0], B_r[0])
A_r[0] -= xi
B_r[0] -= xi
for i in range(N):
    yi = min(B_r[i], A_r[i + 1])
    A_r[1 + i] -= yi
    B_r[i] -= yi
    #
    if i < N - 1:
        xi = min(A_r[1 + i], B_r[1 + i])
        A_r[1 + i] -= xi
        B_r[1 + i] -= xi
    #
    # print("#", A, B, A_all - sum(A))

print(A_all - sum(A))
import itertools

N, M = map(int, input().split())
E = [[N] * (N + 1) for i in range(N + 1)]
for i in range(N):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    E[a].append(b)
    E[b].append(a)

count = 0
for V in itertools.permutations(range(1, N)):
    if V[0] in E[0] and all(V[i] in E[V[i-1]] for i in range(1, N-1)):
        count += 1
print(count)        


### FIXED CODE ###

import itertools

N, M = map(int, input().split())
E = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    E[a].append(b)
    E[b].append(a)

count = 0
for V in itertools.permutations(range(1, N)):
    if V[0] in E[0] and all(V[i] in E[V[i-1]] for i in range(1, N-1)):
        count += 1
print(count)
N, K = map(int, input().split())
x = list(map(int, input().split()))

count_m = 0
count_p = 0
for i in range(N):
    if x[i] > 0:
        count_m = i
        count_p = N-i
        break
    elif x[i] == 0:
        count_m = i
        count_p = N-i-1
        K -= 1
        N -= 1
        x.remove(x[i])
        break
if count_m == 0 and count_p == 0:
    count_m = N

ans = 0
    

y = K
z = K - y
# for j in range(1, y):
#     #if count_m-j>0 and count_m+y-1-j<N-1:
#     if True:

#         print(j)

#         print(x[count_m+y-1-j],x[count_m-j] ,x[count_m-1])



if count_m >= 1:
    tmp = min(x[count_m+y-1-j]-x[count_m-j] *2 for j in range(1, y) if count_m-j>=0  and count_m+y-1-j<N)
    tmp2 = min(x[count_m+y-1-j]*2-x[count_m-j] for j in range(1, y) if count_m-j>=0 and count_m+y-1-j<N)
else:
    tmp = tmp2 = 1000000000

if N==0:
    ans = 0

elif count_p>=K:
    # print(y, "1chi")
    ans = min(tmp, tmp2, x[count_m+min(y, count_p)-1])
elif count_m>=K:
    #print("ni")
    ans = min(tmp, tmp2, -x[count_m-K])
else:
    # print("san")
    ans = min(tmp, tmp2)


print(ans)


### FIXED CODE ###

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

count_m = 0
count_p = 0
for i in range(N):
    if x[i] > 0:
        count_m = i
        count_p = N-i
        break
    elif x[i] == 0:
        count_m = i
        count_p = N-i-1
        K -= 1
        N -= 1
        x.remove(x[i])
        break
if count_m == 0 and count_p == 0:
    count_m = N

ans = 0
    

y = K
z = K - y


if count_m >= 1 and count_p>=1:
    # for j in (range(1,y)):
    #     if count_m-j>=0  and count_m+y-1-j<N:
    #         print(x[count_m+y-1-j], x[count_m-j])
    tmp = min(x[count_m+y-1-j]-x[count_m-j] *2 for j in range(1, y) if count_m-j>=0  and count_m+y-1-j<N)
    tmp2 = min(x[count_m+y-1-j]*2-x[count_m-j] for j in range(1, y) if count_m-j>=0 and count_m+y-1-j<N)
else:
    tmp = tmp2 = 1000000000

if N==0:
    ans = 0


elif count_p>=K:
    # print(y, "1chi")
    ans = min(tmp, tmp2, x[count_m+min(y, count_p)-1])
elif count_m>=K:
    #print("ni")
    ans = min(tmp, tmp2, -x[count_m-K])
else:
    #print("san", tmp, tmp2)
    ans = min(tmp, tmp2)


print(ans)
import math

r = int(input())

S = math.pi * r**2
L = 2 * math.pi * r

print(S, L)

### FIXED CODE ###

import math

r = float(input())

S = math.pi * r**2
L = 2 * math.pi * r

print(S, L)
n,m = map(int,input().split())
da = [map(str,input().split()) for i in range(m)]
penalty = [0 for i in range(n)]
accepted = [False for i in range(n)]
for i in range(m):
  now = int(da[i][0]) - 1
  if da[i][1] == 'AC':
    accepted[now] = True
  elif not accepted[now]:
    penalty[now] += 1
AC,WA = 0,0
for i in range(n):
  if accepted[i]:
    AC += 1
    WA += penalty[i]
print(AC,WA)
    


### FIXED CODE ###

n,m = map(int,input().split())
da = [list(map(str,input().split())) for i in range(m)]
penalty = [0 for i in range(n)]
accepted = [False for i in range(n)]
for i in range(m):
  now = int(da[i][0]) - 1
  if da[i][1] == 'AC':
    accepted[now] = True
  elif not accepted[now]:
    penalty[now] += 1
AC,WA = 0,0
for i in range(n):
  if accepted[i]:
    AC += 1
    WA += penalty[i]
print(AC,WA)
x, k, d = list(map(int, input().split()))

sign = int(x /abs(x))

if (abs(x) // d) < k:
  tmp = x - sign * d * (abs(x) // d)
  #print(tmp)
  if (k - (abs(x) // d)) % 2 == 0:
    print(abs(tmp))
  else:
    print(min(abs(tmp + d), abs(tmp - d)))
else:
  print(abs(x - sign * d * k))

### FIXED CODE ###

x, k, d = list(map(int, input().split()))

sign = 0
if x != 0:
  sign = int(x /abs(x))

if (abs(x) // d) < k:
  tmp = x - sign * d * (abs(x) // d)
  #print(tmp)
  if (k - (abs(x) // d)) % 2 == 0:
    print(abs(tmp))
  else:
    print(min(abs(tmp + d), abs(tmp - d)))
else:
  print(abs(x - sign * d * k))
import sys
while True:
    x = sys.stdin.readline().strip()
    if x == "0 0":
        break
    a = list(map(int, x.strip()))
    for i in range(a[0]):
        sharp = "#" * a[1]
        print(sharp)

### FIXED CODE ###

while True:
    a = list(map(int, input().split()))
    if a[0] == a[1] == 0:
        break
    sharp = "#" * a[1]
    for i in range(a[0]):
        print(sharp)
    print()
N, S = map(int, input().split())
A = map(int, input().split())

def solve(length, target, nums):
  
  dp = [[0]*(target+1)]*(length+1)
  
  for i, n in enumerate(nums):
    for j, comb_num in enumerate(dp[i]):
      sub = j - n
      dp[i + 1][j] += comb_num
      if sub >= 0::
        dp[i + 1][j] += dp[i][sub]
        
  print(dp[length][target])
  
solve(N, S, A)


### FIXED CODE ###

N, S = map(int, input().split())
A = map(int, input().split())
 
def solve(length, target, nums):
  
  dp = [[0]*(target+1) for i in range(length+1)]
  dp[0][0] = 1
  for i, n in enumerate(nums):
    for j, comb_num in enumerate(dp[i]):
      sub = j - n
      dp[i + 1][j] += comb_num * 2
      #print(i, j, sub, dp[i])
      if sub >= 0:
        dp[i + 1][j] += dp[i][sub]
      dp[i + 1][j] %= 998244353
  #print(dp)
  print(dp[length][target])
  
solve(N, S, A)
N, X = map(int, input().split())
L = list(map(int,input().split()))

i = 0
D = 0
while D <= X and i <= N:
    D += L[i]
    i += 1
print(i)

### FIXED CODE ###

N, X = map(int, input().split())
L = list(map(int,input().split()))

count = 1
D = 0
for i in range(N):
  D += L[i]
  if D <= X:
    count += 1
print(count)
import sys
read = sys.stdin.buffer.read
 
K, N, *A = map(int, read().split())
A.append([A[0] + K])
gap = max(y - x for x, y in zip(A, A[1:]))
print(K - gap)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
 
K, N, *A = map(int, read().split())
A += [A[0] + K]
gap = max(y-x for x,y in zip(A, A[1:]))
print(K - gap)
def main():
    A, B, K = map(int, input().split())
    CDD = []
    maxi = max(A,B)
    mini = min(A,B)
    for i in range(1, mini + 1):
        if mini % i == 0:
            if maxi % i == 0:
                CDD.append(i)
    print(CDD)
    print(CDD[-K:-K + 1][0])
main()

### FIXED CODE ###

def main():
    A, B, K = map(int, input().split())
    CDD = []
    maxi = max(A,B)
    mini = min(A,B)
    for i in reversed(range(1, mini + 1)):
        if mini % i == 0:
            if maxi % i == 0:
                CDD.append(i)
    print(CDD[K - 1])
main()
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

k,n = MAP()
a = LIST()
a.sort()

mx = k-a[-1] + a[0]

for i in range(1, n):
    mx = max(mx, a[i]-a[i-1])

print(k-mx)

### FIXED CODE ###

# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

k,n = MAP()
a = LIST()
a.sort()

mx = k-a[-1] + a[0]

for i in range(1, n):
    mx = max(mx, a[i]-a[i-1])

print(k-mx)
n=int(raw_input())
for i in range(0,n):
        zahyou=map(float,raw_input().split(" "))
        a=(zahyou[3]-zahyou[1])/(zahyou[2]-zahyou[0])
        b=(zahyou[7]-zahyou[5])/(zahyou[6]-zahyou[4])
        if a==b or a==-b:
            print "YES"
        else:
            print "NO",

### FIXED CODE ###

n = int(raw_input())
for i in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, raw_input().split())
    print "YES" if abs(((y2-y1)*(x4-x3) - (x2-x1)*(y4-y3))) < 1e-10 else "NO"
print("vowel" if input() in 'a','e','i','o','u' else ""consonant)

### FIXED CODE ###

s = input()
chk = ['a','e','i','o','u']
print("vowel" if s in chk else "consonant")
N = int(input())
A=input().split()

s=int(A[0])//N
if int(A[0])%N==0:
    print('OK')
else:
    if (s+1)*N>=A[1]:
        print('NG')
    else:
        print('OK')


### FIXED CODE ###

N = int(input())
A=input().split()

s=int(A[0])//N
if int(A[0])%N==0:
    print('OK')
else:
    if (s+1)*N>int(A[1]):
        print('NG')
    else:
        print('OK')
from math import factorial
import itertools

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

C=0
t=[math.factorial(N-i) for i in range(2,N)]

t=list(itertools.accumulate(t))
t.append(math.factorial(N-1))
t.reverse()
T=list(itertools.accumulate(t))

C=[(x[j]-x[j-1])*T[j-1] for j in range(1,N) ]

print(sum(C)%((10 ** 9)+7))

### FIXED CODE ###

from math import factorial
 
N = int(input())
x = list(map(int, input().split()))
mod = 10**9 + 7
x_dis = [x[i+1] - x[i] for i in range(N-1)]
ans = 0
m = N-1
fac = factorial(m) % mod
tmp = fac
for i in range(m):
    ans += x_dis[i] * tmp
    ans %= mod
    tmp += (fac*pow((i+2),(mod-2), mod))%mod
print(ans)
import math
a,b,c,d = map(int, input().split())

#cとdの最大公約数を求める
first = [c,d%c]
first.sort()
if d%c==0:
  cd = c
elif first[0]==1:
  cd = 1
else:
  while first[0]>=2:
    first[1] = first[1]%first[0]
    first.sort()
    if first[0]==0:
      cd = first[1]
    elif first[0]==1:
      cd = 1
lcm = c*d/cd
      
zen = b-a+1
c_num = (b//c) -math.ceil(a/c)+1
d_num = (b//d) -math.ceil(a/d)+1
lcm_num = (b//lcm) - math.ceil(a/lcm)+1
ans = zen - c_num - d_num + lcm_num
print(ans)

### FIXED CODE ###

s = input()
s_list = [i for i in s]
flag = True
for i in range(1,4):
  if s_list[i]==s_list[i-1]:
    print('Bad')
    flag = False
    break

if flag:
  print('Good')
N, H, W = [int(x) for x in raw_input().split(' ')]
arr = []
for _ in xrange(N):
    r, c, a = [int(x) for x in raw_input().split(' ')]
    arr.append((a, r-1, c+H-1))
arr = sorted(arr)
ans = 0
P = [-1] * (H+W)
C = [1] * (H+W)

def find(a):
    if P[a] < 0:    return a
    t = find(P[a])
    P[a] = t
    return t

def unite(a, b):
    if par(a) == par(b): return 0
    C[par(a)], C[par(b)] = C[par(a)] + C[par(b)], C[par(a)] + C[par(b)]
    if P[par(b)] == P[par(a)]:
        P[par(b)] = par(a)
        P[par(a)] -= 1
    elif P[par(b)] > P[par(a)]:
        P[par(b)] = par(a)
    else:
        P[par(a)] = par(b)
    
while arr:
    a, r, c = arr.pop()
    unite(r, c)
    if C[find(r)]:
        ans += a
        C[find(r)] -= 1
print(ans)


### FIXED CODE ###

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

def par(a):
    if P[a] < 0: return a
    t = par(P[a])
    P[a] = t
    return t
def unite(a, b):
    if par(a) == par(b): return 0
    C[par(a)], C[par(b)] = C[par(a)] + C[par(b)], C[par(a)] + C[par(b)]
    if P[par(b)] == P[par(a)]:
        P[par(b)] = par(a)
        P[par(a)] -= 1
    elif P[par(b)] > P[par(a)]:
        P[par(b)] = par(a)
    else:
        P[par(a)] = par(b)
N, H, W = map(int, input().split())
P = [-1 for i in range(H+W)]
C = [1] * (H+W)
X = []
for _ in range(N):
    r, c, a = map(int, input().split())
    X.append((a, r-1, c+H-1))
X = sorted(X)
ans = 0
while X:
    a, r, c = X.pop()
    unite(r, c)
    if C[par(r)]:
        ans += a
        C[par(r)] -= 1
print(ans)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import itertools
input()

lis = list(itertools.product([False,True],repeat=10))
for s in sys.stdin:
  d = map( int, s.split() )
  flag = False
  for e in lis:
    lis_r = []
    lis_l = []
    for i in range(10):
      if e[i]:
        lis_r.append(d[i])
      else:
        lis_l.append(d[i])
    f_r = sorted(lis_r)
    f_l = sorted(lis_l)
    if f_r == lis_r and f_l == lis_l:
      flag = True
      break
  if flag:
    print "YES"
  else:
    print "NO"

### FIXED CODE ###

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

n = input()
for s in xrange(n):
  d = map( int, raw_input().split() )
  a = b = 0
  flag = True
  for e in d:
    if a < e: a = e
    elif b < e: b = e
    else: flag = False
  if flag: print "YES"
  else: print "NO"