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

R, C, K = map(int, input().split())

V = [[0]*(C+1) for _ in range(R+1)]
dp = [[[0,0,0,0] for _ in range(C+1)] for _ in range(R+1)]

for _ in range(K):
    r, c, v = map(int, input().split())
    V[r][c] = v

for r in range(1,R+1):
    for c in range(1,C+1):
        v = V[r][c]
        if v==0:
            dp[r][c][0] = max(max(dp[r-1][c]), dp[r][c-1][0])
            for n in range(1,4):
                dp[r][c][n] = dp[r][c-1][n]
        else:
            dp[r][c][0] = max(max(dp[r-1][c]), dp[r][c-1][0])
            dp[r][c][1] = max(max(dp[r-1][c])+v, dp[r][c-1][0]+v, dp[r][c-1][1])
            dp[r][c][2] = max(dp[r][c-1][1]+v, dp[r][c-1][2])
            dp[r][c][3] = max(dp[r][c-1][2]+v, dp[r][c-1][3])

print(max(dp[R][C]))


### FIXED CODE ###

R, C, K = map(int, input().split())

V = [[0]*(C+1) for _ in range(R+1)]
dp1 = [[0,0,0,0] for _ in range(C+1)]

for _ in range(K):
    r, c, v = map(int, input().split())
    V[r][c] = v

for r in range(1,R+1):
    dp0 = dp1
    dp1 = [[0,0,0,0] for _ in range(C+1)]
    
    for c in range(1,C+1):
        v = V[r][c]
        dprc  = dp1[c]
        dprcL = dp1[c-1]
        if v==0:
            dprc[0] = max(max(dp0[c]), dprcL[0])
            for n in range(1,4): dprc[n] = dprcL[n]
        else:
            maxT = max(dp0[c])
            dprc[0] = max(maxT  ,             dprcL[0])
            dprc[1] = max(maxT+v, dprcL[0]+v, dprcL[1])
            dprc[2] = max(        dprcL[1]+v, dprcL[2])
            dprc[3] = max(        dprcL[2]+v, dprcL[3])
        

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

n, q = (int(i) for i in input().split())  
s = input()
l = []
r = []

for i in range(q):
  tmp = [int(j) for j in input().split()]
  l.append(tmp[0])
  r.append(tmp[1])
  
search = [0]
for i in range(1,n):
  if s[i-1:i+1] == "AC":
    search.append(1)
  else:
    search.append(0)

for i in range(q):
  ans = sum(search[l[i]-1:r[i]])
  if search[l[i]-1] == 1:
    ans -= 1
  print(ans)



### FIXED CODE ###

n, q = (int(i) for i in input().split())  
s = input()
t = [0] * (n+1)

for i in range(n):
  if s[i:i+2] == "AC":
    t[i+1] = t[i] + 1
  else:
    t[i+1] = t[i]
    
for i in range(q):
  l, r = (int(i) for i in input().split())
  print(t[r-1] - t[l-1])
### 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):
  a=s[i]
  for j in range(i+1,N-1):
    if a==s[j]:
      continue
    b=s[j]
    k=2*j-i
    if "R" not in a+b:
      try:
        if s[k]=="R":
          ans-=1
      except:
        pass
      
    if "G" not in a+b:
      try:
        if s[k]=="G":
          ans-=1
      except:
        pass
      
    if "B" not in a+b:
      try:
        if s[k]=="B":
          ans-=1
      except:
        pass

print(ans)


### FIXED CODE ###

N=int(input())
s=input()
R=[0]
G=[0]
B=[0]
ans=0
#RGBの累積和を作る
for i in range(N):
  if s[i]=="R":
    R[i]+=1
  elif s[i]=="G":
    G[i]+=1
  else:
    B[i]+=1
  R.append(R[i])
  G.append(G[i])
  B.append(B[i])
del R[-1]
del G[-1]
del B[-1]
#作った

