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

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

#print(N)
#print(P)

SUCCESS = N
pre_max = P[0]
pre_min = P[0]
for i in range(N):
    j = i - 1
    if pre_max < P[i]:
        #print(i, j, pre_max)
        pre_max = P[j]
        SUCCESS -= 1
        continue
    if pre_min < P[i]:
        #print(i, j, pre_min)
        #pre_min = P[j]
        SUCCESS -= 1
        continue
    while j >= 0:
        if pre_min > P[j]:
            pre_min = P[j]      
        if P[i] > P[j]:
            #print("Fail", i,j)
            SUCCESS -= 1
            break        
        j -= 1

print(SUCCESS)

### FIXED CODE ###

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

#print(N)
#print(P)

SUCCESS = N
pre_max = P[0]
pre_min = P[0]
for i in range(N):
    j = i - 1

    if pre_min < P[i]:
        SUCCESS -= 1
        continue
    else:
        pre_min = P[i]
print(SUCCESS)
### BUGGY CODE ###

n = int(input())
a = [0] + list(map(int,input().split()))

def binp(arr, val):
    left,right = 0,len(arr)-1
    while left <= right:
        mid = (left+right)//2
        if val==arr[mid]: return 1
        elif val>=arr[mid]: left = mid+1
        else: right = mid-1
    return 0

ap = [a[i] + i for i in range(1,n+1)]
an = [i - a[i] for i in range(1,n+1)]
an.sort()

ans = 0
for ele in ap:
    if binp(an,ele): ans += an.count(ele)

print(ans)


### FIXED CODE ###

import collections as col

n = int(input())
a = [0] + list(map(int,input().split()))

def binp(arr, val):
    left,right = 0,len(arr)-1
    while left <= right:
        mid = (left+right)//2
        if val==arr[mid]: return 1
        elif val>=arr[mid]: left = mid+1
        else: right = mid-1
    return 0

ap = [a[i] + i for i in range(1,n+1)]
an = [i - a[i] for i in range(1,n+1)]
counter = col.Counter(an)

ans = 0
for ele in ap:
    ans += counter[ele]

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

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

def tempchange(l,change):
  for i in change:
    B,C = i[0],i[1]
    for j in range(B):
      if C > l[0]:
        l[0] = C
        l.sort()
  return l

A.sort()
print(sum(tempchange(A,change)))

### FIXED CODE ###

from heapq import heappush,heappop,heapify

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

def tempchange(l,change):
  heapify(l)  
  for B,C in change:
    for j in range(B):
      a = heappop(l)
      if C - a > 0:
        heappush(l,C)
      else:
        heappush(l,a)
        break
  return sum(l)

#A.sort(reverse = True)
change.sort(key = lambda x:x[1],reverse =True)
print(tempchange(A,change))
### BUGGY CODE ###

N = int(input())
A = tuple(map(lambda n: int(n) - 1, input().split()))

minlen = 10**9
for i in range(1, 2**N):
    remain = 0
    for j in range(N):
        if (i >> j) & 1:
            # 残す
            if A[j] == remain:
                remain += 1
            else:
                break
    else:
        minlen = min(minlen, (N - remain))

if minlen >= N:
    print(-1)
else:
    print(minlen)

### FIXED CODE ###

N = int(input())
A = tuple(map(lambda n: int(n) - 1, input().split()))

rem = 0
bk = 0
for a in A:
    if a == rem:
        rem += 1
    else:
        bk += 1

if bk == N:
    print(-1)
else:
    print(bk)
### BUGGY CODE ###

S=input()
ans=0
while 1:
    flg=True
    for i in range(len(S)-1):
        if S[i]!=S[i+1]:
            ans+=1
            S=S[:i]+S[i+2:]
            flg=False
            break
    if flg:
        break
print(ans*2)

### FIXED CODE ###

S=input()
a=S.count('1')
b=S.count('0')
print(min(a,b)*2)
### BUGGY CODE ###

def mid(n):
    return int((n + 1) / 2)

N = int(input())
X = list(map(int, input().split()))
save = X[:]
for i in range(N):
    X = save[:]
    del X[i]
    X.sort()
    print(X[mid(N - 1) - 1])



### FIXED CODE ###

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

