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

#!/home/matsumotokazuho/.pyenv/shims/pypy
# import math
# from copy import deepcopy
# from operator import itemgetter
# from collections import defaultdict
# from collections import Counter
# from collections import deque
# import pprint
import itertools
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

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

# q = deque()
q = []
for i, j in itertools.product(range(H), range(W)):
    if Board[i][j] == '#':
        # Board[i][j] = 0
        q.append((i, j))

ans = 0
while q:
    qq = []
    ans += 1
    for yx in q:
        for d in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            y, x = [i+j for i, j in zip(yx, d)]
            if y < 0 or H - 1 < y or x < 0 or W - 1 < x:
                pass
            elif Board[y][x] == '.':
                # Board[y][x] = Board[q[0][0]][q[0][1]] + 1
                Board[y][x] = '#'
                qq.append((y, x))
    q = qq

# ans = max(list(itertools.chain.from_iterable(Board)))
# ans = max(itertools.chain.from_iterable(Board))
# pprint.pprint(Board)
print(ans-1)


### FIXED CODE ###

#!/home/matsumotokazuho/.pyenv/shims/pypy
# import math
# from copy import deepcopy
# from operator import itemgetter
# from collections import defaultdict
# from collections import Counter
# from collections import deque
# import pprint
# import itertools
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

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

# q = deque()
q = []
# for i, j in itertools.product(range(H), range(W)):
for i in range(H):
    for j in range(W):
        if Board[i][j] == '#':
            # Board[i][j] = 0
            q.append((i, j))

ans = 0
while q:
    qq = []
    ans += 1
    for yx in q:
        for d in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            y = yx[0] + d[0]
            x = yx[1] + d[1]
            # y, x = [i+j for i, j in zip(yx, d)]
            if y < 0 or H - 1 < y or x < 0 or W - 1 < x:
                pass
            elif Board[y][x] == '.':
                # Board[y][x] = Board[q[0][0]][q[0][1]] + 1
                Board[y][x] = '#'
                qq.append((y, x))
    q = qq

# ans = max(list(itertools.chain.from_iterable(Board)))
# ans = max(itertools.chain.from_iterable(Board))
# pprint.pprint(Board)
print(ans-1)
### BUGGY CODE ###

s = input()
x, y = map(int, input().split())
l = s.split("T")
#print(l)
x -= len(l[0])
ys = []
xs = []
if len(l) == 1:
  if x == 0 and y == 0:
    print("Yes")
  else:
    print("No")
  exit(0)
for i in range(len(l)):
  if i == 0:
    continue
  if i % 2:
    ys.append(len(l[i]))
  else:
    xs.append(len(l[i]))
#移動しうるマスの総数はなんとか全列挙できるレベル
#先頭からi番目まで見たとき、移動可能であるマス
#何x何のDPなら追いつくのか考える
#bitDPするよりずっと現実的

dpy = [[0] * (2 * sum(ys) + 1) for _ in range(len(ys) + 2)]
dpx = [[0] * (2 * sum(xs) + 1) for _ in range(len(xs) + 2)]
dpy[0][sum(ys)] = 1
dpx[0][sum(xs)] = 1
#print(ys, xs)
#print(dpy, dpx)
for i in range(len(ys)):
  for j in range(2 * sum(ys) + 1):
    if dpy[i][j] == 0:
      continue
    #print(i, j)
    dpy[i + 1][j + ys[i]] += dpy[i][j]
    dpy[i + 1][j - ys[i]] += dpy[i][j]
for i in range(len(xs)):
  for j in range(2 * sum(xs) + 1):
    if dpx[i][j] == 0:
      continue
    dpx[i + 1][j + xs[i]] += dpx[i][j]
    dpx[i + 1][j - xs[i]] += dpx[i][j]
#print(dpx, dpy)
if y >= sum(ys) + 1 or x >= sum(xs) + 1:
  print("No")
  exit(0)