#全探索する
for i in range(N-2):
  a=s[i]
  for j in range(i+1,N-1):
    if a==s[j]:
      continue
    b=s[j]
    k=2*j-i
    if "R" not in a+b:
      ans+=R[-1]-R[j]
      try:
        if s[k]=="R":
          ans-=1
      except:
        pass
    
    if "G" not in a+b:
      ans+=G[-1]-G[j]
      try:
        if s[k]=="G":
          ans-=1
      except:
        pass
        
    if "B" not in a+b:
      ans+=B[-1]-B[j]
      try:
        if s[k]=="B":
          ans-=1
      except:
        pass
print(ans)
### BUGGY CODE ###

#!/usr/bin/python3
import sys
input = lambda: sys.stdin.readline().strip()
h, w = [int(x) for x in input().split()]
g = [input() for i in range(h)]
dirs = [(-1, 0), (1, 0), (0, -1), (0, 1)]
hit = [[[0 for j in range(w)] for i in range(h)] for dire in dirs]
for d, dire in enumerate(dirs):
    di, dj = dire
    for i in range(h) if di < 0 else reversed(range(h)):
        for j in range(w) if dj < 0 else reversed(range(w)):
            if g[i][j] != '#':
                hit[d][i][j] = (hit[d][i + di][j + dj] if 0 <= i + di < h and 0 <= j + dj < w else 0) + 1
print(max(sum(hit[d][i][j] for d in range(len(dirs))) - 3 for i in range(h) for j in range(w) if g[i][j] != '#'))

### FIXED CODE ###

#!/usr/bin/python3
import sys
input = lambda: sys.stdin.readline().strip()
h, w = [int(x) for x in input().split()]
g = [input() for i in range(h)]
dirs = [(-1, 0), (1, 0), (0, -1), (0, 1)]
hit = [[[0 for j in range(w)] for i in range(h)] for dire in dirs]
for d, dire in enumerate(dirs):
    di, dj = dire
    for i in range(h) if di < 0 else reversed(range(h)):
        for j in range(w) if dj < 0 else reversed(range(w)):
            if g[i][j] != '#':
                hit[d][i][j] = (hit[d][i + di][j + dj] if 0 <= i + di < h and 0 <= j + dj < w else 0) + 1
print(max(sum(hit[d][i][j] for d in range(len(dirs))) - 3 for i in range(h) for j in range(w) if g[i][j] != '#'))
### BUGGY CODE ###

from collections import deque

h,w=map(int,input().split())
w+=2

a=[list('@'*w)]
for i in range(h):
    a+=[list('@'+input()+'@')]
a+=[list('@'*w)]
h+=2

xy=[(-1,0),(0,-1),(0,1),(1,0)]
que=deque()

def bfs():
    res=0
    while que:
        x,y=que.popleft()
        for dx,dy in xy:
            nx,ny=dx+x,dy+y
            tmp=A[x][y]+1
            if a[nx][ny]!='@':
                if A[nx][ny]<=tmp:continue
                A[nx][ny]=tmp
                que.append((nx,ny))
                res=max(res,tmp)
    return res


A=[[float('inf')]*w for i in range(h)]

res=0
for i in range(1,h-1):
    for j in range(1,w-1):
        if a[i][j]=='#':
            A[i][j]=0
            que.append((i,j))

res=bfs()
print(res)



### FIXED CODE ###

from collections import deque

h,w=map(int,input().split())
w+=2

a=[list('@'*w)]
for i in range(h):
    a+=[list('@'+input()+'@')]
a+=[list('@'*w)]
h+=2

xy=[(-1,0),(0,-1),(0,1),(1,0)]
que=deque()

def bfs():
    res=0
    while que:
        x,y=que.popleft()
        for dx,dy in xy:
            nx,ny=dx+x,dy+y
            tmp=A[x][y]+1
            if a[nx][ny]!='@':
                if A[nx][ny]<=tmp:continue
                A[nx][ny]=tmp
                que.append((nx,ny))
                res=max(res,tmp)
    return res


