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

n = int(input())
s = [list(input()) for _ in range(n)]
for i in range(n):
    for j in range(n):
        if (i==j):
            s[i][j] = 0
            continue
        if (s[i][j]=="1"):
            s[i][j] = 1
        else:
            s[i][j] = float("inf")
#print(s)
for k in range(n):
    for i in range(n):
        for j in range(n):
            s[i][j] = min(s[i][j], s[i][k]+s[k][j])
#print(s)
w = [[] for _ in range(n)]
m = [s[0][0],0,0]
for i in range(n):
    for j in range(n):
        if (s[i][j] > m[0]):
            m = [s[i][j],i,j]
#print(m)
for i in range(n):
    w[s[m[1]][i]].append(i)
#print(w)
for i in range(n):
    if (len(w[i])>=2):
        for j in range(len(w[i])-1):
            for k in range(j+1,len(w[i])):
                if (s[w[i][j]][w[i][k]]==1):
                    print(-1)
                    exit()
print(m[0]+1)


### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    n = int(input())
    s = [list(input()) for _ in range(n)]
    for i in range(n):
        for j in range(n):
            if (i==j):
                s[i][j] = 0
                continue
            if (s[i][j]=="1"):
                s[i][j] = 1
            else:
                s[i][j] = float("inf")
    #print(s)
    for k in range(n):
        for i in range(n):
            for j in range(n):
                s[i][j] = min(s[i][j], s[i][k]+s[k][j])
    #print(s)
    w = [[] for _ in range(n)]
    m = [s[0][0],0,0]
    for i in range(n):
        for j in range(n):
            if (s[i][j] > m[0]):
                m = [s[i][j],i,j]
    #print(m)
    for i in range(n):
        w[s[m[1]][i]].append(i)
    #print(w)
    for i in range(n):
        if (len(w[i])>=2):
            for j in range(len(w[i])-1):
                for k in range(j+1,len(w[i])):
                    if (s[w[i][j]][w[i][k]]==1):
                        print(-1)
                        exit()
    print(m[0]+1)
    

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

S = list(input())
Q = int(input())
L = [input().split() for _ in range(Q)]

def syori(item):
    global S
    if item[0] == '1':
        S.reverse()
    else:
        # Ti = 2 の時
        if item[1] == '1':
            S = [item[2]] + S
        else:
            S = S + [item[2]]

for item in L:
    syori(item)
# print(L)
print(''.join(S))

### FIXED CODE ###

s = input()
q = int(input())
query = []
lead = ''
end = ''
inversion_flg = False
 
for j in range(q):
    i = input().split()
    if i[0] == "1":
        if inversion_flg:
            inversion_flg = False 
        else:
            inversion_flg = True
    else:
        if inversion_flg:
            if i[1] == "1":
                i[1] = "2"
            else:
                i[1] = "1"
        if i[1] == "1":
            lead+=i[2]
        else:
            end+=i[2]
 
lead = lead[::-1]
s = lead+s+end
if inversion_flg:
    s = s[::-1]
print(s)
### BUGGY CODE ###

N,C=map(int,input().split())
D=[list(map(int,input().split())) for _ in range(C)]
c=[list(map(int,input().split())) for _ in range(N)]
cost=[[0 for _ in range(C)],[0 for _ in range(C)],[0 for _ in range(C)]]
for i in range(N):
    for j in range(N):
        for x in range(C):
            cost[(i+j+2)%3][x]+=D[c[j][i]-1][x]
            

ar=[[cost[0][i],i] for i in range(C)]
br=[[cost[1][i],i] for i in range(C)]
cr=[[cost[2][i],i] for i in range(C)]
sa=sorted(ar)
sb=sorted(br)
sc=sorted(cr)
outp=[]
for i in range(3):
    for j in range(3):
        for k in range(3):
            if(sa[i][1]!=sb[j][1] and sa[i][1]!=sc[k][1] and sb[j][1]!=sc[k][1]):
                outp.append(sa[i][0]+sb[j][0]+sc[k][0])
