Harryxun/stf_run huggingface dataset:
from bisect import bisect_left

n = int(input())
ls = list(map(int, input().split())).sort()
count = 0
for i in range(n - 2):
  for j in range(i + 1, n - 1):
    two_sides_sum = ls[i] + ls[j]
    bi = bisect_left(ls, two_sides_sum)
    count += bi-j-1
print(count)

### FIXED CODE ###

import bisect
n = int(input())

li = list(map(int, input().split()))
li.sort()

count = 0

for i in range(n - 2):
  for j in range(i + 1, n - 1):
    bi = bisect.bisect_left(li, li[i] + li[j])
    count += bi - j - 1
print(count)
#coding: utf-8
N, Q = map(int, input().split())
S = input()
T = [0]
for i in range(N):
    if S[i] == "A" and S[i+1] == "C":
        T.append(T[i] + 1)
    else:
        T.append(T[i])
for j in range(Q):
    l, r = map(int, input().split())
    print(T[r] - T[l-1])

### FIXED CODE ###

#coding: utf-8
N, Q = map(int, input().split())
S = input()
T = [0]
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        T.append(T[i] + 1)
    else:
        T.append(T[i])
for j in range(Q):
    l, r = map(int, input().split())
    print(T[r-1] - T[l-1])
a,b,c = int(input())
testList = [a,b,c]

def countOne(self,list):
  count =0
  for i in list:
    if i == 0:
      count +=1
  return count

print(countOne(testList))


### FIXED CODE ###

strTest = input()
print(strTest.count("1"))
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 0:
  print(minus[k-1])
elif len(minus) == 0:
  print(plus[k-1])
elif len(plus) < len(minus):
  for i in range(k-len(minus), min(k-1, len(plus))):
    min_ = min(min_, 2*plus[i]+minus[k-2-i], plus[i]+2*minus[k-2-i])
  if i == k-2 and i+1 < len(plus):
    i += 1
    min_ = min(min_, plus[i])
  print(min_)
else:
  for i in range(k-len(plus), min(k-1, len(minus))):
    min_ = min(min_, 2*minus[i]+plus[k-2-i], minus[i]+2*plus[k-2-i])
  if i == k-2 and i+1 < len(minus):
    i += 1
    min_ = min(min_, minus[i])
  print(min_)  
  


### FIXED CODE ###

