Harryxun/stf_run huggingface dataset:
def isOver(a,b):
    return True if (a[0]-b[0])**2 + (a[1]-b[1])**2 <= 4.0 else False
 
def largestGroup(mtrx,num):
    mx = 1
    ls = [num]
    for i in mtrx[num]:
        if i != num:
        	m = youKnow(mtrx,ls,i)
        	mx = max(mx,m)
    return mx
 
def youKnow(mtrx,ls,num):
    mx = len(ls)
    if set(ls) <= set(mtrx[num]):
        if num not in ls:
            ls.append(num)
        for i in list(set(mtrx[num])-set(ls)):
            m = youKnow(mtrx,ls,i)
            mx = max(mx,m)
    return mx
 
while True:
    max_over = 0
    n = int(raw_input())
    if n == 0: break
    seals = [map(float, raw_input().split(",")) for i in range(n)]
 
    overs = []
    for i in range(n):
        over = []
        for j in range(n):
            if isOver(seals[i],seals[j]):
                over.append(j)
        overs.append(over)
         
    ref = [i for i in range(n)]
    for i in ref:
        num_over = largestGroup(overs,i)
        for j in overs[i]:
            ref.remove(j)
        if num_over > max_over:
            max_over = num_over
    print max_over

### FIXED CODE ###

def isOver(array,x,y):
	return True if (array[0]-x)**2+(array[1]-y)**2 <= 1.01 else False
	
while True:
    mx = 0
    n = int(raw_input())
    if n == 0: break
    seals = [map(float, raw_input().split(",")) for i in range(n)]
    x = 0
    while x < 10.0:
    	y = 0.0
    	while y < 10.0:
    		num = 0
    		for seal in seals:
    			if isOver(seal,x,y):
    				num += 1
    		mx = max(mx,num)
    		y += 0.1
        x += 0.1
    print mx
def run():
    # sys.stdin.readline()
    import sys
    input = sys.stdin.readline
    r,c,k = map(int,input().split())
    t = [[0 for i in range(c)] for i in range(r)]
    for i in range(k):
        a,b,z = map(int,input().split())
        t[a-1][b-1] = z
    t = tuple(t)
    dp = [[[0 for i in range(c)]for i in range(r)]for i in range(4)]
    dp[0][0][0] = 0
    dp[1][0][0] = t[0][0]
    dp[2][0][0] = t[0][0]
    dp[3][0][0] = t[0][0]
    for i in range(r-1):
        dp[0][i+1][0] = dp[1][i][0]
        for j in range(1,4):
            dp[j][i+1][0] = dp[1][i][0]+t[i+1][0]
    for i in range(c-1):
        dp[0][0][i+1] = 0
        for j in range(1,4):
            dp[j][0][i+1] = max(dp[1][0][i],t[0][i+1])
        for j in range(2,4):
            dp[j][0][i+1] = max(dp[2][0][i],dp[1][0][i]+t[0][i+1])
        dp[3][0][i+1] = max(dp[3][0][i],dp[2][0][i]+t[0][i+1])
    for i in range(r-1):
        for j in range(c-1):
            u = max(dp[0][i+1][j],dp[3][i][j+1])
            for s in range(0,4):
                dp[s][i+1][j+1] =  u
            u = max(dp[0][i+1][j]+t[i+1][j+1],dp[1][i+1][j],dp[3][i][j+1]+t[i+1][j+1])
            for s in range(1,4):
                dp[s][i+1][j+1] = u
            u = max(dp[1][i+1][j]+t[i+1][j+1],dp[2][i+1][j],dp[3][i][j+1]+t[i+1][j+1])
            for s in range(2,4):
                dp[s][i+1][j+1] = u
            dp[3][i+1][j+1] = max(dp[2][i+1][j]+t[i+1][j+1],dp[3][i+1][j],dp[3][i][j+1]+t[i+1][j+1])
    print(dp[3][r-1][c-1])