print(min(outp))

### FIXED CODE ###

N,C=map(int,input().split())
D=[list(map(int,input().split())) for _ in range(C)]
c=[list(map(int,input().split())) for _ in range(N)]
cost=[[0 for _ in range(C)],[0 for _ in range(C)],[0 for _ in range(C)]]
for i in range(N):
    for j in range(N):
        for x in range(C):
            cost[(i+j+2)%3][x]+=D[c[j][i]-1][x]
            

ar=[[cost[0][i],i] for i in range(C)]
br=[[cost[1][i],i] for i in range(C)]
cr=[[cost[2][i],i] for i in range(C)]
sa=sorted(ar)
sb=sorted(br)
sc=sorted(cr)
outp=[]
for i in range(3):
    for j in range(3):
        for k in range(3):
            if(sa[i][1]!=sb[j][1] and sa[i][1]!=sc[k][1] and sb[j][1]!=sc[k][1]):
                outp.append(sa[i][0]+sb[j][0]+sc[k][0])
print(min(outp))
### BUGGY CODE ###

import math
ans = 0
N = int(input())
for i in range(N):
    for j in range(N):
        for k in range(N):
            ans += math.gcd(math.gcd(i+1,j+1),k+1)
print(ans)


### FIXED CODE ###

import math
ans = 0
N = int(input())
if N <= 5:
  for i in range(N):
    for j in range(N):
        for k in range(N):
            ans += math.gcd(math.gcd(i+1,j+1),math.gcd(j+1,k+1))
else:
    for i in range(N):
        ans += i+1
    for i in range(N-1):
        for j in range(i+1,N):
            ans += 6*math.gcd(i+1,j+1)
    for i in range(N-2):
        for j in range(i+1,N-1):
            for k in range(j+1,N):
                ans += 6*math.gcd(math.gcd(i+1,j+1),math.gcd(j+1,k+1))
print(ans)
### BUGGY CODE ###

l, r = map(int, input().split())
a = 10**5
for i in range(l,r+1):
	for j in range(i+1,r+1):
		a = min(a,i*j%2019)
print (a)


### FIXED CODE ###

l, r = map(int, input().split())
a = 10**5
if r - l >= 2017:
	print (0)
	exit()
else:
	for i in range(l,r+1):
		for j in range(i+1,r+1):
			a = min(a,i*j%2019)
print (a)
### BUGGY CODE ###

def cmin(a,b):
    if a>b:
        return b
    else:
        return a

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

dp = [0] + [float("inf")]*(N-1)
for i in range(1,N):
    for j in range(1, min(i+1,K+1)):
        dp[i] = cmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[-1])


### FIXED CODE ###

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

cost = [0]
for i in range(2,N+1):
    cost.append( min([cost[j] + abs(h[i-1]-h[j]) for j in range(max(0,i-K-1), i-1)]) )
print(cost[-1])
### BUGGY CODE ###

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

C = [a1^a2 for a1, a2 in zip(A, A[1:])] + [A[0]^A[-1]]
D = [b1^b2 for b1, b2 in zip(B, B[1:])] + [B[0]^B[-1]]

K = []
k = 0
while k < N:
  next_k = k
  is_first = True
  for i in range(N):
    if is_first and C[(k+i)%N] == D[0]:
      next_k = k + i
      is_first = False
    if C[(k+i)%N] != D[i]:
      break
  
  if i == N-1:
    K.append(k)
  
  k = max(k+1, next_k)

for k in K:
  print(k, A[k]^B[0])

### FIXED CODE ###

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

C = [a1^a2 for a1, a2 in zip(A, A[1:])] + [A[0]^A[-1]]
C = C + C
D = [b1^b2 for b1, b2 in zip(B, B[1:])] + [B[0]^B[-1]]

