Harryxun/stf_run huggingface dataset:
#coding:utf-8
n = int(input())
nums = sorted([num - i for i, num in enumerate(list(map(int,input().split())), 1)])


sums = [None for i in range(n)]
sums[0] = nums[0]
allv = sum(nums)

minv = nums[0] * (2 - n) - 2 * sums[0] + allv
for i in range(n-1):
    sums[i+1] = sums[i] + nums[i+1]
    p = sum[i] * (2*(i+1) - n) -2 * sums[i] + allv
    minv = min(minv,p)

print(minv)

### FIXED CODE ###

#coding:utf-8
n = int(input())
nums = sorted([num - i for i, num in enumerate(list(map(int,input().split())), 1)])


sums = [None for i in range(n)]
sums[0] = nums[0]
allv = sum(nums)

minv = nums[0] * (2 - n) - 2 * sums[0] + allv
for i in range(n-1):
    sums[i+1] = sums[i] + nums[i+1]
    p = nums[i] * (2*(i+1) - n) -2 * sums[i] + allv
    minv = min(minv,p)

print(minv)
A_list = []
for i in range(5):
    A_list.append(input())
one_list = []
one_list.append(int(A_list[0][-1]))
one_list.append(int(A_list[1][-1]))
one_list.append(int(A_list[2][-1]))
one_list.append(int(A_list[3][-1]))
one_list.append(int(A_list[4][-1]))
min_num = max(one_list)
for i in range(len(one_list)):
    if one_list[i] != 0 and min_num >= one_list[i]:
        min_num = one_list[i]
        min_one_list_index = i
A_list_min = A_list[min_one_list_index]
del A_list[min_one_list_index]


def ceil(src, range):
    if src % 10 == 0:
        return src
    else:
        return ((int)(src / range) + 1 ) * range


for i in range(len(A_list)):
    A_list[i] = ceil(int(A_list[i]), 10)
print(sum(A_list)+int(A_list_min))

### FIXED CODE ###

A_list = []
for i in range(5):
    A_list.append(input())
one_list = []
one_list.append(int(A_list[0][-1]))
one_list.append(int(A_list[1][-1]))
one_list.append(int(A_list[2][-1]))
one_list.append(int(A_list[3][-1]))
one_list.append(int(A_list[4][-1]))
min_num = max(one_list)
min_one_list_index = 1
for i in range(len(one_list)):
    if one_list[i] != 0 and min_num >= one_list[i]:
        min_num = one_list[i]
        min_one_list_index = i
A_list_min = A_list[min_one_list_index]
del A_list[min_one_list_index]


def ceil(src, range):
    if src % 10 == 0:
        return src
    else:
        return ((int)(src / range) + 1 ) * range


for i in range(len(A_list)):
    A_list[i] = ceil(int(A_list[i]), 10)
print(sum(A_list)+int(A_list_min))
import sys

sys.setrecursionlimit(5000)

def dfs(G, v, cur):
    color[v] = cur;

    for next_v in G[v] :
        if not(color[next_v] == -1) :
            if color[next_v] == cur :
                return 0;
            continue;
        if not(dfs(G,next_v,1-cur)):
            return 0;
    return 1;

n,m = list(map(int,input().split()));

G = [[] for i in range(n)];
for i in range(m) :
    a,b = list(map(int,input().split()));
    G[a-1].append(b-1);
    G[b-1].append(a-1);

color = [-1]*n;

if dfs(G,0,0) :
    print(sum(color)*(n-sum(color))-m);
else :
    print(n*(n-1)//2-m);

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**6)

def dfs(G, v, cur):
    color[v] = cur;

    for next_v in G[v] :
        if not(color[next_v] == -1) :
            if color[next_v] == cur :
                return 0;
            continue;
        if not(dfs(G,next_v,1-cur)):
            return 0;
    return 1;

n,m = list(map(int,input().split()));

G = [[] for i in range(n)];
for i in range(m) :
    a,b = list(map(int,input().split()));
    G[a-1].append(b-1);
    G[b-1].append(a-1);

color = [-1]*n;

if dfs(G,0,0) :
    print(sum(color)*(n-sum(color))-m);
