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

s = list(input())
q = int(input())
ans = s
cnt = 0
for i in range(q):
    f = [i for i in input().split()]
    if f[0] == '1':
        cnt += 1
    else:
        if f[1] == '1':
            if cnt % 2 == 0:
                ans.insert(0,f[2])
            else:
                ans.append(f[2])
        else:
            if cnt % 2 == 0:
                ans.append(f[2])
            else:
                ans.insert(0,f[2])
if cnt % 2 == 0:
    print(''.join(map(str,ans)))
else:
    ans2 = []
    for i in (reversed(ans)):
        ans2.append(i)
    print(''.join(map(str,ans2)))

### FIXED CODE ###

from collections import deque

s = list(input())
q = int(input())
ans = deque(s)
cnt = 0
for i in range(q):
    f = [i for i in input().split()]
    if f[0] == '1':
        cnt += 1
    else:
        if f[1] == '1':
            if cnt % 2 == 0:
                ans.appendleft(f[2])
            else:
                ans.append(f[2])
        else:
            if cnt % 2 == 0:
                ans.append(f[2])
            else:
                ans.appendleft(f[2])
if cnt % 2 == 0:
    print(''.join(map(str,ans)))
else:
    ans2 = []
    for i in (reversed(ans)):
        ans2.append(i)
    print(''.join(map(str,ans2)))
### BUGGY CODE ###

while True:
    try:
        n = int(input())
    except:
        break
    p_table = list(range(2,n+1))
    p = 2
    i = 0
    while i < len(p_table):
        p = p_table[i]
        j = p + p
        while j <= n:
            if j in p_table:
                p_table.remove(j)
            j += p
        i += 1
    print(len(p_table))



### FIXED CODE ###

def f(n):
    table = [False, False] + [True for _ in range(2, n+1)]
    p = 2
    while p**2 <= n:
        if table[p]:
            j = p + p
            while j <= n:
                table[j] = False
                j += p
        p += 1
    return sum(table)


while True:
    try:
        n = int(input())
    except:
        break
    print(f(n))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
from heapq import heappush,heappop,heapify
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
X,Y=[0]*N,[0]*N
dx,dy={},{}
for i in range(N):
    X[i],Y[i]=map(int,input().split())
    if X[i] in dx:
        dx[X[i]].append(i)
    else:
        dx[X[i]]=[i]
    if Y[i] in dy:
        dy[Y[i]].append(i)
    else:
        dy[Y[i]]=[i]
ux,uy=list(set(X)),list(set(Y))
ux.sort()
uy.sort()
uxi={x:i for i,x in enumerate(ux)}
uyi={y:i for i,y in enumerate(uy)}
edge=[[] for i in range(N)]
for i,(x,y) in enumerate(zip(X,Y)):
    for index in dx[x]+dy[y]:
        edge[i].append((0,index))
    if uxi[x]>=1:
        nx=ux[uxi[x]-1]
        for index in dx[nx]:
            if index!=i:
                edge[i].append((abs(nx-x),index))
    if uxi[x]<len(ux)-1:
        nx=ux[uxi[x]+1]
        for index in dx[nx]:
            if index!=i:
                edge[i].append((abs(nx-x),index))
    if uyi[y]>=1:
        ny=uy[uyi[y]-1]
        for index in dy[ny]:
            if index!=i:
                edge[i].append((abs(ny-y),index))
    if uyi[y]<len(uy)-1:
        ny=uy[uyi[y]+1]
        for index in dy[ny]:
            if index!=i:
                edge[i].append((abs(ny-y),index))

def prim(n,edges):
    used=[False]*n
    used[0]=True
    edgelist=[]
    for edge in edges[0]:
        heappush(edgelist,edge)
    cost=0
    while edgelist:
        minedge=heappop(edgelist)
        if used[minedge[1]]:
            continue
        v=minedge[1]
        used[v]=True
        for edge in edges[v]:
            if not used[edge[1]]:
                heappush(edgelist,edge)
        cost+=minedge[0]
    return cost

print(prim(N,edge))

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from heapq import heappush,heappop,heapify
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
X,Y=[],[]
for i in range(N):
    x,y=map(int,input().split())
    X.append((y,i))
    Y.append((x,i))
