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

# coding: utf-8
# Your code here!

if __name__ == '__main__':
    nums = [int(x) for x in input().split()]
    N,T = nums[0],nums[1]
    cities = [int(x) for x in input().split()]

    profs = {}
    for i in range(len(cities)):
        h = i + cities[i:].index(max(cities[i:]))
        #print("highest",i,h)
        profs[(i,h)] = T * (cities[h] - cities[i])

    maxProf = max(profs.values())
    ans = 0
    for v in profs.values():
        if v == maxProf:
            ans += 1
    print(ans)

### FIXED CODE ###

from collections import defaultdict

if __name__ == '__main__':
    nums = [int(x) for x in input().split()]
    N,T = nums[0],nums[1]
    cities = [int(x) for x in input().split()]

    d = defaultdict(int)

    minPrice = 90000000000
    maxProf = -1
    for city in cities:
        minPrice = min(city, minPrice)
        prof = city - minPrice
        d[prof] += 1
        
        maxProf = max(prof,maxProf)
    print(d[maxProf])
### BUGGY CODE ###

N = int(input())

prime = [True] * 100001
like2017 = [False] * 100001
for i in range(2, 100001):
  if prime[i]:
    for j in range(i*2, 100001, i):
      prime[j] = False
    if i != 2 and prime[(i+1)//2]:
      like2017[i] = True

for i in range(N):
  l, r = map(int, input().split())
  print(sum(like2017[l:r+1]))

### FIXED CODE ###

N = int(input())

prime = [True] * 100001
like2017 = [0] * 100001
num = 0
for i in range(2, 100001):
  if prime[i]:
    for j in range(i*2, 100001, i):
      prime[j] = False
    if i != 2 and prime[(i+1)//2]:
      num += 1
  like2017[i] = num

for i in range(N):
  l, r = map(int, input().split())
  print(like2017[r] - like2017[l-1])
### BUGGY CODE ###

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

final = 10**32
for i in range(1, len(total)):
    a = sum(total[:i])
    b = sum(total[i:])
    final = min(final, abs(a - b))

print(final)
    


### FIXED CODE ###

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

total = sum(main)
beg = 0
final = float('inf')
for i in range(len(main) - 1):
    beg += main[i]
    total -= main[i]
    final = min(final, abs(beg - total))

print(final)
### BUGGY CODE ###

def _comp(a,b):
  for x,y in zip(a,b):
    if x==y or y=="?":
      yield x
    elif x=="?":
      yield y
    else:
      return

def comp(a,b):
  m = "".join(_comp(a,b))
  if min(len(a),len(b)) == len(m):
    return m
  else:
    return False

def merge(a,b):
  for i in range(len(a)-len(b)+1):
    m = comp(a[i:],b)
    if m:
      yield a[:i]+m+a[i+len(b):]
  
  for i in range(1,len(b)):
    m = comp(b[i:], a)
    if m:
      yield  b[:i]+m+a[len(b)-i:]
    m = comp(b, a[-len(b)+i:])
    if m:
      yield a[:-len(b)+i]+m+b[-i:]
  yield a+b
  yield b+a

a=input()
b=input()
c=input()
a,b,c=sorted([a,b,c],key=len,reverse=True)

abc = float("inf")
for d in merge(a,b):
  if len(d) > abc:
    break
  l = len(next(merge(d, c)))
  abc = min(abc, l)

for d in merge(a,c):
  if len(d) > abc:
    break
  l = len(next(merge(d, b)))
  abc = min(abc, l)

print(abc)



### FIXED CODE ###

from itertools import *
from heapq import *

def comp(a,b):
  return all(x==y or "?" in (x,y) for x,y in zip(a, b))

def comp3(a,b,c):
  return 

def comp3(i,j,k,a,b,c):
  m = max(i,j,k)
  n = min(i+len(a),j+len(b),k+len(c))
  return all(len({x,y,z}-{"?"}) <= 1 for x,y,z in zip(a[m-i:n-i],b[m-j:n-j],c[m-k:n-k]))

def _merge_mid(a,b):
  la, lb = map(len,[a,b])
  for i in range(la-lb+1):
    if comp(a[i:],b):
      yield i

def merge_mid(a,b):
  return list(_merge_mid(a,b))

def _merge_right(a,b):
  la, lb = map(len,[a,b])
  for i in range(max(la-lb+1, 1),la):
    if comp(b, a[i-la:]):
      yield i
  yield la

def merge_right(a,b):
  return list(_merge_right(a,b))

class K(int):
  def __new__(cls, *args, **kwargs):
    cb = kwargs.pop("cb")
    i = int.__new__(cls, *args, **kwargs)
    i.cb = cb
    return i

def min_merge(a,b,c):
  keys = sorted([a,b,c],key=len,reverse=True)
  len_keys = list(map(len, keys))
  mid = {(i,j):merge_mid(keys[i],keys[j]) for i,j in permutations(range(3), 2)}
  right = {(i,j):merge_right(keys[i],keys[j]) for i,j in permutations(range(3), 2)}
  
  for i in mid[0,1]:
    for j in mid[0,2]:
      if j+len_keys[2] <= i or i+len_keys[2] <= j or (j-i in mid[1,2] or j-i in right[1,2] or i-j in right[2,1]):
        return len_keys[0]
  
  def candicates(a,b,c):
    return chain(
      (K(i+len_keys[b], cb=lambda:(
       (mid[a,c] and mid[a,c][0]+len_keys[c] <= i) or (mid[b,c] and len_keys[a] <= i+mid[b,c][-1]) or 
       any((i-j in right[c,b] if i>j else j-i in mid[b,c]) and comp3(0,i,j,keys[a],keys[b],keys[c]) for j in dropwhile((i-len_keys[c]).__gt__, mid[a,c]+right[a,c]))
      )) for i in dropwhile((len_keys[c]-len_keys[b]+1).__gt__, right[a,b])),
      (K(min(i+next(dropwhile((len_keys[a]-i+1).__gt__, y))+len_keys[b] for i in x), cb=lambda:True) for (x, y) in [sorted((right[a,c], right[c,b]), key=len)]),
    )
  
  can = merge(*(candicates(x,y,z) for x,y,z in permutations(range(3),3)))
  
  for k in can:
    if k.cb():
      return k
  
  return sum(len_keys)

a=input()
b=input()
c=input()

print(min_merge(a,b,c))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Mar 22 13:54:24 2020

@author: naoki
"""
import sys
#f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
N = int(input())
a = list(map(lambda x:int(x)-1,list(input())))
   
all_odd = 0
kai = [0] * N

if (0 not in a) and (1 not in a):
    print(0)
    sys.exit()
if (1 not in a) and (2 not in a):
    print(0)
    sys.exit()
if (0 not in a) and (2 not in a):
    print(0)
    sys.exit()
    
for k in range(1,N):
    count = 0
    p = k
    for _ in range(N):
        if p % 2 == 1:
            kai[k] = kai[k-1] + count
            break
        p = p/2
        count += 1

all_num = 0
for k in range(N):
    if kai[-1] <= kai[k] + kai[N-1-k] and a[k] == 1:
        all_num += 1

if all_num % 2 == 1:
    print(1)
elif 1 in a:
    print(0)
else:
    for i in range(N):
        a[i] = a[i]/2
    for k in range(N):
        if kai[-1] <= kai[k] + kai[N-1-k] and a[k] == 1:
            all_num += 1
    if all_num % 2 == 1:
        print(2)
    else:
        print(0)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Mar 22 13:54:24 2020

@author: naoki
"""
import sys
#f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
N = int(input())
a = list(map(lambda x:int(x)-1,list(input())))
   
all_odd = 0
kai = [0] * N

if (0 not in a) and (1 not in a):
    print(0)
    sys.exit()
if (1 not in a) and (2 not in a):
    print(0)
    sys.exit()
if (0 not in a) and (2 not in a):
    print(0)
    sys.exit()
    
for k in range(1,N):
    count = 0
    p = k
    for _ in range(N):
        if p % 2 == 1:
            kai[k] = kai[k-1] + count
            break
        p = p/2
        count += 1

all_num = 0
for k in range(N):
    if kai[-1] <= kai[k] + kai[N-1-k] and a[k] == 1:
        all_num += 1

if all_num % 2 == 1:
    print(1)
elif 1 in a:
    print(0)
else:
    for i in range(N):
        a[i] = a[i]/2
    for k in range(N):
        if kai[-1] <= kai[k] + kai[N-1-k] and a[k] == 1:
            all_num += 1
    if all_num % 2 == 1:
        print(2)
    else:
        print(0)
### BUGGY CODE ###

from math import gcd
#リスト l の最大公約数
def gcdlist(l):
    a = l[0]
    for i in range(len(l)):
        a = gcd(a,l[i])
    return a
n = int(input())
A = list(map(int, input().split()))
ans = 0

for i in range(n):
    tmp = A.copy()
    del tmp[i]
    gcd_num = gcdlist(tmp)
    ans = max(ans, gcd_num)

print(ans)

### FIXED CODE ###

from math import gcd
#リスト l の最大公約数
def gcdlist(l):
    a = l[0]
    for i in range(len(l)):
        a = gcd(a,l[i])
    return a
n = int(input())
A = list(map(int, input().split()))
ans = 0

x = [0]*n
y = [0]*n
for i in range(1, n):
    x[i] = gcd(x[i-1], A[i-1])
for i in reversed(range(n-1)):
    y[i] = gcd(y[i+1], A[i+1])

for i in range(n):
    tmp = gcd(x[i], y[i])
    ans = max(ans, tmp)

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

import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
def main():
    def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
            if temp % i == 0:
                cnt = 0
                while temp % i == 0:
                    cnt += 1
                    temp //= i
                arr.append([i, cnt])
        if temp != 1:
            arr.append([temp, 1])
        if arr == []:
            arr.append([n, 1])
        return arr

    n = int(input())
    r = 1
    for i1 in range(2, n + 1):
        pn = factorization(i1)
        t1 = i1
        for pne in pn:
            t1 *= (pne[1] + 1)
        r += t1
    print(r)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
read = sys.stdin.read
from math import sqrt, floor
def main():
    n = int(input())
    if n == 1:
        print(1)
        sys.exit()
    # nd:num of div
    nd = [2] * (n + 1)

    for i1 in range(2, floor(n / 2) + 1):
        for i2 in range(i1 * 2, n + 1, i1):
            nd[i2] += 1

    r = 1
    for j1 in range(2, n + 1):
        r += nd[j1] * j1
    print(r)

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

N, M = map(int, input().split())
AB = [list(map(lambda x:int(x)-1, input().split())) for _ in range(M)]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(N)
for i in range(M):
    a, b = AB[i]
    uf.union(a, b)
    
ans = 0
for val in uf.all_group_members().values():
    ans = max(ans, len(val))

print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
AB = [list(map(lambda x:int(x)-1, input().split())) for _ in range(M)]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(N)
for i in range(M):
    a, b = AB[i]
    uf.union(a, b)

ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))

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