K = []
k = 0
while k < N:
  next_k = k
  is_first = True
  for i in range(N):
    if is_first and i>0 and C[k+i]==D[0]:
      next_k = k + i
      is_first = False
    if C[k+i] != D[i]:
      if next_k == k:
        k = k + i + 1
      else:
        if D[k+i-next_k] == C[k+i]:
          k = next_k
        else:
          k = k + i + 1
      break
  
  if i == N-1:
    K.append(k)
    if next_k == k:
      break
    else:
      k = next_k
      if len(K) == 2:
        diff = K[1] - K[0]
        while K[-1] < N:
          K.append(K[-1]+diff)
      
        _ = K.pop()
        break

for k in K:
  print(k, A[k]^B[0])
### BUGGY CODE ###

h, w = map(int, input().split())
S = [list(input()) for _ in range(h)]

TS = list(zip(*S))

TtoUP = [[0] * h for _ in range(w)]
for itr1, line in enumerate(TS):
  cnt = 0
  for itr2, s in enumerate(line):
    if s == ".":
      cnt += 1
      TtoUP[itr1][itr2] = cnt
    else:
      cnt = 0
toUP = list(zip(*TtoUP))


TtoDOWN = [[0] * h for _ in range(w)]
for itr1, line in enumerate(TS):
  cnt = 0
  for itr2, s in enumerate(line[::-1]):
    if s == ".":
      cnt += 1
      TtoDOWN[itr1][h - itr2- 1] = cnt
    else:
      cnt = 0
toDOWN = list(zip(*TtoDOWN))


toLEFT = [[0] * w for _ in range(h)]
for itr1, line in enumerate(S):
  cnt = 0
  for itr2, s in enumerate(line):
    if s == ".":
      cnt += 1
      toLEFT[itr1][itr2] = cnt
    else:
      cnt = 0
    
toRIGHT = [[0] * w for _ in range(h)]
for itr1, line in enumerate(S):
  cnt = 0
  for itr2, s in enumerate(line[::-1]):
    if s == ".":
      cnt += 1
      toRIGHT[itr1][w - itr2 - 1] = cnt
    else:
      cnt = 0

ans = 0
for i in range(h):
  for j in range(w):
    if S[i][j] == ".":
      ans = max(ans, toUP[i][j] + toDOWN[i][j] + toLEFT[i][j] + toRIGHT[i][j] - 3)
print(ans)

### FIXED CODE ###

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

# L, R, U, D方向の照らされるマス数を事前に計算
L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      L[i][j] = 0
    elif j == 0:
      L[i][j] = 1
    else:
      L[i][j] = L[i][j - 1] + 1

for i in range(H):
  for j in reversed(range(W)):
    if S[i][j] == "#":
      R[i][j] = 0
    elif j == W - 1:
      R[i][j] = 1
    else:
      R[i][j] = R[i][j + 1] + 1

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      U[i][j] = 0
    elif i == 0:
      U[i][j] = 1
    else:
      U[i][j] = U[i - 1][j] + 1

for i in reversed(range(H)):
  for j in range(W):
    if S[i][j] == "#":
      D[i][j] = 0
    elif i == H - 1:
      D[i][j] = 1
    else:
      D[i][j] = D[i + 1][j] + 1

ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)

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

import sys
sys.setrecursionlimit(10**6)
s=list(input())
t=list(input())

tsr=list(t)+list(s)
while len(tsr)<2*len(t)+len(s):
  tsr+=s
#print(tsr)

#Z[i]: 文字列Sと各S[i:]の最長共通接頭辞の長さ
def z_alg(S):
  NN=len(S)
  Z=[NN]+[0]*(NN-1)
  i,j=1,0
  while i<NN:
    while i+j<NN and S[j]==S[i+j]:
      j+=1
    if not j:
      i+=1
      continue
    Z[i]=j
    k=1
    while NN-i>k and k<j-Z[k]:
      Z[i+k]=Z[k]
      k+=1
    i+=k
    j-=k
  return Z