if __name__ == "__main__":
    run()

### FIXED CODE ###

s = input()
s = list(s)
ans = [0 for i in range(3)]
p = 0
for i in range(3):
    if s[i] == 'R':
        ans[p] += 1
    else:
        p += 1
print(max(ans[0],ans[1],ans[2]))
a,b = map(int, input().split())
if a<= 8 and b <= 8:
  print("Yay!")
else:
print(":(")

### FIXED CODE ###

a,b = map(int, input().split())
if a<= 8 and b <= 8:
  print("Yay!")
else:
  print(":(")
n=int(input())
S=input()
a='abcdefghijklmnopqrstuvwxyz'
ans=1
for i in range(26):
  cnt=S.count(a[i])
  if cnt >0:
    ans=ans*(1.5**(cnt-1))*2
ans-=1
ans=ans%(10^9+7)
print(int(ans))

### FIXED CODE ###

n=int(input())
S=input()
a='abcdefghijklmnopqrstuvwxyz'
ans=1
for i in range(26):
  cnt=S.count(a[i])
  ans=ans*(cnt+1)
ans-=1
ans=ans%(10**9+7)
print(int(ans))
n,m= map(int,input().split())
a = [int(input()) for _ in range(m)]
d = [0]*(n+1)
if not 1 in a : d[1] = 1
if not 2 in a : d[2] = d[1] + 1
for i in range(3,n+1):
    if not i in a :
        d[i] += d[i-1] + d[i-2]
print(d[i]%1000000007)

### FIXED CODE ###

# DP
mod = 1000000007
 
n, m = map(int, input().split())
b_list = [True] * (n+1)
dp = [0 for _ in range(n+1)]
for i in range(m):
    b_list[int(input())] = False
 
dp[0] = 1
for i in range(n):
    for j in range(i+1, min(n, i+2)+1):
        if b_list[j] == True:
            dp[j] += dp[i]
            dp[j] %= mod
# print(b_list)
# print(dp)
print(dp[n])
a, b, n = map(int, input().split())
c = [0]*(n+1)
for x in range(n+2):
  c[x] = (a*x)//b - a*(x//b)
print(max(c))
  

### FIXED CODE ###

