Harryxun/stf_run huggingface dataset:
N, M = map(int, input().split())
H_list = list(map(int, input().split()))
road_list = []

graph_list = [[] for i in range(N)]

for m in range(M):
    A, B = map(int, input().split())
    road_list.append([A, B])

    A -= 1
    B -= 1

    graph_list[A].append(B)
    graph_list[B].append(A)

visited = [False] * N
visited[0] = True
LorS_list = [0] * N

def dfs(current, graph_list):

    global LorS_list
    global visited

    for i in graph_list[current]:
        if visited[i] == False:
            visited[i] = True


            if H_list[current] > H_list[i] and LorS_list[current] != 1:
                LorS_list[current] = 2
                LorS_list[i] = 1

            elif H_list[current] < H_list[i] and LorS_list[i] != 1:
                LorS_list[current] = 1
                LorS_list[i] = 2

            elif H_list[current] == H_list[i]:
                LorS_list[current] = 1
                LorS_list[i] = 1

            dfs(i, graph_list)

dfs(0, graph_list)
ans = LorS_list.count(2) + visited.count(False)

print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
H_list = list(map(int, input().split()))

good_list = [True] * N

for i in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1

    if H_list[A] > H_list[B]:
        good_list[B] = False
    elif H_list[A] < H_list[B]:
        good_list[A] = False
    elif H_list[A] == H_list[B]:
        good_list[A] = False
        good_list[B] = False

ans = good_list.count(True)
print(ans)





# import sys
# sys.setrecursionlimit(100000000)

# N, M = map(int, input().split())
# H_list = list(map(int, input().split()))
# road_list = []


# graph_list = [[] for i in range(N)]

# for m in range(M):
#     A, B = map(int, input().split())
#     road_list.append([A, B])

#     A -= 1
#     B -= 1

#     graph_list[A].append(B)
#     graph_list[B].append(A)

# visited = [False] * N
# visited[0] = True
# LorS_list = [0] * N

# def dfs(current, graph_list):

#     global LorS_list
#     global visited

#     if len(graph_list[current]) == 0:
#         LorS_list[current] = 2

#     for i in graph_list[current]:
#         if visited[i] == False:
#             visited[i] = True


#             if H_list[current] > H_list[i] and LorS_list[current] != 1:
#                 LorS_list[current] = 2
#                 LorS_list[i] = 1

#             elif H_list[current] < H_list[i] and LorS_list[i] != 1:
#                 LorS_list[current] = 1
#                 LorS_list[i] = 2

#             elif H_list[current] == H_list[i]:
#                 LorS_list[current] = 1
#                 LorS_list[i] = 1

#             dfs(i, graph_list)


# start = 0
# while all(visited) == False:
#     visited[start] = True
#     dfs(start, graph_list)

#     if False in visited:
#         start = visited.index(False)



# ans = LorS_list.count(2)

# print(ans)
S = input()

def func(num, code):
    total = 0
    start = 0
    length = len(num)

    for i in range(1, length):
        if code & 1 == 1: #一番下にビットが立ってるなら
            total = total + int(num[start:i])
            start = i
        code = code >> 1

    total = total + int(num[start:i + 1])

    return total

total_of_all = 0

for i in range(2 ** (len(S) - 1)):
    print(func(S, i))
    total_of_all = total_of_all + func(S, i)

print(total_of_all)

### FIXED CODE ###

S = input()

def func(num, code):
    total = 0
    start = 0
    length = len(num)

    for i in range(1, length):
        if code & 1 == 1: #一番下にビットが立ってるなら
            total = total + int(num[start:i])
            start = i
        code = code >> 1

    total = total + int(num[start:length])

    return total

total_of_all = 0

for i in range(2 ** (len(S) - 1)):
    total_of_all = total_of_all + func(S, i)

print(total_of_all)
N,M = map(int,input().split())
A = list(map(int,input().split()))

A.sort(reverse=True)
S = sum(A)
i = 0
while A[i] > S//(M*4) and i < N:
    i += 1

if i >= M:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

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

A.sort(reverse=True)
S = sum(A)

for i in range(M):
    if A[i] < S/(4*M):
        print('No')
        exit()

print('Yes')
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

ans = 0
min_diff = 10*5
for i in range(N):
  if abs((T - H*0.006) - A) < min_diff:
    ans = i+1
    min_diff = abs((T - H*0.006) - A)
print(ans)


### FIXED CODE ###

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

