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

import sys

if __name__ == "__main__":
    N = int(sys.stdin.readline().strip())
    A = [int(a) for a in sys.stdin.readline().strip().split(" ")]

    count_pair = 0
    for i in range(N):
        for j in range(i + 1, N):
            if (j - i) == (A[j] + A[i]):
                count_pair += 1
    
    print(count_pair)

### FIXED CODE ###

import sys
import array

if __name__ == "__main__":
    N = int(sys.stdin.readline().strip())
    A = array.array('i', [int(a) for a in sys.stdin.readline().strip().split(" ")])

    count_pair = 0
    L = {}
    R = {}

    for i in range(N):
        l = A[i] + (i + 1)
        r = (i + 1) - A[i]

        if l in L:
            L[l].append(i+1)
        else:
            L[l] = [i+1]

        if r in R:
            R[r].append(i+1)
        else:
            R[r] = [i+1]

    print(sum([len(L[m]) * len(R[m]) for m in list(set(L.keys()) & set(R.keys()))]))
### BUGGY CODE ###

# coding: utf-8

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

b = []
for i in range(n):
    if i % 2 != 0:
        b.insert(0, a[i])
    else:
        b.append(a[i])

print(' '.join(map(str, b if n % 2 == 0 else reversed(b))))


### FIXED CODE ###

# coding: utf-8
from collections import deque

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

b = deque()
for i in range(n):
    if i % 2 == (n-1) % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])

print(' '.join(map(str, b)))
### BUGGY CODE ###

N,K = [int(i) for i in input().split()]
n = [int(i) for i in input().split()]
max=0
idx=0
for i in range(N-K+1):
    tmp = sum(n[i:i+K]) 
    if tmp  > max:
        max=tmp 
        idx=i

d=n[idx:idx+K]

print((sum(d)+K)*0.5)


### FIXED CODE ###

import numpy as np

N,K = [int(i) for i in input().split()]
n = np.array([int(i) for i in input().split()])
n=(n+1)
t=np.empty(N+1)
t[0] = 0
t[1:]=np.cumsum(n)
print(max(t[K:]-t[:-K])*0.5)
### BUGGY CODE ###


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

max_d = 0

for i in range(n - k + 1):
    d = 0
    for j in range(k):
        d += (1 + a[i + j])/2
    if d > max_d:
        max_d = d


print(max_d)
        

### FIXED CODE ###

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

max_d = sum(a[0:k])
max_i = 0
total = sum(a[0:k])


for i in range(1,n - k + 1):
    total = total - a[i - 1] + a[i + k - 1]

    if total > max_d:
        max_d = total
        max_i = i

ans = 0
for i in range(max_i,max_i + k):
    ans += (1 + a[i])/2
print("{:7f}".format(ans))
### BUGGY CODE ###

n = int(input())
s_lis =[]
for _ in range(n):
    s = sorted(input())
    s_lis.append("".join(s))


ans = 0
for i in range(n):
    for j in range(i+1,n):
        if s_lis[i] == s_lis[j]:
            ans += 1

print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
dic = {}
for i in range(n):
    s = input()
    s = str(sorted(s))
    tmp = dic.get(s,0)
    ans += tmp
    dic[s] = tmp + 1

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

N = int(input())
A = list(map(int, input().split()))
wa = 0
for i in range(N-1):
    i_wa = 0
    for m in A[i+1:]:
        i_wa += m
    wa += A[i] * i_wa 
print(wa % (10**9+7))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
wa = 0
a = 0
for l in range(N-1):
    a += A[N-l-1]
    wa += a * A[N-l-2]
print(wa % (10**9+7))
### BUGGY CODE ###

import numpy as np

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

for i in range(1,N):
  try:
    dif=min(dif,abs(sum(A[:i])-sum(A[i:])))
  except:
    dif=abs(sum(A[:i])-sum(A[i:]))
print(dif)

### FIXED CODE ###

import numpy as np

N=int(input())
A=np.array(list(map(int, input().split())))
S=sum(A)-A[0]
X=A[0]
ans=abs(S-X)
for i in range(1,N-1):
  X+=A[i]
  S-=A[i]
  ans=min(ans,abs(S-X))