a, b, n = map(int, input().split())
x = min(b-1,n)
print((a*x)//b - a*(x//b))
N,K=map(int,input().split())
p=list(map(int,input().split()))
q=[]
for i in range(len(p)):
  q.append(p[i])
maxi=q[K]-q[0]
for i in range(1,N-K+1):
  sub=q[K+i]-q[i]
  if sub>=maxi:
    maxi=sub
print((maxi+K)/2)

### FIXED CODE ###

N,K=map(int,input().split())
p=list(map(int,input().split()))
q=[]
q.append(0)
for i in range(len(p)):
  q.append(q[-1]+p[i])
maxi=q[K]-q[0]
for i in range(1,N-K+1):
  sub=q[K+i]-q[i]
  if sub>=maxi:
    maxi=sub
print((maxi+K)/2)
n,i = map(int, input())
print(n - i + 1)

### FIXED CODE ###

n,i = map(int, input().split())
print(n - i + 1)
n = int(input())
x = list(map(int,input().split()))
count = 1
if n >=2:
  for i in range(n-1):
    if min(x[0:i])>=x[i+1]:
      count+=1
print(count)

### FIXED CODE ###

n = int(input())
x = list(map(int,input().split()))
count = 1
m = x[0]

for i in range(1,n):
  if m >=x[i]:
    count+=1
    m = x[i]
  
print(count)
N, K = map(int,input().split())
S = input()
S[K-1] = S[K-1].lower()
print('',join(S))


### FIXED CODE ###

N, K = map(int, input().split())
S = list(input())
S[K-1] = S[K-1].lower()
print("".join(S))
import sys
input = sys.stdin.readline
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

"""
(駅、会社)を頂点にグラフを持つ。頂点数O(M)。
そのまま辺を貼ると辺が多くなりすぎる。
(駅、会社) -> (駅、無属性) -> (駅、会社)
"""

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

U = 10 ** 6

V = set(range(1,N+1))
V |= set(p + c * U for p,q,c in PQC)
V |= set(q + c * U for p,q,c in PQC)
V = tuple(V)
v_to_i = {v:i for i,v in enumerate(V)}

# グラフを作成
rows, cols = [],[]
rows += [i for i,pc in enumerate(V) if pc > U]
cols += [v_to_i[pc % U] for i,pc in enumerate(V) if pc > U]
wt = [1] * len(rows)
rows += [v_to_i[p + c * U] for p,q,c in PQC]
cols += [v_to_i[q + c * U] for p,q,c in PQC]
wt += [0] * M

graph = csr_matrix((wt, (rows, cols)), (len(V), len(V)))

start = v_to_i[1]
goal = v_to_i[N]


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = read().rstrip().decode('utf-8')

def F(S):
    yield int(S)
    for i in range(len(S)-1):
        left = S[:i+1]
        right = S[i+1:]
        x = int(left)
        for y in F(right):
            yield x + y

answer = sum(F(S))
print(answer)
def gcd(a, b):
    a = int(a)
    b = int(b)
    m = int(0)
    while(b > 0):
        m = a 
        a = b
        b = m % a
    return a
    

def lcm(a, b):
    return int(a * b / gcd(a, b))

n = int(input())
t = []
for i in range(0, n):
    t.append(int(input()))
cur = t[0]
for i in range(1, n):
    cur = lcm(cur, t[i])
print(int(cur))

### FIXED CODE ###

def gcd(a, b):
    a = int(a)
    b = int(b)
    m = int(0)
    while(b > 0):
        m = a 
        a = b
        b = m % a
    return a
    

def lcm(a, b):
    return int(a * b // gcd(a, b))

n = int(input())
t = []
for i in range(0, n):
    t.append(int(input()))
cur = t[0]
for i in range(1, n):
    cur = lcm(cur, t[i])
print(int(cur))
T=int(input())
X=int(input())

t=(1/X)*T
print(t)

### FIXED CODE ###

i=list(map(int,input().split()))
t=(1/i[1])*i[0]
print(t)
input()
A = list(map(int, input().split))
count = 0
while all(a % 2 == 0 for a in A):
    A = [a/2 for a in A]
    count += 1
print(count)

### FIXED CODE ###

input()
A = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for a in A):
    A = [a/2 for a in A]
    count += 1
print(count)
#N, M = map(int, input().split())
#
#ans = [0 for i in range(M)]
#
#for i in range(N):
#    tmp = list(map(int, input().split()))
#    for j in range(tmp[0]):
#        ans[tmp[j]]+=1
#        
#now = 0
#        
#for i in range(M):
#    if ans[i]==N:
#        now+=1
#        
#print(now)
import math

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

        
ans = 0
now = a[0]

for i in range(N-1):
    now = math.gcd(now, a[i+1])

    
print(now)

### FIXED CODE ###

#N, M = map(int, input().split())
#
#ans = [0 for i in range(M)]
#
#for i in range(N):
#    tmp = list(map(int, input().split()))
#    for j in range(tmp[0]):
#        ans[tmp[j]]+=1
#        
#now = 0
#        
#for i in range(M):
#    if ans[i]==N:
#        now+=1
#        
#print(now)

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

def gcd(a, b):
    if a<b:
        b,a = a,b
        
    while b:
        a, b = b, a%b
    
    return a


ans = 0
now = a[0]

for i in range(N-1):
    tmp = gcd(now, a[i+1])
    now = tmp

    
print(now)
n,k=map(int,input().split())
l=list(map(int,input().split()))
f=[l.count(i) for i in range(1,n+1)]
f.sort()
print(sum(f[0:n-k]))


### FIXED CODE ###

print(input().count("1"))
a,b = list(map(int,input().split()))
if a <= b:
  print(a)*b
else:
  print(b)*a

### FIXED CODE ###

a,b = list(map(int,input().split()))
if a <= b:
  c = str(a)*b
  print(c)
else:
  d = str(b)*a
  print(d)
# import bisect
# import copy
# import fractions
import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product
import statistics as st

def resolve():

    N=int(input())
    x, y = [0] * N, [0] * N
    for i in range(N):
        x[i], y[i] = map(int, input().split())

    total=0
    all=[]
    for i in range(N):
        if i!=N-1:
            all.append(math.sqrt((x[i]-x[i+1])**2+(y[i]-y[i+1])**2))
        else:
            all.append(math.sqrt((x[0]-x[N-1])**2+(y[0]-y[N-1])**2))
            #total+=math.sqrt((x[0]-x[N-1])**2+(y[0]-y[N-1])**2)
    print(sum(all)-st.mean(all))




resolve()

### FIXED CODE ###

# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
from itertools import permutations

def resolve():
    N=int(input())
    l=[[0,0] for i in range(N)]
    for i in range(N):
        x,y=map(int,input().split())
        l[i][0],l[i][1]=x,y

    p=permutations(l)
    dist = 0
    for v in p:
        for i in range(N-1):
            dist+=((v[i][0]-v[i+1][0])**2+(v[i][1]-v[i+1][1])**2)**0.5

    print(dist/len(list(permutations((l)))))


resolve()
n = int(input())
p = tuple(map(int,input().split()))
c = 0
ans = "YES"
for i in range(1,n+1) :
    if p[i] != i :
        c += 1
if c <= 2 :
    ans = "NO"
print(ans)

### FIXED CODE ###

n = int(input())
p = tuple(map(int,input().split()))
c = 0
ans = "YES"
for i in range(n) :
    if p[i] != i+1 :
        c += 1
if c > 2 :
    ans = "NO"
print(ans)
import sys
X = int(input())
MAX = 10**9
M = [0]
i = 1
while i**5 < MAX:
  M.append(i**5)
  M.append(-i**5)
  i += 1
#print(M)
  
for i in M:
  for j in M:
    if i - j == X:
      if j < 0:
        print(int(i**(1/5)), -int((-j)**(1/5)))
      else:
        print(int(i**(1/5)), int(j**(1/5)))
      sys.exit(0)


### FIXED CODE ###

import sys
X = int(input())
MOD = 10**9+7
M = [i*m for i in range(0, 10**4) for m in [-1, 1]]
for i in range(0, 10**4):
  for j in M:
    if i == j:
      break
    if X%(i-j)==0:
      if i**5-j**5==X:
        print(i, j)
        sys.exit(0)
r=int(input())
print(3.1416*r**2)


### FIXED CODE ###

from math import pi
r = float(input())
a = pi*r*r
b = 2*pi*r
print(a,b)
#import sys
#print(sys.maxsize)
N,X,M=map(int,input().split())
table=list(range(M))
for i in range(M):
    table[i]=((table[i]%M)**2)%M
print(table[471])
start=X%M
rireki=list()
rireki.append(start)
ss=0
for j in range(1,N):
    if table[start] in rireki:
        ss=rireki.index(table[start])
        break
    else:
        rireki.append(table[start])
        start=table[start]
nn=len(rireki)
rep=(N-ss)//(nn-ss)
nokori=N-ss-rep*(nn-ss)
loop=rireki[ss:]
#print(nn)
#print(rep)
#print(sum(loop))
#print(ss)
#print(nokori+rep*(nn-ss)+ss)
if 0 in rireki:
    goukei=sum(rireki)
else:
    goukei=rep*sum(loop)+sum(rireki[:ss])+sum(loop[:nokori])
print(goukei)

### FIXED CODE ###

#import sys
#print(sys.maxsize)
N,X,M=map(int,input().split())
#table=list(range(M))
#for i in range(M):
 #   table[i]=((table[i]%M)**2)%M
#print(table[471])
start=X%M
rset=set()
rireki=list()
rset.add(start)
rireki.append(start)
ss=0
for j in range(1,M+1):
    start=(start**2)%M
    if start in rset:
        ss=rireki.index(start)
        break
    else:
        rireki.append(start)
        rset.add(start)
nn=len(rireki)
rep=(N-ss)//(nn-ss)
nokori=N-ss-rep*(nn-ss)
loop=rireki[ss:]
#print(nn)
#print(rep)
#print(sum(loop))
#print(ss)
#print(nokori+rep*(nn-ss)+ss)
if 0 in rireki:
    goukei=sum(rireki)
else:
    goukei=rep*sum(loop)+sum(rireki[:ss])+sum(loop[:nokori])
print(goukei)
n,k=map(int,input().split())
l=sorted(list(map(int,input().split())),reversed=True)

l=l[0:k]
max_l=max(l)

num=0
sum_lis=[]
for i in range(1,max_l+1):
  num+=i
  sum_lis.append(num)
  
ans=0
for i in l:
  a=sum_lis[i-1]
  ans+=(a/i)
  
print(ans)

### FIXED CODE ###

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

for i in range(n):
  l[i]=(l[i]+1)/2

lis=[0]*(n+1)
for i in range(n):
  lis[i+1]=lis[i]+l[i]
  
ans=0
for i in range(n-k+1):
  num=lis[i+k]-lis[i]
  ans=max(num,ans)
  
print(ans)
from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
dic = Counter(ss)
cnt=0
for k, v in dic.items():
  cnt += int(v)
print(cnt)

### FIXED CODE ###

from collections import Counter
n=int(input())
string_list=["".join(sorted(list(input()))) for i in range(n)]
counter=Counter(string_list)
cnt=0
for k, v in counter.items():
  cnt+=int(v*(v-1)/2)
print(cnt)
import fractions
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))

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

