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

import sys

def chmin(a,i,b):
  if a[i] > b:
    a[i] = b
    #print(a)
    return True
  else:
    return False

n,k = map(int,input().split())
h = list( map(int,input().split()))
dp = [sys.maxsize for i in range(n)]

dp[0] = 0
#print(n,h)
#print(dp)

for i in range(len(dp)):
  for j in range(k+1):
    if i - j >= 0:
      #chmin(dp,i, abs(h[i]-h[i-j])+dp[i-j])
      dp[i] = min(dp[i], abs(h[i]-h[i-j])+dp[i-j])

#print(dp)   
print(dp[-1])


### FIXED CODE ###

import sys

def chmin(a,i,b):
  if a[i] > b:
    a[i] = b
    #print(a)
    return True
  else:
    return False

n,k = map(int,input().split())
h = list( map(int,input().split()))
dp = [sys.maxsize for i in range(n)]

dp[0] = 0
#print(n,h)
#print(dp)

for i in range(len(dp)):
  for j in range(k+1):
    if i - j >= 0:
      #chmin(dp,i, abs(h[i]-h[i-j])+dp[i-j])
      dp[i] = min(dp[i], abs(h[i]-h[i-j])+dp[i-j])

#print(dp)   
print(dp[-1])
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split()]

list_ = []
for i in range(N):
  list_.append(sum([1 for a in A if a==i]))

list_.append(0)
for j in list_[1:]:
  print(j)

### FIXED CODE ###

import numpy as np

N = int(input())
A = list(map(int, input().split()))
ans = [0]*N

A.append(0)

for i in range(0, N-1):
  ans[A[i]] += 1
for i in range(1, N):
  print(ans[i])
print(0)
### BUGGY CODE ###

N = int(input())
S = []
for i in range(N):
    S.append(input())
ans = N
for i in range(N):
    for j in range(i):
        if i != j:
            if S[j] == S[i]:
                S[j] = ''
                ans = ans - 1
print(ans)

### FIXED CODE ###

N = int(input())
S = []
ans = N
S = [input() for i in range(N)]
#for i in range(N):
#    S.append(input())
S.sort()
for i in range(N-1):
    if S[i] == S[i+1]:
        ans = ans - 1
print(ans)
### BUGGY CODE ###

# python3


def main():
    # 2 <= N <= pow(10,5), 1 <= K <= 100
    N, K = [int(ele) for ele in input().split()]
    h = [Node(int(ele)) for ele in input().split()]

    for idx, n in enumerate(h):
        if idx != 0:
            s = max(0, idx - K)
            n.parents = h[s:idx]

    for n in h:
        n.cal_dp()

    print(h[-1].dp_val)


class Node():

    def __init__(self, val):
        self.val = val
        self.dp_val = 1000000000000
        self.parents = []

    def cal_dp(self):
        if self.parents == []:
            self.dp_val = 0
            return

        for n in self.parents:
            self.dp_val = min(self.dp_val, abs(n.val - self.val)+n.dp_val)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# python3
import sys

input = sys.stdin.readline


def main():
    # 2 <= N <= pow(10,5), 1 <= K <= 100
    N, K = [int(ele) for ele in input().split()]
    h = [Node(int(ele)) for ele in input().split()]

    for idx, n in enumerate(h):
        s = max(0, idx - K)
        n.parents = h[s:idx]
        n.cal_dp()

    print(h[-1].dp_val)


class Node():

    def __init__(self, val):
        self.val = val
        self.dp_val = 1000000000000
        self.parents = []

    def cal_dp(self):
        if self.parents == []:
            self.dp_val = 0
            return

        for n in self.parents:
            self.dp_val = min(self.dp_val, abs(n.val - self.val)+n.dp_val)


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

def prime(n,a,b):
    num=[i for i in range(n,1,-1) if n%i ==0 and a%i == 0 and b%i == 0]
    prime=[]
    p = 2
    while p <=n**0.5 and len(num) != 0:
        p=num.pop()
        prime.append(p)
        num = [i for i in num if i%p != 0]
    return prime