zlist=z_alg(tsr)
#print(zlist)

match_list=[]
for i in range(len(s)):
  match_list.append(zlist[i+len(t)]>=len(t))
#print(match_list)

path=[-1]*len(s)
for i in range(len(s)):
  if match_list[i]:
    path[i]=(i+len(t))%len(s)
#print(path)

dist=[-1]*len(s)
for i in range(len(s)):
  d=0
  ii=i
  while path[ii]!=-1:
    if d>len(s):
      print(-1)
      sys.exit(0)
    elif dist[ii]!=-1:
      d+=dist[ii]
      break
    ii=path[ii]
    d+=1
  dist[i]=d
    
#print(dist)
print(max(dist))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
s=list(input())
t=list(input())

tsr=list(t)+list(s)
while len(tsr)<2*len(t)+len(s):
  tsr+=s
#print(tsr)

#Z[i]: 文字列Sと各S[i:]の最長共通接頭辞の長さ
def z_alg(S):
  NN=len(S)
  Z=[NN]+[0]*(NN-1)
  i,j=1,0
  while i<NN:
    while i+j<NN and S[j]==S[i+j]:
      j+=1
    if not j:
      i+=1
      continue
    Z[i]=j
    k=1
    while NN-i>k and k<j-Z[k]:
      Z[i+k]=Z[k]
      k+=1
    i+=k
    j-=k
  return Z

zlist=z_alg(tsr)
#print(zlist)

match_list=[]
for i in range(len(s)):
  match_list.append(zlist[i+len(t)]>=len(t))
#print(match_list)

path=[-1]*len(s)
for i in range(len(s)):
  if match_list[i]:
    path[i]=(i+len(t))%len(s)
#print(path)

dist=[-1]*len(s)
for i in range(len(s)):
  if dist[i]!=-1:
    continue
    
  d=0
  offset=0
  stack=[i]
  ii=i
  while path[ii]!=-1:
    if d>len(s):
      print(-1)
      sys.exit(0)
    elif dist[ii]!=-1:
      offset=dist[ii]
      break    
    ii=path[ii]
    stack.append(ii)
    d+=1
  
  cnt=0
  while stack:
    p=stack.pop()
    dist[p]=offset+cnt
    cnt+=1
    
#print(dist)
print(max(dist))
### BUGGY CODE ###

import math
import sys

def main():
    #an+1=(10~n)*7+an
    K=int(input())
    if K%2==0:
        print(-1)
        sys.exit()
    n=0
    a=7
    while True:
        if a%K==0:
            break
        n+=1
        a=(a+(pow(10,n,K)*7))%K
    print(n+1)

if __name__=="__main__":
    main()

### FIXED CODE ###

import math
import sys

def main():
    #an+1=(10~n)*7+an
    K=int(input())

    if K%2==0:
        print(-1)
        sys.exit()
    elif K%5==0:
        print(-1)
        sys.exit()
    n=0
    a=7
    while True:
        if a%K==0:
            break
        n+=1
        a=(a+(pow(10,n,K)*7))%K
    print(n+1)

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

H, W = map(int, input().split())
A = tuple(tuple(map(int, input().split())) for _ in range(H))
B = tuple(tuple(map(int, input().split())) for _ in range(H))

dp = dict()
c = A[0][0]-B[0][0]
dp[(0, 0)] = {c, -c}
lim = 160 * 80

for i in range(H):
    for j in range(W):
        if i == j == 0:
            continue
        c = abs(A[i][j]-B[i][j])
        d = set()
        if i > 0:
            d |= {x + c for x in dp[(i - 1, j)] if x + c < lim}
            d |= {x - c for x in dp[(i - 1, j)] if x - c > -lim}
        if j > 0:
            d |= {x + c for x in dp[(i, j - 1)] if x + c < lim}
            d |= {x - c for x in dp[(i, j - 1)] if x - c > -lim}
        dp[(i, j)] = d