X.sort(key=lambda t:t[0])
Y.sort(key=lambda t:t[0])
edge=[[] for i in range(N)]
for i in range(N-1):
    edge[X[i][1]].append((abs(X[i][0]-X[i+1][0]),X[i+1][1]))
    edge[X[i+1][1]].append((abs(X[i][0]-X[i+1][0]),X[i][1]))
    edge[Y[i][1]].append((abs(Y[i][0]-Y[i+1][0]),Y[i+1][1]))
    edge[Y[i+1][1]].append((abs(Y[i][0]-Y[i+1][0]),Y[i][1]))

def prim(n,edges):
    used=[False]*n
    used[0]=True
    edgelist=[]
    for edge in edges[0]:
        heappush(edgelist,edge)
    cost=0
    while edgelist:
        minedge=heappop(edgelist)
        if used[minedge[1]]:
            continue
        v=minedge[1]
        used[v]=True
        for edge in edges[v]:
            if not used[edge[1]]:
                heappush(edgelist,edge)
        cost+=minedge[0]
    return cost

print(prim(N,edge))
### BUGGY CODE ###

import numpy as np

N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))

def ave(v):
    return np.mean(np.arange(1, v + 1))

vave = np.vectorize(ave)
s = vave(p)

ans = 0
for i in range(N - K + 1):
    ans = max(ans, np.sum(s[i:i+K]))

print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
p = list(map(int, input().split()))
s = [0] * N

for i in range(N):
    s[i] = (1 + p[i]) / 2

answer = sum(s[:K])
current = answer
for i in range(1, N - K + 1):
    current = current - s[i - 1] + s[i + K - 1]
    answer = max(answer, current)

print(answer)
### BUGGY CODE ###

import math
n=int(input())
for i in range(1,n+1):
  j=int(math.sqrt(i))+1
  cnt=0
  for x in range(1,j):
    for y in range(1,j):
      for z in range(1,j):
        if x**2+y**2+z**2+x*y+y*z+z*x==i:
          cnt+=1
  print(cnt)

### FIXED CODE ###

import math
import collections
n=int(input())
m=int(math.sqrt(n)+1)
a=[]
for x in range(1,m):
  for y in range(1,m):
    for z in range(1,m):
      if x**2+y**2+z**2+x*y+y*z+z*x<=n:
        a.append(x**2+y**2+z**2+x*y+y*z+z*x)
c=collections.Counter(a)
for i in range(1,n+1):
  print(c[i])
### BUGGY CODE ###

def comb(n):
    return n*(n-1) // 2
n = int(input())
num_list =  list(map(int,input().split()))
num_list2 = [0]*n
num_list3 = [0]*n
for i in num_list:
    num_list2[i-1] += 1
for i in range(n):
    ans = num_list2[i-1]*(num_list2[i-1]-1)//2
    num_list3[i-1] = ans

for i in num_list:
    ans = (num_list2[i-1]-1)*(num_list2[i-1]-2)//2
    print(ans-num_list3[i-1]+sum(num_list3))
  #  elif size == 1:
        #ans = 0
   # else :
    #    ans = 0 
    #num_list5[num_list2[i]-1] = ans


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
cnt = [0] * n
for i in a:
    cnt[i-1] += 1
total = [0] * n
for i in range(n):
    total[i] = cnt[i] * (cnt[i] - 1) // 2
total_sum = sum(total)
for i in a:
    ans = total_sum
    ans -= total[i-1]
    ans += (cnt[i-1] - 1) * (cnt[i-1] - 2) // 2
    print(ans)
### BUGGY CODE ###

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

for i in range(1, N + 1):
    print(A.index(i) + 1, end=' ')

### FIXED CODE ###

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

import numpy as np

A = np.array(A)
print(' '.join([str(i + 1) for i in A.argsort()]))
### BUGGY CODE ###

import numpy as np
n, y = np.array(list(input().split()), dtype=int)

vals = np.array([10000, 5000, 1000])

def get_tuple(n, y):
    for c in range(n + 1):
        for b in range(n + 1 - c):
            a = n - c - b
            nums = np.array([a, b, c])
            yield nums

for nums in get_tuple(n, y):
    if (nums * vals).sum() == y:
        print("{} {} {}".format(*nums))
        break
else:
    print("-1 -1 -1")

### FIXED CODE ###

import numpy as np
n, y = np.array(list(input().split()), dtype=int)

vals = np.array([10000, 5000, 1000])

table = []
for c in range(n + 1):
    part = np.zeros((n + 1 - c, 3), dtype=int)
    part[:, 0] = c
    part[:, 1] = np.arange(n + 1 - c)
    table += [part]
table = np.concatenate(table)
table[:, 2] = n - table[:, 0:2].sum(axis=1)