print(ans)
### BUGGY CODE ###

from functools import reduce
input()
src = list(map(lambda x: 1 if x=="#" else 0, input()))
ans = sum(src)
for i in range(len(src)):
  ans = min(ans, sum(src[:i]) + len(src[i:]) - sum(src[i:]))
  if ans==0:
    break
print(ans)

### FIXED CODE ###

from functools import reduce
l = int(input())
src = list(map(lambda x: 1 if x=="." else 0, input()))
left_black = 0
right_white = sum(src)
ans = right_white
for i in range(l):
  if src[i]==0:
    left_black+=1
  else:
    right_white-=1
  ans = min(ans, left_black + right_white)
  if ans==0:
    break
print(ans)
### BUGGY CODE ###

import copy
n = int(input())
l = list(map(int, input().split()))
b = []

def gcd(a,b):
	while b:
		a, b = b, a % b
	return a
if n == 2:
	print(max(l[0],l[1]))
elif n == 3:
	print(max(gcd(l[0],l[1]),gcd(l[0],l[2]),gcd(l[2],l[1])))
else:
	for i in range(n):
		tmp = copy.copy(l)
		tmp.pop(i)
		x = gcd(tmp[0],tmp[1])
		for j in list(range(2, n-1)):
			x = gcd(x,tmp[j])
		b.append(x)
	print(max(b))

### FIXED CODE ###

def gcd(a,b):
  while b:a,b=b,a%b
  return a
n,a,b=int(input()),list(map(int,input().split())),[]
if n==2:print(max(a[0],a[1]))
elif n==3:print(max(gcd(a[0],a[1]),gcd(a[0],a[2]),gcd(a[1],a[2])))
else:
  no,mi=a[0],a[0]
  for i in range(1,n):
    s=gcd(no,a[i])
    if s!=no:
      no=max(s,mi)
      mi=gcd(s,mi)
  print(no)
### BUGGY CODE ###

N = int(input())
A = input()
A = A.split()
A = [int(c) for c in A]
count = 0
for i in range(N):
    for j in range(N):
        if A[i] % A[j] == 0 and i != j:
            count += 1
            break
print(len(A)-count)

### FIXED CODE ###