n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [0]+[abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [0]+[a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 1:
  print(minus[k])
elif len(minus) == 1:
  print(plus[k])
else:
  for i in range(min(k+1, len(plus))):
    if k-i < len(minus):
      min_ = min(min_, 2*plus[i]+minus[k-i], plus[i]+2*minus[k-i])
  print(min_)
n, k = map(int, input().split())
s = input()
if s[k-1] == 'A' :
  print(s[:k-2] + 'a' + s[k:n])
elif s[k-1] == 'B' :
  print(s[:k-2] + 'b' + s[k:n])
else s[k-1] == 'C' :
  print(s[:k-2] + 'c' + s[k:n])


### FIXED CODE ###

n, k = map(int, input().split())
s = input()
if s[k-1] == 'A':
  print(s[:k-1] + 'a' + s[k:])
elif s[k-1] == 'B':
  print(s[:k-1] + 'b' + s[k:])
else :
  print(s[:k-1] + 'c' + s[k:])
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
S = list(input())
dp = {}
st = [None]*9
ok = []
l = [None]*N
las = 0
for i in range(N-1,-1,-1):
    s = S[i]
    st[int(s)] = i
    l[i] = las
    if s in dp:
        dp[s].append(i)
    else:
        dp[s] = [i]
        las += 1

ans = 1
for i in range(0,9):
    if st[i]==None:
        continue
    start = st[i] #iが初めて出てくる位置
    for j in range(1,10):
        k = str(j)
        if not k in dp:
            continue
        middle = dp[k]
        ok = len(dp)-1
        ng = 0
        while ok-ng>1:
            m = (ok+ng)//2
            if middle[m]>start:
                ng = m
            else:
                ok = m
        ans *= l[ok]
print(ans)

### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
S = input()
ans = 0
for i in range(1000):
    num = str(i).zfill(3)
    _idx = 0
    flag = True
    for n in num:
        ind = S[_idx:].find(n)
        if ind==-1:
            flag = False
            break
        else:
            _idx = _idx + ind+1
    if flag:
        ans += 1
print(ans)
from collections import defaultdict
from bisect import bisect_left
from collections import deque

N = int(input())
d = defaultdict(list)

for i in range(N):
    v = int(input())
    d[v].append(i)

keys = sorted(d.keys())
s = deque(d[keys[0]])

for k in keys[1:]:
    used = set()
    for i in d[k]:
        j = bisect_left(s, i)
        if 0<j<=len(s):
            if not s[j-1] in used:
                s[j-1] = i
            else:
                s = s[:j] + [i] + s[j:]
        elif j==0:
            s.appendleft(i)
        used |= {i}

print(len(s))

### FIXED CODE ###

from collections import deque
from bisect import bisect_left

N = int(input())
d = deque([])
l = [int(input()) for _ in range(N)]

d.append(l[0])

for i in l[1:]:
    v = bisect_left(d, i)
    if v == 0:
        d.appendleft(i)
    else:
        d[v-1] = i

print(len(d))
A = list(map(int, input().split()))
c=0
for i in range(0,len(A),2):
  if A[i]%2=1:
    c+=1
print(c)

### FIXED CODE ###

N=int(input())
A = list(map(int, input().split()))
c=0
for i in range(0,len(A),2):
  if A[i]%2==1:
    c+=1
print(c)
def func_rfindr(str):
    return str.rfind('R')

def func_lfindw(str, start):
    return str.find('W', start)

def func_replace(target, pos, str):
    ret = ""
    if pos != 0:
        ret = target[0:pos]
    ret = ret + str
    if len(target) - 1 != pos:
        ret = ret + target[pos + 1:]
    return ret

N = int(input())
C = input()
ans = 0

posrr = func_rfindr(C)
poslw = func_lfindw(C)

while poslw != -1 and posrr != -1 and posrr > poslw:
    C = func_replace(C, posrr, "W")
    C = func_replace(C, poslw, "R")
    ans = ans + 1
    posrr = func_rfindr(C)
    poslw = func_lfindw(C, poslw)

print(ans)

### FIXED CODE ###

def func_rfindr(str):
    return str.rfind('R')

def func_lfindw(str):
    return str.find('W')

def func_replace(target, pos, str):
    ret = ""
    if pos != 0:
        ret = target[0:pos]
    ret = ret + str
    if len(target) - 1 != pos:
        ret = ret + target[pos + 1:]
    return ret

N = int(input())
C = input()
ans = 0

posrr = func_rfindr(C)
poslw = func_lfindw(C)

while poslw != -1 and posrr != -1 and posrr > poslw:
    #C = func_replace(C, posrr, "W")
    #C = func_replace(C, poslw, "R")
    C = C[poslw + 1:posrr]
    ans = ans + 1
    posrr = func_rfindr(C)
    poslw = func_lfindw(C)

print(ans)
from collections import deque
n, m = map(int,input().split())
def vertex_node()  -> list:
    v_c = [[] for _ in range(n+1)]
    v = [i.split() for i in q.split("\n")]
    for i in range(m):
        a,b = map(int,input().split())
        v_c[a].append(b)
        v_c[b].append(a)
    return v_c

def bfs(l) -> list:
    dist = [-1] * (n+1)
    dist[0] = 0
    dist[1] = 0
    d = deque()
    d.append(1)
    while d:
        v = d.popleft()
        for i in l[v]:
                if dist[i] != -1:
                    continue
                dist[i] = dist[v] + 1
                d.append(i)
    return dist
if __name__ == "__main__":
    i = vertex_node()
    ans = bfs(i)[2:]
    print(*ans)

### FIXED CODE ###

from collections import deque
n, m = map(int,input().split())
def vertex_node()  -> list:
    v_c = [[] for _ in range(n+1)]
    for i in range(m):
        a,b = map(int,input().split())
        v_c[a].append(b)
        v_c[b].append(a)
    return v_c

def bfs(l) -> list:
    dist = [-1] * (n+1)
    dist[0] = 0
    dist[1] = 0
    d = deque()
    d.append(1)
    while d:
        v = d.popleft()
        for i in l[v]:
                if dist[i] != -1:
                    continue
                dist[i] = v
                d.append(i)
    return dist
if __name__ == "__main__":
    i = vertex_node()
    ans = bfs(i)[2:]
    print("Yes")
    for i in ans:
        print(i)
from collections import deque

def MI():
    return map(int, input().split())

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

N, M = MI()
room = [[] for _ in range(N)]

for _ in range(M):
    A, B = MI()
    room[A - 1].append(B - 1)
    room[B - 1].append(A - 1)

print(room)
print("Yes")

def bfs(G, start, step = 0):
    global visited
    visited[start] = True 
    
    for g in G[start]:
        if g == 0:
            print(step + 1)
            
        elif not visited[g]:
            bfs(G, g, step + 1)

for i in range(1, N):
    visited = [False] * N
    bfs(room, i)

### FIXED CODE ###

import sys
from collections import deque

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

for _ in range(M):
    A, B = map(int, input().split())
    G[A - 1].append(B - 1)
    G[B - 1].append(A - 1)
    if A == 1 or B == 1:
        goal = True

if goal:
    print("Yes")
else:
    print("No")
    sys.exit()

d = deque([0])
ans = [-1] * N

while d:
     q = d.popleft()
     for g in G[q]:
         if ans[g] == -1:
             ans[g] = q + 1
             d.append(g)

for i in range(1, N):
    print(ans[i])
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
eat_p = p[:X]
eat_q = q[:Y]

ans = sum(eat_p) + sum(eat_q)
i, j, k = -1, -1, 0
while True:
    if eat_p[i] < eat_q[j] and eat_p[i] < r[k]:
        ans += r[k] - eat_p[i]
        k += 1
        i -= 1
    if eat_p[i] >= eat_q[j] and eat_q[j] < r[k]:
        ans += r[k] - eat_q[j]
        k += 1
        j -= 1
    if k == C or (eat_p[i] >= r[k] and eat_q[j] >= r[k]):
        break
    if i == -A:
        i = 0
    if j == -B:
        j = 0

print(ans)


### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
eat_p = p[:X]
eat_q = q[:Y]

all_apple = eat_p + eat_q + r
all_apple.sort(reverse=True)

print(sum(all_apple[:X+Y]))
from math import gcd
from functools import reduce

# 2つの数の最小公倍数
def lcm(x,y):
    return (x*y) // gcd(x,y)

# リストを引数にして最小公倍数を表示
def lcm_of_list(a):
    return reduce(lcm, a)

def waruni(a):
    return a//2


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

L = lcm_of_list(b)

for i in range(n):
    if (L//b[i])%2==0:
        print(0)
        exit()

ans = (m//L+1)//2

print(ans)

### FIXED CODE ###

from fractions import gcd
from functools import reduce

# 2つの数の最小公倍数
def lcm(x,y):
    return (x*y) // gcd(x,y)

# リストを引数にして最小公倍数を表示
def lcm_of_list(a):
    return reduce(lcm, a)

def waruni(a):
    return a//2


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

L = lcm_of_list(b)

for i in range(n):
    if (L//b[i])%2==0:
        print(0)
        exit()

ans = (m//L+1)//2

print(ans)
N, M = map(int, input().split())

A=[]
B=[]

for _ in range(M):
  n, m = map(int, input().split())
  A.append(n)
  B.append(m)

roomN = ['N' for _ in range(N)]
roomN[0] = 1
roomPN = [0 for _ in range(N)]

for order in range(2, N+1):
  if ! 'N' in roomN:
    break:
  if order-1 in roomN:
     pres = [i+1 for i,x in enumerate(roomN) if x == order-1]
  for pre in pres:
    if pre in A:
      indexs = [i for i,x in enumerate(A) if x == pre]
      for index in indexs:
        now = B[index] -1
        if roomN[now] == 'N':
          roomN[now] = order
          if roomPN[now] == 0:
            roomPN[now] = pre
    if pre in B:
      indexs = [i for i,x in enumerate(B) if x == pre]
      for index in indexs:
        now = A[index] -1
        if roomN[now] == 'N':
          roomN[now] = order
          if roomPN[now] == 0:
            roomPN[now] = pre

print('Yes')
for i in range(1, N):
  print(roomPN[i])

### FIXED CODE ###

from collections import deque

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

graph=[[] for i in range(n)]

roomSign=[-1]*n

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

D=deque([0])

while D:
    v=D.popleft()
    for i in graph[v]:
        if roomSign[i] == -1:
          roomSign[i]=v
          D.append(i)

print("Yes")

for i in range(1,n):
    print(roomSign[i]+1)
n=int(input())
d=list(map(int,input().split()))
dd=sorted(d)
N=dd[n-1]
sum1=0
sum2=0
count=0
for k in range(N+1):
    for i in range(n):
        if d[i]>=k:
            sum1+=1
        else:
            sum2+=1
    if sum1==sum2:
        count+=1
    sum1=0
    sum2=0
print(count)

### FIXED CODE ###

S=input()
sum=[0,0,0,0]
for t in range(4):
    for i in range(4):
        if S[int(t)]==S[int(i)]:
            sum[int(i)]+=1
if sum[0] == 2 and sum[1] == 2 and sum[2] == 2 and sum[3] == 2:
    print('Yes')
else:
    print('No')
from fractions import gcd
n,x = map(int,input().split())
l = list(map(int,input().split()))
ll = []
for i in range(n-1):
    ll.append(l[i+1]-l[i])
ans = ll[0]
for i in range(len(ll)):
    ans = gcd(ans,ll[i])
print(ans)

### FIXED CODE ###

from fractions import gcd
n,x = map(int,input().split())
l = list(map(int,input().split()))
ll = [abs(x-i) for i in l]
ans = ll[0]
for i in range(len(ll)):
    ans = gcd(ans,ll[i])
print(ans)
H,W,M = map(int,input().split())
h = [0]*M
w = [0]*M

from collections import defaultdict
counter_h = defaultdict(int)
counter_w = defaultdict(int)

for i in range(M):
    h[i],w[i] = map(int, input().split())
    counter_h[h[i]] += 1
    counter_w[w[i]] += 1
    
MAX_h = max(counter_h.values())
h_list = [k for k, v in counter_h.items() if v == MAX_h]
MAX_w = max(counter_w.values())
w_list = [k for k, v in counter_w.items() if v == MAX_w]

import itertools

if len(h_list)*len(w_list)<=3*10**5:
    X = list(itertools.product(h_list, w_list))

    ans = MAX_h+MAX_w
    check = 0


        for i in range(M):
            if (h[i],w[i]) in X:
                check += 1

    if len(X)==check:
        ans -= 1
    
print(ans)

### FIXED CODE ###

H,W,M = map(int,input().split())
h = [0]*M
w = [0]*M

from collections import defaultdict
counter_h = defaultdict(int)
counter_w = defaultdict(int)

for i in range(M):
    h[i],w[i] = map(int, input().split())
    counter_h[h[i]] += 1
    counter_w[w[i]] += 1

MAX_h = max(counter_h.values())
h_list = [k for k, v in counter_h.items() if v == MAX_h]
MAX_w = max(counter_w.values())
w_list = [k for k, v in counter_w.items() if v == MAX_w]


ans = MAX_h+MAX_w
check = 0

for i in range(M):
    if counter_h[h[i]]==MAX_h and counter_w[w[i]]==MAX_w:
        check += 1

if len(h_list)*len(w_list)==check:
    ans -= 1

print(ans)
import math
a,b,c=list(map(int, input().split())) 
kotae1=math.floor(b/c)
kotae2=math.floor(a/c)
ans=kotae1-kotae2
if(c==1):
    ans+=1
else:
    if(a==c):
    ans+=1
print(ans)

### FIXED CODE ###

import math
a,b,c=list(map(int, input().split())) 
kotae1=math.floor(b/c)
kotae2=math.floor(a/c)
ans=kotae1-kotae2
if(a%c==0):
    ans+=1
print(ans)
###間違っとる！！！！
#tmp="9"*(10**6)
tmp=input()
#tmp="78164062862089986280348253421170"
#tmp="314159265358979323846264338327950288419716939937551058209749445923078164062862089986280348253421170"
#tmp="846"
#tmp="253421170"
l=len(tmp)
#print(l)
rev=tmp[::-1]+"0"
seq_flag=False
ans=0
debug=[]
ans_arr=[]
next_bit=0
for i in range(l-1):
    num=int(rev[i])+next_bit
    next_num=int(rev[i+1])
    if not seq_flag:
        if (num<5) or (num==5 and next_num<5):
            ans+=num
            ans_arr.append(ans)
            next_bit=0
            kuri_cal=0
            continue
        seq_s=i
        seq_flag=True
        kuri_cal=10-num
        next_bit+=1
        continue
    #print(kuri_cal)
    if num<5:
        ans+=(kuri_cal+num)
        next_bit=0
        seq_flag=False
    elif num>5:
        kuri_cal+=10-num
    else:
        if next_num<5:
            ans+=(kuri_cal+num)
            next_bit=0
            seq_flag=False
        else:
            kuri_cal+=10-num
        
"""    
        
    if next_num+next_bit<5:
        ans+=(kuri_cal+2)
        ans_arr.append(ans)
        debug.append([i,ans-1])
        seq_flag=False"""
#print(ans)
last=int(tmp[0])+next_bit
#print(last)
#print(kuri_cal)
ans+=kuri_cal+min(last,11-last)
ans_arr.append(ans)
print(ans)

### FIXED CODE ###

def dp_solver(tmp):
    l=len(tmp)
    rev=tmp[::-1]+"0"
    dp=[[float("inf") for _ in range(2)] for _ in range(l+2)]
    dp[0][0]=0
    for i in range(l+1):
        for j in range(2):
            num=int(rev[i])
            num+=j
            if num<10:
                dp[i+1][0]=min(dp[i+1][0],dp[i][j]+num)
            if num>0:
                dp[i+1][1]=min(dp[i+1][1],dp[i][j]+(10-num))

    import numpy as np
    dp=np.array(dp)
    return(dp[l+1])

def y_solver(tmp):
    l=len(tmp)
    rev=tmp[::-1]+"0"
    seq_flag=False
    ans=0
    next_bit=0
    kuri_cal=0
    for i in range(l-1):
        num=int(rev[i])+next_bit
        next_num=int(rev[i+1])
        if not seq_flag:
            if (num<5) or (num==5 and next_num<5):
                ans+=num
                next_bit=0
                kuri_cal=0
                continue
            seq_s=i
            seq_flag=True
            kuri_cal=10-num
            next_bit+=1
            continue
        #print(kuri_cal)
        if num<5:
            ans+=(kuri_cal+num)
            kuri_cal=0
            next_bit=0
            seq_flag=False
        elif num>5:
            kuri_cal+=10-num
        else:
            if next_num<5:
                ans+=(kuri_cal+num)
                next_bit=0
                kuri_cal=0
                seq_flag=False
            else:
                kuri_cal+=10-num
    last=int(tmp[0])+next_bit
    ans+=kuri_cal+min(last,11-last)
    return ans

n=input()
ans=y_solver(n)
print(ans)
N = input()
a = int(N[0])
b = int(N[1])
c = int(N[2])
d = int(N[3])

if a+b+c+d == 7:
	print('{0}+{1}+{2}+{3}=7' .format(a,b,c,d))
	
if a-b+c+d == 7:
	print('{0}-{1}+{2}+{3}=7' .format(a,b,c,d))

if a+b-c+d == 7:
	print('{0}+{1}-{2}+{3}=7' .format(a,b,c,d))

if a+b+c-d == 7:
	print('{0}+{1}+{2—{3}=7' .format(a,b,c,d))

if a-b-c+d == 7:
	print('{0}-{1}-{2}+{3}=7' .format(a,b,c,d))
	
if a+b-c-d == 7:
	print('{0}+{1}-{2}-{3}=7' .format(a,b,c,d))
	
if a-b+c-d == 7:
	print('{0}-{1}+{2}-{3}=7' .format(a,b,c,d))

if a-b-c-d == 7:
	print('{0}-{1}-{2}-{3}=7' .format(a,b,c,d))

### FIXED CODE ###

N = input()
a = int(N[0])
b = int(N[1])
c = int(N[2])
d = int(N[3])

if a+b+c+d ==7:
	print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
	
elif a-b+c+d ==7:
	print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
	
elif a-b-c+d ==7:
	print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
	
elif a+b+c-d ==7:
	print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
	
elif a+b-c-d ==7:
	print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
	
elif a-b+c-d ==7:
	print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
	
elif a+b-c+d ==7:
	print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')

elif a-b-c-d ==7:
	print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
import sys,itertools,copy
input = sys.stdin.readline
N=int(input().strip())
an=[int(x) for x in input().strip().split()]

if N==3:
    if an[0]^an[1]==an[2]:
        print("Yes")
    else:
        print("No")
elif N%3!=0:
    if len(set(an))==1:
        print("Yes")
    else:
        print("No")
else:
    bn = list(set(an))
    if bn[0]^bn[1]!=bn[2]:
        print("No")
    else:
        for b in bn:
            if an.count(b)%(N/3)!=0:
                print("No")
                break
        else:
            print("Yes")

### FIXED CODE ###

import sys,itertools,copy
input = sys.stdin.readline
N=int(input().strip())
an=[int(x) for x in input().strip().split()]

if N==3:
    if an[0]^an[1]==an[2]:
        print("Yes")
    else:
        print("No")
elif N%3!=0:
    if len(set(an))==1:
        print("Yes")
    else:
        print("No")
else:
    bn = list(set(an))
    if len(bn)>3:
        print("No")
    elif len(bn)==1:
        if bn[0]==0:
            print("Yes")
        else:
            print("No")
    elif len(bn)==2:
        if an.count(0)==(N/3):
            print("Yes")
        else:
            print("No")
    elif bn[0]^bn[1]!=bn[2]:
        print("No")
    else:
        for b in bn:
            if an.count(b)!=(N/3):
                print("No")
                break
        else:
            print("Yes")
nums1 = list(map(int,input().split()))
nums2 = list(map(int,input().split()))
nums3 = list(map(int,input().split()))
seen = [nums1[0],nums1[1],nums1[2],nums2[0],nums2[1],nums2[2],nums3[0],nums3[1],nums3[2]]
over = False
N = int(input())
for x in range(N):
  num = int(input())
  print(num)
  if num in seen:
    seen[x] = "O"
print(seen)
if seen[0] == "O":
  if seen[1] == seen[2] == "O":
    print("YES")
    over = True
  elif seen[3] == seen[6] == "O":
    print("YES")
    over = True
  elif seen[4] == seen[8] == "O":
    print("YES")
    over = True
elif seen[4] == "O":
  if seen[2] == seen[6] == "O":
    print("YES")
    over = True
  elif seen[1] == seen[7] == "O":
    print("YES")
    over = True
  elif seen[3] == seen[5] == "O":
    print("YES")
    over = True
elif seen[8] == "O":
  if seen[6] == seen[7] == "O":
    print("YES")
  if seen[2] == seen[5] == "O":
    print("YES")
  over = True
if not over:
  print("NO")

### FIXED CODE ###

seen = [0,0,0,0,0,0,0,0,0]
seen[0],seen[1],seen[2] = (map(int,input().split()))
seen[3],seen[4],seen[5] = (map(int,input().split()))
seen[6],seen[7],seen[8] = (map(int,input().split()))
over = "No"
N = int(input())
for x in range(N):
  num = int(input())
  if num in seen:
    seen[seen.index(num)] = "O"
if seen[0] == "O":
  if seen[1] == "O" and seen[2] == "O":
    over = "Yes"
  if seen[3] == "O" and seen[6] == "O":
    over = "Yes"
  if seen[4] == "O" and seen[8] == "O":
    over = "Yes"
if seen[8] == "O":
  if seen[6] == "O" and seen[7] == "O":
    over = "Yes"
  if seen[2] == "O" and seen[5] == "O":
    over = "Yes"
if seen[4] == "O":
  if seen[6] == "O" and seen[2] == "O":
    over = "Yes"
  if seen[1] == "O" and seen[7] == "O":
    over = "Yes"
  if seen[3] == "O" and seen[5] == "O":
    over = "Yes"
print(over)
from sys import stdin
N = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
data = sorted(data) + [0]

if N == 1 and data[0] == 1:
    print(0)

elif N == 1 and data[0] != 1:
    print(1)

else:
    ans = 0
    num = data[0]
    cnt = 0
    for i in range(N+1):
        if data[i] == num:
            cnt += 1
        else:
            if cnt < data[i-1]:
                ans += cnt
            else:
                ans += (cnt-data[i-1])
            cnt = 1
            num = data[i]
print(ans)

### FIXED CODE ###

from sys import stdin
N = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
data = sorted(data) + [0]

if N == 1 and data[0] == 1:
    print(0)

elif N == 1 and data[0] != 1:
    print(1)

else:
    ans = 0
    num = data[0]
    cnt = 0
    for i in range(N+1):
        if data[i] == num:
            cnt += 1
        else:
            if cnt < data[i-1]:
                ans += cnt
            else:
                ans += (cnt-data[i-1])
            cnt = 1
            num = data[i]
    print(ans)