n = int(input())

s = input()


ans = 3 * 10 ** 5
for  i in range(n):
  tmp = s[:i].count("W") + s[i+1:].count("E")
  if ans > tmp:
    ans = tmp
    
print(ans)

### FIXED CODE ###

n = int(input())

s = input()


a = [0] * (n+1)
b = [0] * (n+1)
ans = 3 * 10 ** 5

aN = s.count("E")
for i in range(n):
  if s[i] == "E":
    a[i+1] = a[i] + 1
    b[i+1] = b[i]
  else:
    a[i+1] = a[i]
    b[i+1] = b[i] + 1
  #print(ans, aN-a[i+1]+b[i])  
  ans = min(ans, aN-a[i+1]+b[i])
  
  
  
print((ans))
### BUGGY CODE ###

#!/usr/bin/env python3
#ABC54 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n,k,l = map(int,input().split())
par1 = [i for i in range(n)]
par2 = [i for i in range(n)]

rank1 = [0]*(n)
rank2 = [0]*(n)

def find(x,i):
    if i == 1:
        if par1[x] == x:
            return x
        else:
            par1[x] = find(par1[x],i)
            return par1[x]
    else:
        if par2[x] == x:
            return x
        else:
            par2[x] = find(par2[x],i)
            return par2[x]

