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

import math
from functools import reduce

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

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
K = int(input())

ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            ans += gcd(i+1,j+1,k+1)
            #1-Kまで
print(ans)

### FIXED CODE ###

import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
K = int(input())
 
 
ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
           
 
                ans += gcd(i+1,j+1,k+1)
            #1-Kまで
print(ans)
### BUGGY CODE ###

n = int(input())
s = list(map(int,input().split()))
ans=0
point=-1
for i in range(n-1):
    mark=0
    if i > point:
        for j in range(n-i-1):
            if s[i+j]>=s[i+j+1]:
                mark+=1
                if mark>=ans:
                    ans=mark
                    point=i+j+1
            else:
                break
print(ans)

### FIXED CODE ###

def main():
    n = int(input())
    s = list(map(int,input().split()))
    ans=0
    point=-1
    for i in range(n-1):
        mark=0
        if i > point and i + ans < n:
            for j in range(n-i-1):
                if s[i+j]>=s[i+j+1]:
                    mark+=1
                    if mark>=ans:
                        ans=mark
                else:
                    if mark>=ans:
                        ans=mark
                        point=i+j
                    break
    print(ans)
main()
### BUGGY CODE ###

from collections import deque
A = deque(input())
while len(A) >= 2:
    if list(A)[:7] == list("dreamer") and list(A)[5:8] != list("era"):
        for _ in range(7):
            A.popleft()
    elif list(A)[:5] == list("dream"):
        for _ in range(5):
            A.popleft()
    elif list(A)[:6] == list("eraser"):
        for _ in range(6):
            A.popleft()
    elif list(A)[:5] == list("erase"):
        for _ in range(5):
            A.popleft()
    else:
        A = deque([0])
if len(A) == 0:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

s = input().replace("eraser", "").replace("erase", "")
s = s.replace("dreamer", "").replace("dream", "")
if s:
    print("NO")
else:
    print("YES")
### BUGGY CODE ###

h,w  = map(int,input().split())
a = [input() for _ in range(h)]
black = []
white = []
ans = 0

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            black.append([i,j])
        else:
            white.append([i,j])

for i in range(len(white)):
    min1 = 10**10
    for j in range(len(black)):
        min1 = min(min1,abs(black[j][0]-white[i][0])+abs(black[j][1]-white[i][1]))
        if min1 == 1:
            break
    ans = max(ans,min1)

print(ans)


### FIXED CODE ###

import copy
#import time

h,w = map(int,input().split())
a = [input() for _ in range(h)]
b = [[False]*w for _ in range(h)]
#s = time.time()
c = []
d = [(-1,0), (1,0), (0,-1), (0,1)]
ans = 0

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            b[i][j] = True
            c.append((i,j))
#print(time.time()-s)

while True:
    tmp = []
    cnt = 0
    for i,j in c:
        for d1,d2 in d:
            if 0 <= i + d1 < h and 0 <= j + d2 < w:
                if not b[i+d1][j+d2]:
                    tmp.append((i+d1, j+d2))
                    b[i+d1][j+d2] = True
                    cnt += 1
    #print(time.time()-s)
    if cnt > 0:
        c = copy.copy(tmp)
        ans += 1
    else:
        break
    #print(time.time()-s)

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

import sys
import numpy as np
def rec(N,dp,i,j,k):
    if dp[i,j,k]>=0:return dp[i,j,k]
    if all([i==0,j==0,k==0]):return 0.0
    res=0.0
    if i>0:res+=rec(N,dp,i-1,j,k)*i
    if j>0:res+=rec(N,dp,i+1,j-1,k)*j
    if k>0:res+=rec(N,dp,i,j+1,k-1)*k
    res+=N
    res*=1.0/(i+j+k)
    dp[i,j,k]=res
    return dp[i,j,k]
def main():
    N=int(sys.stdin.readline())
    a=tuple(map(int,sys.stdin.readline().split()))
    n1,n2,n3=a.count(1),a.count(2),a.count(3)
    dp=np.full((N+1,N+1,N+1),-1,dtype=float)
    print(rec(N,dp,n1,n2,n3))
if __name__=='__main__':main()

### FIXED CODE ###