ans = min(abs(x) for x in dp[H - 1, W - 1])
print(ans)

### FIXED CODE ###

import numpy as np
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

H, W = map(int, input().split())
A = np.array([input().split() for _ in range(H)], dtype=int)
B = np.array([input().split() for _ in range(H)], dtype=int)
dif = np.abs(A - B).tolist()

U = (H + W) * 80
Um = U // 2

dp = [[[] for _ in range(W)] for _ in range(H)]
X = np.zeros(U + 1, dtype=bool)
X[Um + dif[0][0]] = True
X[Um - dif[0][0]] = True
dp[0][0] = X


for i in range(H):
    for j in range(W):
        if i == j == 0:
            continue
        d = dif[i][j]
        X = np.zeros(U + 1, dtype=bool)
        if d:
            if i > 0:
                X[d:] |= dp[i - 1][j][:-d]
                X[:-d] |= dp[i - 1][j][d:]
            if j > 0:
                X[d:] |= dp[i][j - 1][:-d]
                X[:-d] |= dp[i][j - 1][d:]
        else:
            if i > 0:
                X |= dp[i - 1][j]
            if j > 0:
                X |= dp[i][j - 1]
        dp[i][j] = X

tmp = np.arange(U+1)[dp[H-1][W-1]]
ans = np.abs(tmp - Um).min()
print(ans)
### BUGGY CODE ###

N,Q=map(int,input().split())
S=input()
for i in range(Q):
  l,r=map(int,input().split())
  print(S.count('AC',l-1,r))

### FIXED CODE ###

N,Q=map(int,input().split())
S=input()
L=[0]
T=0
for i in range(N-1):
  T+=S.count('AC',i,i+2)
  L.append(T)
for j in range(Q):
  l,r=map(int,input().split())
  print(L[r-1]-L[l-1])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from collections import deque

from sys import setrecursionlimit

setrecursionlimit(1000000)

INF = float("inf")
# Input#
# n = int(input())
n, m = map(int, input().split())
# a = list(map(int, input().split()))

d = deque()
d_tmp = deque()
x = [-1]
y = [-1]

for i in range(m):
    x_in, y_in = map(int, input().split())
    x.append(x_in)
    y.append(y_in)
    d.append((x_in, y_in))

memo = [-1] * (n + 1)
ans = -1


def dp(i):
    global ans
    if memo[i] == -1:
        ret = 0
        for x_in, y_in in d:
            if x_in == i:
                tmp = dp(y_in) + 1
                ret = max(tmp, ret)
        memo[i] = ret
        ans = max(ret, ans)
        return ret
    else:
        return memo[i]


for i, _ in d:
    tmp = dp(i)

print("{}".format(ans))


### FIXED CODE ###

# -*- coding: utf-8 -*-
from collections import deque

from sys import setrecursionlimit

setrecursionlimit(1000000)

INF = float("inf")
# Input#
# n = int(input())
n, m = map(int, input().split())
# a = list(map(int, input().split()))

d = deque()
d_tmp = deque()
x = [-1]
y = [[-1] for _ in range((n + 1))]

for _ in [0] * m:
    x_in, y_in = map(int, input().split())
    #    x.append(x_in)
    y[x_in].append(y_in)
    d.append((x_in, y_in))

memo = [-1] * (n + 1)
ans = -1


def dp(i):
    global ans
    if memo[i] == -1:
        ret = 0
        for x_in in y[i][1:]:
            tmp = dp(x_in) + 1
            if tmp > ret:
                ret = tmp
        memo[i] = ret
        if ret > ans:
            ans = ret
        return ret
    else:
        return memo[i]


for i, _ in d:
    if memo[i] == -1:
        dp(i)

print("{}".format(ans))
### BUGGY CODE ###

S = input()

Q = int(input())