save = X[:]

save.sort()

midL = save[int(N / 2 - 1)]
midR = save[int(N / 2)]

for i in X:
    if i <= midL:
        print(midR)
    else:
        print(midL)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**9)

N = int(input())
a_list=[]
b_list=[]
graph = [[] for i in range(N)]

for i in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append((b,i))
    graph[b-1].append((a,i))
    
ans = [0 for i in range(N-1)]
ten_col = [[] for i in range(N)]
def dfs(start,now):
    for (future,i) in graph[now-1]:
        if future == start:
            pass
        else:
            new_col = 1
            while new_col in ten_col[now-1]:
                new_col += 1
            ten_col[now-1].append(new_col)
            ten_col[future-1].append(new_col)
            ans[i] = new_col

            dfs(now,future)
            
dfs(-1,1)
print(max(ans))
for i in ans:
    print(i)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

N = int(input())

graph = [[] for i in range(N)]

for i in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append((b,i))
    graph[b-1].append((a,i))
    
ans = [0]*(N-1)

def dfs(past,now,edge_col):
    new_col = 1
    for (future,i) in graph[now-1]:
        if future == past:
            pass
        else:
            if new_col == edge_col:
                new_col += 1
            ans[i] = new_col
            dfs(now,future,new_col)
            new_col += 1
            
dfs(-1,1,-1)

print(max(ans))
for i in ans:
    print(i)
### BUGGY CODE ###

n,a,b=list(map(int,input().split()))
from math import factorial as f
ans=1
ans2=1
for i in range(n-a):
    ans*=(n-i)
for i in range(n-b):
    ans2*=(n-i)
print(int(2**n-ans/f(n-a)-ans2/f(n-b)-1))

### FIXED CODE ###

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

p=10**9+7
ans1=1
ans2=1

for i in range(n-a+1,n+1):
    ans1*=i
    ans1%=p

for i in range(1,a+1):
    ans1*=pow(i,p-2,p)
    ans1%=p
    
for i in range(n-b+1,n+1):
    ans2*=i
    ans2%=p

for i in range(1,b+1):
    ans2*=pow(i,p-2,p)
    ans2%=p

print((pow(2,n,p)-ans1-ans2-1)%p)
### BUGGY CODE ###

def two_input():
    return map(int, input().split())

N, M = two_input()
LR = [list(two_input()) for i in range(M)]

cnt = 0
for i in range(1, N+1):
    cnt += 1
    for j in range(M):
        if LR[j][0] > i or LR[j][1] < i:
            cnt -= 1
            break

print(cnt)

### FIXED CODE ###

def two_input():
    return map(int, input().split())

N, M = two_input()
L, R = [], []
for i in range(M):
    l, r = two_input()
    L.append(l)
    R.append(r)
    
maxl = max(L)
minr = min(R)

ans = 0
for i in range(N):
    if maxl <= i+1 <= minr:
        ans += 1

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

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

B = {}
for i in range(N):
    if A[i] not in list(B.keys()):
        B[A[i]] = A.count(A[i])

num = len(B)
C = list(B.values())
C.sort()
ans = 0
if num>K:
    ans = sum(C[0:num-K])
print(ans)


### FIXED CODE ###

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

B = [0]*N
for i in range(N):
    B[A[i]-1]+=1

B.sort()

print(sum(B[0:N-K]))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
s = input()

d = {}

for i in range(n-2):
    for j in range(i+1, n-1):
        for l in range(j+1, n):
            r = ""
            r = s[i] + s[j] + s[l]
            if r not in d:
                d[r] = 0
            d[r] += 1

print(len(d))

### FIXED CODE ###

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

ans = 0
for i in range(1000):
    i = str(i)
    i = (3-len(i)) * '0' + i
    r = 0
    for j in range(n):
        if s[j] == i[r]:
            r += 1
        if r == 3:
            break
    if r == 3:
        ans +=1

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

n,m = map(int,input().split(' '))
cost = 0
count = 0

mlist = list()
for i in range(n):
  mlist.append(list(map(int,input().split(' '))))
mlist.sort(key=lambda x: x[0])
#  print(mlist)


for i in range(n):
  ablist = mlist[i]