import sys
def rec(N,dp,i,j,k):
    if dp[i][j][k]>=0.0:return dp[i][j][k]
    if all([i==0,j==0,k==0]):return 0.0
    res=0.0
    if i>0:res+=rec(N,dp,i-1,j,k)*i
    if j>0:res+=rec(N,dp,i+1,j-1,k)*j
    if k>0:res+=rec(N,dp,i,j+1,k-1)*k
    res=(res+N)*1.0/(i+j+k)
    dp[i][j][k]=res
    return dp[i][j][k]
def main():
    N=int(sys.stdin.readline())
    a=tuple(map(int,sys.stdin.readline().split()))
    n1,n2,n3=a.count(1),a.count(2),a.count(3)
    dp=[[[-1.0 for _ in range(n3+1)] for _ in range(n2+n3+1)] for _ in range(n1+n2+n3+1)]
    print(rec(N,dp,n1,n2,n3))
if __name__=='__main__':main()
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
for i in range(1,N+1):
    print(A.count(i))



### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B=list(range(1, N + 1))
import collections
new_A=collections.Counter(A)
for i in B:
    print(new_A[i])
### BUGGY CODE ###

L, R = map(int, input().split())
min = 2020
for i in range(L, R+1):
    for j in range(i+1, R+1):
        if min > (i * j) % 2019:
            min = (i * j) % 2019
        if j == L + 2020:
            break
    if i == L + 2020:
        break
print(min)

### FIXED CODE ###

L, R = map(int, input().split())
m = 2020
import sys
for i in range(L, R+1):
    for j in range(i+1, R+1):
        if m > (i * j) % 2019:
            m = (i * j) % 2019
        if m == 0:
            print(0)
            sys.exit()
print(m)
### BUGGY CODE ###

X = int(input())
ans = [None, None]

for A in range(1, X+1):
    if X % A == 0:
        B = X // A
        for b in range(1, B+1):
            substitute_a = b + A
            left_side = pow(substitute_a, 4)+pow(substitute_a, 3)*b + pow(substitute_a, 2)*pow(b, 2)+substitute_a*pow(b, 3)+pow(b, 4)
            # print("A,B", A, B, "left_side", left_side)
            if left_side == B:
                ans[0], ans[1] = substitute_a, b
                break
            elif left_side > B:
                b = b * (-1)
                substitute_a = b + A
                left_side = pow(substitute_a, 4)+pow(substitute_a, 3)*b + pow(substitute_a, 2)*pow(b, 2)+substitute_a*pow(b, 3)+pow(b, 4)
                if left_side == B:
                    ans[0], ans[1] = substitute_a, b
    if ans[0] != None:
        break

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


### FIXED CODE ###

X = int(input())

for A in range(-1000, 1001):
    for B in range(-1000, 1001):
        if A**5 - B**5 == X:
            print(A, B)
            quit()
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *
		
s = input()
t = input()
 
dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]

for i in range(len(s)):
	for j in range(len(t)):
		if s[i] == t[j]:
			dp[i+1][j+1] = dp[i][j] + 1
		else:
			dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])
            
y = len(s)
x = len(t)
ans = ""
while 1:
	#print(y, x, ans)
	if x*y == 0:
		break
	elif s[y-1] == t[x-1]:
		ans += s[y-1]
		x -= 1
		y -= 1
	else:
		if dp[y][x] == dp[y-1][x]:
			y -= 1
		elif dp[y][x] == dp[y][x-1]:
			x -= 1
            
print(ans[::-1])

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *
		
s = input()
t = input()
 
dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]

for i in range(len(s)):
	for j in range(len(t)):
		if s[i] == t[j]:
			dp[i+1][j+1] = dp[i][j] + 1
		else:
			dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])
            
y = len(s)
x = len(t)
ans = ""
while 1:
	#print(y, x, ans)
	if x*y == 0:
		break
	elif s[y-1] == t[x-1]:
		ans += s[y-1]
		x -= 1
		y -= 1
	else:
		if dp[y][x] == dp[y-1][x]:
			y -= 1
		elif dp[y][x] == dp[y][x-1]:
			x -= 1
            
print(ans[::-1])
### BUGGY CODE ###