N = int(input())
A_list = list(map(int, input().split()))
A_list.sort()
A_max = A_list[-1]
count = 0
cnt_list = [1] * ((10 ** 6) + 1)
for i in range(len(A_list)-1):
    if cnt_list[A_list[i]] == 1:
        for j in range((A_max // A_list[i]) + 1):
            cnt_list[A_list[i] * j] = 0
        if A_list[i] != A_list[i+1]:
            count += 1
if cnt_list[A_list[-1]] == 1:
    count += 1
print(count)
### BUGGY CODE ###

import itertools

N, K = map(int, input().split())
menu = {}

for i in range(N):
    t, d = map(int, input().split())
    menu[i] = (t, d)

def manzoku(s):
    #Oishisa basic point
    Oishisa = sum([menu[i][1] for i in s])
   
    #Syurui bonus point
    Syurui = len(set([menu[i][0] for i in s]))**2
    
    #Manzoku point
    return Oishisa + Syurui

#K sushi    
shushi = itertools.combinations(menu, K)
print(max([manzoku(c) for c in shushi]))

### FIXED CODE ###

N, K = map(int, input().split())
menu_ = []

for i in range(N):
    t, d = map(int, input().split())
    menu_.append((t, d))

menu = sorted(menu_, key = lambda x:x[1], reverse=True)
neta = set()
duplicates = []

for m in menu[:K]:
    if m[0] in neta:
        duplicates.append(m[1])
    else:
        neta.add(m[0])

p = sum([d for (t, d) in menu[:K]]) + len(neta)**2
ans = p

for m in menu[K:]:
    if m[0] not in neta and duplicates:
        neta.add(m[0])
        duplicate = duplicates.pop()
        
        p += (m[1] - duplicate) + 2 * len(neta) - 1 
        #print(ans, p)
        ans = max(ans, p)

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

# ABC066C - pushpush (ARC077)
n = int(input())
lst = list(map(int, input().rstrip().split()))
b = []
for i in lst:
    b += [i]
    b = b[::-1]
print(*b)

### FIXED CODE ###

# ABC066C - pushpush (ARC077)
from collections import deque

n = int(input())
lst = list(map(int, input().rstrip().split()))
b = deque()
parity = n % 2
for i, j in enumerate(lst, start=1):
    if i % 2 == parity:
        b.appendleft(j)
    else:
        b.append(j)
print(*b)
### BUGGY CODE ###

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

cnt = 0
for i in range(n):
    x = a[i]
    f = 1
    for j in range(n):
        if i == j:
            continue
        if x%a[j]==0:
            f = 0
            break   
    if f:
        cnt += 1
        
print(cnt)

### FIXED CODE ###

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

cnt = [0]*(10**6+1)

for elem in a:
    cnt[elem] += 1

unique = []
for i in range(10**6+1):
    if cnt[i] == 1:
        unique.append(i)

cnt = [0]*(10**6+1)
a = list(set(a))

for elem in a:
    for m in range(elem*2,10**6+1,elem):
        cnt[m] = 1

ans = 0
for elem in unique:
    if cnt[elem] == 0:
        ans += 1

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

import bisect

A,B,Q = map(int,input().split())

s = [-1 * float("inf")]
t = [-1 * float("inf")]

for i in range(A):

    S = int(input())
    s.append(S)

for i in range(B):

    T = int(input())
    t.append(T)

s.append(float("inf"))
t.append(float("inf"))

for i in range(Q):

    x = int(input())

    si = bisect.bisect_left(s,x)
    ti = bisect.bisect_left(t,x)

    now = min( max(s[si],t[ti]) - x  ,  x - min(s[si-1],t[ti-1]) )
    now = min( now , 2 * min( s[si] - x , x - t[ti-1] ) + max(s[si] - x , x - t[ti-1]))
    now = min( now , 2 * min( t[ti] - x , x - s[si-1] ) + max(t[ti] - x , x - s[si-1]))

    print (now)


### FIXED CODE ###

import bisect

A,B,Q = map(int,input().split())

s = [-1 * float("inf")]
t = [-1 * float("inf")]

for i in range(A):

    S = int(input())
    s.append(S)

for i in range(B):

    T = int(input())
    t.append(T)

s.append(float("inf"))
t.append(float("inf"))

for i in range(Q):

    x = int(input())

    si = bisect.bisect_left(s,x)
    ti = bisect.bisect_left(t,x)

    now = min( max(s[si],t[ti]) - x  ,  x - min(s[si-1],t[ti-1]) )
    now = min( now , 2 * min( s[si] - x , x - t[ti-1] ) + max(s[si] - x , x - t[ti-1]))
    now = min( now , 2 * min( t[ti] - x , x - s[si-1] ) + max(t[ti] - x , x - s[si-1]))

    print (now)
### BUGGY CODE ###

N = int(input())
L = list(map(int, input().split()))
L.sort()

count = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        a = L[i]
        b = L[j]
        low = max(a-b, b-a)
        hi = a+b
        for k in range(j+1, N):
            c = L[k]
            if low < c and c < hi:
                count += 1
            elif c >= hi:
                break
print(count)

### FIXED CODE ###

import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()

count = 0
for i in range(N):
    for j in range(i+1, N):
        a = L[i]
        b = L[j]
        k = bisect.bisect_left(L, a+b)
        if k > j:
            count += k -j -1
print(count)
### BUGGY CODE ###

N,K=map(int, input().split())
import numpy as np
a_ls=np.array(list(map(int, input().split())))


t=1
track=[]
while not(t in track):
	track+=[t]
	t=a_ls[t-1]

#print(track)
#print(t)
#print(track.index(t)) #dokokara loop ga hajimaruka

if track.index(t)>K:
	print(track[K])
else:
	s=(K-track.index(t))%(len(track)-track.index(t))
	print(track[s+track.index(t)])


### FIXED CODE ###

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

j=1
step=0
s=set([])
l=[]
loop_s=-1
loop_g=-1

while True:
	s.add(j)
	l+=[j]
	j=a_ls[j-1] #update
	if j in s:
		loop_s=l.index(j)
		loop_g=len(l)
		break


#print(l)
#print(loop_s)
#print(loop_g)

if K<loop_s:
	print(l[K])
elif (K+1-loop_s)%(loop_g-loop_s)!=0:
	print(l[loop_s+(K+1-loop_s)%(loop_g-loop_s)-1])
else:
	print(l[-1])
### BUGGY CODE ###

#atcorder beginner contest 141
#D powerful discount tickets
import math

goods, tickets = input().split()
goods = int(goods)
tickets = int(tickets)

price = []
total = 0

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

for i in range(tickets):
    max_index = price.index(max(price))
    max_price = math.floor(max(price) / 2)
    price[max_index] = max_price


for i in range(goods):
    total += price[i]

print(total)

### FIXED CODE ###

#atcorder beginner contest 141
#D powerful discount tickets
import math
import heapq

goods, tickets = map(int, input().split())

price = []
price = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(price)


for i in range(tickets):
    max = heapq.heappop(price) * (-1)
    heapq.heappush(price, math.ceil(-max/2))
   

total = 0
for i in range(goods):
    total += price[i]

print(total * (-1))
### BUGGY CODE ###

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

print(ans)


### FIXED CODE ###

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


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

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

def f(x):
    return (A*x)//B - A*(x//B)

ans = 0
for i in range(1, min(B, N)+1):
    ans = max(ans, f(i))
print(ans)


### FIXED CODE ###

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

def f(x):
    return (A*x)//B - A*(x//B)

if B > N:
    print(f(N))
elif B == N:
    print(f(N-1))
else:
    print(f(B-1))
### BUGGY CODE ###

N, K  = map(int, input().split())
As = sorted(list(map(int, input().split())))
Fs = sorted(list(map(int, input().split())),reverse=True)
Xs = sorted([(a*f,i) for i,(a,f) in enumerate(zip(As,Fs))],reverse=True)
# print("X",Xs)

import heapq
q = []
heapq.heapify(q)
for i,(a,f) in enumerate(zip(As,Fs)):
    heapq.heappush(q,(-a*f,i))

for k in range(K):
    a,i = heapq.heappop(q)
    # print(-a,i)
    As[i] -= 1
    upd = (As[i])*Fs[i]
    heapq.heappush(q,(-upd,i))
ans,i = heapq.heappop(q)
print(-ans)



# print("A",As)
# print("F",Fs)


### FIXED CODE ###

N, K  = map(int, input().split())
As = sorted(list(map(int, input().split())))
Fs = sorted(list(map(int, input().split())),reverse=True)
Xs = [a*f for a,f in zip(As,Fs)]
X_M = max(Xs)

def f(x):
    K_tmp = sum([max(0,a-x//f) for a,f in zip(As,Fs)])
    return K_tmp <= K

def  binarySearch(l,r,target):
    while r - l > 1:
        mid = (l+r)//2
        """計算を入れる"""
        # print(mid, guess)
        if f(mid):
            r = mid
        else:
            l = mid
    return r

print(binarySearch(-1,X_M,K))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)


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

for _ in range(M):
    x, y = map(int, input().split())
    to[x - 1].append(y - 1)


count = 0
def dfs(v, temp=0):
    global count
    if to[v]:
        for nv in to[v]:
            dfs(nv, temp + 1)
    else:
        count = max(count, temp)


def main():
    ans = 0
    for i in range(N):
        dfs(i)
        ans = max(ans, count)
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)


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

for _ in range(M):
    x, y = map(int, input().split())
    to[x - 1].append(y - 1)

# dp[i] : iを始点とする最長経路
dp = [0] * N
seen = [0] * N

def dfs(v):
    if seen[v]:
        return dp[v]
    seen[v] = 1
    res = 0
    for nv in to[v]:
        res = max(res, dfs(nv) + 1)
    dp[v] = res
    return res


def main():
    ans = 0
    for i in range(N):
        ans = max(ans, dfs(i))
    print(ans)


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

import collections
n, m = [ int(v) for v in input().split() ]
num_list = [ int(v) for v in input().split() ]
total_counter = collections.Counter([])

for i in range(m):
    b, c =  [ int(v) for v in input().split() ]
    total_counter[c] += b
for i in num_list:
    total_counter[i] += 1


total_counter_2 = list(zip(total_counter.keys(), total_counter.values()))

ans_list = []
c = 0
for i in sorted(total_counter_2,reverse = True):
    p, q = i
    for j in range(q):
        ans_list.append(p)
    c += q
    if c >= n:
        break
print(sum(ans_list[:n]))


### FIXED CODE ###

import sys
input = sys.stdin.readline

def swap(a):
    return ((a[1],a[0]))


n, m = [ int(v) for v in input().split() ]
num_list = [ (int(v), 1) for v in input().split() ]
change_list = [ swap([ int(v) for v in input().split() ]) for i in range(m) ]
total_list = sorted(num_list + change_list, reverse = True)

k = n
ans = 0

for i in total_list:

    j = min(i[1], k)
    k -= j
    ans += i[0] * j
    if k == 0:
        break
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N=int(input())
S=input()
dic={}
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            tmp=S[i]+S[j]+S[k]
            dic[tmp]=1
print(len(dic))

### FIXED CODE ###

import sys
import copy
input = sys.stdin.readline

N=int(input())

S=input()


T=[[0] * 10 for _ in range(30000)]
for i in range(N):
    if i!=0:
        T[i]=copy.deepcopy(T[i-1])
    T[i][int(S[i])]+=1
#print(T)

dic={}
flag=[False]*10
for i in range(N-2):
    if flag[int(S[i])]==True:
        continue
    flag[int(S[i])]=True
    for j in range(i+1,N-1):
        tmp2=copy.deepcopy(T[N-1])
        tmp3=copy.deepcopy(T[j])
        tmp4=""
        for k in range(10):
            if tmp2[k]-tmp3[k]!=0:
                tmp4=S[i]+S[j]+str(k)
                #print(tmp4)
                if tmp4 in dic:
                    pass
                else:    
                    dic[tmp4]=1
           
print(len(dic))
#print(dic)
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')

N, W = MAP()
w, v = ZIP(N)
max_v = N*sum(v)
dp = [INF]*(max_v+1)
dp[0] = 0
for i in range(N):
	for j in range(max_v, -1, -1):
		if j-v[i] >= 0:
			dp[j] = min(dp[j], dp[j-v[i]]+w[i])

ans = 0
for i in range(max_v+1):
	if dp[i] <= W:
		ans = i
print(ans)


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')

N, W = MAP()
w, v = ZIP(N)
max_v = sum(v)
dp = [INF]*(max_v+1)
dp[0] = 0
for w, v in zip(w, v):
	for i in range(max_v, -1, -1):
		if i-v >= 0:
			dp[i] = min(dp[i], dp[i-v]+w)

ans = 0
for i in range(len(dp)):
	if dp[i] <= W:
		ans = i
print(ans)
### BUGGY CODE ###

import itertools
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
ans = 0
for L in itertools.permutations(A):
    temp = 0
    for i in range(1, N):
        temp += min(L[0], L[i-1])
    ans = max(ans, temp)
print(ans)


### FIXED CODE ###

import itertools
import sys
input = sys.stdin.readline

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

ans = A[0]
for i in range(2, N):
    ans += A[i//2]

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

N, M = map(int, input().split(" "))
A = [int(i) for i in input().split(" ")]

for i in range(M):
    tmp_index = A.index(max(A))
    A[tmp_index] = A[tmp_index] / 2
    
import math
B = [math.floor(A[i]) for i in range(len(A))]
print(sum(B))

### FIXED CODE ###

import heapq

N, M = map(int, input().split(" "))
A = [-int(_) for _ in input().split(" ")]

heapq.heapify(A)

for i in range(M):
    heapq.heappush(A, -(-heapq.heappop(A)// 2))
    
print(-sum(A))
### BUGGY CODE ###

# Five, Five Everywhere

#インポート
import math

#55,555以下の素数リスト作成
def generate_sosulist():
    sosu = []
    for i in range(2,55556):
        flag = True
        for j in range(2,i):
            if i%j == 0:
                flag = False
        if flag == True:
            sosu.append(i)
    return sosu

P = generate_sosulist()

#5で割って余り1を抽出
P = [i for i in P if i % 5 == 1]

#入力
N = int(input())

#出力
print("{} ".format(P[0:N]))

### FIXED CODE ###

# Five, Five Everywhere

#インポート
from math import sqrt, ceil

#55,555以下の素数リスト作成

def sosu_list(N):
    temp = [True]*(N+1)
    temp[0] = temp[1] = False
    for i in range(2, ceil(sqrt(N+1))):
        if temp[i]:
            temp[i+i::i] = [False]*(len(temp[i+i::i]))                            
    primes = [ n for n in range(N+1) if temp[n] ]
    return primes

P = sosu_list(55555)

#5で割って余り1を抽出
P = [i for i in P if i % 5 == 1]

#入力
N = int(input())

#出力
for i in range(N):
	print("{} ".format(P[i]),end ="")
### BUGGY CODE ###

import random
import copy
import numpy as np


def main():
    D = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(D)]

    t = [0] * D

    # 貪欲法でまず求める
    penalty = np.array(c)
    for i in range(D):
        ind = 0
        tmp = 0
        for j in range(26):
            if penalty[j] + s[i][j] > tmp:
                tmp = penalty[j] + s[i][j]
                ind = j
        penalty[ind] = 0
        t[i] = ind + 1
        for j in range(26):
            penalty[j] += c[j]

    # 適当なtをスワップしてスコアが伸びればそれを採用する
    ans = calc(s, c, t)
    rand = list(range(365))
    for i in range(1000):
        swap = random.sample(rand, 2)
        t[swap[0]], t[swap[1]] = t[swap[1]], t[swap[0]]
        tmp = calc(s, c, t)
        if tmp < ans:
            # 元に戻す
            t[swap[0]], t[swap[1]] = t[swap[1]], t[swap[0]]

    return t


def output(t):
    for tt in t:
        print(tt)


def calc(s, c, t):
    d = [0] * 26

    ans = 0
    days = 0
    for tt in t:
        for i in range(26):
            d[i] += 1
        d[tt-1] = 0
        ans += s[days][tt-1]
        for i in range(26):
            ans -= d[i] * c[i]
        days += 1
        # print(ans)

    return ans


if __name__ == "__main__":
    t = main()
    output(t)


### FIXED CODE ###

def main():
    D = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(D)]

    for i in range(D):
        print(1)


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

import sys

def read():
    return sys.stdin.readline().rstrip()

def main():
    n, m, k = map(int, read().split())
    friend = [set() for _ in range(n)]
    block = [set() for _ in range(n)]
    potential = [set() for _ in range(n)]
    for _ in range(m):
        a, b = [int(i) - 1 for i in read().split()]
        friend[a].add(b)
        friend[b].add(a)
    for _ in range(k):
        c, d = [int(i) - 1 for i in read().split()]
        block[c].add(d)
        block[d].add(c)
    sd = set()
    for u in range(n):
        if u in sd:
            continue
        sn = [u]
        pf = set()
        while sn:
            p = sn.pop()
            if p in sd:
                continue
            sd.add(p)
            pf.add(p)
            for f in friend[p]:
                sn.append(f)
        for pfi in pf:
            potential[pfi] |= pf
    print(*[len(potential[i] - friend[i] - block[i] - {i}) for i in range(n)])

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from collections import deque

def read():
    return sys.stdin.readline().rstrip()

def main():
    n, m, k = map(int, read().split())
    friend = [[] for _ in range(n)]
    block = [set() for _ in range(n)]
    potential = [set() for _ in range(n)]
    for _ in range(m):
        a, b = [int(i) - 1 for i in read().split()]
        friend[a].append(b)
        friend[b].append(a)
    for _ in range(k):
        c, d = [int(i) - 1 for i in read().split()]
        block[c].add(d)
        block[d].add(c)
    sd = set()
    for u in range(n):
        if u in sd:
            continue
        sn = deque([u])
        pf = set()
        while sn:
            p = sn.pop()
            if p in sd:
                continue
            sd.add(p)
            pf.add(p)
            for f in friend[p]:
                sn.append(f)
        for pfi in pf:
            potential[pfi] = pf
    print(*[len(potential[i]) - len(block[i] & potential[i]) - len(friend[i]) - 1 for i in range(n)])

if __name__ == '__main__':
    main()