def check(x,y,i):
    return find(x,i) == find(y,i)

def union(x,y,i):
    x = find(x,i)
    y = find(y,i)
    if i == 1:
        if rank1[x] < rank1[y]:
            par1[x] = y
        else:
            par1[y] = x
            if rank1[x] == rank1[y]:
                rank1[x] += 1
    else:
        if rank2[x] < rank2[y]:
            par2[x] = y
        else:
            par2[y] = x
            if rank2[x] == rank2[y]:
                rank2[x] += 1

for _ in range(k):
    p,q = map(int,input().split())
    union(p-1,q-1,1)
for _ in range(l):
    r,s = map(int,input().split())
    union(r-1,s-1,2)

ans = []
for i in range(n):
    cnt = 1
    for j in range(n):
        if i == j:
            continue
        if check(i,j,1) and check(i,j,2):
            cnt += 1
    ans.append(cnt)
print(*ans)


### FIXED CODE ###

#!/usr/bin/env python3
#ABC54 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n,k,l = map(int,input().split())
par1 = [i for i in range(n)]
par2 = [i for i in range(n)]

rank1 = [0]*(n)
rank2 = [0]*(n)

def find(x,i):
    if i == 1:
        if par1[x] == x:
            return x
        else:
            par1[x] = find(par1[x],i)
            return par1[x]
    else:
        if par2[x] == x:
            return x
        else:
            par2[x] = find(par2[x],i)
            return par2[x]