# coding: utf-8


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A = [a-1 for a in A]  # 0-index

    cnt = 0
    i = 0
    appeared = [0]
    roop_s = None
    n_roop = None
    for _ in range(N):
        i = A[i]
        cnt += 1

        if cnt == K:
            return i+1

        # if i == 0:
        if i in appeared:
            for j in range(len(appeared)):
                if appeared[j] == i:
                    roop_s = j
                    n_roop = len(appeared) - roop_s
                    break

            break
        
        appeared.append(i)

    # K > cnt
    rest = (K-roop_s) % n_roop
    i = appeared[roop_s]
    for _ in range(rest):
        i = A[i]

    return i+1


print(main())


### FIXED CODE ###

# coding: utf-8


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A = [a-1 for a in A]  # 0-index

    cnt = 0
    i = 0
    # appeared = [0]
    appeared = [False] * N
    appeared[0] = True
    arrive = [None] * (N+1)
    arrive[0] = 0
    roop_s = None
    n_roop = None
    for k in range(N):
        i = A[i]
        cnt += 1

        if cnt == K:
            return i+1

        if appeared[i]:
            for j in range(N+1):
                if arrive[j] == i:
                    roop_s = j
                    n_roop = (k+1) - roop_s
                    break
        # if i in appeared:
            # for j in range(len(appeared)):
            #     if appeared[j] == i:
            #         roop_s = j
            #         n_roop = len(appeared) - roop_s
            #         break

            break

        # appeared.append(i)
        appeared[i] = True
        arrive[k+1] = i

    # K > cnt
    rest = (K-roop_s) % n_roop
    # i = appeared[roop_s]
    i = arrive[roop_s]
    for _ in range(rest):
        i = A[i]

    return i+1


print(main())
### BUGGY CODE ###

N = int(input())
P = [i for i in range(1, N + 1)]
# 1 2 3 4 5 6 7 8 9 10 11 12 13
# 2 3 4 5 6 7 8 9 10 11 12 13 1
print(sum(P) - P[-1])


### FIXED CODE ###

N = int(input())
ret = (1 + N) * N // 2 - N 
# 1 2 3 4 5 6 7 8 9 10 11 12 13
# 2 3 4 5 6 7 8 9 10 11 12 13 1
print(ret)
### BUGGY CODE ###

s=list(input())
ans=0
for i in range(len(s)-1):
    if s[i]=="B":
        ans+=s[i+1:].count("W")
        if s[i+1:].count("W")==0:
            break
print(ans)

### FIXED CODE ###

s=list(input())
n=len(s)
ans=0
res=0
for i in range(n):
    if s[n-1-i]=="W":
        res+=1
    else:
        ans+=res
print(ans)
### BUGGY CODE ###

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

l = []
a = 0
for i in range(N):
    for j in range(1,p[i]+1):
        a += j
    l.append(a/p[i])
    a = 0

k = []
for i in range(len(l)):
    k.append(sum(l[i:i+K]))

print(max(k))

### FIXED CODE ###

import numpy as np
N,K = map(int,input().split())
p = list(map(int,input().split()))

l = []
for i in range(N):
    l.append((1+p[i])/2)

a = [0] * N
a[0] = l[0]
for i in range(1,len(l)):
    a[i] = a[i-1] + l[i]

ans = 0
for i in range(K,len(l)):
    ans = max(ans,a[i]-a[i-K])

if N == 1 or N - K == 0:
    print(max(a))
else:
    print(ans)
### BUGGY CODE ###

import numpy as np

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


b=[]
for i in range(1,n):
  b.append(a[i]+a[0])

c=[i for i in range(n)]

b=np.array(b)
c=np.array(c)
c=c[1:]

ans=0
ans+=np.sum(b==c)
for i in range(1,n):
  b+=a[i]-a[i-1]
  c-=1

  d=b-c
  ans+=np.count_nonzero(d==0)

print(ans)

### FIXED CODE ###

from collections import Counter

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

q1=[]
q2=[]

for i in range(n):
  q1.append(i+a[i])
  q2.append(i-a[i])

c1=Counter(q1)
c2=Counter(q2)

ans=0
for i in c1.keys():
  num1=c1[i]
  num2=c2[i]
  ans+=num1*num2

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