accum = (table * vals).sum(axis=1)
flags = np.where(accum == y)[0]

if len(flags) == 0:
    print("-1 -1 -1")
else:
    nums = table[flags[0]]
    print("{} {} {}".format(*nums))
### BUGGY CODE ###

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

def expected_value(list):
  exp_list = []
  for i in range(len(list)):
    sum = list[i]*(list[i]+1)/2
    exp = sum/list[i]
    exp_list.append(exp)
  return exp_list

ans = 0
for i in range(N-K+1):
  exp_list = expected_value(p[i:i+K])
  exp = sum(exp_list)
  if exp >= ans:
    ans = exp
    
print(ans)

### FIXED CODE ###

def cal(x): return (x+1)/2

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

ans  = sum(cal(p[i]) for i in range(K))
    
cnt = ans

for i in range(K, N):
  cnt = cnt-cal(p[i-K])+cal(p[i])
  ans = max(cnt, ans)
print(ans)
### BUGGY CODE ###

import collections

N,K,Q=map(int, input().split())
#print(N,K,Q)

if K>Q:
  for j in range(N):
    print('Yes')
else:    
 A=list()
 for j in range(Q):
   A.append(int(input()))

 for k in range(N):
  score=K
  cond=0
  for j in range(Q):
   if k+1 != A[j]:
    score=score-1
   if score<=0:
      print('No')
      cond=1
      break
  if cond==0:
    print('Yes')
  
  

### FIXED CODE ###

N,K,Q=map(int, input().split())
score=[Q]*N
#print(score)
for j in range(Q):
  c=int(input())
  score[c-1] += -1
 
#print(score)

for j in range(N):
  if score[j]<K:
    print('Yes')
  else:
    print('No')
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 0
for e,i in enumerate(a):
    c = 1
    for f,j in enumerate(a[e+1:]):
        if c == i+j:
            # print(e,f,i,j)
            ans +=1
        # print(e,f,i,j)
        c+=1
print(ans)


### FIXED CODE ###

n = int(input())
from collections import defaultdict
a = list(map(int,input().split()))
ans = 0
dp = defaultdict(int)
for e,i in enumerate(a,1):
    if  e - i>= 0 :ans += dp[e-i]
    dp[i+e]+=1
print(ans)
### BUGGY CODE ###

import sys

n, m = [int(i) for i in sys.stdin.readline().split()]
graph = {i:[] for i in range(n)}
for i in range(m):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

que = [0]
res = {0:-1}
while len(que) > 0:
    cur = que.pop(0)
    for _next in graph[cur]:
        if _next in res:
            continue
        res[_next] = cur
        que.append(_next)
if len(res) < n:
    print("No")
else:
    print("Yes")
    for i in range(1,n):
        print(res[i]+1)

### FIXED CODE ###

import sys
from collections import deque

n, m = [int(i) for i in sys.stdin.readline().split()]
graph = {i:[] for i in range(n)}
for i in range(m):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

que = deque([0])
res = {0:-1}
while len(que) > 0:
    cur = que.popleft()
    for _next in graph[cur]:
        if _next in res:
            continue
        res[_next] = cur
        que.append(_next)

if len(res) < n:
    print("No")
else:
    print("Yes")
    for i in range(1,n):
        print(res[i]+1)
### BUGGY CODE ###

# -*- coding:utf-8 -*-
n = int(input())
a = list(map(int,input().split()))
for tmp in range(1,len(a)):
    a[0:tmp+1] = reversed(a[0:tmp+1])
a = map(str,a)
print(" ".join(a))

### FIXED CODE ###

# -*- coding:utf-8 -*-
from collections import deque
def odd(num):
    return True if num%2!=0 else False
n = int(input())
a = list(input().split())
b = deque()
for tmp in range(len(a)):
    if odd(n) == odd(tmp+1):
        b.appendleft(a[tmp])
    else:
        b.append(a[tmp])
print(' '.join(b))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from collections import deque

S = input()
Q = int(input())

querys = []
op1_cnt = 0
op2_cnt = 0
prefix = deque()
suffix = deque()
for i in range(Q):
    query = input()
    if len(query) == 1:
        op1_cnt += 1

        if op2_cnt != 0:
            prefix.extend(S)
            prefix.extend(suffix)
            S = ''.join(prefix)
            prefix.clear()
            suffix.clear()
            op2_cnt = 0

    else:
        op2_cnt += 1

        if op1_cnt % 2 != 0:
            S = S[::-1]

        op1_cnt = 0

        t, F, C = query.split()
        if F == "1":
            prefix.appendleft(C)
        else:
            suffix.append(C)