def union(x,y,i):
    x = find(x,i)
    y = find(y,i)
    if i == 1:
        if rank1[x] < rank1[y]:
            par1[x] = y
        else:
            par1[y] = x
            if rank1[x] == rank1[y]:
                rank1[x] += 1
    else:
        if rank2[x] < rank2[y]:
            par2[x] = y
        else:
            par2[y] = x
            if rank2[x] == rank2[y]:
                rank2[x] += 1

for _ in range(k):
    p,q = map(int,input().split())
    union(p-1,q-1,1)
for _ in range(l):
    r,s = map(int,input().split())
    union(r-1,s-1,2)

f = defaultdict(lambda : 0)
for i in range(n):
    x = (find(i,1),find(i,2))
    f[x] += 1
    
ans = []
for i in range(n):
    x = (find(i,1),find(i,2))
    ans.append(f[x])
print(*ans)
### BUGGY CODE ###

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
RC110 D
"""


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

from math import sqrt
from collections import deque
def divisors(x):
    divs = deque()
    sx = int(sqrt(x))
    if x == sx**2:
        divs.append(sx)
        sx = sx-1
    for i in range(sx,0,-1):
        if x%i==0:
            divs.append(i)
            divs.appendleft(x//i)
    return(divs)

mdivs = list(divisors(m))
from collections import defaultdict
divsdict = defaultdict(list)
for d in mdivs:
    divsdict[d] = [dd for dd in mdivs if d%dd==0]

dpdict = defaultdict(int)
for d in mdivs:
    dpdict[d]=0
dpdict[1] = 1

cut = 10**9+7

for i in range(n):
    dpdicttmp = dpdict
    for d in mdivs:
        dpdict[d] = sum(map(lambda x:dpdict[x],divsdict[d]))%(10**9+7)

print(dpdict[m])



### FIXED CODE ###

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
RC110 D
"""


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