def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    inlis.sort()

    while len(inlis) > 1:
        tmp = 0
        i = 1
        while tmp < len(inlis):
            #print(i, tmp)
            if inlis[i] % inlis[0] != 0:
                inlis[i] %= inlis[0]
                i += 1
                if i >= len(inlis):
                    break
            else:
                inlis.remove(inlis[i])
            tmp += 1
        inlis.sort()
        #print(inlis, len(inlis))
    print(inlis[0])


if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    inlis = set(inlis)
    inlis = list(inlis)
    inlis.sort()

    while len(inlis) > 1:
        tmp = 0
        i = 1
        while tmp < len(inlis):
            #print(i, tmp)
            if inlis[i] % inlis[0] != 0:
                inlis[i] %= inlis[0]
                i += 1
                if i >= len(inlis):
                    break
            else:
                inlis.remove(inlis[i])
            tmp += 1
        inlis = set(inlis)
        inlis = list(inlis)
        inlis.sort()
        #print(inlis, len(inlis))
    print(inlis[0])


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

import numpy as np

H, W, K = map(int, input().split())
S = []
for _ in range(H):
    S.append(list(map(int, list(input()))))
S = np.array(S)

if S.sum() <= K:
    print(0)
    exit(0)

def satisfy(left, right, S2):
    global K
    for row in S2:
        if row[left:(right + 1)].sum() > K:
            return False
    return True

# ex. horizons = [0, 0, 1, 0, 0, 1]
def greedy(horizons):
    global W, S
    answer = sum(horizons)
    left = 0
    right = 0
    # greedyに縦線を引いていく
    # TODO: 横線で分けた後のそれぞれのブロックで集計
    # ex.
    # S  = [[1, 1, 1, 0, 0],
    #       [1, 0, 0, 0, 1],
    #       [0, 0, 1, 1, 1]]
    # horizons = [0, 1]のとき,
    # S2 = [[2, 1, 1, 0, 0],
    #       [0, 0, 1, 1, 1]]
    # となる
    top = 0
    bottom = 0
    S2 = []
    for h in horizons:
        if h == 1:
            S2.append(S[:][top:(bottom + 1)].sum(axis=0))
            top = bottom + 1
        bottom += 1
    S2.append(S[:][top:].sum(axis=0))
    while right <= W - 1:
        if not satisfy(left, right, S2):
            # 無理(ブロックの中のホワイトチョコの数をk以下にできない)だったら-1を返す
            if left == right:
                return -1
            left = right
            answer += 1
        else:
            right += 1
    return answer

answer = (H - 1) * (W - 1)

# result = greedy([0, 1, 0])

for i in range(0, 2 ** (H - 1)):
    horizons = list(map(int, list(bin(i)[2:].zfill(H - 1))))
    result = greedy(horizons)
    if result > 0 and result < answer:
        answer = result

print(answer)


### FIXED CODE ###

import numpy as np

def main():
    H, W, K = map(int, input().split())
    S = []
    for _ in range(H):
        S.append(list(map(int, list(input()))))
    S = np.array(S)
    if S.sum() <= K:
        print(0)
        exit(0)
    answer = float('INF')
    for i in range(0, 2 ** (H - 1)):
        horizons = list(map(int, list(bin(i)[2:].zfill(H - 1))))
        result = greedy(W, S, K, horizons, answer)
        answer = min(answer, result)
    print(answer)

# ex. horizons = [0, 0, 1, 0, 0, 1]
def greedy(W, S, K, horizons, current_answer):
    answer = sum(horizons)
    # ex.
    # S  = [[1, 1, 1, 0, 0],
    #       [1, 0, 0, 0, 1],
    #       [0, 0, 1, 1, 1]]
    # horizons = [0, 1]のとき,
    # S2 = [[2, 1, 1, 0, 0],
    #       [0, 0, 1, 1, 1]]
    # となる
    top = 0
    bottom = 0
    S2 = []
    for h in horizons:
        if h == 1:
            S2.append(S[:][top:(bottom + 1)].sum(axis=0).tolist())
            top = bottom + 1
        bottom += 1
    S2.append(S[:][top:].sum(axis=0).tolist())
    # ブロック毎の累積和を計算する
    h = len(S2)
    partial_sums = [0] * h
    for right in range(W):
        current = [0] * h
        for idx in range(h):
            current[idx] = S2[idx][right]
            partial_sums[idx] += S2[idx][right]
        # 1列に含むホワイトチョコの数がkより多い場合
        if max(current) > K:
            return float('INF')
        # 無理な(ブロックの中のホワイトチョコの数をk以下にできない)場合
        if max(partial_sums) > K:
            answer += 1
            if answer >= current_answer:
                return float('INF')
            partial_sums = current
    return answer

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