for _ in range(Q):
    op = input().split()
    if len(op) == 1:
        S = S[::-1]
    else:
        if op[1] == '1':
            S = op[2] + S
        else:
            S = S + op[2]
print(S)


### FIXED CODE ###

import collections

S = input()

Q = int(input())

list1 = collections.deque()
list2 = []
flag = 1

for _ in range(Q):
    op = input().split()
    if len(op) == 1:
        flag *= -1
    else:
        if flag == 1:
            if op[1] == '1':
                list1.appendleft(op[2])
            else:
                list2.append(op[2])
        else:
            if op[1] == '1':
                list2.append(op[2])
            else:
                list1.appendleft(op[2])

if flag == 1:
    print("".join(list1) + S + "".join(list2))
else:
    print(("".join(list1) + S + "".join(list2))[::-1])
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
from collections import defaultdict
INF = float("inf")
MOD = 10**9+7


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.E = defaultdict(list)

    def add_edge(self, f, t, w=1):
        self.E[f].append((t, w))
        self.E[t].append((f, w))


N = int(input())
c = [x-1 for x in map(int, input().split())]
A = [None]*(N-1)
B = [None]*(N-1)
for i in range(N-1):
    A[i], B[i] = map(int, input().split())

g = Graph(N)
for a, b in zip(A, B):
    g.add_edge(a-1, b-1)

# k=1, 2, ..., Nに対して
# 色kが塗られている頂点を一度以上通るような単純パスの数を求める
# 全パスの個数 - 色kが塗られている頂点を一度も通らない単純パスの数
# 全パスの個数はN*(N+1)/2

# グラフを色kのノードで分割して、部分グラフ内での単純パスの総数を求めれば良い
# 各ノードに状態として辞書をもたせる。
# 辞書は色iを通らずに到達可能な頂点の数を持つ。

# 回答用
ans = [0]*N


def f(curr, par=-1):
    # 再帰関数
    # curr: 現在の節点
    # par : 親節点の番号
    ret = defaultdict(int)
    for dest, w in g.E[curr]:
        if dest == par:
            continue
        child = f(dest, curr)

        # 自身の色と同じ場合、子の頂点の数から加算
        n = child[c[curr]]
        ans[c[curr]] += n*(n+1)//2

        # マージ
        if len(ret) < len(child):
            child, ret = ret, child
        for key in child:
            ret[key] += child[key]
        ret[c[curr]] = 0

    for color in range(N):
        if color != c[curr]:
            ret[color] += 1
    return ret


ret = f(0)
for color in range(N):
    if color != c[0]:
        n = ret[color]
        ans[color] += n*(n+1)//2

tot = N*(N+1)//2
for a in ans:
    print(tot-a)


### FIXED CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
from collections import defaultdict
INF = float("inf")
MOD = 10**9+7


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.E = defaultdict(list)

    def add_edge(self, f, t, w=1):
        self.E[f].append((t, w))
        self.E[t].append((f, w))


N = int(input())
c = [x-1 for x in map(int, input().split())]
A = [None]*(N-1)
B = [None]*(N-1)
for i in range(N-1):
    A[i], B[i] = map(int, input().split())

g = Graph(N)
for a, b in zip(A, B):
    g.add_edge(a-1, b-1)

# k=1, 2, ..., Nに対して
# 色kが塗られている頂点を一度以上通るような単純パスの数を求める
# 全パスの個数 - 色kが塗られている頂点を一度も通らない単純パスの数
# 全パスの個数はN*(N+1)/2

# グラフを色kのノードで分割して、部分グラフ内での単純パスの総数を求めれば良い
# 各ノードに状態として辞書をもたせる。
# x辞書は色iを通らずに到達可能な頂点の数を持つ。
# o辞書は色iを通らずに到達不可能な頂点の数を持つ。

# 回答用
ans = [0]*N