if op1_cnt % 2 != 0:
    S = S[::-1]

if op2_cnt != 0:
    prefix.extend(S)
    prefix.extend(suffix)
    S = ''.join(prefix)


print(S)


### FIXED CODE ###

# -*- coding: utf-8 -*-
S = input()
Q = int(input())

reverse = 0
head = []
tail = []
for i in range(Q):
    query = input()
    if len(query) == 1:
        reverse = (reverse + 1) % 2

    else:
        t, F, C = query.split()
        if reverse == 0:
            if F == "1":
                head.append(C)
            else:
                tail.append(C)
        else:
            if F == "1":
                tail.append(C)
            else:
                head.append(C)

if reverse == 0:
    S = ''.join(head[::-1] + list(S) + tail)
else:
    S = ''.join(tail[::-1] + list(S[::-1]) + head)


print(S)
### BUGGY CODE ###

import queue

H, W = map(int, input().split())
A = []
D = [[-1 for _ in range(W)] for _ in range(H)]
q = queue.Queue()
for i in range(H):
    S = input()
    for j in range(W):
        if S[j] == "#":
            q.put((i, j))
            D[i][j] = 0
    A.append(S)

ans = 0
while not q.empty():
    pos = q.get()
    ans = max(ans, D[pos[0]][pos[1]])
    for (y, x) in [(0, -1), (0, 1), (-1, 0), (1, 0)]:
        ny = pos[0] + y
        nx = pos[1] + x
        if 0 <= nx and nx < W and 0 <= ny and ny < H:
            if D[ny][nx] < 0:
                D[ny][nx] = D[pos[0]][pos[1]] + 1
                q.put((ny, nx))
print(ans)

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
A = []
D = [[-1 for _ in range(W)] for _ in range(H)]
q = deque([])
for i in range(H):
    S = input()
    for j in range(W):
        if S[j] == "#":
            q.append((i, j))
            D[i][j] = 0
    A.append(S)

while q:
    pos = q.popleft()
    py, px = pos[0], pos[1]
    for (y, x) in [(0, -1), (0, 1), (-1, 0), (1, 0)]:
        ny = py + y
        nx = px + x
        if nx < 0 or W <= nx or ny < 0 or H <= ny:
            continue
        if D[ny][nx] < 0:
            D[ny][nx] = D[py][px] + 1
            q.append((ny, nx))

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, D[i][j])
print(ans)
### BUGGY CODE ###

h,w=map(int,input().split())
ch,cw=map(int,input().split())
dh,dw=map(int,input().split())
s=[0]*h
for i in range(h):
  st=str(input())
  st=list(st)
  s[i]=st
  
from collections import deque
temp=[[999999]*w for i in range(h)]
temp[ch-1][cw-1]=0
queue = deque([[ch-1, cw-1]])
while queue:  
  x,y=queue.popleft()
  for i,j in [[1,0],[-1,0],[0,1],[0,-1],[2,2],[2,1],[2,0],[2,-1],[2,-2],[1,2],[1,1],[1,-1],[1,-2],[0,2],[0,-2],[-1,2],[-1,1],[-1,-1],[-1,-2],[-2,2],[-2,1],[-2,0],[-2,-1],[-2,-2]]:
    xtemp,ytemp=x+i,y+j
    if xtemp<0 or h<=xtemp or ytemp<0 or w<=ytemp or s[xtemp][ytemp]!=".":
      continue
    if temp[xtemp][ytemp]<=temp[x][y]:
      continue
    if (i==1 and j==0) or (i==-1 and j==0) or (i==0 and j==1) or (i==0 and j==-1):
      temp[xtemp][ytemp]=min(temp[xtemp][ytemp],temp[x][y])
    else:
      temp[xtemp][ytemp]=min(temp[xtemp][ytemp],temp[x][y]+1)
    if [xtemp,ytemp] not in queue:
      queue.append([xtemp,ytemp])

if temp[dh-1][dw-1]==999999:
  print(-1)
else:
  print(temp[dh-1][dw-1])

### FIXED CODE ###

h,w=map(int,input().split())
ch,cw=map(int,input().split())
dh,dw=map(int,input().split())
s=[0]*h
for i in range(h):
  st=str(input())
  st=list(st)
  s[i]=st
  