A=[[float('inf')]*w for i in range(h)]

res=0
for i in range(1,h-1):
    for j in range(1,w-1):
        if a[i][j]=='#':
            A[i][j]=0
            que.append((i,j))

res=bfs()
print(res)
### BUGGY CODE ###

N = int(input())
numbers = []
for i in range(N):
    numbers.append(int(input()))
    
for n in numbers:
    aaa = max(numbers)
    if aaa == n:
        print(sorted(numbers)[-2])
    else:
        print(aaa)

### FIXED CODE ###

N = int(input())
numbers = []
for i in range(N):
    numbers.append(int(input()))
    
    
aaa = max(numbers)
bbb = sorted(numbers)[-2]

for n in numbers:
    if aaa == n:
        print(bbb)
    else:
        print(aaa)
### BUGGY CODE ###

from collections import Counter

def solve():
  n = int(input())
  A = list(map(int, input().split()))

  # 書かれた番号の頻度
  Freq = sorted(Counter(A).items(), key=lambda x: x[1], reverse=True)

  # 答えのメモ (複数回計算しないように)
  memo = dict()

  for a in A:
    if memo.get(a) != None:
      print(memo[a])
      continue

    ans = 0
    for kv in Freq:
      # 大きい順に見ているので1個になったら終了
      if kv[1] < 2: break
      # key -> value : 番号 -> ボール個数
      cnt = kv[1]
      # 自身は取り除く
      if kv[0] == a: cnt -= 1
      # 2個未満はスキップ
      if cnt < 2: continue
      # 2つ選ぶ方法は n*(n-1)//2
      ans += cnt * (cnt-1) // 2
    print(ans)
    memo[a] = ans

solve()

### FIXED CODE ###

from collections import Counter

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

# 書かれた番号の頻度
Freq = dict(sorted(Counter(A).items(), key=lambda x: x[1], reverse=True))

# 答えの最大値
ans_max = 0
for kv in Freq.items():
  ans_max += kv[1] * (kv[1] - 1) // 2