if dpy[len(ys)][y + sum(ys)] > 0 and dpx[len(xs)][x + sum(xs)] > 0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s = input()
x, y = map(int, input().split())
l = s.split("T")
#print(l)
x -= len(l[0])
ys = []
xs = []
if len(l) == 1:
  if x == 0 and y == 0:
    print("Yes")
  else:
    print("No")
  exit(0)
for i in range(len(l)):
  if i == 0:
    continue
  if i % 2:
    ys.append(len(l[i]))
  else:
    xs.append(len(l[i]))
#移動しうるマスの総数はなんとか全列挙できるレベル
#先頭からi番目まで見たとき、移動可能であるマス
#何x何のDPなら追いつくのか考える
#bitDPするよりずっと現実的
#集合を使うと無駄なカウントがない
dpx = set()
dpx.add(0)
for i in range(len(xs)):
  nextset = set()
  for j in dpx:
    nextset.add(j + xs[i])
    nextset.add(j - xs[i])
  dpx = nextset
dpy = set()
dpy.add(0)
for i in range(len(ys)):
  nextset = set()
  for j in dpy:
    nextset.add(j + ys[i])
    nextset.add(j - ys[i])
  dpy = nextset
if x in dpx and y in dpy:
  print("Yes")
else:
  print("No")
### BUGGY CODE ###

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

init=0
loop=N
C=0
Done=[0 for _ in range(N)]
Done[0]=1
Order=[0]

while max(Done)<2 and len(Order)<N:
    C=A[C]-1
    Done[C]+=1
    if Done[C]==2:
        init=Order.index(C)
        loop=len(Order)-init
        break
    Order.append(C)

if K<=init:
    print(Order[K]+1)
else:
    print(1+Order[(K-init)%loop+init])

### FIXED CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
done=[-1 for _ in range(N)]
done[0]=0
n=0
now=0
init=0
loop=N
log=[0]

while n<N:
    log.append(A[log[-1]]-1)
    n+=1
    if done[log[-1]]>-1:
        init=done[log[-1]]
        loop=n-done[log[-1]]
        break
    done[log[-1]]=n

if K<init:
    print(log[K]+1)
else:
    num=init+(K-init)%loop
    print(log[num]+1)
### BUGGY CODE ###

import sys

n = int(input())
list_input = list(map(int, sys.stdin.readline().strip().split()))

if 0 in list_input:
    print(0)
    exit()

a = 1
for i in list_input:
    a *= i


if a > pow(10, 18):
    print(-1)
else:
    print(a)


### FIXED CODE ###

import sys

n = int(input())
list_input = list(map(int, sys.stdin.readline().strip().split()))

if 0 in list_input:
    print(0)
    exit()

a = 1
for i in list_input:
    a *= i
    if a > pow(10, 18):
        break


if a > pow(10, 18):
    print(-1)
else:
    print(a)
### BUGGY CODE ###

n = int(input())
a = [input() for i in range(n)]
for i in range(n):
    tmp = a[i]
    a.pop(i)
    print(max(a))
    a.insert(i, tmp)


### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
a_sort = sorted(a.copy())
for i in range(n):
    print(a_sort[-2] if a[i] == a_sort[-1] else a_sort[-1])
### BUGGY CODE ###

s = input()
t = input()
for _ in range(26):
    sigma = set()
    for x, y in zip(s, t):
        if x != y:
            x, y = sorted([x, y])
            sigma.add((x,y))
    sigma = sorted(sigma)
    for c1, c2 in sigma:
        tem = ""
        for c in s:
            if c == c1:
                tem += c2
            elif c == c2:
                tem += c1
            else:
                tem += c
        s = tem
    if s == t:
        print('Yes')
        exit()
print('No')

### FIXED CODE ###

s = input()
t = input()
a_z = 'abcdefghijklmnopqrstuvwxyz'
D1 = dict(zip([c for c in a_z],[-1 for _ in range(len(a_z))]))
D2 = dict(zip([c for c in a_z],[-1 for _ in range(len(a_z))]))
for x, y in zip(s, t):
    if D1[x] == -1:
        D1[x] = y
    else:
        if D1[x] != y:
            print('No')
            exit()
    if D2[y] == -1:
        D2[y] = x
    else:
        if D2[y] != x:
            print('No')
            exit()
