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

import sys
input = sys.stdin.readline

N = int(input())
edge = [[] for _ in range(N)]
sum_w = 0
for i in range(N-1):
    u, v, w = map(int, input().split())
    edge[u-1].append([v-1,w])
    edge[v-1].append([u-1,w])
    sum_w += w

dist = [sum_w]*N
comp = [None]*N
# rest = [i for i in range(N)]

is_finish = False
dist[0] = 0
while not is_finish:
    min_dist = sum_w+1
    min_ptr = -1
    for i in range(N):
        if comp[i] == None and dist[i] < min_dist:
            min_dist = dist[i]
            min_ptr = i
    if min_ptr < 0:
        is_finish = True
    else:
        comp[min_ptr] = 1
        for i in edge[min_ptr]:
            if comp[i[0]] == None:
                if i[0] < min_ptr:
                    dist[i[0]] = dist[min_ptr] + i[1]
                elif i[0] > min_ptr:
                    dist[i[0]] = dist[min_ptr] + i[1]

for item in dist:
    print(item%2)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
tree = [[] for _ in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    tree[u-1].append([v-1,w])
    tree[v-1].append([u-1,w])

dist = [None]*N
dist[0] = 0
comp = [0]*N
next_ptr = [0]
for ptr in next_ptr:
    comp[ptr] = 1
    edges = tree[ptr]
    for edge in edges:
        if comp[edge[0]] == 0:
            dist[edge[0]] = dist[ptr] + edge[1]
            next_ptr.append(edge[0])

for item in dist:
    print(item%2)
### BUGGY CODE ###

N=int(input())
s=input().split()
result=1
for i in range (N):
  result=result*int(s[i])
if result<= 10**18:
  print(result)
else:
  print(-1)
  

### FIXED CODE ###

N=int(input())
s=input().split()
result=1
if '0' in s:
  print(0)
else:
  for i in range (N):
    result=result*int(s[i])
    if result> 10**18:
      print(-1)
      break
    elif i==N-1 and result<=10**18:
      print(result)
### BUGGY CODE ###

k,s = map(int, input().split())
ans = 0
x = range(k + 1)
y = range(k + 1)
z = range(k + 1)


for i in x:
	for j in y:
		for k in z:
			if s - i - j <= (k+1) and i + j + k == s:
				ans += 1

print(ans)



### FIXED CODE ###

k,s = map(int, input().split())
ans = 0
x = range(k + 1)
y = range(k + 1)
z = range(k + 1)


for i in x:
	for j in y:
			if 0 <= s - i - j <= k:
				ans += 1

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

def main():
    import sys
    input = sys.stdin.readline

    inf = 1 << 30
    L = 30

    N, T = map(int, input().split())

    ps = []
    coef_0 = []
    for _ in range(N):
        a, b = map(int, input().split())
        if a == 0:
            coef_0.append(b + 1)
        else:
            ps.append((a, b))  # namedtupleやめた,coef,const

    ps.sort(key=lambda p: p[0] / (p[1] + 1), reverse=True)
    coef_0.sort()

    dp = [inf] * (L + 1)
    dp[0] = 0
    for coef, const in ps:
        for visited in reversed(range(L)):
            dp[visited + 1] = min(
                dp[visited + 1],
                (dp[visited] + 1) * (coef + 1) + const
            )

    def accumulate(a):
        s = 0
        yield s  # start=x->0
        for x in a:
            s += x
            yield s

    *acc, = accumulate(coef_0)

    ans = max(k for k in range(L + 1) if dp[k] <= T)
    cnt = len(acc) - 1
    for visited, consumption_time in enumerate(dp):
        rest = T - consumption_time
        if rest < 0: continue  # le->lt
        while cnt >= 0 and acc[cnt] > rest:  # bisect_right->しゃくとり
            cnt -= 1
        if cnt == 0:
            break  # 途中で離脱するようにした
        ans = max(ans, visited + cnt)
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# https://atcoder.jp/contests/hitachi2020/submissions/10704509

def main():
    import sys
    input = sys.stdin.readline

    inf = 1 << 30
    L = 30

    N, T = map(int, input().split())

    ps = []
    coef_0 = []
    for _ in range(N):
        a, b = map(int, input().split())
        if a == 0:
            coef_0.append(b + 1)
        else:
            ps.append((a, b))  # namedtupleやめた,coef,const

    ps.sort(key=lambda p: p[0] / (p[1] + 1), reverse=True)
    coef_0.sort()

    dp = [inf] * (L + 1)
    dp[0] = 0
    for coef, const in ps:
        for visited in reversed(range(L)):
            dp[visited + 1] = min(
                dp[visited + 1],
                (dp[visited] + 1) * (coef + 1) + const
            )

    def accumulate(a):
        s = 0
        yield s  # start=x->0
        for x in a:
            s += x
            yield s

    *acc, = accumulate(coef_0)

    ans = {0}
    cnt = len(acc) - 1
    for visited, consumption_time in enumerate(dp):
        rest = T - consumption_time
        if rest < 0: break  # le->lt,continue->break,restは狭義単調減少
        while cnt > 0 and acc[cnt] > rest:  # bisect_right->しゃくとり
            cnt -= 1
        ans.add(visited + cnt)
    print(max(ans))


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

from itertools import accumulate
from operator import add

N, K = map(int, input().split())
K2 = 2 * K

# Gss[i][j]: 「市松模様の黒い部分の右上のマス」が(i,j)のとき、満たせる要望の個数
Gss = [[0] * K2 for i in range(K2)]

for i in range(N):
    x, y, c = input().split()
    x, y = int(x), int(y)

    # 要望を「0<=x<2K, 0<=y<K, 'B'」に変換する
    if c == 'W':
        x -= K
    x, y = x % K2, y % K2

    if y >= K:
        x, y = (x - K) % K2, y - K

    # 要望を満たす「市松模様の黒い部分の右上のマス」に対して、+1する
    # （後で累積和を取る）
    Gss[x][y] += 1
    Gss[x][y - K] += -1
    if x != K:
        Gss[x - K][y - K] += 1
        Gss[x - K][y] += -1
    if x > K:
        Gss[0][y] += 1
        Gss[0][y - K] += -1

# 累積和を取る
Gss = [list(accumulate(Gs)) for Gs in Gss]
Gss = [list(accumulate(Gs)) for Gs in zip(*Gss)]
Gss = list(map(list, zip(*Gss))) # 転置

# 「K<=y<2K」の部分を、「0<=y<K」に重ね合わせる
Gss = [list(map(add, Gss[i][:K], Gss[i - K][K:])) for i in range(K2)]

# Gssの最大値が答え
print(max(map(max, Gss)))


### FIXED CODE ###

from operator import sub

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

numA = [[0] * K for i in range(K)]
numB = [[0] * K for i in range(K)]

for i in range(N):
    x, y, c = input().split()
    x = int(x) % (2 * K)
    y = int(y) % (2 * K)

    if c == 'B':
        if (x // K == 0 and y // K == 0) or (x // K == 1 and y // K == 1):
            numA[x % K][y % K] += 1
        else:
            numB[x % K][y % K] += 1
    else:
        if (x // K == 1 and y // K == 0) or (x // K == 0 and y // K == 1):
            numA[x % K][y % K] += 1
        else:
            numB[x % K][y % K] += 1


sumXA = list(map(sum, numA))
sumYA = list(map(sum, zip(*numA)))

sumXB = list(map(sum, numB))
sumYB = list(map(sum, zip(*numB)))

sumA = sum(sumXA)
sumB = sum(sumXB)

Arr = [[0] * K for i in range(K)]
numOKA = sumA
numOKB = sumB
for x in range(K):

    tempOKA = numOKA
    tempOKB = numOKB
    for y in range(K):
        Arr[x][y] = max(tempOKA + sumB - tempOKB, sumA - tempOKA + tempOKB)
        tempOKA -= sumYA[y]
        tempOKB -= sumYB[y]

    sumYA = list(map(sub, sumYA, numA[x]))
    sumYA = list(map(sub, sumYA, numA[x]))
    numOKA -= sumXA[x]

    sumYB = list(map(sub, sumYB, numB[x]))
    sumYB = list(map(sub, sumYB, numB[x]))
    numOKB -= sumXB[x]

print(max(map(max, Arr)))
### BUGGY CODE ###

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

ans = 0
for i in range(n):
    is_valid = True
    for j in range(i+1):
        if p[i] > p[j]:
            is_valid = False
            break
    if is_valid:
        ans += 1
print(ans)


### FIXED CODE ###

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

ans = 0
min_value = p[0]
for i in range(n):
    if p[i] <= min_value:
        ans += 1
    min_value = min(p[i], min_value)

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

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

if(1 in a == False):
  print(-1)
  exit()
if(a == list(map(lambda x: x+1, range(len(a))))):
  print(0)
  exit()

count = 0
for i in range(n):
  if(i+1 in a == False):
    break
  if(i < len(a)):
    while(len(a) > i and a[i] != i+1):
      a.pop(i)
      count += 1
 
if count == 0 or len(a) == 0:
  print(-1)
else:
  print(count)

### FIXED CODE ###

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

c = 0
for i in range(n):
  if a[i] == c + 1:
    c += 1
if c == 0:
  print(-1)
else:
  print(n - c)
### BUGGY CODE ###

def lcs(s,t):
    m,n = len(s),len(t)
    a = [[0 for j in range(n+1)]for i in range(m+1)]
    k,p = "",0
    for i in range(m+1):
        for j in range(n+1):
            if i==0 or j==0:
                a[i][j]=0
            elif s[i-1]==t[j-1]:
                a[i][j]=a[i-1][j-1]+1
            else:
                a[i][j] = max(a[i-1][j],a[i][j-1])
    i,j = m,n
    while i>0 and j>0:
        if s[i-1]==t[j-1]:
            k+=s[i-1]
            i-=1
            j-=1
        elif a[i-1][j]>a[i][j-1]:
            i-=1
        else:
            j-=1
    return k[::-1]
s = input()
t = input()
k = lcs(s,t)
print(k)

### FIXED CODE ###

def lcs(s,t):
    m,n = len(s),len(t)
    a = [[0 for j in range(n+1)]for i in range(m+1)]
    k,p = "",0
    for i in range(m+1):
        for j in range(n+1):
            if i==0 or j==0:
                a[i][j]=0
            elif s[i-1]==t[j-1]:
                a[i][j]=a[i-1][j-1]+1
            else:
                a[i][j] = max(a[i-1][j],a[i][j-1])
    i,j = m,n
    while i>0 and j>0:
        if s[i-1]==t[j-1]:
            k+=s[i-1]
            i-=1
            j-=1
        elif a[i-1][j]>a[i][j-1]:
            i-=1
        else:
            j-=1
    return k[::-1]
s = input()
t = input()
k = lcs(s,t)
print(k)
### 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)
    
n=int(input())
ans=0

for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans+=gcd(i,j,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)
    
n=int(input())
ans=0

for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans+=gcd(i,j,k)

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

from itertools import permutations

def input_list() :
    return list(map(int, input().split()))

n, m ,r = input_list()
road = input_list()
road = [x-1 for x in road]
d = [[float('inf')] * n for i in range(n)]
for i in range(n) :
    d[i][i] = 0
for i in range(m) :
    a, b, c = input_list()
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c

for k in range(n) :
    for i in range(n) :
        for j in range(n) :
            dist = d[i][k]+d[k][j]
            if d[i][j] > dist :
                d[i][j] = dist

ans = float('inf')
for p in permutations(road) :
    dist = 0
    for i in range(r-1) :
        dist += d[p[i]][p[i+1]]
    if ans > dist :
        ans = dist

print(ans)

### FIXED CODE ###

from itertools import permutations

def input_list() :
    return list(map(int, input().split()))

def main() :
    n, m ,r = input_list()
    road = input_list()
    road = [x-1 for x in road]
    d = [[float('inf')] * n for i in range(n)]
    for i in range(n) :
        d[i][i] = 0
    for i in range(m) :
        a, b, c = input_list()
        a -= 1
        b -= 1
        d[a][b] = c
        d[b][a] = c

    for k in range(n) :
        for i in range(n) :
            for j in range(n) :
                dist = d[i][k]+d[k][j]
                if d[i][j] > dist :
                    d[i][j] = dist

    ans = float('inf')
    for p in permutations(road) :
        dist = 0
        for i in range(r-1) :
            dist += d[p[i]][p[i+1]]
        if ans > dist :
            ans = dist

    print(ans)

main()
### BUGGY CODE ###

#https://atcoder.jp/contests/dp/tasks/dp_b
#2019-01-13
N, K = map(int, input().split())
h = list(map(int, input().split()))

DP = [0]
for i in range(N-1):
    act = float("inf")
    for k in range(K):
        if i-k < 0 : continue
        act = min(DP[-1-k] + abs(h[i-k]-h[i+1]) , act)
    DP += [act]

print(DP[-1])

### FIXED CODE ###

#https://atcoder.jp/contests/dp/tasks/dp_b
#2019-01-13
N, K = map(int, input().split())
h = list(map(int, input().split()))

DP = [0]
for i in range(N-1):
    act = float("inf")
    for k in range(K):
        if i-k < 0 : continue
        act = min(DP[-1-k] + abs(h[i-k]-h[i+1]) , act)
    DP += [act]

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

"""
最長経路問題として解く。

各試合のノードを作成。
各試合ノードごとに、「この試合が終わったら、次はこの試合ができるようになる。」という対応関係を作っていく。
"""
import sys
sys.setrecursionlimit(1000000)

N = int(input())

A = [[0]*(N)]
for _ in range(N):
    A.append([0]+list(map(int,input().split())))
 
#選手iにとって、選手jが何番目の相手かを逆引きするメモを用意しておく。
reverseMemo = {i:{} for i in range(1,N+1)}
for i in range(1,N+1):
    for j in range(1,N):
        a = A[i][j]
        reverseMemo[i][a] = j

matchs = []
for i in range(1,N+1):
    for j in range(i+1,N+1):
        matchs.append((i,j))

edges = {}
for match in matchs:
    edges[match] = []
    i,j = match
    if reverseMemo[i][j] != N-1:
        nx = A[i][reverseMemo[i][j]+1]
        edges[match].append((min(i,nx),max(i,nx)))
    if reverseMemo[j][i] != N-1:
        nx = A[j][reverseMemo[j][i]+1]
        edges[match].append((min(j,nx),max(j,nx)))

stepMemo = {}
def dfs(i,j,cnt):
    if cnt > len(matchs):
        print(-1)
        exit()
    #i,jの試合日を含めて、あと何日必要なのかを返す。
    if (i,j) not in stepMemo:
        res = 1
        for a,b in edges[(i,j)]:
            res = max(res,dfs(a,b,cnt+1)+1)
        stepMemo[(i,j)] = res
    return stepMemo[(i,j)]

ans = 0
for i in range(1,N+1):
    for j in range(i+1,N+1):
        ans = max(ans,dfs(i,j,1))
print(ans)

### FIXED CODE ###

"""
最長経路問題として解く。

各試合のノードを作成。
各試合ノードごとに、「この試合が終わったら、次はこの試合ができるようになる。」という対応関係を作っていく。
"""
def main():
    import sys
    sys.setrecursionlimit(1000000)
    input = sys.stdin.readline

    N = int(input())

    A = [[0]*(N)]
    for i in range(N):
        A.append([0]+list(map(int,input().split())))
    
    #選手iにとって、選手jが何番目の相手かを逆引きするメモを用意しておく。
    reverseMemo = [[-1]*(N+1) for _ in range(N+1)]
    for i in range(1,N+1):
        for j in range(1,N):
            a = A[i][j]
            reverseMemo[i][a] = j
    edges = {}
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            match = (i,j)
            edges[match] = []
            if reverseMemo[i][j] != N-1:
                nx = A[i][reverseMemo[i][j]+1]
                edges[match].append((min(i,nx),max(i,nx)))
            if reverseMemo[j][i] != N-1:
                nx = A[j][reverseMemo[j][i]+1]
                edges[match].append((min(j,nx),max(j,nx)))
    
    del reverseMemo
    del A
    
    stepMemo = {}
    def dfs(i,j,path):
        #i,jの試合日を含めて、あと何日必要なのかを返す。
        if (i,j) not in stepMemo:
            if (i,j) in path:
                print(-1)
                exit()
            else:
                path.add((i,j))
            res = 1
            for a,b in edges[(i,j)]:
                res = max(res,dfs(a,b,path)+1)
            stepMemo[(i,j)] = res
        return stepMemo[(i,j)]

    ans = 0
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            if (i,j) not in stepMemo:
                ans = max(ans,dfs(i,j,set()))
    print(ans)
main()
### BUGGY CODE ###

N = int(input())
S = list(input() for i in range(N))
set = set(S)
dic = {}

for i in set:
    dic[i] = S.count(i)

max_k_list = [kv[0] for kv in dic.items() if kv[1] == max(dic.values())]

max_k_list.sort()

for i in max_k_list:
    print(i)


### FIXED CODE ###

import collections

N = int(input())
S = list(input() for i in range(N))
dict = {}

for l in S:
        if l in dict:
            dict[l] += 1;
        else:
            dict[l] = 1;
            
max = max(dict.values())

max_k_list = [kv[0] for kv in dict.items() if kv[1] == max]

max_k_list.sort()

for i in max_k_list:
    print(i)
### BUGGY CODE ###

import functools

n = int(input())
xs = input().split()

def foldSum(acc, x):
    return acc*int(x)

res = functools.reduce(foldSum, xs, 1)

if res > 1e18:
    print(-1)
else:
    print(res)



### FIXED CODE ###

import functools

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

def foldMulti(acc, x):
    return acc*x

if 0 in xs:
    print(0)
elif len([x for x in xs if x > 1]) >= 60:
    print(-1)
else:
    res = functools.reduce(foldMulti, xs, 1)

    if res > 1e18:
        print(-1)
    else:
        print(res)
### BUGGY CODE ###

import math
A,B,N = map(int, input().split())
d = []
x = 0
for i in range(N+1):
    C = math.floor(A*x/B)
    D = math.floor(x/B)
    ans = C-A*D
    d.append(ans)
    x += 1
print(max(d))
    


### FIXED CODE ###

import math
A,B,N = map(int, input().split())
if (B-1)<=N:
    print(math.floor(A*(B-1)/B)-math.floor((B-1)/B)*A)
else:
    print(math.floor(A*N/B)-math.floor(N/B)*A)
### BUGGY CODE ###

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

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

if K == 1:
    N = 0

else:
    while abs(N-K)<N:
        N = abs(N-K)
print(N)



### FIXED CODE ###

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

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

if K == 1:
    N = 0

else:
    if N // K > 0:
        i = N//K
        N = N - (K * i)
    while abs(N-K)<N:
        N = abs(N-K)
print(N)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0 for _ in range(n)]

for i in range(1, n):
    dp[i] = dp[i - 1] + abs(h[i] - h[i - 1])
    for j in range(2, k + 1):
        if i - j >= 0:
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))
        else:
            break