import heapq

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
BC = [list(map(int, input().split())) for _ in range(M)]
heapq.heapify(A)
BC = sorted(BC, key=lambda x: x[1], reverse=True)

for i in range(M):
    for j in range(BC[i][0]):
        a = heapq.heappop(A)
        heapq.heappush(A,max(BC[i][1],a))

print(sum(A))

### FIXED CODE ###

import collections

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

c = collections.Counter(A)
values,counts = zip(*c.most_common())
D=[]
for i in range(len(counts)):
    D.append([counts[i],values[i]])
for i in range(M):
    D.append(BC[i])
D=sorted(D,key=lambda x:x[1], reverse=True)

t=0
i=0
ans=0
while t<N:
    if D[i][0]+t<=N:
        ans+=D[i][1]*D[i][0]
        t+=D[i][0]
        i+=1
    else:
        ans+=D[i][1]*(N-t)
        t+=N-t
print(ans)
### BUGGY CODE ###

N, K = map(int,input().split())
dices = list(map(int,input().split()))
ans = 0
for i in range(N-K+1):
    check = 0
    for j in range(K):
        check += dices[i+j]
    if check > ans:
        ans = check
print((ans+K)/2)         

### FIXED CODE ###

N, K = map(int,input().split())
dices = list(map(int,input().split()))
list =[]
check=0
for i in range(K):
    check+=dices[i]
list.append(check)
for j in range(N-K):
    check -= dices[j]
    check += dices[j+K]
    list.append(check)    
print((max(list)+K)/2)
### BUGGY CODE ###

class UnionFind:
  def __init__(self, size):
    self.parents = [x for x in range(size)]
    self.sizes = [1] * size
  
  def unite(self, a, b):
    if self.find(a) == self.find(b):
      return
    
    if self.size_of(a) > self.size_of(b):
      self.sizes[self.find(a)] += self.size_of(b)
      self.parents[self.find(b)] = self.find(a)
    else:
      self.sizes[self.find(b)] += self.size_of(a)
      self.parents[self.find(a)] = self.find(b)
  
  def is_same(self, a, b):
    return self.find(a) == self.find(b)
  
  def size_of(self, a):
    return self.sizes[self.find(a)]
  
  def find(self, a):
    if a == self.parents[a]:
      return a
    else:
      self.parents[a] = self.find(self.parents[a])
      return self.parents[a]


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

u = UnionFind(N)

# 自分自身・友達・ブロック関係のいずれかの場合はフラグ立つ
relations = [1 << i for i in range(N)]

for _ in range(M):
  a, b = map(int, input().split())
  a, b = a - 1, b - 1
  relations[a] |= 1 << b
  relations[b] |= 1 << a
  u.unite(a, b)
  
for _ in range(K):
  c, d = map(int, input().split())
  c, d = c - 1, d - 1
  
  # 同じ連結成分に含まれないブロック関係は無視してok
  if u.is_same(c, d):
    relations[c] |= 1 << d
    relations[d] |= 1 << c

candidates = []

for i in range(N):
  # candidates.append(u.size_of(i) - bin(relations[i]).count('1'))
  candidates.append(u.size_of(i) - bin(relations[i]).count('1'))
    
print(' '.join(str(x) for x in candidates))

### FIXED CODE ###

import sys
sys.setrecursionlimit(2 ** 30)
N, M, K = map(int, input().split())

groups = [None] * N
visited = set()

# 連結成分を求める
def dfs(group, i):
  if i in visited:
    return
  
  visited.add(i)
  group.add(i)
  groups[i] = group
  # 他のノード
  for c in graph[i]:
    if not c in visited:
      dfs(group, c)
  