else:
    print('Yes')
### BUGGY CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
N,M = LI()

um = [[] for i in range(M)]
for i in range(M):
    um[i] = LI()
S,T = LI()
S -= 1
T -= 1
routes = [[] for i in range(N)]
for i in range(M):
    u,m = um[i]
    u -= 1
    m -= 1
    routes[u].append(m)

used = [[mod,mod,mod] for i in range(N)]

# print(routes)
# def skip(now,move_cnt):
#     flag = True
#     if used[now] != mod:
#         if used[now] % 3 == 0 and move_cnt > used[now]:
#             flag = False
#     if used[now] > move_cnt:
#         if used[now] % 3 == 0 and move_cnt % 3 != 0:
#             pass
#         else:
#             used[now] = move_cnt
#     if flag:
#         for route in routes[now]:
#             skip(route,move_cnt+1)
def move2next(now,move_cnt):
    flag = True
    if used[now][move_cnt % 3] == mod:
        used[now][move_cnt % 3] = move_cnt
    elif used[now][move_cnt % 3] <= move_cnt:
        flag = False # この条件だと前より遅いので探索ストップ
    else:
        used[now][move_cnt % 3] = move_cnt
    if flag:
        for route in routes[now]:
            move2next(route, move_cnt+1)

move2next(S,0)
# print(used)
try:
    ans = used[T][0]
    if ans == mod:
        ans = -1
    else:
        ans = ans/3
except:
    ans = -1
print(int(ans))


### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import numpy as np
import queue

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
N,M = LI()

um = [[] for i in range(M)]
for i in range(M):
    um[i] = LI()

S,T = LI()
S -= 1
T -= 1
routes = [[] for i in range(N)]

for i in range(M):
    u,m = um[i]
    u -= 1
    m -= 1
    routes[u].append(m)

used = [[mod,mod,mod] for i in range(N)]

from collections import deque

# q = queue.Queue()
q = deque()
q.append((S,0))
# Deep First Serch
while q:
    now, cost = q.popleft()
    for route in routes[now]:
        n_state = (cost + 1) % 3
        if used[route][n_state] == mod:
            used[route][n_state] = cost + 1
            q.append((route,cost+1))


# print(used)
try:
    ans = used[T][0]
    if ans == mod:
        ans = -1
    else:
        ans = ans/3
except:
    ans = -1
print(int(ans))
### BUGGY CODE ###

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

cumpro=[]

pro=1
for i in range(n):
    pro*=a[i]
    cumpro.append(pro)


for j in range(k,n):
    if j==k:
        a=cumpro[k-1]
        b=cumpro[j]/cumpro[j-k]
    else:
        a=cumpro[j-1]/cumpro[j-1-k]
        b=cumpro[j]/cumpro[j-k]

    if b>a:
        print('Yes')
    else:
        print('No')



### FIXED CODE ###

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

for i in range(k,n):
    if a[i]>a[i-k]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###


def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

#####segfunc######
def segfunc(x,y):
    return x.union(y)

def init(init_val, seg):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])

def update(k,x, seg):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q, seg):
    if q<=p:
        return set()
    p += num-1
    q += num-2
    res=set()
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

n = n_in()
S = s_in()
Q = n_in()


ide_ele = 0

alphabets = 'abcdefghijklmnopqrstuvwxyz'

# T = {}

# n = 500000
# S = 'a'*nA

num = 2**(n-1).bit_length()
seg = [set() for _ in range(2*num)]
init([set([s]) for s in S] , seg)

for _ in range(Q):
    n, i, j = input().split()
    if int(n) == 1:
        update(int(i)-1, set([j]), seg)
    else:
        print(len(query(int(i)-1, int(j), seg)))


### FIXED CODE ###


def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