print(dp[-1])

### FIXED CODE ###

# -*- coding: utf-8 -*-
n, k = map(int, input().split())
h = list(map(int, input().split()))

INF = float('inf')
dp = [INF for _ in range(n)]
dp[0] = 0

for i in range(1, n):
    l, r = max(i - k, 0), i
    dp[i] = min([pdp + abs(h[i] - ph) for pdp, ph in zip(dp[l:r], h[l:r])])

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

s = input().strip()
x = s[0]
for i in range(1,len(s)):
    if s[i]=="C" and s[i-1]=="B":
        x = x[:-1]+"T"
    else:
        x += s[i]
cnt = 0
ca = 0
for i in range(len(x)):
    if x[i]=="A":
        ca += 1
    elif x[i]=="T":
        cnt += ca
    elif x[i]=="B" or x[i]=="C":
        ca = 0
print(cnt) 

### FIXED CODE ###

s = input().strip()
x = [s[0]]
for i in range(1,len(s)):
    if s[i]=="C" and s[i-1]=="B":
        x.pop()
        x.append("T")
    else:
        x.append(s[i])
cnt = 0
ca = 0
for i in range(len(x)):
    if x[i]=="A":
        ca += 1
    elif x[i]=="T":
        cnt += ca
    elif x[i]=="B" or x[i]=="C":
        ca = 0