count=a[0]
for i in range(n-1):
    count=lcm(count,a[i+1])
ans=0
for i in range(n):
    ansa=count//a[i]
    ans+=ansa%=mod
    ans%=mod
print(ans)

### FIXED CODE ###

import fractions
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))

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

count=a[0]
for i in range(n-1):
    count=lcm(count,a[i+1])
ans=0
for i in range(n):
    ansa=count//a[i]
    ans+=ansa
    
print(ans%mod)
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n = I()
A = LI()


ans = 1
color = [0, 0, 0]
for i in range(n):
    ans = ans * color.count(A[i]) % mod
    color[color.index(A[i])] += 1



print(ans)






### FIXED CODE ###

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n = I()
A = LI()


ans = 1
color = [0, 0, 0]
for i in range(n):
    ans = ans * color.count(A[i]) % mod
    for j in range(3):
        if color[j] == A[i]:
            color[j] += 1
            break



print(ans)
A = int(input())
B = int(input())
N = int(input())
print(int(A*(N-1)/B)-A*int((N-1)/B))

### FIXED CODE ###

A,B,N=map(int,input().split())
if N+1>=B:
    T=int(A*(B-1)/B)
    print(T)
else:
    T=int(A*N/B)
    print(T)
# coding: utf-8
w = int(input())
ans = [i + 1 for i in range(w)]
loop = int(input())