class SegmentTree():
    def __init__(self, n, init_val, segfunc, unifunc):
        self.n = n
        self.size = 2**(n-1).bit_length()
        self.segfunc = segfunc
        self.unifunc = unifunc

        self.seg = [unifunc() for _ in range(2*self.size)]

        for i in range(self.n):
            self.seg[i+self.size-1] = init_val[i]

        for i in range(self.size-2,-1,-1):
            self.seg[i] = self.segfunc(self.seg[2*i+1], self.seg[2*i+2])


    def update(self, k, x):
        k += self.size-1
        self.seg[k] = x
        while k:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2])

    def query(self, p, q): # [p, q)
        if q <= p:
            return self.unifunc()
        p += self.size-1
        q += self.size-2
        res = self.unifunc()

        while q-p > 1:
            if p&1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
        return res

n = n_in()
S = s_in()
Q = n_in()


dic={i:j for i,j in zip('abcdefghijklmnopqrstuvwxyz',[2**i for i in range(26)])}

T = SegmentTree(n,
    [dic[s] for s in S],
    lambda x,y: x|y,
    lambda: 0
    )

for _ in range(Q):
    n, i, j = input().split()
    if int(n) == 1:
        T.update(int(i)-1, dic[j])
    else:
        print(bin(T.query(int(i)-1, int(j))).count('1'))
### BUGGY CODE ###

def judge(n):
    if n<2:
        return False
    if n==2:
        return True
    if n%2==0:
        return False
    i=3
    while i<n:
        if n%i==0:
            return False
        i+=1
    return True

N=int(input())
count=0
for i in range(N):
    if(judge(int(input()))==True):
        count+=1

print(count)

### FIXED CODE ###

import math


def judge(n):
    if n < 2:
        return False
    i = 2
    while i <= math.sqrt(n):
        if n % i == 0:
            return False
        i += 1
    return True


count = 0
n = int(input())
for i in range(n):
    if judge(int(input())):
        count += 1
print(count)
### BUGGY CODE ###

n= int(input())
l=[]

for i in range(n):
    x = input()
    if (x in l)==False:
        l.append(x)
    sorted(l)
print(len(l))
    

### FIXED CODE ###

n= int(input())
l=[]

for i in range(n):
    x=input()
    l.append(x)
    
l2=list(set(l))    
print(len(l2))
### BUGGY CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
B = Counter(A)
seen = [-1]*(10**6)
for i in range(N):
    if seen[A[i]] != -1:
        print(seen[A[i]])
        continue
    B[A[i]] -= 1
    ans = 0
    for n in B.values():
        ans += n*(n-1)//2
    print(ans)
    seen[A[i]] = ans
    B[A[i]] += 1

### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
B = Counter(A)

ans = 0
for i in B.values():
    ans += i*(i-1)//2