print(cnt)
### BUGGY CODE ###

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

li2 = []
li3 = []

for i in range(m):
    li2.append(li[i][0]*10**6)

for i in range(1,n+1):
    for j in range(m):
        if li[j][0] == i:
            li3.append(li[j][1])
    li3.sort()
    for j in range(m):
        for k in range(len(li3)):
            if li[j][1] == li3[k]:
                li2[j] += k+1
    li3.clear()

for i in li2:
    if i % 10**10 != i:
        i = "0" + str(i)
        print(i)
    elif i % 10**9 != i:
            i = "00" + str(i)
            print(i)
    elif i % 10**8 != i:
        i = "000" + str(i)
        print(i)
    elif i % 10**7 != i:
        i = "0000" + str(i)
        print(i)
    elif i % 10**6 != i:
        i = "00000" + str(i)
        print(i)
    else:
        print(i)


### FIXED CODE ###

n,m = map(int,input().split())
py = []
li = [1] * (10**5 + 10)

for i in range(m):
    p,y = map(int,input().split())
    py.append((p,y,i))

py.sort(key = lambda x: x[1])

ans = []

for p,y,i in py:
    ans_tmp = '0' * (6 - len(str(p))) + str(p) + '0' * (6 - len(str(li[p]))) + str(li[p])
    li[p] += 1
    ans.append([ans_tmp, i])

