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

from random import random, randint

K = 26
d = int(input())

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

s = []
for i in range(d):
    q = list(map(int, input().split()))
    s.append(q)

ans = []
last = [-1 for i in range(K)]
for i in range(d):
    x = []
    for j in range(K):
        x.append(pow(s[i][j] * c[j] * (i - last[j]), 3))

    sum = 0
    for j in range(K):
        sum += x[j]

    for j in range(K):
        x[j] /= sum

    prob = random()
    cur = 0
    for j in range(K):
        if cur + x[j] <= prob:
            cur += x[j]
            continue
        ans.append(j)
        last[j] = i
        break


def get_result():
    res = 0
    last = [-1 for i in range(K)]
    for i in range(d):
        res += s[i][ans[i]]
        last[ans[i]] = i
        for j in range(K):
            res -= c[j] * (i - last[j])
    return res


# print(get_result())
for qq in range(1000):
    i = randint(0, d - 1)
    nw = randint(0, K - 1)

    old = ans[i]
    old_res = get_result()

    ans[i] = nw
    res = get_result()

    if res < old_res:
        ans[i] = old

    # print(get_result())

for u in ans:
    print(u + 1)

### FIXED CODE ###

from random import random

K = 26
d = int(input())

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

s = []
for i in range(d):
    q = list(map(int, input().split()))
    s.append(q)

ans = []
last = [-1 for i in range(K)]
for i in range(d):
    x = []
    for j in range(K):
        x.append(pow(s[i][j] * s[i][j] * s[i][j] * c[j] * (i - last[j]) * c[j] * (i - last[j]), 2))

    sum = 0
    for j in range(K):
        sum += x[j]

    for j in range(K):
        x[j] /= sum

    prob = random()
    cur = 0
    for j in range(K):
        if cur + x[j] <= prob:
            cur += x[j]
            continue
        ans.append(j)
        last[j] = i
        break


def get_result():
    res = 0
    last = [-1 for i in range(K)]
    for i in range(d):
        res += s[i][ans[i]]
        last[ans[i]] = i
        for j in range(K):
            res -= c[j] * (i - last[j])
    return res


# print(get_result())
for u in ans:
    print(u + 1)
### BUGGY CODE ###

from collections import defaultdict


N = int(input())
A = list(map(int, input().split())) 
MOD = 10**9 + 7
def gcd(a,b):
  x = max([a,b])
  y = min([a,b])
  while y:
    x, y = y, x % y
  return x


def lcm(x, y):
  return x * y // gcd(x, y)


l = 1

for a in A:
    l = lcm(l, a)