ans = 0
min_diff = 10**5
for i in range(N):
  if abs((T - H[i]*0.006) - A) < min_diff:
    ans = i+1
    min_diff = abs((T - H[i]*0.006) - A)
print(ans)
n, m = map(int, input().split())

num = [str(x) for x in range(10**(n-1), 10**n)]
judge = [True]*len(num)

for i in range(m):
  s, c = map(int, input().split())
  for j in range(len(num)):
    if num[j][s] != c:
      judge[j] = False
      
ans = -1
for i in range(len(num)):
  if judge[i] == True:
    ans = num[i]
    break

print(ans)

### FIXED CODE ###

import sys

n, m = map(int, input().split())
key = [-1 for i in range(n)]
for i in range(m):
  s, c = map(int, input().split())
  if key[s-1] == -1:
    key[s-1] = c
  else:
    if key[s-1] == c:
      continue
    else:
      print(-1)
      sys.exit()

for i in range(n):
  if key[i] == -1:
    if i != 0:
      key[i] = 0
    elif n == 1:
      key[i] = 0
    else:
      key[i] = 1
  key[i] = str(key[i])

ans = int("".join(key))
if 10**(n-1) <= ans < 10**n:
  print(ans)
elif n == 1 and ans == 0:
  print(0)
else:
  print(-1)
n=int(input())
    k=int(input())
    x=int(input())
    y=int(input())
    if n<=k:
        ans=n*x
    else:
        sum=k*x+(n-k)*y
    print(sum)

### FIXED CODE ###

n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n<=k:
    sum=n*x
else:
    sum=k*x+(n-k)*y
print(sum)
items=int(input())
x,y=map(split( ), items)
a=x*y
b=2*x+2*y
print(a,b)

### FIXED CODE ###

a, b = map(int, input().split(" "))
area = a*b
perimeter = 2*(a+b)
print(area, perimeter)
s=input()
s=list(s)
if s[0]=="?" and s[1]=="D":
    s[0]="P"
elif s[0]=="?" and (s[1]=="P" or s[1]=="?"):
    s[0]="D"
if s[-1]=="?":
    s[-1]="D"
for i in range(1,len(s)-1):
    if s[i]=='?':
        if s[i-1]=="D" and (s[i+1]=="D" or s[i+1]=="?"):
           s[i]="P"
        else:
            s[i]="D"
s1="".join(s)
print(s1)

### FIXED CODE ###

s=input()
s2=list(s)
s1=""
if s2[-1]=="?":
    s2[-1]="D"
if s2[0]=="?" and s2[1]=="D":
    s2[0]="P"
elif s2[0]=="?" and (s2[1]=="P" or s2[1]=="?"):
    s2[0]="D"
for i in range(1,len(s2)-1):
    if s2[i]=='?':
        if s2[i-1]=="D" and (s2[i+1]=="D" or s2[i+1]=="?"):
           s2[i]="P"
        else:
            s2[i]="D"
for i in s2:
    s1+=i
print(s1)
l,r = map(int,input().split())
L = l%2019
R = r%2019  #2019 = 3*673
N = r-l+1

if N >= 2019 or L>R:
    print(0)
else:
    ans = l*(l+1)%2019
    for i in range(L,R):  #この時点でL<Rは決定済み
        for j in range(i+1,R+1):
            if (i*j)%2019 < ans:
                ans = (i*j)%2019
                if ans == 0:
                    break

print(ans)

### FIXED CODE ###

l,r = map(int,input().split())
L = l%2019
R = r%2019  #2019 = 3*673
N = r-l+1

if N >= 2019 or L>R:
    print(0)
else:
    ans = l*(l+1)%2019
    for i in range(L,R):  #この時点でL<Rは決定済み
        for j in range(i+1,R+1):
            ans = min(ans,(j*i)%2019)
        if ans == 0:
            break
    print(ans)
import itertools

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

cnt = 0

for i in range(n+1):
    for v in itertools.combinations(x,i+1):
        if sum(v) == a*(i+1): #組み合わせのカードの平均がaと等しいならば
            cnt = cnt + 1

print(cnt)


### FIXED CODE ###

n, k, x, y = map(int, [input() for i in range(4)])

if k <= n:
    total = k*x + (n-k)*y
else :
    total = n*x

print(total)
import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra

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

gy = np.zeros((n, n))
gs = np.zeros((n, n))
for _ in range(m):
    u, v, a, b = map(int, input().split())
    gy[u-1][v-1] = a
    gy[v-1][u-1] = a
    gs[u-1][v-1] = b
    gs[v-1][u-1] = b