ans.sort(key = lambda x: x[1])
for i in range(m):
    print(ans[i][0])
### BUGGY CODE ###

N = int(input())
S = input()

ans = 0
for i in range(N-1):
    for j in range(i+1+ans, N-ans):
        for l in range(ans+1, min(j-i, N-j)+1):
            if S[i:i+l] == S[j:j+l]:
                ans = max(ans, l)
            else:
                break

print(ans)


### FIXED CODE ###

N = int(input())
S = input()
DP = [[0]*5005 for _ in range(5005)]

for i in range(N):
    for j in range(N):
        if S[i] == S[j]:
            DP[N-i][N-j] = DP[N-i+1][N-j+1] + 1
ans = 0
for i in range(N):
    for j in range(N):
        if i >= j:
            continue
        now = min(DP[i][j], j-i)
        ans = max(ans, now)

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

n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b

for i in range(n-2):
    for j in range(i+1,n-1):
        if 2*j-i<=n-1 and s[i]!=s[j] and s[j]!=s[2*j-i] and s[2*j-i]!=s[i]:
                ans-=1

print(ans)

### FIXED CODE ###

from collections import Counter
n=int(input())
s=list(input())
C=Counter(s)
r,g,b=C["R"],C["G"],C["B"]
ans=r*g*b