ans = 0
for a in A:
    ans += (l // a)
ans %= MOD

print(ans)


### FIXED CODE ###

from fractions import gcd


def main():
        
    N = int(input())
    A = list(map(int, input().split())) 
    MOD = 10**9 + 7


    l = 1

    for a in A:
        l = l * a // gcd(l, a)


    ans = 0
    for a in A:
        ans += (l // a)
    ans %= MOD

    print(ans)


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

import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
import heapq

def main():
    s = input().strip()
    n = len(s)
    stq = set()
    k = int(input().strip())
    for i in range(n):
        for j in range(i+1, n+1):
            stq.add(s[i:j])
    stq = list(stq)
    heapq.heapify(stq)
    for i in range(k):
        ans = heapq.heappop(stq)
        if i == k-1:
            print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
import heapq

def main():
    s = input().strip()
    n = len(s)
    stq = set()
    k = int(input().strip())
    for i in range(n):
        for j in range(i+1, min(i+1+k+1, n+1)):
            stq.add(s[i:j])
    stq = list(stq)
    heapq.heapify(stq)
    for i in range(k):
        ans = heapq.heappop(stq)
        if i == k-1:
            print(ans)

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

from collections import Counter

def main():
  num = int(input())

  tmp = [input() for i in range(num)]

  count = Counter(tmp)

  tmp2 = [k for k, v in count.items() if count.most_common(1)[0][1] == v]

  for t in sorted(tmp2):
    print(t)

main()

### FIXED CODE ###

def main():
  num = int(input())

  tmp = [input() for i in range(num)]

  tmp2 = {}
  for t in tmp:
    if len(tmp2) == 0:
      tmp2[t] = 1
    else:
      if t in tmp2:
        tmp2[t] += 1
      else:
        tmp2[t] = 1

  _tmp2 = sorted(tmp2.items(), key=lambda x:x[1])
  tmp3 = sorted(tmp2.items())
  for t in tmp3:
    if _tmp2[-1][1] == t[1]:
      print(t[0])

main()
### BUGGY CODE ###

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

### FIXED CODE ###

import math
K = int(input())
b = []
ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        b.append(math.gcd(i, j))
n = len(b)
for i in range(n):
    for k in range(1, K+1):
        ans += math.gcd(b[i], k)
print(ans)
### BUGGY CODE ###

import heapq
n,k=map(int,input().split())
can=[]
for i in range(k):
    l,r=map(int,input().split())
    for j in range(l,r+1):
        can.append(j)
table=[0]*n
table[0]=1
ka=[0]*(n+1)
ka[0]=1
que=[0]
heapq.heapify(que)
can.sort()
while que:
    now=heapq.heappop(que)
    ka[now]=0
    for j in can:
        if now+j>=n:
            break
        table[now+j]=(table[now+j]+table[now])%998244353
        if ka[now+j]==0:
            heapq.heappush(que,now+j)
            ka[now+j]=1
print(table[-1]%998244353)

### FIXED CODE ###

p=998244353
n,k=map(int,input().split())
kukan=[]
for i in range(k):
    l,r=map(int,input().split())
    kukan.append((l,r))
dp=[0]*n
sdp=[0]*(n+1)
dp[0]=1
sdp[1]=1
for i in range(1,n):
    for l,r in kukan:
        left=max(0,i-r)
        right=max(0,i-l+1)
        dp[i]=(dp[i]+sdp[right]-sdp[left])%p
    sdp[i+1]=(sdp[i]+dp[i])%p
print(dp[-1])
### BUGGY CODE ###

n = int(input())
*a, = map(int, input().split())
ans = 0
mod = 10**9 + 7
for i in range(n):
    ans += a[i]*sum(a[i+1:])
print(ans % mod)

### FIXED CODE ###

from itertools import accumulate
n = int(input())
*a, = map(int, input().split())
cumsum = [0] + list(accumulate(a))
ans = sum(a[i]*cumsum[i] for i in range(n))
mod = 10**9 + 7
print(ans % mod)
### BUGGY CODE ###

s = input()
s = s.replace('BC', 'D')
s = list(s)

cnt = 0
pre = -1
while cnt != pre:
    pre = cnt
    for i in range(len(s)-1):
        if s[i:i+2] == list('AD'):
            cnt += 1
            s[i] = 'D'
            s[i+1] = 'A'
            
print(cnt)

### FIXED CODE ###

s = input()
s = s.replace('BC', 'D')

a = 0
cnt = 0
for x in s:
    if x == 'A':
        a += 1
    elif x == 'D':
        cnt += a
    else:
        a = 0

print(cnt)
### BUGGY CODE ###

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

dp=[0]*n
for i in range(n):
  dp[i]=((1/2)*P[i]*(P[i]+1)) / P[i]
ans=0
for i in range(n-k+1):
  ans=max(ans,sum(dp[i:i+k]))
print(ans)

### FIXED CODE ###

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

dp=[0]*n
ans,total=0,0
for i in range(n):
  dp[i]=((1/2)*P[i]*(P[i]+1)) / P[i]
  if i>=k:
    ans=max(ans,total)
    total-=dp[i-k]
  total+=dp[i]
ans=max(ans,total)
print(ans)
### BUGGY CODE ###

a=sorted(list(map(int,[input()for i in range(5)])),key=lambda x:x%10)
while str(a[0])[-1]=='0':
  a+=[a[0]]
  del a[0]
print(sum([a[0]]+[10*(0--i//10)for i in a[1:]]))

### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
li=[a,b,c,d,e]
li=sorted(li,key=lambda x:10 if x%10==0 else x%10)
print(li[0]+sum(map(lambda x:x+((10-x%10)if x%10 else 0),li[1:])))
### BUGGY CODE ###

from sys import stdin
from collections import Counter


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    a_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    count = Counter(a_arr)
    cnt = 0
    keys = count.keys()
    for key in keys:
        _ = count[key]
        if key+1 in keys:
            _ += count[key+1]
        if key-1 in keys:
            _ += count[key-1]
        cnt = max(cnt,_)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


### FIXED CODE ###

from sys import stdin
from collections import Counter


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    a_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    count = Counter(a_arr)
    cnt = 0
    keys = sorted(count.keys())
    for key in keys:
        _ = count[key]
        try:
            _ += count[key+1]
        except:
            pass
        try:
            _ += count[key-1]
        except:
            pass
        cnt = max(cnt,_)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)
### BUGGY CODE ###

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

dic = {}
for s_i in s:
	dic[s_i] = s.count(s_i)+1

p = 10**9+7
res = 1
for v in dic.values():
	res = (res*v)%p

print((res-1)%p)

### FIXED CODE ###

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

dic = {}
for s_i in set(s):
	dic[s_i] = s.count(s_i)+1

p = 10**9+7
res = 1
for v in dic.values():
	res = (res*v)%p

print(res-1)
### BUGGY CODE ###

n,m = map(int,input().split())
ab = [ list(map(int,input().split())) for i in range(n)]
# print(ab)
ab.sort(reverse=True)
# print(ab)
# print(len(ab))
from heapq import heappush
from heapq import heappop
from heapq import heapify

heap = [0]*m

ans = 0
for i in reversed(range(m)):
    # print(ab)
    # print("i={}".format(i))
    if i < 0:
        break
    else:
        # print("n={}".format(n))
        for j in range(n):
            if (ab[j][0]+i) > m:
                pass
            else:
                heappush(heap, -(ab[j][1]))
                ab[j][1] = 0
        # print(heap)
    ans += heappop(heap)
    # print(ans)

# print(ans)
print(abs(ans))

### FIXED CODE ###

n,m = map(int,input().split())
ab = [ list(map(int,input().split())) for i in range(n) ]
# print(ab)
ab.sort()
# print(ab)
import heapq
heap = []
ans = 0
i = 0
for day in reversed(range(m)):
    while i<n and ab[i][0]==(m-day):
        heapq.heappush(heap,-ab[i][1])
        i += 1
    if len(heap) > 0:
        ans += -heapq.heappop(heap)
    # print(day,i,ans,heap)
print(ans)
### BUGGY CODE ###

#B問題
import bisect

N = int(input())
S = list(str(input()))
mod = 998244353
N_factorial = 1
for i in range(N):
    N_factorial*=(i+1)
    N_factorial%=mod

r,g,b = [],[],[]
for i in range(3*N):
    if S[i] == "R":
        r.append(i)
    if S[i] == "G":
        g.append(i)
    if S[i] == "B":
        b.append(i)
        
m,M = [],[]
for i in range(N):
    m.append(min(r[i],g[i],b[i]))
    M.append(max(r[i],g[i],b[i]))
    
A,B,C = [],[],[]    
    
for i in range(N):
    A.append(m[i])
    C.append(M[i])
    
for i in range(3*N):
    if i not in A and i not in C:
        B.append(i)
        
count = 1
for i,B_ind in enumerate(B):
    x = bisect.bisect_left(A,B_ind)-i
    y = i+1-bisect.bisect_right(C,B_ind)
    count*=(x*y)%mod
        
ans = (count*N_factorial)%mod
print(ans)

### FIXED CODE ###

#B問題
import bisect

N = int(input())
S = list(str(input()))
mod = 998244353
N_factorial = 1
for i in range(N):
    N_factorial*=(i+1)
    N_factorial%=mod

r,g,b = [],[],[]
for i,s in enumerate(S):
    if s == "R":
        r.append(i)
    if s == "G":
        g.append(i)
    if s == "B":
        b.append(i)
        
A,B,C = [],[],[]
for i in range(N):
    rgb = [r[i],g[i],b[i]]
    rgb.sort()
    A.append(rgb[0])
    B.append(rgb[1])
    C.append(rgb[2])

ans = N_factorial
for i,B_ind in enumerate(B):
    x = bisect.bisect_left(A,B_ind)-i
    y = i+1-bisect.bisect_left(C,B_ind)
    ans*=(x*y)
    ans%=mod

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

n = int(input())
s = [input() for i in range(n)]
for k in range(n):
    s[k]=''.join(sorted(list(s[k])))
count = 0

for x in range (n-1):
    for y in range (x+1,n):
        if s[x]==s[y]:
            count += 1
print(count)


### FIXED CODE ###

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

n = int(input())
s = [input() for i in range(n)]
for k in range(n):
    s[k]=sorted(list(s[k]))
s=sorted(s)

c = 1
count = 0

for x in range (n-1):
        if s[x]==s[x+1]:
            c += 1
        else:
            if c>= 2:
                count += cmb(c,2)
            c = 1
if c >=2:
    count += cmb(c,2)
print(count)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    h, w, k = input_int_list()
    num = 0
    grid = []
    for _ in range(h):
        grid.append(list(input()))

    # 分割統治法
    def solver(x_b, y_b, x_e, y_e):  # x_end,y_endは包含/排他範囲
        # いちごの数を数える
        cnt = 0
        first = None
        second = None
        for i in range(x_b, x_e):
            for j in range(y_b, y_e):
                if grid[i][j] == "#":
                    cnt += 1
                    if not first:
                        first = [i, j]
                    elif not second:
                        second = [i, j]
        if cnt == 1:
            nonlocal num
            num += 1
            for i in range(x_b, x_e):
                for j in range(y_b, y_e):
                    grid[i][j] = num
            return
        # いちごが少なくとも1つ含まれるように分割する
        if cnt > 1:
            if first[0] != second[0]:
                x_edge = max(first[0], second[0])
                solver(x_b, y_b, x_edge, y_e)
                solver(x_edge, y_b, x_e, y_e)
            elif first[1] != second[1]:
                y_edge = max(first[1], second[1])
                solver(x_b, y_b, x_e, y_edge)
                solver(x_b, y_edge, x_e, y_e)

    solver(0, 0, h, w)
    for line in grid:
        print(*line)

    return


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    h, w, k = input_int_list()
    num = 0
    grid = []
    for _ in range(h):
        grid.append(list(input()))

    # 分割統治法
    def solver(x_b, y_b, x_e, y_e):  # x_end,y_endは包含/排他範囲
        # いちごの数を数える
        cnt = 0
        first = None
        second = None
        for i in range(x_b, x_e):
            for j in range(y_b, y_e):
                if grid[i][j] == "#":
                    cnt += 1
                    if not first:
                        first = [i, j]
                    elif not second:
                        second = [i, j]
        if cnt == 1:
            nonlocal num
            num += 1
            for i in range(x_b, x_e):
                for j in range(y_b, y_e):
                    grid[i][j] = num
            return
        # いちごが少なくとも1つ含まれるように分割する
        if cnt > 1:
            if first[0] != second[0]:
                x_edge = max(first[0], second[0])
                solver(x_b, y_b, x_edge, y_e)
                solver(x_edge, y_b, x_e, y_e)
            elif first[1] != second[1]:
                y_edge = max(first[1], second[1])
                solver(x_b, y_b, x_e, y_edge)
                solver(x_b, y_edge, x_e, y_e)

    solver(0, 0, h, w)
    for line in grid:
        print(*line)

    return


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

S = input()

count = 0
mod_check = {}
mod_check[0] = 1
check_S = 0
for x in range(len(S) - 1, -1, -1):
    check_S += int(S[x]) * (10 ** (len(S) - x - 1))
    mod = check_S % 2019
    mod_check.setdefault(mod, 0)
    mod_check[mod] += 1
mod_match = 0
for x in mod_check.values():
    mod_match += x * (x - 1) // 2
print(mod_match)


### FIXED CODE ###

S = input()

count = 0
mod_check = [0] * 2019
mod_check[0] = 1
check_S = 0
d = 1
for i in reversed(S):
    check_S += int(i) * d
    check_S %= 2019
    mod_check[check_S] += 1
    d *= 10
    d %= 2019
    count += 1
mod_match = 0
for x in mod_check:
    mod_match += x * (x - 1) // 2
print(mod_match)
### BUGGY CODE ###

import sys, numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson  
from collections import defaultdict
from itertools import product, permutations, combinations

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

N, u, v = map(int, input().split())

adjm = [[float('inf')] * N for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    adjm[a][b] = 1
    adjm[b][a] = 1
    
dv = dijkstra(adjm, indices=v-1)
du = dijkstra(adjm, indices=u-1)
dOK = [(i>j)*i for i, j in zip(dv, du)]

print(int(max(dOK)-1))



### FIXED CODE ###

import sys, heapq
from collections import defaultdict
from itertools import product, permutations, combinations

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

N, u, v = map(int, input().split())



def dijkstra_heap(s,edge):
#始点sから各頂点への最短距離
    d = [10**20] * N
    used = [True] * N #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

AB = [list(map(int, input().split())) for _ in range(N-1)]

adjl = [[] for _ in range(N)]
for ab in AB:
    a, b = ab[0]-1, ab[1]-1
    adjl[a].append([1, b])
    adjl[b].append([1, a])

du = dijkstra_heap(u-1, adjl)
dv = dijkstra_heap(v-1, adjl)
dOK = [j for i, j in zip(du, dv) if i < j]

print(int(max(dOK)-1))
### BUGGY CODE ###

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()))
c = collections.Counter(A)

for i in range(1, N+1):
    print(c[i])
### BUGGY CODE ###

from fractions import gcd
# 逆元なしでいけるか確認

N = int(input())
A = tuple(map(int, input().split()))
MOD = 10 ** 9 + 7


lcm = A[0]
for i in range(1, N):
    lcm = (lcm * A[i] // (gcd(lcm, A[i])))
ans = 0

for a in A:
    ans = (ans + lcm // a) % MOD

print(ans)

### FIXED CODE ###

from fractions import gcd

N = int(input())
A = tuple(map(int, input().split()))
MOD = 10 ** 9 + 7


def modinv(a, mod=10 ** 9 + 7):
    return pow(a, mod - 2, mod)

lcm = A[0]
for i in range(1, N):
    lcm = (lcm * A[i] // (gcd(lcm, A[i])))
ans = 0
lcm %= MOD

for a in A:
    ans = (ans + lcm * modinv(a)) % MOD

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

from functools import lru_cache
import sys
sys.setrecursionlimit(10**9)
@lru_cache(maxsize=None)
def f(n):
    if 0 < n and n  < 10:
        return n
    else:
        n = str(n)
        if int(n[-1]) == 0:
            return f(int(n)-1)
        if int(n[0]) < int(n[-1]):
            k = len(n) - 2
            n = int(n)
            if k > 0:
                return f(n-1) + int('1'*k)*2
            else:
                return f(n-1)
        elif int(n[0]) > int(n[-1]):
            k = len(n) - 1
            n = int(n)
            s = int('1'*k)*2
            return  f(n-1) + s
        else:
            k = len(n) - 2
            if k > 0:
                N = int(n)
                return f(N-1) + int('1'*k)*2  + int(n[1:-1])*2 + 3
            else:
                N = int(n)
                return f(N-1) + 3
                
p = int(input())
print(f(p))

### FIXED CODE ###

from functools import lru_cache
import sys
sys.setrecursionlimit(10**9)
@lru_cache(maxsize=None)
def f(n):
    if 0 < n and n  < 10:
        return n
    else:
        n = str(n)
        if int(n[-1]) == 0:
            return f(int(n)-1)
        if int(n[0]) < int(n[-1]):
            k = len(n) - 2
            n = int(n)
            if k > 0:
                return f(n-1) + int('1'*k)*2
            else:
                return f(n-1)
        elif int(n[0]) > int(n[-1]):
            k = len(n) - 1
            n = int(n)
            s = int('1'*k)*2
            return  f(n-1) + s
        else:
            k = len(n) - 2
            if k > 0:
                N = int(n)
                return f(N-1) + int('1'*k)*2  + int(n[1:-1])*2 + 3
            else:
                N = int(n)
                return f(N-1) + 3
                
p = int(input())
print(f(p))
### BUGGY CODE ###

a, b, k= map(int, input().split())
for x in range(a,b+1):
    if x < a + k:
        print(x)
    elif x > b - k:
        print(x)  
    else:
        continue

### FIXED CODE ###

a, b, k= map(int, input().split())
for x in range(a,min(a+k,b+1)):
    print(x)
for x in range(b-k+1,b+1):
    if x < a+k:
        continue
    else:
        print(x)