def chk_prime(n):
    for i in range(2,-1*int(-n**0.5//1)):
        if n%i == 0:
            return False
    return True

def main():
    a,b=map(int,input().split(' '))

    ans = 1
    if chk_prime(min(a,b)):
        if max(a,b)%min(a,b) == 0 and min(a,b) != 1:
            ans = 2
    elif chk_prime(max(a,b)):
        pass
    else:
        prime_list=prime(int(min(a,b)/2),a,b)
        for i in prime_list:
            if a%i == 0 and b%i==0:
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

from math import *
def gcd(n,m):
    while m != 0:
        n,m=m,n%m
    return n
def main():
    a,b=map(int,input().split(' '))
    g=gcd(a,b)
    cnt = 1
    g2 = int(sqrt(g))
    for i in range(2,g2+1):
        if g%i ==0:
            while g%i ==0:
                g //= i
            cnt += 1
    if g > 1:
        cnt += 1
    print(cnt)

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

import numpy as np

n,m = map(int,input().split())
A = list(map(int,input().split()))
B = []
res = 0

for a in A:
    res += a
    B.append(res)
B = np.array(B)

ans = 0
for i in range(n):
    b = B[i:]
    # print(b)
    ans += np.count_nonzero(b%m == 0)
    B -= B[i]

print(ans)

### FIXED CODE ###

from collections import Counter

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

B = [0]
res = 0
for a in A:
	res += a
	B.append(res%m)

C = Counter(B)
ans = 0
for c in C.values():
	ans += c*(c-1)//2

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

#import numpy as np
import sys

input = sys.stdin.readline

N,M = [int(a) for a in input().split()]
A = [int(a) for a in input().split()]

for i in range(M):
    m = max(A)
    A[A.index(m)] //= 2

print(sum(A))

### FIXED CODE ###

import sys
import heapq
from math import ceil

input = sys.stdin.readline

N,M = [int(a) for a in input().split()]
A = [int(a) for a in input().split()]

hq = []
for i in range(N):
    heapq.heappush(hq, -A[i])

for i in range(M):
    m = heapq.heappop(hq)
    heapq.heappush(hq, ceil(m / 2))

print(-sum(hq))
### BUGGY CODE ###

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

cnt = 0

for i in range(1, N):
    x = A[0:i]
    y = A[i:N]
    
    for _x in x:
        if _x in y:
            cnt += 1
        
if cnt > 0:
    result = 'NO'
else:
    result = 'YES'
        
print(result)

### FIXED CODE ###

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

A_set = set(A)

if len(A) == len(A_set):
    print('YES')
else:
    print('NO')
### BUGGY CODE ###

N,K=map(int,input().split())
listA=[]
listB=[]
for z in range(N):
    a,b=map(int,input().split())
    if a in listA:
        n=listA.index(a)
        listB[n]+=b
    else:
        listA.append(a)
        listB.append(b)
while True:
    kotae=min(listA)
    basho=listA.index(kotae)
    if listB[basho]<K:
        K-=listB[basho]
    else:
        print(kotae)
        break
    listA.pop(basho)
    listB.pop(basho)


### FIXED CODE ###

N,K=map(int,input().split())
listA=[0]*10**5
for z in range(N):
    a,b=map(int,input().split())
    listA[a-1]+=b
count=0
y=0
while count<=10**5-1:
    y+=listA[count]
    if y>=K:
        print(count+1)
        break
    else:
        count+=1
### BUGGY CODE ###

from itertools import count
from itertools import chain

def gen_check_numbers(n):
    center = n // 2
    l2 = chain.from_iterable(zip(reversed(range(1, center + 1)), range(center + 1 , n + 1)))
    return l2

def main():
    n = int(input())
    l = [ int(input().rstrip()) for i in range(n)]

    ans = 0
    center = n // 2
    for i in gen_check_numbers(n):
        i1 = l.index(i)
        if i <= center:
            i2 = l.index(i + 1)
            if( i2 < i1):
                l.remove(i)
                l.insert(0,i)
                ans += 1
        else:
            i2 = l.index(i - 1)
            if( i1 < i2):
                l.remove(i)
                l.append(i)
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = int(input())
    l = [ int(input().rstrip()) for i in range(n)]

    s = {}
    for i in l:
        if i - 1 in s:
            s[i] = s[i - 1] + 1
            del s[i - 1]
        else:
            s[i] = 1
    print(n - max(s.values()))

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

H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]

numbers = {}
for y in range(H):
	for x in range(W):
		numbers[A[y][x]] = (y, x)

for l, r in LR:
	cost = 0
	while l != r:
		f, t = numbers[l], numbers[l + D]
		cost += abs(f[0] - t[0]) + abs(f[1] - t[1])
		l += D
	print(cost)


### FIXED CODE ###

H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]