for i in range(n-2):
    for j in range(i+1,n-1):
        k=2*j-i
        if k<=n-1 and s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
                ans-=1

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

import fractions
from functools import reduce

N = int(input())
A = list(map(int,input().split()))
g_max = 0
for i in range(N):
    B = A.copy()
    B[i:i+1] = []
    g = reduce(fractions.gcd,B)
    if g_max < g:
        g_max = g
print(g_max)


### FIXED CODE ###

def gcd(x,y):
    while y != 0:
        x,y = y,x%y
    return x
n = int(input())
a = list(map(int,input().split()))

L,R = [0],[0]
for i in range(1,n+1): #L[i]は左i個,R[i]は右i個
    L.append(gcd(L[-1],a[i-1]))
    R.append(gcd(R[-1],a[n-i]))
print(max(gcd(L[i],R[n-i-1]) for i in range(n)))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 18:19:39 2020

@author: matsui
"""


N,W=map(int,input().split())
dp=[0]*(W+1)
L = sorted([list(map(int,input().split())) for i in range(N)])
s=0

for w, v in L:
    s+=w
    for j in range(min(W,s),w-1,-1):
        dp[j]=max(dp[j],dp[j-w]+v) 
    
print(max(dp))


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 18:19:39 2020

@author: matsui
"""