else :
    print(n*(n-1)//2-m);
# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ！！
if __name__ == '__main__':
    S = input()
    if 'AC' in S:
        print 'Yes'
    else:
        print 'No'


### FIXED CODE ###

# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ！！
if __name__ == '__main__':
    S = raw_input()
    flg = True
    for index in range(len(S) - 1):
        if S[index]+S[index+1] == 'AC':
            print 'Yes'
            flg = False
            break
    if flg:
        print 'No'
n,k=int(input())
l=list(map(int, input().split()))
l.sort(reverse=True)
length=0
for i in range(k):
  length+=l[i]
print(length)

### FIXED CODE ###

n,k=map(int, input().split())
l=list(map(int, input().split()))
l.sort(reverse=True)
length=0
for i in range(k):
  length+=l[i]
print(length)
import numpy as np

n, m = map(int, input().split())
g = np.zeros((n, n), dtype=np.int)
for _ in range(m):
    a, b = map(int, input().split())
    g[a-1, b-1] = 1
    g[b-1, a-1] = 1

res = 'IMPOSSIBLE'
for i in range(n):
    if g[n-1, i] == 0:
        continue
    if g[i, 0] == 1:
        res = 'POSSIBLE'
        break

print(res)


### FIXED CODE ###

import numpy as np

n, m = map(int, input().split())
from_1 = np.zeros(n+1, dtype=np.int)
to_n = np.zeros(n+1, dtype=np.int)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        from_1[b] = 1
    elif b == n:
        to_n[a] = 1

print('IMPOSSIBLE') if np.sum(from_1*to_n) == 0 else print('POSSIBLE')
r, g, b, n = map(int, input().split())

dp = [[0 for i in range(n)] for j in range(3)]

for i in range(r-1, n, r):
    dp[0][i] = 1

dp[1][g-1] = 1
for i in range(n):
    dp[1][i] += dp[0][i]
    if i-g >= 0:
        dp[1][i] += dp[1][i-g]

dp[2][b-1] = 1
for i in range(n):
    dp[2][i] += dp[1][i]
    if i-b >= 0:
        dp[2][i] += dp[2][i-b]

print(dp[2][n-1])

### FIXED CODE ###

r, g, b, n = map(int, input().split())

dp = [0 for i in range(n+1)]
dp[0] = 1

for i in range(r, n+1, r):
    dp[i] = 1

for i in range(g, n+1):
    dp[i] += dp[i-g]

for i in range(b, n+1):
    dp[i] += dp[i-b]

print(dp[n])
N = int(input())
S = list(input())

count_1 = 0
count_2 = 0
for i in range(N-1):
  if S[i] == "#" and S[i+1] == ".":
    count_1 += 1
for i in range(N-1):
  if S[N - i - 1] == "." and S[N - i - 2] == "#":
    count_2 += 1
    
print(min(count_1, count_2))

### FIXED CODE ###

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

D = max([A, B])
E = min([A, B])
if E <= C <= D:
  print("Yes")
else:
  print("No")
N, M = [int(x) for x in input().split(" ")]
S = input()
T = input()

N = len(S)
M = len(T)

import sys
sys.setrecursionlimit(500000)


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


def maxkobai(a, b):
    return a * b // gcd(a, b)


#print(gcd(N, M))
#print(maxkobai(N, M))


L = maxkobai(N, M)
ret = L
#x = ['-' for i in range(L+1)]
x = ['-'] * (L*10)

for n in range(0, N):
    x[n * (L//N) + 1] = S[n]

# print(x)

for m in range(0, M):
    idx = m * (L // M) + 1
    x_idx = x[idx]
    if x_idx != '-' and x_idx != T[m]:
        ret = -1
        break

print(ret)

### FIXED CODE ###

N, M = [int(x) for x in input().split(" ")]
S = input()
T = input()

N = len(S)
M = len(T)


S = [ord(c) for c in S]
T = [ord(c) for c in T]


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


def maxkobai(a, b):
    return a * b // gcd(a, b)


L = maxkobai(N, M)
ret = L
x = dict()

for n in range(0, N):
    x[n * (L//N) + 1] = S[n]


for m in range(0, M):
    idx = m * (L // M) + 1
    tmp = x.get(idx, 0)

    if tmp != T[m] and tmp != 0:
        ret = -1
        break

print(ret)
import numpy as np
n,m,c = map(int, input().split())
b = np.array([int(i) for i in input().split()])
ans = 0
for i in range(n):
    a = np.array([int(i) for i in input().split()])
    if (a@b + c) > 0:
        ans += 1
print(ans)


### FIXED CODE ###

import numpy as np
n,m,c = map(int, input().split())
b = np.array([int(i) for i in input().split()])
ans = 0
for ii in range(n):
    a = np.array([int(i) for i in input().split()])
    if (np.dot(a,b) + c) > 0:
        ans += 1
print(ans)
A,B=map(int,input().split())
if A=1:
    A=14
if B=1:
    B=14
print(['ABloibc e'[A<B::2],'Draw'][A==B])

### FIXED CODE ###

A,B=map(int,input().split())
if A==1:
    A=14
if B==1:
    B=14
print(['ABloibc e'[A<B::2],'Draw'][A==B])
import numpy as np
import sys

data = []

for l in sys.stdin:
    data.append(l)
    
last = int(data[0][-1])

if last in [2,4,5,7,9]:
  print('hon')
elif last in [0,1,6,8]:
  print('pon')
else:
  print('hon')

### FIXED CODE ###

last = int(input()[-1])
     
if last in [2,4,5,7,9]:
  print('hon')
elif last in [0,1,6,8]:
  print('pon')
else:
  print('bon')
R,G,B,N=map(int,input().split())

ans=[]

count=0
for r in range(int(N/R)+1):
    for g in range(int((N-r*R)/G)+1):
        
        if (N-r*R-g*G)%13B==0:
            count+=1
            #ans.append([r,g,(N-r*R-g*G)/B])

#print(ans)
print(count)

### FIXED CODE ###

R,G,B,N=map(int,input().split())

ans=[]

count=0
for r in range(int(N/R)+1):
    for g in range(int((N-r*R)/G)+1):
        
        if (N-r*R-g*G)%B==0:
            count+=1
            #ans.append([r,g,(N-r*R-g*G)/B])

#print(ans)
print(count)
n,m=map(int,input().split())
hw_days=0
for i in range(m):
  hw_days+=int(input())
print(n-hw_days if (n-hw_days)>0 else -1)

### FIXED CODE ###

n,m=map(int,input().split())
list1=list(map(int,input().split()))
ans=n-sum(list1)
print(ans if ans>=0 else -1)
# -*- coding: utf-8 -*-
test = input()
a, b, c = map(int, test.split())  # 変数a,b,cにそれぞれN、A、Bをint型にして入力する　
x = []
for i in range(1,a+1):  # list型の変数xに１からNまでの要素を入れる
    x.append(i)


len_x = len(x)  # リスト型の変数xの要素数を獲得

d = 0  # リストの各行の和を入れるための変数
f = []  # 各行の和がA以上B以下の要素を入れるための変数
x = map(str, x)  # リストxの書く要素をstr型に変換

for i in range(len_x):
    e = x[i]           # xのi番目の要素を抽出
    e = list(e)  # xのi番目の要素を一文字ずつのstr型としてリスト型の変数に入れる
    e = map(int, e)  # xのi番目の要素をint型に変換
    e_number = len(e)  # リスト型の変数eの要素数を取得
    d = 0              # 位の合計の判定用の変数
    for g in range(e_number):
        d += e[g]  # 位の合計
    if b <= d <= c:  # 位の合計がA以上B以下ならリストfに要素を追加
        f.append(x[i])
answer = 0  # 条件位合う要素の合計を入れる変数
f = map(int, f)
for h in f:  # 要素に合う要素の合計
    answer += h
print(answer)






### FIXED CODE ###

# coding: utf-8
# Your code here!
#-*- coding: utf-8 -*-#
test = input()
a, b, c = map(int, test.split())  # 変数a,b,cにそれぞれN、A、Bをint型にして入力する　
x = []
e = []
for i in range(1,a+1):  # list型の変数xに１からNまでの要素を入れる
    x.append(i)
len_x = len(x)  # リスト型の変数xの要素数を獲得
d = 0  # リストの各行の和を入れるための変数
f = []  # 各行がA以上B以下の要素を入れるための変数
x = map(str, x) # リストxの各要素をstr型に変換
x = list(x)
e_number = 0
for i in range(len_x):
    e = x[i]           # xのi番目の要素を抽出
    e = list(e)  # xのi番目の要素を一文字ずつのstr型としてリスト型の変数に入れる
    e = map(int, e)# xのi番目の要素をint型に変換
    e = list(e)
    e_number = len(e)   # リスト型の変数eの要素数を取得
    d = 0              # 位の合計の判定用の変数
    for g in range(e_number):
        d += e[g-1]  # 位の合計
    if b <= d <= c:  # 位の合計がA以上B以下ならリストfに要素を追加
        f.append(x[i])
answer = 0  # 条件位合う要素の合計を入れる変数
f = map(int, f)
for h in f:
    answer += h  # 要素に合う要素の合計
print(answer)
mod = pow(10, 9)+7

n, k = map(int, input().split())
blues = k
reds = n-k

C = [[0]*2000 for i in range(2000)]

def preprocess():
	global C

	for i in range(2000):
		for j in range(i+1):
			if i==j or j==0:
				C[i][j] = 1
			else:
				C[i][j] = (C[i-1][j-1] + C[i-1][j])%mod
preprocess()

for i in range(k):
	slots = reds + 1
	res = (C[slots][i+1]*C[k-1][i])%mod
	print(res)


### FIXED CODE ###

n, k = map(int, input().split())
reds = n-k
blues = k

mod = pow(10, 9) + 7

maxn = 2000
C = [[0]*(maxn+1) for i in range(maxn+1)]

def preprocess():
	global C
	for i in range(maxn+1):
		for j in range(i+1):
			if i == 0 or j== i :
				C[i][j] = 1
			else:
				C[i][j] = (C[i-1][j-1] + C[i-1][j])%mod
preprocess()


for i in range(k):
	slots = reds + 1
	res = (C[slots][i+1]*C[blues - 1][i])%mod
	print(res)
a,b = [int(i) for i in input()]

print(max([a + b, a - b, a * b]))

### FIXED CODE ###

a, b = [int(i) for i in input().split()]

print(max([a + b, a - b, a * b]))
x_sum = [3]
y_sum = [3]
s = 3

for pk in range(1,N):
  k = pk+1

  for i,c in enumerate(map(sum,zip(x_sum,y_sum))):
    c %= MOD
    dp[i,pk] = c
    x_sum[i] += c

  x_sum.append(0)
  y_sum.append(2*s%MOD)
  s = 3*s%MOD
  subQ = Q[k]

  for i,j in list(dp.keys()):
    for l,x in subQ:
      if x != (l<=i)+(l<=j):
        c = dp[i,j]
        x_sum[i] -= c
        y_sum[j] -= c
        y_sum[j] %= MOD
        s -= c
        del dp[i,j]
        break

  for i in range(pk):
    x_sum[i] %= MOD
  s %= MOD

print(s)

### FIXED CODE ###

from collections import defaultdict

MOD = 1000000007
iist = lambda: map(int,input().split())

N,M = iist()
Q = defaultdict(list)
for i in range(M):
  l,r,x = iist()
  Q[r].append((l,x))

if any(x != 1 for l,x in Q[1]):
  print(0)
  exit(0)

dp = defaultdict(int)
dp[0,0] = 3

x_sum = [3]
y_sum = [3]
s = 3

for pk in range(1,N):
  k = pk+1

  for i,(a,b) in enumerate(zip(x_sum,y_sum)):
    c = (a+b)%MOD
    dp[i,pk] = c
    x_sum[i] += c

  x_sum.append(0)
  y_sum.append((2*s)%MOD)
  s *= 3
  subQ = Q[k]

  for i,j in list(dp.keys()):
    for l,x in subQ:
      if x != (l<=i)+(l<=j)+1:
        c = dp[i,j]
        x_sum[i] -= c
        y_sum[j] -= c
        s -= c
        del dp[i,j]
        break

  for i in range(pk):
    x_sum[i] %= MOD
    y_sum[i] %= MOD
  s %= MOD

print(s)
a, b, m = list(map(int, input().split()))

pa = [int(p) for p in input().split()]
pb = [int(p) for p in input().split()]

pc = []
for c in range(m):
  x, y, d = list(map(int, input().split()))
  pc.append(pa[x-1]+pa[y-1]-d)
  
min_c = min(pc)
min_ab = min(pa)+min(pb)

if min_c < min_ab:
  print(min_c)
else:
  print(min_ab)

### FIXED CODE ###

a, b, m = list(map(int, input().split()))

pa = [int(p) for p in input().split()]
pb = [int(p) for p in input().split()]

pc = []

for c in range(m):
  x, y, d = list(map(int, input().split()))
  pc.append(pa[x-1]+pb[y-1]-d)
  
min_c = min(pc)
if min_c<0:
  min_c=0
min_ab = min(pa)+min(pb)

if min_c < min_ab:
  print(min_c)
else:
  print(min_ab)
W, H, x, y = map(int, input().split())

s1 = float(min(x*H, W*H-x*H))
s2 = float(min(y*W, W*H-y*W))
s3 = float(min((y/x*W * W * 0.5), H/((-1*(H-y)/x) + H) * H * 0.5))

print(max(s1, s2, s3), 0 if s1 != s2 != s3 else 1)

### FIXED CODE ###

W, H, x, y = [int(i) for i in input().split()]
print(W*H / 2, int(x*2 == W and y*2 == H))
from math import log
class SegmentTree :
	def __init__ (self, N):
		self.N = N
		self.tree = [0 for i in range(2 * N - 1)]

	def update(self,i,x):
		node = i + self.N - 1
		self.tree[node] += x
		while node > 0:
			node = (node-1) / 2
			self.tree[node] += x

	def sum(self,here,l,r,hl,hr): #init : hl = 0, hr = N = 2 ** x - 1
		if here >= self.N - 1 or l == hl and r == hr:
			return self.tree[here]
		midle = (hl + hr + 1) / 2 # belong to rchild
		result = 0
		if l < midle :
			result += self.sum(2 * here + 1, l, min(r,midle - 1), hl, midle - 1) 
		if r >= midle :
			result += self.sum(2 * here + 2, max(l,midle), r, midle, hr) 
		return result
while 1 :
	n, m = map(int,raw_input().split(" "))
	if (n, m) == (0,0):
		break
	Lon_idx = log(n,2)
	Lat_idx = log(m,2)
	LonN = 2 ** (int(Lon_idx) if Lon_idx.is_integer() else (int(Lon_idx)+1))
	LatN = 2 ** (int(Lat_idx) if Lat_idx.is_integer() else (int(Lat_idx)+1))
	LonST = SegmentTree(LonN)
	LatST = SegmentTree(LatN)
	for i in range(0,n):
		LonST.update(i,int(raw_input()))
	for i in range(0,m):
		LatST.update(i,int(raw_input()))
	Lon = [0 for i in range(n*1000+1)]
	Lat = [0 for i in range(m*1000+1)]
	for i in range(1,n+1):
		for j in range(n+1-i):
			Lon[LonST.sum(0,j,j+i-1,0,LonN-1)]+=1
	for i in range(1,m+1):
		for j in range(m+1-i):
			Lat[LatST.sum(0,j,j+i-1,0,LatN-1)]+=1
	max_width = min(LonST.tree[0],LatST.tree[0])
	print sum([Lon[i]*Lat[i] for i in range(1,max_width+1)])

### FIXED CODE ###

while 1 :
	n, m = map(int,raw_input().split(" "))
	if (n, m) == (0,0):
		break
	Lon = [0 for _ in range(1000 * n + 1)]
	Lat = [0 for _ in range(1000 * m + 1)]
	Lon_sum = []
	Lat_sum = []
	for _ in range(0,n):
		h = int(raw_input())
		Lon_sum = [h + j for j in Lon_sum] + [h]
		for j in Lon_sum:
			Lon[j] += 1
	for _ in range(0,m):
		w = int(raw_input())
		Lat_sum = [w + j for j in Lat_sum] + [w]
		for j in Lat_sum:
			Lat[j] += 1
	max_width = min(Lon_sum[0],Lat_sum[0])
	print sum([Lon[i]*Lat[i] for i in range(1,max_width+1)])
n, x = map(int, input().split())
L = list(map(int, input().split()))
d = 0
bound = 1
for l in L:
	d += l
	if d > X:
		break
	bound += 1
print(bound)

### FIXED CODE ###

n, x = map(int, input().split())
L = list(map(int, input().split()))
d = 0
bound = 1
for l in L:
	d = d + l
	if d > x:
		break
	bound += 1
print(bound)
n, k = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(n)]
sushi.sort(key=lambda x: x[1])
t = {}
x = []
z = 0
for i in range(n - 1, n - k - 1, -1):
    if sushi[i][0] in t.keys():
        x.append(i)
        t[sushi[i][0]] += 1
    else:
        t[sushi[i][0]] = 1
    z += sushi[i][1]

y = list(t.keys())
ans = z + len(y) ** 2
k = 1
for i in range(n - k - 1, -1, -1):
    if sushi[i][0] not in y:
        y.append(sushi[i][0])
        xi = x[-k]
        z += sushi[i][1] - sushi[xi][1]
        ans = max(ans, z + len(y) ** 2)
        k += 1

print(ans)


### FIXED CODE ###

import heapq

n, k = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(n)]
sushi.sort(key=lambda x: x[1])
t = {}
x = []
z = 0
for i in range(n - 1, n - k - 1, -1):
    ti, di = sushi[i]
    if ti in t.keys():
        heapq.heappush(x, di)
        t[ti] += 1
    else:
        t[ti] = 1
    z += di

p = len(t.keys())
ans = z + p ** 2
for i in range(n - k - 1, -1, -1):
    if len(x) == 0:
        break
    ti, di = sushi[i]
    if ti not in t.keys():
        t[ti] = 1
        z += di - heapq.heappop(x)
        p += 1
        ans = max(ans, z + p ** 2)

print(ans)
n,m=map(int,input().split())
a=list(map(int,input().split()))
s=[]
l= 0
r = n
for i in range(m):
    ln,rn=map(int,input().split())
    if ln>l:
        l=ln
    if rn<r:
        r=rn
print(rn-ln+1)

### FIXED CODE ###

n,m=map(int,input().split())

s=[]
l= 0
r = n
for i in range(m):
    ln,rn=map(int,input().split())
    if ln>l:
        l=ln
    if rn<r:
        r=rn
if r-l+1>0:
    print(r-l+1)
else:
    print(0)
n=int(input())
s=input()
t=input()
count=0
for i in range(n):
  if s[n-1-i]==t[i]:
    count+=1
  else:
    break
print(2×n-count)

### FIXED CODE ###

n=int(input())
s=input()
t=input()
count=0
for i in range(n):
  if s[n-1-i:n]==t[0:i+1]:
    count=i+1
print(n+n-count)
stack =[]
for item in raw_input().split():
    stack.append(item)


def Cal(sym,n1,n2):
    n1 = int(n1)
    n2 = int(n2)
    if sym == '+':
        ans = n1 + n2
    elif sym == '-':
        ans = n1 - n2
    else:
        ans = n1 * n2
        
    return ans

sym_stack = []
ans_stack = []

while len(stack)>0:
    m = stack.pop()
    if not m.isdigit():
        sym_stack.append(m)
    else:
        n2 = m
        n1 = stack.pop()
        sym = sym_stack.pop()
        ans = Cal(sym,n1,n2)
        ans_stack.append(ans)

while len(sym_stack)>0:
    n2 = ans_stack.pop()
    n1 = ans_stack.pop()
    sym = sym_stack.pop()
    ans = Cal(sym,n1,n2)
    ans_stack.append(ans)
Ans = ans_stack.pop()

print Ans

### FIXED CODE ###

def Cal(sym,n1,n2):
    n1 = int(n1)
    n2 = int(n2)
    if sym == '+':
        ans = n1 + n2
    elif sym == '-':
        ans = n1 - n2
    else:
        ans = n1 * n2
        
    return ans

stack = []

for item in raw_input().split():
    if item.isdigit():
        stack.append(item)
    else:
        n2 = stack.pop()
        n1 = stack.pop()
        sym = item
        ans = Cal(sym,n1,n2)
        stack.append(ans)

Ans = stack.pop()

print Ans
mod = 10**9+7
import sys
import math
from collections import Counter, defaultdict, deque
import copy

# from itertools import product, permutations, combinations, combinations_with_replacement
# from itertools import accumulate
# from operator import itemgetter
# from bisect import bisect_bound_list,bisect
# from heapq import heappop,heappush
# from math import ceil,floor
# from copy import deepcopy
# from heapq import heappop,heappush,heapify
# import heapq


# def combinations(n, r):
# 	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# def gcd(a, b):
# 	if b == 0:
# 		return a
# 	else:
# 		return gcd(b, a%b)
 
# def lcm(a, b):
# 	return a // gcd(a, b) * b

# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))

S = input()
ans = len(S)
for i in range(len(S)-1):
    if S[i]!=S[i+1]:
        ans = min(ans, max(i + 1, N - i - 1))
print(ans)


















### FIXED CODE ###

mod = 10**9+7
import sys
import math
from collections import Counter, defaultdict, deque
import copy

# from itertools import product, permutations, combinations, combinations_with_replacement
# from itertools import accumulate
# from operator import itemgetter
# from bisect import bisect_bound_list,bisect
# from heapq import heappop,heappush
# from math import ceil,floor
# from copy import deepcopy
# from heapq import heappop,heappush,heapify
# import heapq


# def combinations(n, r):
# 	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# def gcd(a, b):
# 	if b == 0:
# 		return a
# 	else:
# 		return gcd(b, a%b)
 
# def lcm(a, b):
# 	return a // gcd(a, b) * b

# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))

S = input()
ans = len(S)
N = ans
for i in range(len(S)-1):
    if S[i]!=S[i+1]:
        ans = min(ans, max(i + 1, N - i - 1))
print(ans)
x = [input().split() for i in range(3)]
N = int(input())
b = [int(input()) for n in range(N)]
l = [[0]*3, [0]*3, [0]*3]
for val in b:
    for i in range(3):
        for j in range(3):
            if val == int(x[i][j]):
                l[i][j] = 1
if l[0][0] + l[0][1] + l[0][2] == 3:
    print('Yes')
elif l[1][0] + l[1][1] + l[1][2] == 3:
    print('Yes')
elif l[2][0] + l[2][1] + l[2][2] == 3:
    pritn('Yes')
elif l[0][0] + l[1][0] + l[2][0] == 3:
    print('Yes')
elif l[0][1] + l[1][1] + l[2][1] == 3:
    print('Yes')
elif l[0][2] + l[1][2] + l[2][2] == 3:
    print('Yes')
elif l[0][0] + l[1][1] + l[2][2] == 3:
    print('Yes')
elif l[0][2] + l[1][1] + l[2][0] == 3:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

x = [input().split() for i in range(3)]
N = int(input())
b = [int(input()) for n in range(N)]
l = [[0]*3, [0]*3, [0]*3]
for val in b:
    for i in range(3):
        for j in range(3):
            if val == int(x[i][j]):
                l[i][j] = 1
if l[0][0] + l[0][1] + l[0][2] == 3:
    print('Yes')
elif l[1][0] + l[1][1] + l[1][2] == 3:
    print('Yes')
elif l[2][0] + l[2][1] + l[2][2] == 3:
    print('Yes')
elif l[0][0] + l[1][0] + l[2][0] == 3:
    print('Yes')
elif l[0][1] + l[1][1] + l[2][1] == 3:
    print('Yes')
elif l[0][2] + l[1][2] + l[2][2] == 3:
    print('Yes')
elif l[0][0] + l[1][1] + l[2][2] == 3:
    print('Yes')
elif l[0][2] + l[1][1] + l[2][0] == 3:
    print('Yes')
else:
    print('No')