for a in A:
  # 1個しか存在しない番号は、取り除いても答えに影響しない
  if Freq.get(a) == 1:
    print(ans_max)
    continue

  # x個の場合と、x-1個の場合と、の差分
  x = Freq.get(a)
  diff = (x * (x-1) // 2) - ((x-1) * (x-2) // 2)

  # そのぶんだけ、答えの最大値から減らす
  ans = ans_max - diff
  print(ans)
### BUGGY CODE ###

from math import factorial

def power(a, b, p): #a^b (mod p)を求める #二分累乗法を使う
    if b == 0:
        return 1
    elif b % 2 == 0:
        x = power(a, b//2, p)
        return x ** 2 % p
    elif b % 2 == 1:
        y = power(a, b-1, p)
        return a * y % p

H, W, A, B = map(int, input().split())
C = H - A
D = W - B
p = 1000000007
b = power(factorial(B-1), p-2, p)
d = power(factorial(D-1), p-2, p)

x = 0
for i in range(C):
    k = factorial(i+B-1) % p
    l = factorial(D+H-i-2) % p
    x += k * l * b * d * power(factorial(i), p-2, p) * power(factorial(H-i-1), p-2, p)
print(x % p)


### FIXED CODE ###

H, W, A, B = map(int, input().split())
C = H - A
D = W - B
p = 1000000007

def power(a, b): #a^b (mod p)を求める #二分累乗法を使う
    if b == 0:
        return 1
    elif b % 2 == 0:
        return power(a, b//2) ** 2 % p
    else:
        return power(a, b//2) ** 2 * a % p

f = [1] #f[i] = i! % p
for i in range(H+W):
    f.append(f[i] * (i+1) % p)

I_f = [0] * (H+W+1) #I_f[i] = (i!)^(-1) % p
I_f[H+W] = power(f[H+W], p-2)
for i in reversed(range(H+W)):
    I_f[i] = I_f[i+1] * (i+1) % p

def combi(a, b): #(a+b)!/a!b! (mod p)を求める
    return f[a+b] * I_f[a] * I_f[b] % p

x = 0
for i in range(C):
    x = (x + combi(i, B-1) * combi(D-1, H-i-1)) % p
print(x)
### BUGGY CODE ###

from collections import Counter

n = int(input())
s = [input() for _ in range(n)]

c = Counter(s)
ans_number = c.most_common()[0][1]
    
s_max = []
for i in range(n):
  if s.count(s[i]) == ans_number:
    s_max.append(s[i])
    
s_max = list(set(s_max))
s_max.sort()
for i in range(len(s_max)):
  print(s_max[i])

### FIXED CODE ###

from collections import Counter

n = int(input())
s = [input() for _ in range(n)]

c = Counter(s)
c = c.most_common()
ans_number = c[0][1]
c.sort()

for i in range(len(c)):
  if c[i][1] == ans_number:
    print(c[i][0])
### BUGGY CODE ###

N,M=map(int,input().split())
H=[int(h) for h in input().split()]
AB=[]
cnt=0
for i in range(M):
    A,B=map(int,input().split())
    AB.append([A,B])
NUMBERS=[int(x) for x in range(1,N+1)]

for i in range(M):
    if AB[i][0] in NUMBERS or AB[i][1] in NUMBERS:
        if H[AB[i][0]-1]>H[AB[i][1]-1]:
            if AB[i][1] in NUMBERS:
                NUMBERS.remove(AB[i][1])
        elif H[AB[i][0]-1]==H[AB[i][1]-1]:
            if AB[i][0] in NUMBERS:
                NUMBERS.remove(AB[i][0])
            if AB[i][1] in NUMBERS:
                NUMBERS.remove(AB[i][1])
        else:
            if AB[i][0] in NUMBERS:
                NUMBERS.remove(AB[i][0])
print(len(NUMBERS))


### FIXED CODE ###

N,M=map(int,input().split())
H=[int(h) for h in input().split()]
cnt=[0]*N
for i in range(M):
    a,b=map(int,input().split())
    if H[a-1]>H[b-1]:
        cnt[b-1]+=1
    elif H[a-1]==H[b-1]:
        cnt[a-1]+=1
        cnt[b-1]+=1
    else:
        cnt[a-1]+=1
print(cnt.count(0))
### BUGGY CODE ###

A,B,C,K = map(int, input().split())
count = 0
ans = 0
while(count < K):
    for i in range(A):
        if (count == K):
            break
        ans += 1
        count += 1

        #print("A")
    for i in range(B):
        if (count == K):
            break
        count += 1
        #print("B")
    for i in range(C):
        if (count == K):
            break
        ans -= 1
        count += 1
        #print("C")

print(ans)

### FIXED CODE ###

A,B,C,K = map(int, input().split())
count = 0
ans = 0

if(A+B>=K):
    if(A>K):
        ans = K
    else:
        ans = A
else:
    count = K-(A+B)
    ans = A - count

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

k,s = map(int, input().split())
ans = 0
for x in range(k+1):
    if x>s:
        break
    for y in range(k+1):
        if x+y>s:
            break
        for z in range(k+1):
            if x+y+z==s:
                ans += 1
                break
print(ans)

### FIXED CODE ###

k,s = map(int, input().split())
ans = 0
for x in range(k+1):
    if x>s:
        break
    for y in range(k+1):
        if x+y<=s and s-(x+y)<=k:
            ans += 1
        if x+y>s:
            break
print(ans)
### BUGGY CODE ###

N = input()
ans = 1
A = list(map(int, input().split()))
if 0 in A:
  ans = 0
else:
  for a in A:
    ans *= a
ans = -1 if ans > 10 ** 18 else ans
print(ans)

### FIXED CODE ###

N = int(input())
ans = 1
A = list(map(int, input().split()))
A.sort(reverse=True)
if A[N-1] == 0:
  ans = 0
else:
  for a in A:
    ans *= a
    if ans > 10 ** 18:
      ans = -1
      break
print(ans)
### BUGGY CODE ###

n = int(input().strip())
ans = int(1)
a = map(int, input().strip().split());
for i in a:
	ans *= i
if ans > int(1e18):
	print(-1)
else:
	print(ans)

### FIXED CODE ###

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

	if 0 in A:
		print(0)
		return

	prod = 1
	for a in A:
		prod *= a
		if prod > int(1e18):
			print(-1)
			return

	print(prod)

main()
### BUGGY CODE ###

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

def input_converter(key_string):
    key_string = key_string.replace('A', '1')
    key_string = key_string.replace('T', '2')
    key_string = key_string.replace('C', '3')
    key_string = key_string.replace('G', '4')
    return int(key_string)


class HashTable(object):
    def __init__(self, hash_size = 2 ** 26):
        self.hash_size = hash_size
        self.hash_array = [None] * self.hash_size

    def insert_value(self, data, key):
        collision_number = 0
        next_index = self.hash_function(key, collision_number)
        while self.hash_array[next_index] is not None:
            collision_number += 1
            next_index = self.hash_function(key, collision_number)
        # print self.hash_array[next_index]
        self.hash_array[next_index] = data

    def search_value(self, data, key):
        collision_number = 0
        next_index = self.hash_function(key, collision_number)
        next_data = self.hash_array[next_index]
        while True:
            if (next_data is None) or (collision_number > self.hash_size):
                return False
            elif next_data == data:
                return True
            else:            
                collision_number +=1
                next_index = self.hash_function(key, collision_number)
                next_data = self.hash_array[next_index]

    def hash_function(self, key, collision_number):
        def h1(key):
            return key % self.hash_size
    
        def h2(key):
            return key % (self.hash_size - 1)

        return (h1(key) + collision_number * h2(key)) % self.hash_size


def main():
    input_size = int(raw_input())
    hash_table = HashTable(2 ** 20)
    counter = 0
    while counter < input_size:
        command, key = raw_input().split(' ')
        if command == 'insert':
            hash_table.insert_value(key, input_converter(key))
        else:
            if hash_table.search_value(key, input_converter(key)):
                print 'yes'
            else:
                print 'no'
        counter += 1


if __name__ == '__main__':
    main()

### FIXED CODE ###

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

dictionary = {}
input_num = int(raw_input())
counter = 0
while counter < input_num:
    command, key = raw_input().split(' ')
    if command == 'insert':
        dictionary[key] = None
    else:
        if key in dictionary:
            print 'yes'
        else:
            print 'no'

    counter += 1
### BUGGY CODE ###

n, k = map(int, input().split())
List = list(map(int, input().split()))
score = []
max = 0
index = 0
res = 0

a = n - k + 1
b = k

for i in range(a):
    for j in range(b):
        score.append(List[i+j])
    pre = sum(score)

    if max < pre:
        max = pre
        index = i
        pre = 0
    else:
        pre = 0
    score.clear()

for i in range(index, index+k):
    res += 1 + 0.5 * (List[i]-1)

print(res)

### FIXED CODE ###

n, k = map(int, input().split())
List = list(map(int, input().split()))
score = []
score1 = []

def cal_score(num):
    return 1 + 0.5 * (num - 1)

score.append(cal_score(List[0]))

for i in range(1, n):
    score.append(score[i - 1] + cal_score(List[i]))
    
score1.append(score[k - 1])
m = 0
for i in range(k, n):
    score1.append(score[i] - score[m])
    m += 1

#print(score)    
#print(score1)
print(max(score1))
### BUGGY CODE ###

q = int(input())

def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,int(n**0.5) + 1):
        # 既にfalseになってたらスキップ
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
prime_ls = primes(10**5)

def binary_search(l, item):
    left = 0
    right = len(l) - 1
    while left <= right:
        mid  = (left + right) // 2
        if l[mid] == item:
            return True
        elif l[mid] < item:
            left = mid + 1
        else:
            right = mid - 1
    return False

ans_ls = [0] * q
for i in range(q):
    l,r = map(int,input().split())
    ans = 0
    for j in range(l,r+1):
        if binary_search(prime_ls, j):
            # 2は例外として処理したい
            if binary_search(prime_ls, (j + 1)// 2):
                ans += 1
    ans_ls[i] = ans
for ans in ans_ls:
    print(ans)


### FIXED CODE ###

q = int(input())

def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,int(n**0.5) + 1):
        # 既にfalseになってたらスキップ
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return is_prime
prime_ls = primes(10**5)

csum = [0] * (10**5)
for i in range(1,10**5):
    if prime_ls[i]:
        if prime_ls[(i+1) // 2]:
            csum[i] = csum[i-1] + 1
        else:
            csum[i] = csum[i-1]
    else:
        csum[i] = csum[i-1]

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

# まずDPを使う理由はあるs[i]=t[j]の時 そのs[i],t[j]を追加した時に増える部分列の場合の数は前の部分列の場合の数+1増えるから
# 前の要素を利用するということはDPを疑う
import sys
input=sys.stdin.readline

mod = 10**9 + 7
n,m = map(int, input().split())
s = input().split()
t = input().split()

dp = [[0] * (m+1) for i in range(n+1)]
S = [[0] * (m+1) for i in range(n+1)]

for i in range(n):
    for j in range(m):
        if s[i] == t[j]:
            dp[i+1][j+1] += (S[i][j] + 1)
            dp[i+1][j+1] %= mod
        else:
            dp[i+1][j+1] = 0 # i番目,j番目を追加すると増える場合の数 iとjが等しくないならば場合の数は増えないから0
        S[i+1][j+1] = S[i][j+1] + S[i+1][j] + dp[i+1][j+1] - S[i][j]
        S[i+1][j+1] %= mod

print(S[n][m]+1)

### FIXED CODE ###

# まずDPを使う理由はあるs[i]=t[j]の時 そのs[i],t[j]を追加した時に増える部分列の場合の数は前の部分列の場合の数+1増えるから
# 前の要素を利用するということはDPを疑う
import sys
input=sys.stdin.readline

mod = 10**9 + 7
n,m = map(int, input().split())
s = input().split()
t = input().split()

dp = [[0] * (m+1) for i in range(n+1)]
S = [[0] * (m+1) for i in range(n+1)]

for i in range(n):
    for j in range(m):
        if s[i] == t[j]:
            dp[i+1][j+1] += (S[i][j] + 1)
            dp[i+1][j+1] %= mod
        else:
            dp[i+1][j+1] = 0 # i番目,j番目を追加すると増える場合の数 iとjが等しくないならば場合の数は増えないから0
        S[i+1][j+1] = S[i][j+1] + S[i+1][j] + dp[i+1][j+1] - S[i][j]
        S[i+1][j+1] %= mod

print(S[n][m]+1)
### BUGGY CODE ###

N = int(input())

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    
# BITの定義
import math
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    # index 1からiの値の和を返す
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    # index iの値にxを加算する
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

#######################
# 開始
from operator import itemgetter
def solve():
    p_list = XY[:]

    # y座標の圧縮
    p_list = sorted(p_list, key=itemgetter(1))
    p_list = [ (x, y, i+1) for i, (x, y) in enumerate(p_list)]

    # xでソート
    p_list= sorted(p_list)

    a = [0] * N # 左下
    b = [0] * N# 左上
    c = [0] * N# 右下
    d = [0] * N# 右上

    # a,bを求める
    bit = Bit(N)
    for i, (x, y, r) in enumerate(p_list):
        tmp = bit.sum(r)
        a[i] = tmp
        b[i] = i-tmp
        bit.add(r, 1)

    # c,dを求める
    bit = Bit(N)
    for i, (x, y, r) in enumerate(reversed(p_list)):
        tmp = bit.sum(r)
        c[i] = tmp
        d[i] = i-tmp
        bit.add(r, 1)
    c = c[::-1]
    d = d[::-1]

    # ある点が四角に含まれる場合の総数を求めるメソッド
    power = [1] * N
    for i in range(1, N):
        power[i] = power[i-1] * 2 % 998244353

    ans = 0
    for _a,_b,_c,_d in zip(a,b,c,d):
        _a = power[_a] - 1
        _b = power[_b] - 1
        _c = power[_c] - 1
        _d = power[_d] - 1

        ret = (_a+1) * (_d+1) * _c * _b
        ret += (_b+1) * (_c+1) * _a * _d
        ret -= _a*_b*_c*_d
        ret += power[N-1]
        ans += ret % 998244353

    print(ans % 998244353)
    
solve()


### FIXED CODE ###

N = int(input())

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    
# BITの定義
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    # index 1からiの値の和を返す
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    # index iの値にxを加算する
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

#######################
# 開始
from operator import itemgetter
def solve():
    p_list = XY[:]

    # y座標の圧縮
    p_list = sorted(p_list, key=itemgetter(1))
    p_list = [ (x, y, i+1) for i, (x, y) in enumerate(p_list)]

    # xでソート
    p_list= sorted(p_list)

    # ある点が四角に含まれる場合の総数を求めるメソッド
    power = [1] * N
    for i in range(1, N):
        power[i] = power[i-1] * 2 % 998244353

    # a,bを求める
    bit = Bit(N)
    ans = 0
    for i, (x, y, r) in enumerate(p_list):
        tmp = bit.sum(r)
        a = tmp
        b = i-tmp
        c = r-tmp-1
        d = (N-r+1)-(i-tmp)-1
        bit.add(r, 1)
        _a = power[a] - 1
        _b = power[b] - 1
        _c = power[c] - 1
        _d = power[d] - 1

        ret = (_a+1) * (_d+1) * _c * _b
        ret += (_b+1) * (_c+1) * _a * _d
        ret -= _a*_b*_c*_d
        ret += power[N-1]
        ans += ret % 998244353

    print(ans % 998244353)
    
solve()
### BUGGY CODE ###

n,m,q= map(int,input().split())
lrList=[list(map(int,input().split()))for i in range(m)]
pqList=[list(map(int,input().split()))for i in range(q)]
for pq in pqList:
    ans = list(filter(lambda x: pq[0]<=x[0] and pq[1]>=x[1],lrList))
    print(len(ans))

### FIXED CODE ###

n,m,q= map(int,input().split())
dataList = [[0 for xIndex in range(n+1)]for yIndex in range(n+1)]

for i in range(m):
    xTemp,yTemp = map(int,input().split())
    dataList[yTemp][xTemp]+=1
pqList=[list(map(lambda x:int(x),input().split()))for i in range(q)]
for yIndex in range(1,n+1):
    for xIndex in range(1,n+1):
        dataList[yIndex][xIndex]+=dataList[yIndex][xIndex-1]
for yIndex in range(1,n+1):
    for xIndex in range(1,n+1):
        dataList[yIndex][xIndex]+=dataList[yIndex-1][xIndex]

for pq in pqList:
    p = pq[0]-1
    q = pq[1]
    print(dataList[q][q]+dataList[p][p]-dataList[p][q]-dataList[q][p])
### BUGGY CODE ###

import collections

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

for i in range(1,n+1):
    print(a.count(i))

### FIXED CODE ###

import collections

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

l = [0] * n

for i in range(n-1):
    l[a[i]-1] = l[a[i]-1] + 1

for i in range(n):
    print(l[i])