N,W=map(int,input().split())
dp=[0]*(W+1)
L = sorted([list(map(int,input().split())) for i in range(N)])
s=0

for w, v in L:
    s+=w
    for j in range(min(W,s),w-1,-1):
        if dp[j-w]+v > dp[j]: dp[j]=dp[j-w]+v
    
print(max(dp))
### BUGGY CODE ###

import heapq
def SME(Whole,start,end,L,ANS):
    A = []
    if end > N : end = N
    count = 0
    count2 = 0
    for i,x in enumerate(Whole[start:end]):
        heapq.heappush(A,[x,i])
    for j in range(start,end):
        a = heapq.heappop(A)
        tmp = count
        for i in range(L):
            idx = a[1] + i
            try :
                if ANS[idx] == 0 and idx < end:
                    ANS[idx] = a[0]
                    count += 1
            except IndexError : continue
        if count == tmp : count2 += 1
        if count2 > 90 : break
    for i in range(L):
        if ANS[i] == 0 : ANS[i] = min(Whole[:i+1])
    for i in range(L,N):
        if ANS[i] == 0 : ANS[i] = min(Whole[i+1-L:i+1])
    return ANS

[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ANS = [0]*N
start = 0
K = L * int(N ** 0.3 + 2 )
if K > N : K = N
end = K
while (end <= N):
    ANS = SME(A, start, end, L, ANS)
    start = end
    end += K 
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])