numbers = {}
for y in range(H):
	for x in range(W):
		numbers[A[y][x]] = (y, x)

numbers_sum = [0] * (H * W + 1)
for n in range(D + 1, H * W + 1):
	f, t = numbers[n], numbers[n - D]
	cost = abs(f[0] - t[0]) + abs(f[1] - t[1])
	numbers_sum[n] = numbers_sum[n - D] + cost

for l, r in LR:
	print(numbers_sum[r] - numbers_sum[l])
### BUGGY CODE ###

import sys

def main():
    N = int(input())
    A = [int(input()) for i in range(N)]

    for j in range(N):
        if j == 0:
            print(max(A[1:]))

        elif j == N-1:
            print(max(A[:N-1]))

        else:
            print(max(max(A[:j]), max(A[j+1:])))


main()

### FIXED CODE ###

import sys

def main():
    N = int(input())
    A = [int(sys.stdin.readline()) for i in range(N)]
    anoA = sorted(A)
    mA = max(A)

    for j in range(N):
        if mA == A[j]:
            print(anoA[-2])

        else:
            print(mA)


main()
### BUGGY CODE ###

import math
K=int(input())
k=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            d=math.gcd(a,b)
            d=math.gcd(d,c)
            k+=d
print(k)


### FIXED CODE ###

import math
K=int(input())
k=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            d=math.gcd(a,b)
            d=math.gcd(d,c)
            k+=d
print(k)
### BUGGY CODE ###

n, m = map(int, input().split())
a = [0]*m
for i in range(m):
  a[i] = int(input())


r1 = 1
if 1 in a:
  r = 0
else:
  r = 1
for i in range(2, n+1):
  r2 = r1
  r1 = r
  if i in a:
    r = 0
  elif r1 == 0 and r2 == 0:
    r = 0
    break
  else:
    r = (r1 + r2)%1000000007

print(r)

### FIXED CODE ###

n, m = map(int, input().split())
a = [0]*m
for i in range(m):
  a[i] = int(input())

up = [0]*(m+1)
if m == 0:
  up[0] = n
else:
  up[0] = a[0]-1
  up[m] = n - a[m-1]-1
  for i in range(m-1):
    up[i+1] = a[i+1]-a[i]-2

ans = 1
if -1 in up:
  ans = 0
else:
  f = [0]*(max(up)+1)
  f[0] = 1
  if max(up) > 0:
    f[1] = 1
    for i in range(2, max(up)+1):
      f[i] = f[i-1] + f[i-2]
  for i in range(m+1):
    ans *= f[up[i]]

print(ans % 1000000007)
### BUGGY CODE ###

k = int(input()) + 1
ans = 0
 
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
 
for i in range(1,k):
  for j in range(1,k):
    for l in range(1,k):
      ans += gcd(gcd(i, j),l)
      
print(ans) 

### FIXED CODE ###

from math import gcd
k = int(input()) + 1
ans = 0
for i in range(1,k):
  for j in range(1,k):
    for l in range(1,k):
      ans += gcd(gcd(i, j),l)
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

R, G, B, N = map(int, input().split())

lst = [R, G, B]
lst.sort(reverse=True)
R = lst[0]
G = lst[1]
B = lst[2]

counter = 0
for r in range(int(N/R) + 1):
    for g in range(int(N/G) + 1):
        if R*r + G*g > N:
            break
        if (N - R*r - G*g) % B == 0:
            counter += 1

print(counter)

### FIXED CODE ###

# -*- coding: utf-8 -*-

R, G, B, N = map(int, input().split())

counter = 0
for r in range(int(N/R) + 1):
    for g in range(int(N/G) + 1):
        t = R*r + G*g
        if t > N:
            break
        if (N - t) % B == 0:
            counter += 1

print(counter)
### BUGGY CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
i = k
for _ in range(n-k):
    if sum(a[i-k+1:i+1])>sum(a[i-k:i]):
        print("Yes")
    else:
        print("No")
    i+=1