# swap
for _ in range(loop):
    left, right = map(int, input().split(","))
    ans[left-1], ans[right-1] = ans[right-1], ans[left-1]

# result
for i in ans:
    print(i)


### FIXED CODE ###

# coding: utf-8
w = int(input())
ans = [i + 1 for i in range(w)]
loop = int(input())

# swap
for _ in range(loop):
    left, right = map(int, input().split(","))
    ans[left-1], ans[right-1] = ans[right-1], ans[left-1]

# result
for i in ans:
    print(i)
#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

p = 1 ** 61 - 1
p2 = 10 ** 8 + 7
q = 10 ** 2

def rollingHash(N, M, A, ans):
	mul = 1
	for i in range(M):
		mul = (mul * q) % p

	Droll = defaultdict(lambda:-1)
	val = 0
	for i in range(M):
		val = val * q + A[i]
		val %= p

	Droll[val] = 0
	for i in range(N - M):
		val = (val * q - A[i] * mul + A[i + M]) % p
		if Droll[val] != -1 and i + 1 - Droll[val] >= M:
			return M

		Droll[val] = i + 1
	return ans

#処理内容
def main():
	N = int(input())
	S = list(input())
	for i in range(N):
		S[i] = ord(S[i]) - 97

	ans = 0
	for i in range(1, N):
		ans = rollingHash(N, i, S, ans)

	print(ans)