#  print(ablist)
  for j in range(ablist[1]):
    count += 1
    if count <= m:
      cost += ablist[0]
#      print(count,"本", cost,"円")
print(cost)



### FIXED CODE ###

n,m = map(int,input().split(' '))
cost = 0
count = 0

mlist = list()
for i in range(n):
  mlist.append(list(map(int,input().split(' '))))
mlist.sort(key=lambda x: x[0])

for i in range(n):
  ablist = mlist[i]
  if count+ablist[1] <= m:
    count += ablist[1]
    cost += ablist[0]*ablist[1] 
  else:
    for j in range(ablist[1]):
      count += 1
      if count <= m:
        cost += ablist[0]
      else:
        break_t = True
        break
    if break_t:
      break
print(cost)
### BUGGY CODE ###

import sys

N = int(sys.stdin.readline().rstrip())
S = sys.stdin.readline().rstrip()

if len(set(S)) == 1 or N < 3:
    print(0)
    sys.exit()

def check(i, j, k):
    if j - i == k - j:
        return False
    if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
        return True
    else:
        return False

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            if check(i, j, k):
                ans += 1

print(ans)

### FIXED CODE ###

import sys

N = int(sys.stdin.readline().rstrip())
S = sys.stdin.readline().rstrip()

if len(set(S)) == 1 or N < 3:
    print(0)
    sys.exit()

Rs = S.count("R")
Gs = S.count("G")
Bs = S.count("B")
ans = Rs * Gs * Bs


for i in range(N - 1):
    for j in range(i + 1, N):
        k = j + (j - i)
        if k >= N: break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1
print(ans)
### BUGGY CODE ###

from collections import deque,Counter
N,T=map(int, raw_input().split())
A=map(int, raw_input().split())

q=deque(A)
max_n=max(q)


b=[]
for i in range(N-1):
	q.popleft()
	if A[i]==max_n:
		max_n=max(q)

	b.append(max_n-A[i])

C=Counter(b)
max_key=max(C.keys())

print C[max_key]

### FIXED CODE ###

from collections import Counter
N,T=map(int, raw_input().split())
A=map(int, raw_input().split())

A_r=[None for i in range(N)]
n=0
for i in range(N-1,-1,-1):
	n=max(A[i],n)
	A_r[i]=n

B=[]
for i in range(N-1):
	B.append(A_r[i+1]-A[i])


C=Counter(B)

print C[max(B)]
### BUGGY CODE ###

def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    ls = [0] * n
    mt = [0] * n
    cnt = 0
    bbb = 0
    for w in range(10 ** 15):
        cnt += 1
        f = [False] * n
        for i in range(n):
            if ls[i] != -1:
                mt[i] = a[i][ls[i]]
        bb = False
        for i in range(n):
            if not f[i]:
                if ls[i] != -1:
                    if i + 1 == mt[mt[i]-1]:
                        if ls[i] + 1 < n - 1:
                            ls[i] += 1
                            bb = True
                        else:
                            ls[i] = -1
                            bbb += 1
        if bbb == n:
            print(cnt)
            exit()
        if not bb:
            print(-1)
            exit()


if __name__ == '__main__':
    slove()


### FIXED CODE ###

def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    ad = [0] * n
    dq = collections.deque([[0, i + 1] for i in range(n)])
    for i in range(10 ** 15):
        fd = {}
        while True:
            if len(dq) != 0:
                d, q = dq.popleft()
                q -= 1
                if d <= i:
                    if ad[q] < n - 1:
                        qq = a[q][ad[q]] - 1
                        tq = a[qq][ad[qq]] - 1
                        if q == tq and qq not in fd and tq not in fd:
                            ad[qq] += 1
                            ad[tq] += 1
                            if ad[qq] < n - 1:
                                dq.append([d + 1, qq + 1])
                            if ad[tq] < n - 1:
                                dq.append([d + 1, tq + 1])
                            fd[qq] = 0
                            fd[tq] = 0
                else:
                    dq.append([d, q + 1])
                    break
            else:
                break
        if len(dq) == 0:
            b = True
            for v in ad:
                if v != n - 1:
                    b = False
                    break
            if b:
                print(i + 1)
                exit()
            else:
                print(-1)
                exit()


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

import heapq

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

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