graph = [set() for _ in range(N)]

friends_count = [0] * N
block_count = [0] * N

for _ in range(M):
  a, b = map(int, input().split())
  a, b = a - 1, b - 1
  friends_count[a] += 1
  friends_count[b] += 1
  graph[a].add(b)
  graph[b].add(a)
  
for i in range(N):
  dfs(set(), i)
      
for _ in range(K):
  c, d = map(int, input().split())
  c, d = c - 1, d - 1
  
  # 同じ連結成分に含まれないブロック関係は無視してok
  if d in groups[c]:
    block_count[c] += 1
    block_count[d] += 1

candidates = []

for i in range(N): 
  candidates.append(
    len(groups[i]) - friends_count[i] - block_count[i] - 1
  )
    
print(' '.join(str(x) for x in candidates))
### BUGGY CODE ###

import numpy as np
N = int(input())
A = list(map(int, input().split()))

for i in range(N):
  ans = 0
  for j in range(i, N + i):
    if (j - i) % 2 == 0:
      ans += A[j % N]
    else:
      ans -= A[j % N]
  print(ans ,end = "")
  if i != N - 1:
    print(" ", end = "")
  else:
    print()

### FIXED CODE ###

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

ans = 0
for i in range(N):
  tmp = ans
  if i == 0:
    for j in range(N):
      if j % 2 == 0:
        ans += A[j]
      else:
        ans -= A[j]
  else:
    ans = 2 * A[i - 1] - tmp

  tmp = ans
  print(ans, end = "")
  if i != N - 1:
    print(" ", end = "")
  else:
    print()
### BUGGY CODE ###

from itertools import product as pro

n = int(input())
s = str(input())

r = [i for i in range(n) if s[i] == 'R']
g = [i for i in range(n) if s[i] == 'G']
b = [i for i in range(n) if s[i] == 'B']
cnt = len(r)*len(g)*len(b)

for i, j in pro(r, g):
    if 2*j-i in b:
        cnt -= 1
    if 2*i-j in b:
        cnt -= 1
    if (i+j)/2 in b:
        cnt -= 1

print(cnt)


### FIXED CODE ###

from itertools import product as pro

n = int(input())
s = str(input())

r = [i for i in range(n) if s[i] == 'R']
g = [i for i in range(n) if s[i] == 'G']
b = [i for i in range(n) if s[i] == 'B']
cnt = len(r)*len(g)*len(b)

length = max(len(r), len(g), len(b))
if length == len(r):
    max1 = set(r)
    min1 = g
    min2 = b

if length == len(g):
    max1 = set(g)
    min1 = r
    min2 = b

if length == len(b):
    max1 = set(b)
    min1 = g
    min2 = r

for i, j in pro(min1, min2):
    if 2*j-i in max1:
        cnt -= 1
    if 2*i-j in max1:
        cnt -= 1
    if (i+j)/2 in max1:
        cnt -= 1

print(cnt)
### BUGGY CODE ###

n = int(input())
A = input().split()
A = [int(t) for t in A]

d = 10**9 + 7

ans = 0
for i in range(len(A) - 1):
    ans += A[i] * (sum(A[i+1:]))
print(ans % d)

### FIXED CODE ###

n = int(input())
A = input().split()
A = [int(t) for t in A]

d = 10**9 + 7
s = sum(A)
ans = 0
for i in range(len(A) - 1):
    s = s - A[i]
    ans += A[i] * (s)

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

n,k,q,*a=map(int,open(0).read().split())
s=sorted
m=1e18
for b in a:
    i=0
    l=[]
    for j,t in enumerate(a+[-1]):
        if t<b:
            l.extend(s(a[i:j])[::-1][k-1:])
            i=j+1
    l.sort()
    if len(l)>=q:m=min(m,l[q-1]-b)
print(m)

### FIXED CODE ###

n,k,q,*a=map(int,open(0).read().split())
s=sorted
m=1e18
for b in a:
    i=[i for i,t in enumerate(a)if t<b]
    l=s(u for t in[s(a[i+1:j])[::-1][k-1:]for i,j in zip([-1]+i,i+[n])]for u in t)
    if len(l)>=q:m=min(m,l[q-1]-b)
print(m)