if __name__ == '__main__':
	main()

### FIXED CODE ###

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

p = 10 ** 9 + 7
p2 = 10 ** 9 + 9
q = 1007
q2 = 2009

def rollingHash(N, M, A, ans):
	mul1 = 1
	mul2 = 1
	for i in range(M):
		mul1 = (mul1 * q) % p
		mul2 = (mul2 * q2) % p2

	Droll1 = defaultdict(lambda:-1)
	Droll2 = defaultdict(lambda:-1)
	val1 = 0
	val2 = 0
	for i in range(M):
		val1 = val1 * q + A[i]
		val1 %= p
		val2 = val2 * q2 + A[i]
		val2 %= p2

	Droll1[val1] = 0
	Droll2[val2] = 0
	rolling_Hash1 = [None] * (N - M + 1)
	rolling_Hash1[0] = val1
	rolling_Hash2 = [None] * (N - M + 1)
	rolling_Hash2[0] = val2

	for i in range(N - M):
		val1 = (val1 * q - A[i] * mul1 + A[i + M]) % p
		val2 = (val2 * q2 - A[i] * mul2 + A[i + M]) % p2
		rolling_Hash1[i + 1] = val1
		rolling_Hash2[i + 1] = val2

		if Droll1[val1] == -1:
			Droll1[val1] = i + 1
		else:
			if rolling_Hash1[i + 1] == rolling_Hash1[Droll1[val1]] and rolling_Hash2[i + 1] == rolling_Hash2[Droll1[val1]] and i + 1 - Droll1[val1] >= M:
				return M

	return ans