for i in range(M):
    uvab[i][0] -= 1
    uvab[i][1] -= 1

railways = [[] for _ in range(N)]
max_a = 0
for u, v, a, b in uvab:
    railways[u].append((v, a, b))
    railways[v].append((u, a, b))
    max_a = max(max_a, a)
del uvab

max_silver = max_a * (N - 1)

ans = [-1] * N
d = dict()
d[(S, 0)] = 0  # silver, station
Q = [(0, S, 0)]  # time, silver, station
sum_reached = 0
reached = [False] * N

while Q:
    t, sv, st = heapq.heappop(Q)
    if not reached[st]:
        ans[st] = t
        reached[st] = True
        sum_reached += 1
        if sum_reached == N:
            break

    new_key = (sv + cd[st][0], st)
    new_value = t + cd[st][1]
    if new_key not in d or d[new_key] > new_value:
        d[new_key] = t + cd[st][1]
        heapq.heappush(Q, (new_value, *new_key))

    for dist, a, b in railways[st]:
        if sv >= a:
            new_key = (sv - a, dist)
            new_value = t + b
            if new_key not in d or d[new_key] > new_value:
                d[new_key] = new_value
                heapq.heappush(Q, (new_value, *new_key))

print(*ans[1:], sep="\n")


### FIXED CODE ###

import heapq

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

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

for i in range(M):
    uvab[i][0] -= 1
    uvab[i][1] -= 1

railways = [[] for _ in range(N)]
max_a = 0
for u, v, a, b in uvab:
    railways[u].append((v, a, b))
    railways[v].append((u, a, b))
    max_a = max(max_a, a)
del uvab

max_silver = max_a * (N - 1)

ans = [-1] * N
d = dict()
d[(S, 0)] = 0  # silver, station
Q = [(0, S, 0)]  # time, silver, station
sum_reached = 0
reached = [False] * N

while Q:
    t, sv, st = heapq.heappop(Q)
    if not reached[st]:
        ans[st] = t
        reached[st] = True
        sum_reached += 1
        if sum_reached == N:
            break

    new_key = (min(max_silver, sv + cd[st][0]), st)
    new_value = t + cd[st][1]
    if new_key not in d or d[new_key] > new_value:
        d[new_key] = t + cd[st][1]
        heapq.heappush(Q, (new_value, *new_key))

    for dist, a, b in railways[st]:
        if sv >= a:
            new_key = (sv - a, dist)
            new_value = t + b
            if new_key not in d or d[new_key] > new_value:
                d[new_key] = new_value
                heapq.heappush(Q, (new_value, *new_key))

print(*ans[1:], sep="\n")
### BUGGY CODE ###

l,r = map(int,input().split())

m = 10000000000000000
cnt_i = 0
for i in range(l,r+1):
    cnt_j = 0
    if cnt_i == 2019:
        break
    cnt_i += 1
    for j in range(i+1,r+1):
        if cnt_j == 2019:
            break
        cnt_j += 1
        m = min(m,i%2019*j%2019)
print(m)


### FIXED CODE ###

l,r = map(int,input().split())

if r-l >= 672:
    m = 0
else:
    m = 10000000000000000
    cnt_i = 0
    for i in range(l,r+1):
        cnt_j = 0
        if cnt_i == 2019:
            break
        cnt_i += 1
        for j in range(i+1,r+1):
            if cnt_j == 2019:
                break
            cnt_j += 1
            m = min(m,i%2019*j%2019)
print(m)
### BUGGY CODE ###

import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    N = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zer
    ans = [0]*N
    x,y,z = 1,1,1
    a = x**2 + y**2 + z**2 +x*y + y*z + z*x

    for x in range(1,N):
        for y in range(1,N):
            for z in range(1,N):
                a = x**2 + y**2 + z**2 +x*y + y*z + z*x
                if a > N:
                    break
                s = set([x,y,z])
                if len(s) == 1:
                    ans[a-1] = 1
                elif len(s) == 2:
                    ans[a-1] = 3
                else:
                    ans[a-1] = 6

    for i in range(N):
        print(ans[i])