Gy = csgraph_from_dense(gy)
dy = dijkstra(Gy, indices=s-1)

Gs = csgraph_from_dense(gs)
ds = dijkstra(Gs, indices=t-1)

dist = []
for i in range(n):
    dist.append(dy[i]+ds[i])

for i in range(n):
    print(10**15-int(min(dist[i:])))


### FIXED CODE ###

import numpy as np
from heapq import heappush, heappop

n, m, s, t = map(int, input().split())
G = [[] for _ in range(n+1)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    G[u].append((v, a, b))
    G[v].append((u, a, b))


def dijkstra(start, mode):
    INF = 10 ** 15
    dist = [INF] * (n+1)
    dist[start] = 0
    q = [(0, start)]
    while q:
        d, v = heappop(q)
        if dist[v] < d:
            continue
        for w, *a in G[v]:
            d1 = d + a[mode]
            if dist[w] > d1:
                dist[w] = d1
                heappush(q, (d1, w))
    return dist


d1 = np.array(dijkstra(s, 0))
d2 = np.array(dijkstra(t, 1))

# print(d1)


d = []
for i in range(n+1):
    d.append(d1[i]+d2[i])


ans = []
B = 10**15
for i in range(n):
    B = min(B, d[n-i])
    ans.append(B)
ans = ans[::-1]

for i in range(n):
    print(10**15-ans[i])
s = input()
vis_a = 0
vis_b = 0

for i in s:
  if s == 'A':
    vis_a = 1
  if s == 'B':
    vis_b = 1

if vis_a and vis_b:
  print("Yes")
else
  print("No")

### FIXED CODE ###

s = input()
vis_a = 0
vis_b = 0

for i in s:
  if i == 'A':
    vis_a = 1
  if i == 'B':
    vis_b = 1

if vis_a and vis_b:
    print("Yes")
else:
    print("No")
a,b = int(input().split())
c=a*b
if c % 2 == 0:
  print("Odd")
else:
  print("Even")
 

### FIXED CODE ###

a, b = map(int, input().split())
c = a * b
if c % 2 == 0:
  print("Even")
else:
  print("Odd")
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float("inf")]*n
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
        if i-j >= 0:
            dp[i] = min(abs(h[i-j] - h[i]) + dp[i-j], dp[i])
print(dp[-1])

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
dp = [0]
dp.append(abs(h[1]-h[0]))
if n > 2:
    for i in range(2,n):
        dp.append(min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]))
print(dp[-1])
def check2(x,y,p,t):
    for i in range(p,t,1):
        if x % i == 0 and y % i == 0 :
            return i
        if i * i > t :
            return -1