#処理内容
def main():
	N = int(input())
	S = list(input())
	for i in range(N):
		S[i] = ord(S[i]) - 97

	ans = 0
	for i in range(1, int(N // 2) + 1):
		ans = rollingHash(N, i, S, ans)

	print(ans)



if __name__ == '__main__':
	main()
#!/usr/bin/env python3

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

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

def get_objective_function(output):
    objective_function = 0
    last = [[-1 for i in range(26)] for d in range(D)]

    for d in range(D):
        objective_function += s[d][output[d]]

        last[d][output[d]] = d
        if d < D-1:
            for i in range(26):
                last[d+1][i] = max(last[d][i], last[d+1][i])

        for i in range(26):
            objective_function -= c[i] * (d-last[d][i])
        print(objective_function)

    point = max(10 ** 6 + objective_function, 0)


output = [0, 16, 12, 13, 12]

# 最大効用での戦略
#output = []
#for d in range(D):
#    output.append(s[d].index(max(s[d])))
#for d in output:
#    print(d+1)

get_objective_function(output)

### FIXED CODE ###

#!/usr/bin/env python3

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

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

def get_objective_function(output):
    objective_function = 0
    last = [[-1 for i in range(26)] for d in range(D)]

    for d in range(D):
        objective_function += s[d][output[d]]

        last[d][output[d]] = d
        if d < D-1:
            for i in range(26):
                last[d+1][i] = max(last[d][i], last[d+1][i])

        for i in range(26):
            objective_function -= c[i] * (d-last[d][i])
        print(objective_function)

    point = max(10 ** 6 + objective_function, 0)

## outputの作成
# IOに基づくパターン
output = []
for _ in range(D):
    output.append(int(input())-1)

# 最大効用での戦略
#output = []
#for d in range(D):
#    output.append(s[d].index(max(s[d])))
#for d in output:
#    print(d+1)

## 目的関数の確認
get_objective_function(output)
# coding:utf8
S = input()

if S == hi or S ==hihi or S=hihih or S=hihihihi or S=hihihihihi:
    print("Yes")
else :
    print("No")
    

### FIXED CODE ###

# coding:utf8
S = input()

if S == "hi" or S =="hihi" or S=="hihihi" or S=="hihihihi" or S=="hihihihihi":
    print("Yes")
else :
    print("No")
import numpy

a = input().split()
L = a[0]
R = a[1]
d = a[2]

N = R/d

print(math.floor(N))


### FIXED CODE ###

l,r,d = map(int,input().split())
     
print( r//d -(l-1)//d )
na=input()
a=int(na)
nb=input()
b=int(nb)
c=a*b
if (c%2==0):
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

a,b = map(int,input().split())
c = a*b
if(c%2==0):
    print("Even")
elif(c%2==1):
    print("Odd")
a,b,c,k = map(int,input().split())
sum=0
if(a>k):
  sum+=k
else:
  sum+=a
  k=k-a
  if(k==0):
    print(sum)
    exit()
  if(b>k):
    print(sum)
  else:
    k = k-b
    if(k==0):
      print(sum)
      exit()
    if(c>k):
      sum-=k
      print(sum)
    else:
      sum-=c
      print(sum)


### FIXED CODE ###

a = input()
b = input()
last_char = b[len(b)-1]
if (a+last_char == b):
  print("Yes")
else:
  print("No")
import numba as nb
@nb.njit
def fun(a,k,n): ## k different steps can be taken
    if n==1:
        return 0
    dp = [0]*n
    dp[1]=dp[0]+abs(a[0]-a[1])
    for i in range(2,len(a)):
        t = 0
        min_ = float('inf')
        for j in range(i-1,-1,-1):
            if t==k:
                break
            else:
                t+=1
            if dp[j]+abs(a[i]-a[j]) < min_ :
                   min_ = dp[j]+abs(a[i]-a[j])
        dp[i]=min_
    return dp[-1]
from sys import stdin , stdout
n,k = map(int , stdin.readline().split())
a = list(map(int , stdin.readline().split()))
print(fun(a,k,n))

### FIXED CODE ###

def fun(a,k,n): ## k different steps can be taken
    if n==1:
        return 0
    dp = [0]*n
    dp[1]=dp[0]+abs(a[0]-a[1])
    for i in range(2,len(a)):
        t = 0
        min_ = float('inf')
        for j in range(i-1,-1,-1):
            if t==k:
                break
            else:
                t+=1
            if dp[j]+abs(a[i]-a[j]) < min_ :
                   min_ = dp[j]+abs(a[i]-a[j])
        dp[i]=min_
    return dp[-1]
from sys import stdin , stdout
n,k = map(int , stdin.readline().split())
a = list(map(int , stdin.readline().split()))
print(fun(a,k,n))
n = int(input())
A = list(map(int, input().split()))

for i in range(n):
    if A[i]%2 == 0 and A[i]%3 != 0:
        print('DENIED')
    elif A[i]%2 == 0 and A[i]%5 != 0:
        print('DENIED')
    else:
        print('APPROVED')

### FIXED CODE ###

a,b,c=map(int,input().split())

if a==b and a!=c:
    print("Yes")
elif a==c and a!=b:
    print("Yes")
elif b==c and b!=a:
    print("Yes")
else:
    print("No")