from collections import deque
temp=[[999999]*w for i in range(h)]
temp[ch-1][cw-1]=0
queue0 = deque([[ch-1, cw-1, 0]])
queue1 = deque()
while queue0:  
  x,y,c=queue0.popleft()
  queue1.append((x,y,c))
  for i,j in [[1,0],[-1,0],[0,1],[0,-1]]:
    xtemp,ytemp=x+i,y+j
    if xtemp<0 or h<=xtemp or ytemp<0 or w<=ytemp or s[xtemp][ytemp]!=".":
      continue
    if temp[xtemp][ytemp]<=c:
      continue
    temp[xtemp][ytemp]=c
    queue0.append([xtemp,ytemp,temp[xtemp][ytemp]])
    
  if len(queue0)==0:      
    while queue1:
      x,y,c=queue1.popleft()
      for i,j in [[2,2],[2,1],[2,0],[2,-1],[2,-2],[1,2],[1,1],[1,-1],[1,-2],[0,2],[0,-2],[-1,2],[-1,1],[-1,-1],[-1,-2],[-2,2],[-2,1],[-2,0],[-2,-1],[-2,-2]]:
        xtemp,ytemp=x+i,y+j
        if xtemp<0 or h<=xtemp or ytemp<0 or w<=ytemp or s[xtemp][ytemp]!=".":
          continue
        if temp[xtemp][ytemp]<=c+1:
          continue
        temp[xtemp][ytemp]=c+1
        queue0.append([xtemp,ytemp,temp[xtemp][ytemp]])
        
if temp[dh-1][dw-1]==999999:
  print(-1)
else:
  print(temp[dh-1][dw-1])
### BUGGY CODE ###

from itertools import permutations
N, M, R = map(int, input().split())
rs = map(lambda x: int(x) - 1, input().split())
dist = [[10**9 for _ in range(N)] for _ in range(N)]
for _ in range(M):
    v1, v2, d = map(int, input().split())
    dist[v1-1][v2-1] = dist[v2-1][v1-1] = d
for i in range(N):
    dist[i][i] = 0
for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
ans = 10**9
for r in permutations(rs):
    t = 0
    for i in range(R-1):
        t += dist[r[i]][r[i+1]]
        if t > 10**9:
            break
    ans = min(t, ans)
print(ans)

### FIXED CODE ###

from itertools import permutations
N, M, R = map(int, input().split())
rs = map(lambda x: int(x) - 1, input().split())
dist = [[10**9 for _ in range(N)] for _ in range(N)]
for _ in range(M):
    v1, v2, d = map(int, input().split())
    dist[v1-1][v2-1] = dist[v2-1][v1-1] = d
for i in range(N):
    dist[i][i] = 0
for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
ans = 10**9
for r in permutations(rs):
    t = 0
    for i in range(R-1):
        t += dist[r[i]][r[i+1]]
        if t > 10**9:
            break
    ans = min(t, ans)
print(ans)
### BUGGY CODE ###

# coding: utf-8
# Your code here!

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

# dp = [float('inf') for i in range(len(h))]
dp = [float('inf')] * n
dp[0] = 0
# dp[1] = abs(h[0] - h[1])
# print(dp)

for i in range(1, n):
    # for j in range(1, min(k + 1, n - i)):
    #     dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))
    dp[i] = min([dp[j] + abs(h[j] - h[i]) for j in range(max(0, i - k), i)])
            
        # print(dp)
        
print(dp[-1])

### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * n
    a[0] = 0
    for i in range(1, n):
        a[i] = min([a[j] + abs(h[i] - h[j]) for j in range(max(0, i - k), i)])
    print(a[-1])
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

s=list(input())
for _ in range(int(input())):
  t=list(input().split())
  if int(t[0])==1:
    s=s[::-1]
  else:
    if int(t[1])==1:
      s=s[::-1]
      s.append(t[2])
      s=s[::-1]
    else:
      s.append(t[2])
print(''.join(s))

### FIXED CODE ###

from collections import deque
s=deque(input())
f=False
for _ in range(int(input())):
  t=list(input().split())
  if t[0]=='1':
    if f is False:
      f = True
    else:
      f = False
  else:
    if t[1]=='1':
      if f is False:
      	s.appendleft(t[2])
      else:
        s.append(t[2])
    else:
      if f is False:
      	s.append(t[2])
      else:
        s.appendleft(t[2])
x=''.join(map(str,s))
if f is False:
	print(x)
else:
  print(x[::-1])
### BUGGY CODE ###

n = int(input())
a = sorted(map(int,input().split()))