from math import sqrt
from collections import deque
def divisors(x):
    divs = deque()
    sx = int(sqrt(x))
    if x == sx**2:
        divs.append(sx)
        sx = sx-1
    for i in range(sx,0,-1):
        if x%i==0:
            divs.append(i)
            divs.appendleft(x//i)
    return(divs)

mdivs = list(divisors(m))
from collections import defaultdict
divsdict = defaultdict(list)
for d in mdivs:
    divsdict[d] = [dd for dd in mdivs if d%dd==0]

nbin = list(map(int,format(n,'b')))
nnbin = len(nbin)
dpdicts = [defaultdict(int) for i in range(nnbin)]
for d in mdivs:
    dpdicts[0][d]=1

cut = 10**9+7

for i in range(1,nnbin):
    for d in mdivs:
        dpdicts[i][d] = sum(map(lambda x:dpdicts[i-1][x]*dpdicts[i-1][d//x],divsdict[d]))%(10**9+7)

dpdictbin = defaultdict(int)
for d in mdivs:
    dpdictbin[d]=0
dpdictbin[1]=1

nbin.reverse()
for i in filter(lambda x:nbin[x]==1,range(nnbin)):
    for d in mdivs:
        dpdictbin[d] = sum(map(lambda x:dpdictbin[x]*dpdicts[i][d//x],divsdict[d]))%(10**9+7)



print(dpdictbin[m])
### BUGGY CODE ###

s = input()
t = input()

dp = ['']* len(t)
# dp_len = [0]* len(t)

for i in range(len(s)):
    s_temp = s[i]
    temp_max = ''
    max_len = 0
    for j in range(len(t)):
        before = dp[j]
        if(s_temp == t[j]):
            dp[j] = temp_max + s_temp
        if(max_len < len(before)):
            temp_max = before
            max_len = len(temp_max)

ans = ''
for j in range(len(t)):
    if(len(dp[j]) > len(ans)):
        ans = dp[j]

print(ans)

### FIXED CODE ###

s = input()
t = input()

s_len = len(s)
t_len = len(t)

dp = [[0] * (t_len+1) for _ in range(s_len+1)]

for i in range(1,s_len+1):
    s_temp = s[i-1]
    for j in range(1, t_len+1):
        if(s_temp == t[j-1]):
            dp[i][j] = max(dp[i-1][j], dp[i][j-1], dp[i-1][j-1] + 1)
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

ans = ''
while(s_len > 0 and t_len > 0):
    if(dp[s_len][t_len] == dp[s_len-1][t_len]):
        s_len -= 1
    elif(dp[s_len][t_len] == dp[s_len][t_len-1]):
        t_len -= 1
    else:
        ans = s[s_len-1]  + ans
        s_len -= 1
        t_len -= 1

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

n = int(input())

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

a.sort()

dp = [True] * n

for i in range(len(a) - 1):
    if dp[i] == True:
        for j in range(1, n - i):
            if dp[i + j] == True:
                if a[i + j] % a[i] == 0:
                    dp[i + j] = False
        
        if a[i] == a[i + 1]:
            dp[i] = False

print(sum(dp))

### FIXED CODE ###

n = int(input())

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

a.sort()

dp = [True] * (a[-1] + 1)

ans = 0

m = a[-1]

for i, x in enumerate(a[:-1]):
    if not a[i+1] == x and dp[x]:
        ans += 1
    for b in range(x, m + 1, x):
        dp[b] = False

if dp[a[-1]]:
    ans += 1

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

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


class RangeMinimumQuery:
    def __init__(self, n, inf=2 ** 31 - 1):
        self.n = 1 << (n - 1).bit_length()
        self.INF = inf
        self.segtree = [self.INF] * (2 * self.n)

    # i番目の値(0-indexed)をxに変更
    def update(self, i, x):
        i += self.n
        self.segtree[i] = x
        while i > 0:
            i //= 2
            self.segtree[i] = min(self.segtree[2 * i], self.segtree[2 * i + 1])

    # [l, r)のmin
    def query(self, l, r):
        L, R = l + self.n, r + self.n
        R = min(R, len(self.segtree))
        s = self.INF
        while L < R:
            if L & 1:
                s = min(s, self.segtree[L])
                L += 1

            if R & 1:
                s = min(s, self.segtree[R - 1])
                R -= 1

            L >>= 1
            R >>= 1

        return s


# 番兵を設置
A = [0] + A + [0]
N = N + 2


# セグ木を初期化
RMQ = RangeMinimumQuery(N)
for i, a in enumerate(A):
    RMQ.update(i, a)


# r_indexes := 自分より右側であって、最も近い、自分より小さなもののindex
# l_indexes := 自分より左側であって、最も近い、自分より小さなもののindex
r_indexes = [None] * N
l_indexes = [None] * N


# 右側についてにぶたん := iからm内の区間最小値がai以上か？
for i, a in enumerate(A[1: -1], start=1):
    ok, ng = i, N - 1
    while abs(ok - ng) > 1:
        m = (ok + ng) // 2

        if a <= RMQ.query(i, m + 1):
            ok = m
        else:
            ng = m

    r_indexes[i] = ok + 1

# 左側についてにぶたん := iからm内の区間最小値がai以上か？
for i, a in enumerate(A[1: -1], start=1):
    ok, ng = i, 0
    while abs(ok - ng) > 1:
        m = (ok + ng) // 2

        if a <= RMQ.query(m, i + 1):
            ok = m
        else:
            ng = m

    l_indexes[i] = ok - 1


# 答えを計算
ans = 0
for i, (a, l, r) in enumerate(zip(A[1: -1], l_indexes[1: -1], r_indexes[1: -1]), start=1):
    ans += a * (i - l) * (r - i)

print(ans)


### FIXED CODE ###

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

d = [0] * (N+1)
for i in range(N):
    d[a[i]] = i

left = list(range(N+1))
right = list(range(N+1))

ans = 0
for i in range(N, 0, -1):
    di = d[i]
    ans += i * (right[di]-di+1) * (di-left[di]+1)
    right[left[di] - 1] = right[di]
    left[right[di] + 1] = left[di]

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

S = input()
Q = int(input())

for i in range(Q):
    q = input()
    if q == '1':
        S = S[::-1]
        continue
    t,f,c = q.split()
    if f == '1':
        S = c + S
    else:
        S = S + c

print(S)

### FIXED CODE ###

S = input()
Q = int(input())



front = ''
back = ''

r_flg = False
for i in range(Q):
    q = input()
    if q == '1':
        r_flg = False if r_flg else True
        continue
        
    t,f,c = q.split()
    if not r_flg:
        if f == '1':
            front += c
        else:
            back += c
    else:
        if f == '1':
            back += c
        else:
            front += c
    
if not r_flg:
    print(front[::-1]+S+back)
else:
    print(back[::-1] + S[::-1] + front)
### BUGGY CODE ###

n = int(input())
A = tuple(map(int, input().split()))
fact_counts = dict()
def fact(n):
    if n%2 == 0:
        fact_counts.setdefault(2, 0)
        fact_counts[2] += 1
    while n%2 == 0:
        n //= 2

    for f in range(3, int(n**0.5)+1, 2):
        if n%f == 0:
            fact_counts.setdefault(f, 0)
            fact_counts[f] += 1
        while n%f == 0:
            n //= f
    if n > 1:
        fact_counts.setdefault(n, 0)
        fact_counts[n] += 1

for a in A:
    fact(a)

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == n:
        print('not coprime')
    else:
        print('setwise coprime')


### FIXED CODE ###

N = int(input())
A = tuple(map(int, input().split()))
maxa = max(A)
min_facts = [0] * (maxa+1)
def p(n):
    """ """
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if not is_prime[i]:
            continue
        min_facts[i] = i
        
        for j in range(i*2, n+1, i):
            is_prime[j] = False
            if min_facts[j] == 0:
                min_facts[j] = i
p(maxa)
fact_counts = dict()
for a in A:
    while min_facts[a] > 0:
        f = min_facts[a]
        fact_counts.setdefault(f, 0)
        fact_counts[f] += 1
        while a%f == 0:
            a //= f

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == N:
        print('not coprime')
    else:
        print('setwise coprime')