for a in A:
    k = B[a]
    print(ans - (k*(k-1)//2)+((k-1)*(k-2)//2))
### BUGGY CODE ###

import sys


def isp(n):
    a = 1
    for i in range(2, (n + 1) // 2 + 2):
        if not n % i:
            a = 0
            break
    return a


for i in sys.stdin:
    i = int(i)
    if i == 2:
        print(1)
    elif i == 3:
        print(2)
    else:
        s = 2
        for x in range(2, i + 1):
            if isp(x):
                s += 1
        print(s)

### FIXED CODE ###

import sys

f = [1, 0, 0, 0, 1, 0] * (1000000 // 6 + 1)
f = [0, 0, 1, 1] + f[3:-2]

i = 5
while i < 1000:
    if f[i] == 1:
        j = i * i
        while j <= 1000000:
            f[j] = 0
            j += i + i
    i += 2

for n in sys.stdin:
    i = int(n)
    print(sum(f[:i + 1]))
### BUGGY CODE ###

n = int(input())
sq = list(map(int, input().split()))
for _ in range(n):
    c = sq.pop()
    if c in sq:
        print('NO')
        exit()
print('YES')

### FIXED CODE ###

n = int(input())
sq = list(map(int, input().split()))
st = set(sq)
if len(sq) == len(st):
    print('YES')
else:
    print('NO')
### BUGGY CODE ###

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

re = 0
max_dif = 0
for i in range(1, N):
    dif = A[i] - min(A[0:i])
    if max_dif < dif:
        max_dif = dif
        re = 1
    elif dif == max_dif:
        re += 1

print(re)

### FIXED CODE ###

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

re = 0
max_dif = 0
A_min = A[0]
for i in range(1, N):
    A_min = min(A_min, A[i-1])
    dif = A[i] - A_min
    if max_dif < dif:
        max_dif = dif
        re = 1
    elif dif == max_dif:
        re += 1

print(re)
### BUGGY CODE ###

import sys
from collections import deque, defaultdict
import copy
import bisect
#input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)


N, Q = list(map(int, input().split()))
STX=[]
D=[]
for i in range(N):
    STX.append(list(map(int, input().split())))
for i in range(Q):
    D.append(int(input()))

dist = [10000000000000 for i in range(Q)]

for i in range(N):
    s = STX[i][0] - STX[i][2]
    t = STX[i][1] - STX[i][2] - 1
    a = bisect.bisect_left(D, s)
    b = bisect.bisect_right(D, t)
    for j in range(a, b):
        dist[j] = min(dist[j], STX[i][2])


for i in range(Q):
    if dist[i] > 100000000000:
        print(-1)
    else:
        print(dist[i])

### FIXED CODE ###

import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)


N, Q = list(map(int, input().split()))
STX=[]
D=[]
for i in range(N):
    S, T, X = list(map(int, input().split()))
    STX.append((X, S, T))
STX = sorted(STX, key=lambda x: x[0])

for i in range(Q):
    D.append(int(input()))

skip = [-1]*Q

dist = [-1]*Q

for X, S, T in STX:
    s = S - X
    t = T - X - 1
    a = bisect.bisect_left(D, s)
    b = bisect.bisect_right(D, t)
    #print(D)
    j = a
    while j < b:
        if skip[j] == -1:
            skip[j] = b
            dist[j] = X
            j+=1
        else:
            j=skip[j]


for i in range(Q):
    print(dist[i])
### BUGGY CODE ###

s=input()

a=[1,0,0,0]

for i in range(len(s)):
    c=s[i]
    if c=="A":
        a[1]+=a[0]
    elif c=="B":
        a[2]+=a[1]
    elif c=="C":
        a[3]+=a[2]
    elif c=="?":
        tmp=[a[i] for i in range(4)]
        a[0]=tmp[0]*3
        for j in range(3):
            a[j+1]=tmp[j+1]*3+tmp[j]

print(a[3]%1000000007)

### FIXED CODE ###

s=input()

a=[1,0,0,0]

for i in range(len(s)):
    c=s[i]
    if c=="A":
        a[1]+=a[0]
    elif c=="B":
        a[2]+=a[1]
    elif c=="C":
        a[3]+=a[2]
    elif c=="?":
        tmp=[a[i] for i in range(4)]
        a[0]=tmp[0]*3
        for j in range(3):
            a[j+1]=tmp[j+1]*3+tmp[j]

    a=[a[i]%1000000007 for i in range(4)]

print(a[3])
### BUGGY CODE ###

#D
n = int(input())
s = input()
s_l = list(s)


cnt = 0
for i in range(n-2):
    for j in range(i,n-1):
        if s_l[i] != s_l[j]:
            for k in range(j,n):
                if s_l[i] != s_l[k] and s_l[j] != s_l[k] and j-i != k-j:
                    cnt += 1

print(cnt)
     

### FIXED CODE ###

#D
n = int(input())
s = input()
s_l = list(s)

a = s_l.count('R') * s_l.count('G') * s_l.count('B')
cnt = 0
#i,j,kがそれぞれ異なり、j-i = k-jであるものを求める
for i in range(n-2):
    for j in range(i,n-1):
        if 2*j - i < n:
            if s_l[i] != s_l[j] and s_l[i] != s_l[2*j-i] and s_l[j] != s_l[2*j-i]:
                cnt += 1
                
print(a - cnt)
### BUGGY CODE ###

N, M, K = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
arui = [0]
brui = [0]
for i in range(N):
    arui.append(a[i] + arui[i])
for i in range(M):
    brui.append(b[i] + brui[i])

ans = 0
for i in range(N + 1):
    if arui[i] > K:
        break
    bcnt = M
    while brui[bcnt] + arui[i] > K:
        bcnt -= 1
    ans = max(ans, i + bcnt)

print(ans)

### FIXED CODE ###

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)

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

n = int(input())
s = input()
ans = 0
r, g, b = [], [], []
for i in range(n):
    if s[i] == "R":
        r.append(i)
    elif s[i] == "G":
        g.append(i)
    else:
        b.append(i)
tmp = []
for i in r:
    tmp.append(i)
    for j in g:
        tmp.append(j)
        for k in b:
            tmp.append(k)
            tmp.sort()
            if tmp[1] - tmp[0] != tmp[2] - tmp[1]:
                ans += 1
            tmp.remove(k)
        tmp.remove(j)
    tmp.remove(i)

print(ans)


### FIXED CODE ###

n = int(input())
s = input()
r, g, b = set(), set(), set()
for i in range(n):
    if s[i] == "R":
        r.add(i)
    elif s[i] == "G":
        g.add(i)
    else:
        b.add(i)

ans = len(r)*len(b)*len(g)
for i in r:
    for j in g:
        chk = j - i
        if chk + j in b:
            ans -= 1
        if i - chk in b:
            ans -= 1
        if (i + j)/2  in b:
            ans -= 1

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

import sys
input = sys.stdin.readline
X,Y,Z,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
DD = [i+j for i in A for j in B]
DD.sort()
F = [(i+j)
     for i in DD[max(len(DD)-3001,0):]
     for j in C
]
F.sort()
for i in range(K):
    print(F[-1-i])
        


### FIXED CODE ###

import sys
import heapq
input = sys.stdin.readline
X,Y,Z,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
DD = [i+j for i in A for j in B]
DD.sort()
heap = []
for i in DD[max(len(DD)-3001,0):]:
     for j in C:
         heapq.heappush(heap,-(i+j))
for i in range(K):
    print(-heapq.heappop(heap))
### BUGGY CODE ###

import numpy as np

def SUM(n):
    return (1+n)*n//2


D=int(input())
c=np.array(list(map(int,input().split())))
s=[list(map(int,input().split())) for _ in range(D)]
t=[np.random.randint(1,27) for _ in range(D)]

M=5000
MAX=0
for _  in range(M):
    d=np.random.randint(1,D+1)
    q=np.random.randint(1,27)
    contest=[[] for _ in range(26)]
    for i in range(D):
        if i==d-1:
            contest[q-1].append(d)
            continue
        contest[t[i]-1].append(i+1)
    v=0
    for i in range(26):
        pre=0
        minus=0
        for j in contest[i]:
            v+=s[j-1][i]
            minus+=SUM(j-pre-1)*c[i]
            pre=j
        minus+=SUM(D-pre)*c[i]
        v-=minus
    if v>MAX:
        MAX=v
        t[d-1]=q

for i in range(D):
    print(t[i])

### FIXED CODE ###

import numpy as np

D=int(input())
c=np.array(list(map(int,input().split())))
s=[list(map(int,input().split())) for _ in range(D)]
t=[np.random.randint(1,27) for _ in range(D)]

MAX=0
for _ in range(1000):
    d=np.random.randint(1,D+1)
    q=np.random.randint(1,27)
    last=np.array([0]*26)
    v=0
    for i in range(1,D+1):
        if i==d:
            v+=s[d-1][q-1]
            last[q-1]=d
            v-=np.dot(c,d-last)
            continue
        v+=s[i-1][t[i-1]-1]
        last[t[i-1]-1]=i
        v-=np.dot(c,i-last)
    if v>MAX:
        MAX=v
        t[d-1]=q

for i in range(D):
    print(t[i])