def f(curr, par=-1):
    # 再帰関数
    # curr: 現在の節点
    # par : 親節点の番号
    ret = defaultdict(int)
    size = 1
    for dest, w in g.E[curr]:
        if dest == par:
            continue
        sz, child = f(dest, curr)
        size += sz

        # 自身の色と同じ場合、子の頂点の数から加算
        n = sz-child[c[curr]]
        ans[c[curr]] += n*(n+1)//2

        # マージ
        if len(ret) < len(child):
            child, ret = ret, child
        for key in child:
            ret[key] += child[key]

    ret[c[curr]] = size
    return size, ret


sz, ret = f(0)
for color in range(N):
    if color != c[0]:
        n = sz-ret[color]
        ans[color] += n*(n+1)//2

tot = N*(N+1)//2
for a in ans:
    print(tot-a)
### BUGGY CODE ###

import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
l = inpl()
dic = {}
for i in range(0, len(l)):
    dic.setdefault(i, l[i])
ans = ''
sl = sorted(dic.items(), key=lambda x:x[1])
for d in sl:
    ans = ' '.join([ans, str(d[0] + 1)])
print(ans)

### FIXED CODE ###

import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
l = inpl()
dic = {}
for i in range(0, len(l)):
    dic.setdefault(i, l[i])
ans = ''
sl = sorted(dic.items(), key=lambda x:x[1])
for d in sl:
    ans = ''.join([ans,' ', str(d[0] + 1)])
print(ans)
### BUGGY CODE ###

import sys

input = sys.stdin.readline
n, m = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(m)]
BC.sort(key=lambda x: -x[1])

extend = A.extend
[extend([BC[i][1]] * BC[i][0]) for i in range(m)]

A.sort(key=lambda x: -x)
print(sum(A[:n]))

### FIXED CODE ###

import sys

input = sys.stdin.readline
n, m = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(m)]
BC.sort(key=lambda x: -x[1])

maxi = n*2
extend = A.extend
[extend([ls[1]] * ls[0]) for ls in BC if len(A) <= maxi]
A.sort(reverse=True)

print(sum(A[:n]))
### BUGGY CODE ###

a,b = map(int,input().split())
ret = 0
for i in range(a,b+1):
    ret = ret^i
print(ret)

### FIXED CODE ###

a,b = map(int,input().split())
if a % 2 ==0:
    if (b - a + 1) % 4 == 0:
        print(0)
    if (b - a + 1) % 4 == 1:
        print(b)
    if (b - a + 1) % 4 == 2:
        print(b ^ (b -1))
    if (b - a + 1) % 4 == 3:
        print(b ^ (b -1) ^ (b-2))
else :
    if (b - a + 1) % 4 == 0:
        print(a ^ b ^ (b -1) ^ (b-2))
    if (b - a + 1) % 4 == 1:
        print(a)
    if (b - a + 1) % 4 == 2:
        print(a ^ b)
    if (b - a + 1) % 4 == 3:
        print(a ^ b ^ (b -1))
### BUGGY CODE ###

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

def isOK(L):
    num = 0
    for A in As:
        num += -(-A // L) - 1
    return num <= K

ng, ok = 0, 10**9
while abs(ok-ng) > 10**-6:
    mid = (ng+ok) / 2
    if isOK(mid):
        ok = mid
    else:
        ng = mid

k = int(-(-ok // 1))
#print('ok:', ok, '/ k:', k)

for L in range(max(1, k-2), k+3):
    if isOK(L):
        print(L)
        break


### FIXED CODE ###

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

def isOK(L):
    num = 0
    for A in As:
        num += -(-A // L) - 1
    return num <= K

ng, ok = 0, 10**9
while abs(ok-ng) > 10**-6:
    mid = (ng+ok) / 2
    if isOK(mid):
        ok = mid
    else:
        ng = mid

k = int(-(-ok // 1))
#print('ok:', ok, '/ k:', k)

for L in range(max(1, k-2), k+3):
    if isOK(L):
        print(L)
        break