### FIXED CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
temp,i = sum(a[:k]),k
for _ in range(n-k):
    score = temp+a[i]-a[i-k]
    print("Yes" if score>temp else "No")
    temp = score
    i+=1
### BUGGY CODE ###

import itertools
import sys

sys.setrecursionlimit(10 ** 7)

h, w, d = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
q = int(input())
l, r = [], []
for _ in range(q):
    x, y = map(int, input().split())
    l.append(x)
    r.append(y)


coordinates = {a[x][y] : (x, y) for x, y in itertools.product(range(h), range(w))}
cache = {}
def f(x, y):
    if x == y:
        return 0

    key = (x, y)
    if not key in cache:
        i1, j1 = coordinates[x]
        i2, j2 = coordinates[x + d]
        cache[key] = abs(i1 - i2) + abs(j1 - j2) + f(x + d, y)

    return cache[key]


for i in range(q):
    print(f(l[i], r[i]))

### FIXED CODE ###

h, w, d = map(int, input().split())

coordinates = {}
for i in range(h):
    row = list(map(int, input().split()))
    for j in range(w):
        coordinates[row[j]] = (i, j)

costs = [0] * (h * w + 1)
for i in range(d + 1, h * w + 1):
    x1, y1 = coordinates[i]
    x2, y2 = coordinates[i - d]
    costs[i] = abs(x1 - x2) + abs(y1 - y2) + costs[i - d]

q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(costs[r] - costs[l])
### BUGGY CODE ###

N = int(input())
sta = list(map(int, input().split()))
sta2 = []

count_i = 0
for i in sta:
    sta2.append(i)
    if i <= min(sta2):
        count_i += 1

print(count_i)

### FIXED CODE ###

N = int(input())
sta = list(map(int, input().split()))
min_i = sta[0]
count_i = 0
for i in sta:
    if min_i > i:
        min_i = i
    if i <= min_i:
        count_i += 1

print(count_i)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split())) # 横入力

cs = [0]
aa = 0
for i in range(n):
    aa += a[i]
    cs.append(aa)

ans = 0
for i in range(n):
    for j in range(i+1,n+1):
        if cs[j] - cs[i] == 0:
            ans += 1

print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split())) # 横入力

cs = [0]
aa = 0
for i in range(n):
    aa += a[i]
    cs.append(aa)

cs.sort()
cnt = 1
ans = 0
for i in range(n):
    if cs[i] == cs[i+1]:
        cnt += 1
    else:
        if cnt != 1:
            ans += cnt*(cnt-1)//2
            cnt = 1
if cnt != 1:
    ans += cnt*(cnt-1)//2
print(ans)
### BUGGY CODE ###

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

b = []
for i in a:
  b.append(i)
  b.reverse()

print(*b)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]
count = 0
i = 0
j = -1
k = -1

for _ in range(n):
  if count % 2 == 0:
    b[i] = a[k]
    i += 1
    k -= 1
  else:
    b[j] = a[k]
    j -= 1
    k -= 1
  count += 1

print(*b)
### BUGGY CODE ###

N, A, B = map(int, input().split())
p = int(10e9+7)

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p


fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res


ans = modpow(2, N, p)-1-cmb(N, A, p)-cmb(N, B, p)
print(ans)

### FIXED CODE ###

p = int(1e9+7)
def modpow(a, n, p):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % p
        a = a * a % p
        n >>= 1
    return res

n, a, b = map(int, input().split())
h = max(a, b)
l = min(a, b)

x = n
y = 1
c_low = x*modpow(y, p-2, p) % p
for i in range(1, h):
    x = x*(n-i) % p
    y = y*(i+1) % p
    if i+1 == l:
        c_low = x*modpow(y, p-2, p) % p
c_high = x*modpow(y, p-2, p) % p

print((modpow(2, n, p) -1 -c_low - c_high) % p)
### BUGGY CODE ###

from collections import Counter
N=int(input())
A=list(map(int, input().split()))
q=int(input())
Q=[list(map(int, input().split())) for _ in range(q)]

L=[0]*(10**5+1)
B=dict(Counter(A))
for k in B.keys():
    L[k]=B[k]
# print(L)

C=set(B)
sum = 0
for k in B.keys():
    sum += k*B[k]