A,B = map(int,input().split())
ans = 1
p = 2
t = min(A, B)
while True :
    p = check2(A,B,p,t)
    if p == -1 :
        break
    while True :
        if A % p == 0 and B % p == 0 :
            A = (A//p)
            B = (B//p)
        else :
            break
    ans += 1
print(ans)


### FIXED CODE ###

def gcd(x, y):
    if y == 0 :
        return x
    else:
        return gcd(y,x%y)
def prime(x):
    global  ans
    m = x ** (0.5)
    for i in range(2,int(m+1)):
        if x % i == 0 :
            while True:
                if x % i != 0 :
                    break
                else:
                    x = (x//i)
            ans +=1
    if x != 1 :
        ans += 1
    return ans
A,B = map(int,input().split())
t = gcd(A,B)
ans = 1
print(prime(t))
import itertools
n, m, q = map(int, input().split(" "))
asset = []
for i in range(q):
    asset.append(list(map(int, input().split(" "))))
A = []


max = 0
print (asset)
for a in itertools.product(list(range(1, m + 1)), repeat = n):
    A.append((list(a)))
for i in range(len(A)):
    total = 0
    for j in range(0, n):
        if A[j] <= A[j - 1]:
            continue
    for j in range(q):
        if A[i][asset[j][1] - 1] - A[i][asset[j][0] - 1] == asset[j][2]:
            total += asset[j][3]
    max = total if total > max else max
print(max)


### FIXED CODE ###

import itertools

n,m,q = map(int, input().split(" "))
a,b,c,d = [],[],[],[]
for i in range(q):
  inpu = input()
  a.append((int)(inpu.split(" ")[0]))
  b.append((int)(inpu.split(" ")[1]))
  c.append((int)(inpu.split(" ")[2]))
  d.append((int)(inpu.split(" ")[3]))

balls = list(itertools.combinations_with_replacement(range(1, m + 1), n))
#print(balls)
max = 0
for i in range(len(balls)):
  temp = 0
  for j in range(q):
    if balls[i][b[j] - 1] - balls[i][a[j] - 1] == c[j]:
      temp += d[j]
  if temp > max:
    max = temp
print(max)
import copy

N = int(input())

Height = []
tmp = []
for i in range(N):
    x, y, h = map(int, input().split())
    if i == 0:
        for c_x in range(0, 101):
            for c_y in range(0, 101):
                if h != 0:
                    H = h + abs(x-c_x) + abs(y-c_y)
                    d = (c_x, c_y, H)
                    Height.append(d)
                else:
                    pass
    else:
        for c_x in range(0, 101):
            for c_y in range(0, 101):
                if h != 0:
                    H = h + abs(x-c_x) + abs(y-c_y)
                    d = (c_x, c_y, H)
                    if d in Height:
                        if d not in tmp:
                            tmp.append(d)
                else:
                    pass
        if i == N-1:
            Height.clear()
            break
        else:
            Height = copy.deepcopy(tmp)
            tmp.clear()

tmp[0] = [str(i) for i in tmp[0]]

print(' '.join(tmp[0]))


### FIXED CODE ###

import sys

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

H.sort(key=lambda x: x[2], reverse=True)

for i in H:
    x, y, h = i
    for c_x in range(101):
        for c_y in range(101):
            Height = h + abs(x-c_x) + abs(y-c_y)
            for j in range(N):
                if H[j][2] != max(Height-abs(H[j][0]-c_x)-abs(H[j][1]-c_y), 0):
                    break
                if j == N-1:
                    print(c_x, c_y, Height)
                    sys.exit()
n=int(input())
z=0
N=[0]*10000
ans=0
ko=0
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            ko=x**2+y**2+z**2+x*y+y*z+z*x
            if ko<=n:
                N[ko]+=1
            else:
                break
for i in range(n):
    print(N[i])

### FIXED CODE ###

n=int(input())
z=0
N=[0]*10000
ans=0
ko=0
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            ko=x**2+y**2+z**2+x*y+y*z+z*x
            if ko<=n:
                N[ko-1]+=1
            else:
                break
for i in range(n):
    print(N[i])
import math
import copy
from queue import Queue

#n = int(input())
n, m = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
s = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#s = [int(input()) for i in range(n)]
#s = input()
#list = list(s)
# dp = [[0 for _ in range(2)] for _ in range(13)]

#a = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

for i in range(m) :
    s[s.index(max(s))] = math.floor(max(s)/2)

print(sum(s))

### FIXED CODE ###

import math
import copy
from queue import Queue
import heapq

#n = int(input())
n, m = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
s = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#s = [int(input()) for i in range(n)]
#s = input()
#list = list(s)
# dp = [[0 for _ in range(2)] for _ in range(13)]

#a = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

s = list(map(lambda x: x*(-1), s))
heapq.heapify(s)

for i in range(m) :
    heapq.heappush(s, math.ceil(heapq.heappop(s)/2))

print(sum(s)*(-1))
N,M = map(int,input().split())
X=[int(i) for i in input().split()]
X.sort()

if N==1:
  print(X[M-1]-X[0])
elif N>=M:
  print(0)
elif N+1=M:
  print(X[0])
else:
  Y=list()
  [Y.append(X[i]-X[i-1]) for i in range(M)[1:]]
  Y.sort()
  print(sum(Y[:-(N-1)]))


### FIXED CODE ###

N,M = map(int,input().split())
X=sorted([int(i) for i in input().split()])

Y=list()
for i in range(M)[1:]:
  diff = X[i]-X[i-1]
  Y.append(diff)

Y=sorted(Y)

if N==1:
  print(sum(Y))
else:
  print(sum(Y[:-(N-1)]))
h,n = (int(i) for i in input().split())
a=input().split()
if sum(a)>=h:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

h,n = (int(i) for i in input().split())
a=[]
for i in input().split():
  a.append(int(i))
if sum(a)>=h:
  print('Yes')
else:
  print('No')
if S == 'AAA' or S == 'BBB':
  print('No')
else:
  print('Yes')

### FIXED CODE ###

S = input()
if S == 'AAA' or S == 'BBB':
  print('No')
else:
  print('Yes')
import numpy as np
from math.fraction import gcd

def lcm(x, y):
    return x * y // gcd(x, y)
A, B, C, D = [int(x) for x in input().split(" ")]
n_targets = B - A + 1

n_compC = n_targets - (B // C - (A - 1) // C)
n_compD = n_targets - (B // D - (A - 1) // D)
n_compCandD = n_targets - (B // lcm(C, D) - (A - 1) // lcm(C, D))

print(n_compC + n_compD - n_compCandD)

### FIXED CODE ###

import numpy as np
from fractions import gcd

def lcm(x, y):
    return x * y // gcd(x, y)
A, B, C, D = [int(x) for x in input().split(" ")]
n_targets = B - A + 1

n_compC = n_targets - (B // C - (A - 1) // C)
n_compD = n_targets - (B // D - (A - 1) // D)
n_compCandD = n_targets - (B // lcm(C, D) - (A - 1) // lcm(C, D))

print(n_compC + n_compD - n_compCandD)
s=int(raw_input())
h=s/3600
m=s/60%60
s=s%60
print str(h)+":"str(m)+":"str(s)

### FIXED CODE ###

s=int(raw_input())
h=s/3600
m=s/60%60
s=s%60
print str(h)+":"+str(m)+":"+str(s)
n = int(input())
a = map(int, input().split())
b = len(a)
c = len(set(a))
if b == c:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = len(a)
c = len(set(a))
if b == c:
  print("YES")
else:
  print("NO")
N = input()
for i in range(N):
	A = [int(i) for i in input().split()]
P=round(sum(A)/N)
B=0
for i in range(N):
	B=B+(A[i]-P)**2
print(B)


### FIXED CODE ###

N,R=map(int, input().split()) 
if N>=10:
    print(R)
if 0<=N<10:
    print(R+100*(10-N))
import sys

input = sys.stdin
N, W = input().split()
aArr = list()
ans = 0
tmp = int(N)
MOD = 10 ** 9 + 7
aArr = set(map(int, input()))

tmp = 0
tmpB = 0
ans = 1
for i in range(int(N)):
    if (i in aArr):
        tmp = 0
    elif i < 2:
        tmp = 1
    else:
        tmp = ans
    ans = (tmp + tmpB) % MOD
    tmpB = tmp
print(ans)


### FIXED CODE ###

import sys
N, W = input().split()
aArr = list()
ans = 0
tmp = int(N)
MOD = 10 ** 9 + 7
aArr = set(map(int, sys.stdin))

tmp = 0
tmpB = 0
ans = 1
for i in range(int(N)):
    if (i in aArr):
        tmp = 0
    elif i < 2:
        tmp = 1
    else:
        tmp = ans
    ans = (tmp + tmpB) % MOD
    tmpB = tmp
print(ans)
l=int(input())
x=l/3
#print((l/3)**3)
print(f"{x*x*x:09f}")


### FIXED CODE ###

l=float(input())

x=l/3
print((l/3)**3)
#print(f"{x*x*x:0.6f}")
import math

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

mincost = [math.inf for _ in range(N)]
mincost[0] = 0
mincost[1] = abs(h[1] - h[0])

for i in range(2, N):
    mincost[i] = min(mincost[i - 2] + abs(h[i] - h[i - 2]), mincost[i - 1] + abs(h[i] - h[i - 1]))

print(mincost[N - 1])

### FIXED CODE ###

n = int(input())
h = [int(x) for x in input().split()]

def abs(x):
    if x >= 0:
        return x
    return -x

c = [0]
c.append(abs(h[1] - h[0]))
for k in range(2, n):
    cnext = min(c[k-2] + abs(h[k]-h[k-2]), c[k-1] + abs(h[k] - h[k-1]))
    c.append(cnext)

print(c[-1])
n=int(input())
s=input()
t=input()
for i in range(n):
    if s[i:] == t[:n-i]:
        print(n+i)
        exit(1)
else:
    print(n*2)


### FIXED CODE ###

n=int(input())
s=input()
t=input()
for i in range(n):
    if s[i:] == t[:n-i]:
        print(n+i)
        break
else:
    print(n*2)
ans = -(10**9)
ans = max(a*c, ans)
ans = max(a*d, ans)
ans = max(b*c, ans)
ans = max(b*d, ans)
print(ans)


### FIXED CODE ###

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

ans = -(10**18)
ans = max(a*c, ans)
ans = max(a*d, ans)
ans = max(b*c, ans)
ans = max(b*d, ans)
print(ans)
a = list(map(int, input().split()))
#print(a)
try:
    b=[0]*a[1]
    c=[0]*(a[1]+1)
    b[0]=int(input())
    c[0]=b[0]-0
    for x in range(a[1]-1):
        b[x+1]=int(input())
        c[x+1]=b[x+1]-b[x]-1
    c[-1]=a[0]-b[-1]
    max = 0
    min = a[0]+100
    for x in c:
        if x>max:
            max=x
        if x<min:
            min=x
except:
    print(0)
#print(c)
#print(max," ",min)
if min==0:
    print(0)
else:
    num=[0]*(max)
    for x in range(max):
        if x==0:
            num[0]=1
        elif x==1:
            num[1]=1
        else:
            num[x]=num[x-1]+num[x-2]
        #print("num[",x,"]=",num[x])
        
    answer=1
    for x in c:
        answer *=num[x-1]
        if answer==0:
            print(0)
            break
        else:
            answer%=1000000007
    print(answer)

### FIXED CODE ###

n,m = list(map(int, input().split()))
a=[]
a.append(-1)
for x in range(m):
  tmp=int(input())
  a.append(tmp)
a.append(n+1)
diff = []
for x in range(len(a)-1):
  diff.append(a[x+1]-a[x])
              
large = 0
small = 123456789012345
for x in diff:
  large=max(large,x)
  small=min(small,x)

num=[0,0,1]
for _ in range(large):
  num.append((num[-1]+num[-2])%1000000007)
    
answer=1
for x in diff:
  #print(x,num[x])
  answer *=num[x]
  answer%=1000000007
print(answer)
import sys
input = sys.stdin.readline

N, M = map(int, input().strip().split())
A = list(map(int, input().strip().split()))
for i in range(M):
    B, num = map(int, input().strip().split())
    for j in range(B):
        A[A.index(min(map(lambda x: x - num, nums))+num)] = max(num,x)
print(sum(A))

### FIXED CODE ###

A, B = map(int, input().strip().split())
if A >= 13:
    print(B)
elif 6 <= A <= 12:
    print(B // 2)
else:
    print(0)
A = set()
for i in range(int(input())):
    a = int(input())
    A ^= set(a)
print(len(A))

### FIXED CODE ###

A = set()
for i in range(int(input())):
    A ^= set([int(input())])
print(len(A))
def solve(A, N, day=0):
    # check if end
    if all([len(a) == 0 for a in A]):
        return day
    # get available games
    available_games = set()
    for player in range(N):

        if len(A[player]) == 0:
            continue

        opponent = A[player][0]

        if opponent == player or len(A[opponent]) == 0:
            continue

        if A[opponent][0] == player:
            if player > opponent:
                player, opponent = opponent, player
            available_games.add((player, opponent))
    if len(available_games) == 0:
        return -1

    for game in available_games:
        player, opponent = game
        A[player].pop(0)
        A[opponent].pop(0)
    return solve(A, N, day + 1)


if __name__ == '__main__':
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(N)]
    for i in range(N):
        for j in range(N - 1):
            A[i][j] -= 1

    answer = solve(A, N)
    print(answer)


### FIXED CODE ###

import sys
from collections import deque

input = sys.stdin.readline

n = int(input())

to_battle_with = [deque([i - 1 for i in map(int, input().split())]) for _ in range(n)]


def update_battle(player, battle_set, to_battle_with):
    if not to_battle_with[player]:
        return
    next_opponent = to_battle_with[player][0]
    if not to_battle_with[next_opponent]:
        return
    if to_battle_with[next_opponent][0] == player:
        if player > next_opponent:
            player, next_opponent = next_opponent, player
        battle_set.add((player, next_opponent))


battles_today = set()
for player in range(n):
    update_battle(player, battles_today, to_battle_with)

day_count = 0
battle_count = 0
num_all_battles = (n * (n - 1)) // 2

while battles_today:
    battles_tomorrow = set()
    for p1, p2 in battles_today:
        battle_count += 1
        to_battle_with[p1].popleft()
        to_battle_with[p2].popleft()
        for p in [p1, p2]:
            update_battle(p, battles_tomorrow, to_battle_with)
    battles_today = battles_tomorrow
    day_count += 1

if battle_count == num_all_battles:
    print(day_count)
else:
    print(-1)
h, w = input().split()
for i in range(h):
  s = input()
  print(s)
  print(s)

### FIXED CODE ###

h, w = map(int, input().split())
for i in range(h):
  s = input()
  print(s)
  print(s)