Harryxun/stf_run huggingface dataset:
N = int(input())
H = input().split(" ")
c = [10 ** 7 for i in range(N)]
c[0] = 0
c[1] = abs(int(h[0])-int(h[1]))
for i in range(N-2):
  c[i+2] = min(c[i]+abs(H[i]-H[i+2]),c[i+1]+abs(H[i+1]-H[i+2])
print(c[-1])

### FIXED CODE ###

N = int(input())
H = input().split(" ")
c = [10 ** 7 for i in range(N)]
c[0] = 0
c[1] = abs(int(H[0])-int(H[1]))
for i in range(N-2):
  c[i+2] = min(c[i]+abs(int(H[i])-int(H[i+2])),c[i+1]+abs(int(H[i+1])-int(H[i+2])))
print(c[len(c)-1])
n=int(input())
G=[[] for i in range(n)]
for i in range(n-1):
    a,b,w=map(int,input().split())
    a-=1;b-=1
    G[a].append((b,w))
    G[b].append((a,w))
C=[-1]*n 
C[0]=0
def dfs(x):
    for v,w in G[x]:
        if C[v]==-1:
            C[v]=1-C[x] if w%2==1 else C[x]
            dfs(v)

dfs(0)
#print(G)
for i in range(n):
    print(C[i])

### FIXED CODE ###

import copy ; import sys ; sys.setrecursionlimit(11451419)
n=int(input())
color=[-1 for i in range(n)]
color[0]=1
G=[[] for i in range(n)]
for i in range(n-1):
  a,b,d=map(int,input().split())
  G[a-1].append([b-1,d])
  G[b-1].append([a-1,d])
  
def dfs(x):
  
  for i,dis in G[x]:
    
    if color[i] != -1: continue
    if dis %2==1:
      color[i]=1-color[x]
    else:
      color[i]=color[x]
    dfs(i)
dfs(0)
for i in range(n):
  print(color[i])
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

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

N = int(input())
A = [int(x) for x in input().split()]
As = []
for i in A:
    if(not i in As):
        As+=[i]
As.sort()
cand = -1
mingcd = gcd_list(As)
typ = -1
if(N==2):
    print(max(As))
else:
    for i in range(len(As)-1):
        if(mingcd==gcd(As[i],As[i+1])):
            if(i<N-2):
                if(mingcd==gcd(As[i],As[i+2])):
                    cand = i
                else:
                    cand = i+1
                break
            else:
                cand = i+1
    if(cand==-1):
        cand = len(As)-1
    print(gcd_list(As[:cand]+As[cand+1:]))


### FIXED CODE ###

import fractions
from functools import reduce

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

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

N = int(input())
A = [int(x) for x in input().split()]
L = [0]*N
R = [0]*N
ans = 0
for i in range(N):
    if(i==0):
        L[i] = A[0]
        R[i] = A[-1]
    else:
        L[i] = gcd(A[i],L[i-1])
        R[i] = gcd(A[-i-1],R[i-1])

for i in range(N):
    if(i==0):
        ans = R[-2]
    elif(i==N-1):
        ans = max(ans,L[-2])
    else:    
        ans = max(ans,gcd(L[i-1],R[-i-2]))
print(ans)
map(int, input().split()).sort()

### FIXED CODE ###

ary=list(map(int, input().split()))
ary.sort()
print("{} {} {}".format(ary[0], ary[1], ary[2]))
import numpy as np
from scipy.sparse import csgraph

xs, ys, xt, yt = [int(_) for _ in input().split()]
N = int(input())
XYR = np.array([[xs, ys, 0]] + [[int(_) for _ in input().split()]
                                for _ in range(N)] + [[xt, yt, 0]])
edge = [[0] * (N + 2) for _ in range(N + 2)]
for i in range(N + 1):
    for j in range(i + 1, N + 2):
        edge[i][j] = edge[j][i] = max(
            ((XYR[i][0] - XYR[j][0])**2 +
             (XYR[i][1] - XYR[j][1])**2)**0.5 - XYR[i][2] - XYR[j][2], 0)
G = csgraph.csgraph_from_dense(edge, null_value=np.inf)
print(csgraph.dijkstra(G, directed=False, indices=0)[-1])


### FIXED CODE ###

from heapq import *

xs, ys, xt, yt = [int(_) for _ in input().split()]
N = int(input())
XYR = [[xs, ys, 0]] + [[int(_) for _ in input().split()]
                       for _ in range(N)] + [[xt, yt, 0]]
G = [[0] * (N + 2) for _ in range(N + 2)]
for i in range(N + 1):
    for j in range(i + 1, N + 2):
        G[i][j] = G[j][i] = max(
            ((XYR[i][0] - XYR[j][0])**2 +
             (XYR[i][1] - XYR[j][1])**2)**0.5 - XYR[i][2] - XYR[j][2], 0)


def dijkstra(V, G, start):
    INF = float('inf')
    D = [INF for _ in range(V)]
    D[start] = 0
    H = [(0, start)]
    while H:
        du, u = heappop(H)
        if D[u] < du:
            continue
        for v, d in enumerate(G[u]):
            if D[v] > du + d:
                D[v] = du + d
                heappush(H, (D[v], v))
    return D


D = dijkstra(N + 2, G, 0)
print(D[-1])
n = int(input())
s = input()

ruisekiR = [0] * (n+1)
ruisekiG = [0] * (n+1)
ruisekiB = [0] * (n+1)

for i,c in enumerate(s):
    ruisekiR[i+1] = ruisekiR[i] + ( 1 if c == "R" else 0)
    ruisekiG[i+1] = ruisekiG[i] + ( 1 if c == "G" else 0)
    ruisekiB[i+1] = ruisekiB[i] + ( 1 if c == "B" else 0)

ans = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        if s[i] == s[j]:
            continue
        c = "R"
        if "R" in (s[i], s[j]):
            c = "G"
            if "G" in (s[i], s[j]):
                c = "B"

        if c == "R":
            ans += (ruisekiR[n] - ruisekiR[j])
        if c == "G":
            ans += (ruisekiG[n] - ruisekiG[j])
        if c == "B":
            ans += (ruisekiB[n] - ruisekiB[j])

        if j+(j-i)<n and s[j+(j-i)] == c:
            ans -= 1

print(ans)

### FIXED CODE ###

n = input()
if '7' in n:
  print('Yes')
else:
  print('No')
import math
a,b,c,d=map(int,input())
ans=0
# print(a,b,c,d,b//c,a//c)
ans+=(b//c-a//c+(a%c==0))
# print(ans)
ans+=(b//d-a//d+(a%d==0))
# print(ans)
lcm=c*d//math.gcd(c,d)
ans-=(b//lcm-a//lcm+(a%lcm==0))
print(b-a+1-ans)

### FIXED CODE ###

def G(x,y):
    if(x<y):
        x,y=y,x
    if(y==0):
        return x
    return G(y,x%y)


a,b,c,d=map(int,input().split())
ans=0
# print(a,b,c,d,b//c,a//c)
ans+=(b//c-a//c+(a%c==0))
# print(ans)
ans+=(b//d-a//d+(a%d==0))
# print(ans)
lcm=c*d//G(c,d)
ans-=(b//lcm-a//lcm+(a%lcm==0))
print(b-a+1-ans)
N = int(input())
A = list(range(1,N+1))
B = list(range(2,N+1))+[1]
ans = 0
for i in range(N):
  ans+=A[i]%B[i]
print(ans)

### FIXED CODE ###

def main():
  N = int(input())
  if N==1:
    print(0)
    return
  ans = sum(range(1,N))
  print(ans)
main()
a, b = map(int.input().split())

if a > b:
 print('a > b')
elif a < b:
 print('a < b')
else:
 print('a == b')

### FIXED CODE ###

a, b = map(int, input().split())
if a < b:
    print('a < b')
elif a > b:
    print('a > b')
else:
    print('a == b')
from collections import defaultdict
n=int(input())
b=[]
for i in range(n):
    x,y=map(int,input().split())
    b.append((x,y))
C=defaultdict(int)
for i in range(n):
    for j in range(i+1,n):
        p,q=b[i][0]-b[j][0],b[i][1]-b[j][1]
        C[(p,q)]+=1
        C[(-p,-q)]+=1

l=[]
for i in C.items():
    l.append(i)
l.sort(key=lambda x:x[1],reverse=True)
print(n-l[0][1])



### FIXED CODE ###

from collections import defaultdict
n=int(input())
m=[[(0,0) for j in range(n)] for i in range(n)]
b=[]
if n==1:
    ans=1
else:
    for i in range(n):
        x,y=map(int,input().split())
        b.append((x,y))
    C=defaultdict(int)
    for i in range(n):
        for j in range(i+1,n):
            p,q=b[i][0]-b[j][0],b[i][1]-b[j][1]
            C[(p,q)]+=1
            C[(-p,-q)]+=1
                
    l=[]
    for i in C.items():
        l.append(i)
    l.sort(key=lambda x:x[1],reverse=True)

    ans=n-l[0][1]
print(ans)
while True:
    n,x = map(int,input().split())

    if n==0 and x==0:
        break

    print(sum( [ len(range(max(i+1,x-i-n),min(n,(x-i+1)//2))) for i in range(1,min(n-1,x//3)) ]))

### FIXED CODE ###

import math

def factorize(p):
    l = []
    while p % 2 == 0:
        p //= 2
        l.append(2)

    r = 3
    while r < int(math.sqrt(p)+1):
        if p % r == 0:
            p //= r
            l.append(r)
        else:
            r += 2

    if p != 1:
        l.append(p)

    return l

n = int(input())
l = factorize(n)

print(str(n)+":",*l)
def num_2n(i):
    count = 0
    while(i % 2 == 0):
        i = i / 2
        count += 1
    return count



def main():
    num_ans = int(input())
    ans_list = list(map(int, input().split()))
    num_2n_list =[]
    for i in ans_list:
        num_2n_list.append(num_2n(i))
    num_2n_list.sort()
    num_2n_list.reverse()
    print(num_2n_list[0])


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    ans_list = list(str(input().split()))
    print(ans_list.count("1"))


if __name__ == '__main__':
    main()
N = int(input())
D = map(int, input().split())

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        ans += D[i] * D[j]

print(ans)

### FIXED CODE ###

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

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        ans += D[i] * D[j]

print(ans)
import math
a, b = map(int, input().split())
print(math.celi((a+b)/2)))

### FIXED CODE ###

a, b = map(int, input().split())
if (a+b) % 2 == 0:
    ans = (a+b) / 2
else:
    ans = (a+b) // 2 + 1
print(int(ans))
import math

N, X = map(int, input().split())
arr = [int(_) for _ in input().split(' ')]

a = 1000000000000000

for i in range(N):
    for j in range(N):
        if math.gcd(abs(arr[i] - X), abs(arr[i] - X)) < a:
            a = math.gcd(abs(arr[i] - X), abs(arr[i] - X))

print(a)

### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

N, X = map(int, input().split())
x = [int(_) for _ in input().split(' ')]

dist = [abs(i - X) for i in x]

ans = dist[0]

for i in range(N-1):
    ans = gcd(ans, dist[i+1])

print(ans)
from sys import stdin
from itertools import accumulate#累積和

n = int(stdin.readline().rstrip())
if n == 1:
    print(0)
else:
    a = list(range(1, n))
    b = list(accumulate(a))
    print(b[-1])  

### FIXED CODE ###

from sys import stdin

n = int(stdin.readline().rstrip())
point = n*(n-1)//2
print(point)
x, y, z = map(int,input())
print(z, x, y)

### FIXED CODE ###

x, y, z = map(int,input().split())
print(z, x, y)
A, B = [int(input()) for _ in range(2)]
 
P = A + B
M = A - B
T = A * B
 
lst = [P, M, T]
print(max(lst))


### FIXED CODE ###

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

P = A + B
M = A - B
T = A * B

print(max(P, M, T))
n = int(input())
a = list(map(int, input().split()))

dp = [[None] * len(a) for _ in a]


def solve(i, j):
    if dp[i][j]:
        return dp[i][j]

    if i == j:
        return a[i]

    dp[i][j] = max(a[j] - solve(i, j-1), a[i] - solve(i+1, j))
    return dp[i][j]


print(solve(0, len(a) - 1))


### FIXED CODE ###

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

dp = [[None] * len(a) for _ in a]

for i in range(len(a)-1, -1, -1):
    for j in range(i, len(a)):
        if i == j:
            dp[i][j] = a[i]
            continue

        dp[i][j] = max(a[j] - dp[i][j-1], a[i] - dp[i+1][j])

print(dp[0][len(a) - 1])
import math
N = int(input())
x = list(map(int, input().split()))

s = float(x[0])
for i in range(N-1):
	t = (s + x[i+1]) / 2

min = math.floor(t)

print(min)

### FIXED CODE ###

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

for i in range(0,N):
     t += x[i]/N

s = round(t)
for i in range(0,N):
    min += (x[i] - s) **2

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

d = 0
cnt = 0
if l[0] == 0:
    print(0)
else:
    cnt += 1
    for i in range(1,n):
        d += l[i - 1]
        if d <= x:
            cnt += 1
    print(cnt)


### FIXED CODE ###

x, a = map(int, input().split())
 
if x < a:
  print(0)
else:
  print(10)
def func(z,c):
    if c == 0:
        z = 0
    else:
        z = z%c
    a = bin(z)
    b = 0
    for i in range(len(a)):
        if a[i] == "1":
            b += 1
    return z,b

n = int(input())
x = input()
c = 0
sw = 0
for i in range(n):
    if x[i] == "1":
        c += 1
s0 = int(x,2)%(c+1)
if c <= 1:
    s1 = 0
else:
    s1 = int(x,2)%(c-1)
for i in range(n):
    sw = 0
    if x[i] == "0":
        d = c + 1
        z = (s0 + pow(2,n-i-1,d))%d
    else:
        d = c - 1
        if d == 0:
            sw = 1
        else:
            z = (s1 - pow(2,n-i-1,d))%d
    ans = 1
    p = bin(z)
    e = 0
    for A in str(p):
        if A == "1":
            e += 1
    d = e
    if sw == 1 or d == 0:
        ans = 0
    else:
        while z:
            z,d = func(z,d)
            ans += 1
    print(ans)

### FIXED CODE ###

def func(z,c):
    if c == 0:
        z = 0
    else:
        z = z%c
    a = bin(z)
    b = 0
    for i in range(len(a)):
        if a[i] == "1":
            b += 1
    return z,b

n = int(input())
x = input()
c = 0
for i in range(n):
    if x[i] == "1":
        c += 1
s0 = int(x,2)%(c+1)
if c <= 1:
    s1 = 0
else:
    s1 = int(x,2)%(c-1)
for i in range(n):
    sw = 0
    if x[i] == "0":
        d = c + 1
        z = (s0 + pow(2,n-i-1,d))%d
    else:
        d = c - 1
        if d == 0:
            z = 0
            sw = 1
        else:
            z = (s1 - pow(2,n-i-1,d))%d
    ans = 1
    p = bin(z)
    e = 0
    for A in str(p):
        if A == "1":
            e += 1
    d = e
    if sw == 1:
        ans = 0
    else:
        while z:
            z,d = func(z,d)
            ans += 1
    print(ans)
x=input("Please Enter Nunber")
print(x*x*x)



### FIXED CODE ###

x=int(input())
print(x*x*x)
S = list(input())
T = list(input())

ans = 0

for i in range(len(S)):
  ans += (S[i]=T[i])

print(ans)

### FIXED CODE ###

S = list(input())
T = list(input())

ans = 0

for i in range(len(S)):
  ans += (S[i]!=T[i])

print(ans)
def main():
    H, W = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(H)]
    N = 0
    yx = []
    for i in range(H):
        for j in range(W - 1):
            if a[i][j] % 2 == 0:
                continue
            if 9 > a[i][j + 1]:
                a[i][j] -= 1
                a[i][j + 1] += 1
                N += 1
                yx.append([i + 1, j + 1, i + 1, j + 2])
            elif 9 > a[i + 1][j]:
                a[i][j] -= 1
                a[i + 1][j] += 1
                N += 1
                yx.append([i + 1, j + 1, i + 2, j + 1])
        if H > i + 1 and a[i][j + 1] % 2 != 0 and 9 > a[i + 1][j + 1]:
            a[i][j + 1] -= 1
            a[i + 1][j + 1] += 1
            N += 1
            yx.append([i + 1, j + 2, i + 2, j + 2])
    print(N)
    for row in yx:
        print(' '.join(list(map(str, row))))


main()


### FIXED CODE ###

def main():
    H, W = map(int, input().split())
    a = [[0] * W]
    for _ in range(H):
        ai = list(map(int, input().split()))
        ai.insert(0, 0)
        a.append(ai)
    N = 0
    yx = []
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if a[i][j] % 2 == 0:
                continue
            if W >= j + 1:
                a[i][j] -= 1
                a[i][j + 1] += 1
                N += 1
                yx.append([i, j, i, j + 1])
            elif H >= i + 1:
                a[i][j] -= 1
                a[i + 1][j] += 1
                N += 1
                yx.append([i, j, i + 1, j])
        if H > i + 1 and a[i][j] % 2 != 0:
            a[i][j] -= 1
            a[i + 1][j] += 1
            N += 1
            yx.append([i, j + 1, i + 1, j])
    print(N)
    for row in yx:
        print(' '.join(list(map(str, row))))


main()
h, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(k)]
dp = [0 for i in range(10**3+1)]
for i in range(1, h+1):
    dp[i] = min(dp[i - a]+b for a,b in ab)
print(dp[h])

### FIXED CODE ###

h, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(k)]
maxa = max(a for a,b in ab)
dp = [0 for i in range(h+maxa)]
for i in range(1, h+maxa):
    dp[i] = min(dp[i - a]+b for a,b in ab)
print(min(dp[h:]))
N, R = int(input())

if N >= 10:
    print(R)
else:
    print(R + 100*(10-N))


### FIXED CODE ###

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

if N >= 10:
    print(R)
else:
    print(R + 100*(10-N))
s = input()
t = input()
print(t,s)

### FIXED CODE ###

S,T = input().split()
print(T+S)
S=input()
T=input()
match=0
for i in range(len(S)-len(T)):
    count=0
    for j in range(len(T)):
        if S[i+j]==T[j]:
            count=count+1
    if match<count:
        match=count
print(len(T)-match)

### FIXED CODE ###

D,T,S = input().split()
if int(D)/int(S) > int(T):
  print('No')
else:
  print('Yes')
N = input()
s = map(int, input().split())
count = 0
while True:
  if np.all(np.array(s)%2):
    count += 1
  else:
    break
print(count)


### FIXED CODE ###

import numpy as np
N = input()
s = np.array(list(map(int, input().split())))
count = 0
while True:
  _exp = 2**(count+1)
  if np.all( s%_exp == 0):
    count += 1
  else:
    break
print(count)
def an(a, b):  # a is time b is place
    if a > b:
        return float('INF')
    elif a == b:
        return a
    else:
        return min(an(a + 1, b), an(a + 1, b - a))


X = int(input())
print(an(1, X))


### FIXED CODE ###

X = int(input())
c = 0
for i in range(1, 1000000000):
    c += i
    if c > X:
        print(i)
        exit()
    elif c == X:
        print(i)
        exit()
import copy
n, m = list(map(int, input().split()))
city_list = [[] for i in range(n)]
numbers = []

for i in range(m):
    pm, ym = list(map(int, input().split()))
    city_list[pm-1].append(ym)
city_list_copied = copy.deepcopy(city_list)

for i in range(n):
    city_list_copied[i].sort()
    for j in range(len(city_list[i])):
        cindex = city_list_copied[i].index(city_list[i][j])
        print("{:0=6}{:0=6}".format(i+1, cindex+1))

### FIXED CODE ###

x, y = list(map(int, input().split()))
print("{} ".format(int(x+y/2)))
1 N = int(input())
2 s = [input() for i in range(N)]
3 for v in ['AC', 'WA', 'TLE', 'RE']:
4 print('{0} x {1}'.format(v, s.count(v)))

### FIXED CODE ###

N = int(input())
s = [input() for i in range(N)]
for v in ['AC', 'WA', 'TLE', 'RE']:
  print('{0} x {1}'.format(v, s.count(v)))
import math
A,B = map(int,input().split())
ans = (A*B)//(math.gcd(A,B))
print(ans)


### FIXED CODE ###

import fractions
A,B = map(int,input().split())
print((A*B)//fractions.gcd(A,B))
n,k = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
px=[]
mx=[]
for i in range(n):
    if x[i]>=0:
        px = x[i:]
        mx = x[:i]
        break
res = 1000000000
p = len(px)
m = len(mx)
if p>0 and m>0:
    for i in range(1,min(m,k)+1):
        if p>=k-i:
            res = min(res,2*abs(mx[-i])+px[k-i-1])
    for j in range(1,min(p,k)+1):
        if m>=k-j:
            res = min(res,2*px[j-1]+abs(mx[-k+j]))
elif p>0:
    res = px[k-1]
else:
    res = abs(mx[-k])
print(res)

### FIXED CODE ###

n,k = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
res = 1000000000
for i in range(n-k+1):
    xl = x[i]
    xr = x[i+k-1]
    tmp = min(abs(xl)+abs(xr-xl), abs(xr)+abs(xr-xl))
    res = min(res,tmp)
print(res)
import os, sys, re, math

(N, K) = [int(n) for n in input().split()]

lk = math.log2(K - 1)

p = 0
for i in range(1, N + 1):
    if i >= K:
        p += 1.0
    else:
        p += (0.5 ** (int(lk - math.log2(i) + 1)))
    print(int(lk - math.log2(i) + 1))

print(p / N)


### FIXED CODE ###

import os, sys, re, math

(N, K) = [int(n) for n in input().split()]

if K == 1:
    print(1)
else:
    lk = math.log2(K - 1)
    p = 0
    for i in range(1, N + 1):
        if i >= K:
            p += 1.0
        else:
            p += (0.5 ** (int(lk - math.log2(i) + 1)))
    print(p / N)
N,Q=map(int,input().split())
S=input()
L=[]
R=[]
C=[0]*N
c=0
for i in range(Q):
    A=list(map(int,input().split()))
    L.append(A[0])
    R.append(A[1])
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        c+=1
        C[i]=c
    else:
        C[i]=c
C[N-1]=c
for i in range(Q):
    p=0
    if S[R[i]-1]=="A" and S[R[i]]=="C":
        p=C[R[i]-1]-C[L[i]-1]-1
    else:
        p=C[R[i]-1]-C[L[i]-1]
    if S[L[i]-1]=="A" and S[L[i]]=="C":
        p+=1
    print(p)


### FIXED CODE ###

N,Q=map(int,input().split())
S=input()
L=[]
R=[]
C=[0]*N
c=0
for i in range(Q):
    A=list(map(int,input().split()))
    L.append(A[0])
    R.append(A[1])
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        c+=1
        C[i]=c
    else:
        C[i]=c
C[N-1]=c
S+="X"
for i in range(Q):
    p=0
    if S[R[i]-1]=="A" and S[R[i]]=="C":
        p=C[R[i]-1]-C[L[i]-1]-1
    else:
        p=C[R[i]-1]-C[L[i]-1]
    if S[L[i]-1]=="A" and S[L[i]]=="C":
        p+=1
    print(p)
#!/usr/bin/python3
# -*- coding: utf-8 -*-
s = int(input())
mod = 10**9 + 7
a_list = [0] * (s + 1)
a_list[0] = 1
a_list[1] = 0
a_list[2] = 0
a_list[3] = 1
for i in range(4, s + 1):
    a_list[i] = a_list[i - 1] + a_list[i - 3]
    a_list[i] %= mod
print(a_list[s])

### FIXED CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-
s = int(input())
mod = 10**9 + 7
a_list = [0] * (2000 + 1)
a_list[0] = 1
a_list[1] = 0
a_list[2] = 0
a_list[3] = 1
for i in range(4, s + 1):
    a_list[i] = a_list[i - 1] + a_list[i - 3]
    a_list[i] %= mod
print(a_list[s])
N = int(input())
A = int(input())

N = N % 500
if N =< A:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N = int(input())
A = int(input())

B = N % 500
if B <= A:
  print("Yes")
else:
  print("No")
input_n = input()
n = str(input_n)

listN = list(n)
#listN = n.split(' ')

if listN[len(listN) - 1] = "s":
    listN.append("e")
    listN.append("s")
else:
    listN.append("s")

for i in range(len(listN) - 1):
    print(listN[i], end = "")


### FIXED CODE ###

input_n = input()
n = str(input_n)

listN = list(n)
#listN = n.split(' ')

if listN[len(listN) - 1] == "s":
    listN.append("e")
    listN.append("s")
else:
    listN.append("s")

for i in range(len(listN)):
    print(listN[i], end = "")
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
    print(0)
for num in range(n):
    x *= a[num]
    if x > 10**18:
        print(-1)
        sys.exit()
print(x)



### FIXED CODE ###

import sys
n = int(input())
a = list(map(int,input().split()))
x = 1
if 0 in a:
    print(0)
    sys.exit()
for num in range(n):
    x  *= a[num]
    if x > 10**18:
        print(-1)
        sys.exit()
print(x)
N,M=map(int,input().split())
wa=0
ac=0
already=[]
for i in range(M+1):
    P,S=map(input().split())
    if S=="WA" and already.count(P)==0:
        wa=wa+1
    if S=="AC" and already.count(P)==0:
        ac=ac+1
        already.append(P)
    else:
        pass
print(wa,ac)


 
    


    

    




### FIXED CODE ###

N,M=map(int,input().split())
ac=0
wa=0
a=[0]*N
w=[0]*N
for i in range(M):
    P,S=input().split()
    if S=="WA":
        w[int(P)-1]+=1
    else:
        if a[int(P)-1]==0:
            a[int(P)-1]+=1
            ac=ac+1
            wa+=w[int(P)-1]
        else:
            pass
print(ac,wa)
x=int(input())
    int i=0;
    while(1){
        scanf("%d", &x);
        if(x==0)break;
        printf("Case %d: %d\n", ++i, x);
    


### FIXED CODE ###

num = 1
while True:
    x = int(input())
    if x == 0: break
    print ("Case {0}: {1}".format(num,x))
    num += 1
import bisect

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

A.sort()
B.sort()
C.sort()

ans = 0
for b in B:
    a = bisect.bisect_left(A, x)
    b = bisect.bisect_right(C, x)
    ans += (a + 1)*b 

print(ans)

### FIXED CODE ###

import bisect
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for i in range(N):
    x = bisect.bisect_left(A, B[i])
    y = N-bisect.bisect_right(C, B[i])
    ans += x*y
print(ans)
a = list(map(int, input().split()))
a.sorted()
if a[0]+a[1] == a[2]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a = list(map(int, input().split()))
a.sort()
if a[0]+a[1] == a[2]:
  print("Yes")
else:
  print("No")
# coding=utf-8

import numpy as np

A = []
n, m = map(int, raw_input().split())
for _ in xrange(n):
    A.append(map(int, raw_input().split()))
A = np.array(A)
# print A

b = []
for _ in xrange(m):
    b.append(input())
b = np.array(b)
# print b

Ab = np.dot(A, b)
# print Ab
for x in Ab:
    print x

### FIXED CODE ###

# coding=utf-8

n, m = map(int, raw_input().split())
A = [map(int, raw_input().split()) for _ in xrange(n)]
b = [input() for _ in xrange(m)]
Ab = [sum([A[i][j] * b[j] for j in xrange(m)]) for i in xrange(n)]
for x in Ab:
    print x