for i in range(q):
    x=Q[i][0]
    y=Q[i][1]
    if L[x]==0:
        print(sum)
        continue
    L[y]+=L[x]
    L[x]=0
    C.add(y)
    C.remove(x)
    sum=0
    for k in C:
        sum+=k*L[k]
    print(sum)

### FIXED CODE ###

N=int(input())
A=list(map(int, input().split()))
q=int(input())
Q=[list(map(int, input().split())) for _ in range(q)]

L=[0]*(10**5+1)
S=0
for i in range(N):
    L[A[i]]+=1
    S+=A[i]

for i in range(q):
    S+=L[Q[i][0]]*(Q[i][1]-Q[i][0])
    L[Q[i][1]]+=L[Q[i][0]]
    L[Q[i][0]]=0
    # print(L)
    print(S)
### BUGGY CODE ###

from itertools import combinations
N,K = map(int,input().split())
P = list(map(int,input().split()))

res = 10**16
for t in combinations(range(N), K):
  res = min(res, sum([P[i] for i in t]))
print(res)


### FIXED CODE ###

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

print(sum(P[:K]))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [a[i] - b[i] for i in range(n)]
c.sort()
k = 0
neg = 0

if sum(a) < sum(b):
  print(-1)
else:
  k = sum(x < 0 for x in c)
  
  if k == 0:
    print(0)
  else:
    for i in range(n):
      if sum(c[len(c) - 1 - i:]) >= -sum(c[:k]):
        print(k + i + 1)
        break

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = sorted([a[i] - b[i] for i in range(n)])
k = sum(x < 0 for x in c)
neg = -sum(c[:k])
pos = c[len(c) - 1]

if sum(c) < 0:
  print(-1)
elif k == 0:
  print(0)
else:
  for i in range(n):
    if pos >= neg:
      print(k + i + 1)
      break
    else: pos += c[len(c) - 2 - i]
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
if(len(a) == 1):
    print(1)
else:
    a.sort()
    flug = 1
    for j in range(n):
        numl = []
        if(j >= len(a)):
            break
        else:
            flug = 1
            for i in range(j+1, len(a)):
                if(a[i] == a[j] and flug == 1):
                    numl.append(j)
                    flug = 0
                    numl.append(i)
                elif(a[i] % a[j]==0):
                    numl.append(i)
            for i in range(len(numl)):
                a.pop(numl[-(i+1)])
    print(len(a))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
result=0
flug = 0
if(len(a) == 1):
    print(1)
else:
    a.sort()
    dp = [True] * a[-1]
    flug = 1
    for j in range(n):
        if(dp[a[j]-1] == True):
            if(a[j] == a[j-1]):
                if(flug == 0):
                    result-=1
                    flug = 1
            else:
                result+=1
                flug = 0
            k = a[j] * 2
            while(k-1 < len(dp)):
                dp[k-1] = False
                k+=a[j]
                
    print(result)
### BUGGY CODE ###

N,Q = map(int, input().split())
S = input()

t = [0]*Q
d = [0]*Q
for q in range(Q):
    t[q],d[q] = map(str, input().split())

mas = [[-1] for i in range(26)]
for n in range(N):
    mas[ord(S[n])-65].append(n)

cnt = [1]*N

for q in range(Q):
    if d[q] == 'L':
        for n in mas[ord(t[q])-65]:
            if n == -1:
                continue
            if n == 0:
                cnt[n] = 0
            else:
                cnt[n-1] += cnt[n]
                cnt[n] = 0 
    else:
        for n in reversed(mas[ord(t[q])-65]):
            if n == -1:
                continue
            if n == N-1:
                cnt[n] = 0
            else:
                cnt[n+1] += cnt[n]
                cnt[n] = 0

ans = 0
for n in range(N):
    ans += cnt[n]
print(ans)

### FIXED CODE ###

N,Q = map(int, input().split())
S = input()

t = [0]*Q
d = [0]*Q
for q in range(Q):
    t[q],d[q] = map(str, input().split())


s1 = 0
sN = N-1

for q in reversed(range(Q)):
    if t[q] == S[s1] and d[q] == 'L':
        s1 += 1
    elif s1 > 0:
        if d[q] == 'R' and S[s1-1] == t[q]:
            s1 -= 1
    if t[q] == S[sN] and d[q] == 'R':
        sN -= 1
    elif sN < N-1:
        if d[q] == 'L' and S[sN+1] == t[q]:
            sN += 1
    if s1 > sN:
        break
    #print(s1,sN)