ans = 0

while len(a) > 1:
    a0 = a[0]
    i_s = []
    for i in range(1,len(a)):
        if a[i]%a0 == 0:
            i_s.append(i)
    if a0 != a[1]:
        for i in range(len(i_s))[::-1]:
            a.pop(i_s[i])
        a.pop(0)
        ans += 1
    else:
        for i in range(len(i_s))[::-1]:
            a.pop(i_s[i])
        a.pop(0)

if len(a) == 1:
    ans += 1

print(ans)

### FIXED CODE ###

n = int(input())
a = sorted(map(int,input().split()))

ans = 0

baisu = [0]*(a[n-1]+1)
an = a[n-1]

for i in range(n):
    a0 = a[i]
    a1 = a0
    while a1 <= an:
        baisu[a1] += 1
        a1 += a0


for i in range(n):
    if baisu[a[i]] == 1:
        ans += 1
print(ans)
### BUGGY CODE ###

n=int(input())
g={(i,j):set() for i in range(n+1) for j in range(n+1) if i<j}
visit={(i,j):0 for i in range(n+1) for j in range(n+1) if i<j}
d={(i,j):0 for i in range(n+1) for j in range(n+1) if i<j}

inf=10**10

for i in range(1,n+1):
    last=(0,1)
    for j in list(map(int,input().split())):
        current=(min(i,j),max(i,j))
        g[last].add(current)
        last=current

def dfs(u):
    if visit[u]==2:
        return d[u]
        
    if len(g[u])==0:
        return 0
    
    ans=0
    visit[u]=1
    for v in g[u]:
        if visit[v]==1:
            print(-1)
            exit(0)
        
        ans=max(ans,1+dfs(v))
    
    visit[u]=2
    d[u]=ans
    return d[u]

print(dfs((0,1)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

n=int(input())
g=[set() for _ in range(n*(n-1)//2+1)]
visit=[0]*(n*(n-1)//2+1)
d=[0]*(n*(n-1)//2+1)

for i in range(1,n+1):
    last=0
    for j in list(map(int,input().split())):
        mi,ma=(min(i-1,j-1),max(i-1,j-1))
        current=ma*(ma-1)//2+mi+1
        g[last].add(current)
        last=current

def dfs(u):
    if visit[u]==2:
        return d[u]
    
    ans=0
    visit[u]=1
    for v in g[u]:
        if visit[v]==1:
            print(-1)
            exit(0)
        
        d[u]=max(d[u],1+dfs(v))
    
    visit[u]=2
    return d[u]

print(dfs(0))
### BUGGY CODE ###

n,m=map(int,input().split())
lis=[]
ng=[[] for _ in range(n)]

for i in range(m):
    A,B=map(int,input().split())
    lis.append([A,B])
    ng[A].append(B)
    
lis.sort()
now=[]
cu=0
for i in range(1,n):
    now.append(i)
    for j in now:
        if(i+1 in ng[j]):
            cu+=1
            now=[]
            break
            
print(cu)

### FIXED CODE ###

n,m=map(int,input().split())
ng=[set() for _ in range(n)]

for i in range(m):
    A,B=map(int,input().split())
    ng[A].add(B)
    
now=[]
danger=set()
cu=0
for i in range(1,n):
    now.append(i)
    for j in ng[i]:
        danger.add(j)
    if(i+1 in danger):
        cu+=1
        danger.clear()
            
print(cu)
### BUGGY CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7

NOW=[0]*(K+1)
NOW[0]=1#そこまでi個使ったときの場合の数


for i in range(N):
    NEXT=[0]*(K+1)
    NOWSUM=[0]
    for n in NOW:
        NOWSUM.append(NOWSUM[-1]+n)
        
    for j in range(K+1):
        NEXT[j]=(NEXT[j]+NOWSUM[j+1]-NOWSUM[max(0,j-A[i])])%mod

    NOW=NEXT
    #print(NOWSUM,NOW)

print(NOW[K])

### FIXED CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7

NOW=[0]*(K+1)
NOW[0]=1#そこまでi個使ったときの場合の数


for i in range(N):
    NEXT=[0]*(K+1)
    NOWSUM=[0]
    for n in NOW:
        NOWSUM.append(NOWSUM[-1]+n)
        
    for j in range(K+1):
        NEXT[j]=(NEXT[j]+NOWSUM[j+1]-NOWSUM[max(0,j-A[i])])%mod

    NOW=NEXT
    #print(NOWSUM,NOW)

print(NOW[K])