if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    N = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zer
    ans = [0]*N
    for x in range(1,int(N**0.5)+1):
        for y in range(1,int(N**0.5)+1):
            for z in range(1,int(N**0.5)+1):
                a = x**2 + y**2 + z**2 +x*y + y*z + z*x
                if a > N:
                    break
                ans[a-1] += 1

    for i in range(N):
        print(ans[i])



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

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

ans = n

for i in range(0, n):
  kaeru = sum(s[j] == 'W' for j in range(i)) + sum(s[j] == 'E' for j in range(i+1,n))
  
  ans = min(kaeru, ans)
print(ans)


### FIXED CODE ###

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

w = [0] * n
for i in range(n-1):
  w[i+1] = w[i] + int(s[i] == 'W')
    
    
e = [0] * n
for i in reversed(range(1, n)):
  e[i-1] = e[i] + int(s[i] == 'E')
    
print(min(ww+ee for ww, ee in zip(w, e)))
### BUGGY CODE ###

import math
num = 100000
s = set([i for i in range(2,num+1)])
p = set()
mi = 0
while mi<=math.sqrt(num):
    mi = min(s)
    t = set([i*mi for i in range(1,num//mi+1)])
    p.add(mi)
    s-=t
p = p|s
p2 = set([i for i in p if (i+1)//2 in p])

q = int(input())
for i in range(q):
    l , r = map(int, input().split())
    s2 = set([i for i in range(l,r+1) if i in p2])
    print(len(s2))

### FIXED CODE ###

import math
num = 100000
s = set([i for i in range(2,num+1)])
p = set()
mi = 0
while mi<=math.sqrt(num):
    mi = min(s)
    t = set([i*mi for i in range(1,num//mi+1)])
    p.add(mi)
    s-=t
p = p|s
p2 = set([i for i in p if (i+1)//2 in p])
c = 0
x = [0]*100001
for i in range(1,num+1):
    if i in p2:
        c+=1
    x[i]=c

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

X = input()
X = list(X)
prev = ""
for i in range(len(X) - 1):
    if X[i] + X[i + 1] == "ST":
        X.insert(0,X.pop(i))
        X.insert(1,X.pop(i+1))


for i in range(0, len(X)):
    if X[len(X) - (i+1)] == "T":
        print(i * 2)
        break

### FIXED CODE ###

X = input()
Y = []
for i in X:
    Y.append(i)
    if len(Y) > 1:
        if Y[-2] + Y[-1] == "ST":
            Y.pop()
            Y.pop()
print(len(Y))
### BUGGY CODE ###

A,B,K=map(int,input().split())
L={i for i in range(A,A+K)}
R={i for i in range(B-K+1,B+1)}
S=[i for i in range(A,B+1) if i in L or i in R]
for i in range(len(S)):
  print(S[i])

### FIXED CODE ###

A,B,K=map(int,input().split())
S=[i for i in range(A,B+1) if i<A+K or i>=B-K+1]
for i in range(len(S)):
  print(S[i])
### BUGGY CODE ###

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

class Node:
    def __init__(self, root):
        self.root = root
        self.children = []
        self.val = 0

    def add_child(self, child_node):
        self.children.append(child_node)
        if self.root is not None:
            self.root.add_child(child_node)

    def calc(self):
        res = self.val
        curr = self
        while True:
            root = curr.root
            if root is None:
                break
            res += root.val
            curr = root
        return res

nodes = [Node(None)] * n

for i in range(1, n):
    a, b = map(int, input().split())
    a_node = nodes[a - 1]
    nodes[b - 1] = Node(a_node)
    a_node.add_child(nodes[b - 1])

for j in range(q):
    p, x = map(int, input().split())
    node = nodes[p - 1]
    node.val += x
    # children = node.children
    # for child in children:
    #     child.val += x

res = []
for node in nodes:
    res.append(str(node.calc()))
print(" ".join(res))

### FIXED CODE ###

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

children_map = [None] * n
vals = [0] * n

for i in range(1, n):
    a, b = map(int, input().split())
    children_map[b - 1] = a - 1

for j in range(q):
    p, x = map(int, input().split())
    vals[p - 1] += x

res = []
for i in range(n):
    parent = children_map[i]
    if parent is not None:
        vals[i] += vals[parent]
    res.append(str(vals[i]))

print(" ".join(res))