print(sN-s1+1)
### BUGGY CODE ###

N, Y = map(int, input().split())
counter = True
for a in range(round(Y/10000)+1):
    for b in range(round(Y/5000)+1):
        for c in range(round(Y/1000)+1):
            if a+b+c >N:
                break
            elif a+b+c <= N and counter:
                if a*10000+b*5000+c*1000 == Y:
                    print(str(a)+' '+str(b)+' '+str(c))
                    counter = False
                else:
                    pass
            else:
                pass
if counter:
    print('-1 -1 -1 ')

### FIXED CODE ###

N, Y = map(int, input().split())
counter = True
for i in range(N+1):
    for j in range(N - i+1):
        if j >= 0 and (N-i-j) >= 0 and counter:
            if 10**4*i + 5*10**3*j + 10**3*(N-i-j) == Y:
                #print(str(i)+" "+str(j)+" "+str(N-i-j))
                print(i, j, N-i-j)
                counter = False
        else:
            break
if counter:
    print("-1 -1 -1")
### BUGGY CODE ###

K,S=input().split()
K=int(K)
S=int(S)
A=0
for x in range(0,K+1):
    for y in range(0,K+1):
        for z in range(0,K+1):
            if x+y+z==S:
                A=A+1
print(A)

### FIXED CODE ###

K,S=input().split()
K=int(K)
S=int(S)
A=0
for x in range(0,K+1):
    for y in range(0,K+1):
        z=S-x-y
        if 0<=z<=K:
            A=A+1
print(A)
### BUGGY CODE ###

n, m = map(int, input().split())
a = []
for _ in range(m):
    a.append(int(input()))
dp = [0]*(n+1)
dp[0] = 1
for i in range(n):
    if i+1 not in a:
        dp[i+1] += dp[i]
    if i<n-1 and i+2 not in a:
        dp[i+2] += dp[i]
print(dp[-1]%(10**9+7))

### FIXED CODE ###

n, m = map(int, input().split())
a = []
for _ in range(m):
    a.append(int(input()))
a = set(a)
dp = [0]*(n+1)
dp[0] = 1
for i in range(n):
    if i+1 not in a:
        dp[i+1] += dp[i]
    if i<n-1 and i+2 not in a:
        dp[i+2] += dp[i]
print(dp[-1]%(10**9+7))
### BUGGY CODE ###

def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    for i in range(0,n-1):
        for j in range(i+1,n):
            temp=(a[i] ^ a[j])
            ans+=temp%MOD
    print(ans%MOD)
if __name__=='__main__':
    main()


### FIXED CODE ###

def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    cnt1=[0]*60
    for num in a:
        for i in range(60):
            cnt1[i] += (num >> i) & 1
    for i in range(60):
        ans += cnt1[i] * (n - cnt1[i]) * pow(2,i,MOD)
    print(ans % MOD)


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

e,a,b,c=1,0,0,0
for i in input():
  if i == "A":
    a+=e
  elif i == "B":
    b+=a
  elif i == "C":
    c+=b
  else:
    e,a,b,c = 3*e,e+3*a,a+3*b,b+3*c
print(c%1000000007) 


### FIXED CODE ###

e,a,b,c=1,0,0,0
p=1000000007
for i in input():
  if i == "A":
    a+=e
  elif i == "B":
    b+=a
  elif i == "C":
    c+=b
  else:
    e,a,b,c = (3*e)%p,(e+3*a)%p,(a+3*b)%p,(b+3*c)%p
print(c%1000000007)
### BUGGY CODE ###

n, m = map(int, input().split())
a = list(int(input()) for _ in range(m))

dp = [0] * (n+1)
dp[0] = 1

if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1

for i in range(2, n+1):
    if i in a:
        continue
    dp[i] = dp[i-1] + dp[i - 2]
    dp[i] %= 1000000007

print(dp[n])


### FIXED CODE ###

n, m = map(int, input().split())
a = set([int(input()) for _ in range(m)])

dp = [0] * (n+1)
dp[0] = 1

if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1

for i in range(2, n+1):
    if i in a:
        continue
    dp[i] = dp[i-1] + dp[i - 2]
    dp[i] %= 1000000007

print(dp[n])