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

h, w, k = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())

sum = [[0] * (w+1) for _ in range(h+1)]
for i in range(h):
    for j in range(w):
        sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + (1 if s[i][j] == '1' else 0)

ans = h + w - 2
for ptn in range(1<<h-1):
    cand = 0

    sep = [0]
    for i in range(h-1):
        if((ptn >> i) & 1):
            sep.append(i+1)
            cand += 1
    sep.append(h)

    left = 0
    for pos in range(w):
        cur = []
        for i in range(len(sep)-1):
            cur.append(sum[sep[i+1]][pos+1] - sum[sep[i+1]][left] - sum[sep[i]][pos+1] + sum[sep[i]][left])
        if max(cur) > k:
            if left == pos:
                cand = h * w
                break
            else:
                cand += 1
                left = pos
    ans = cand if cand < ans else ans

print(ans)


### FIXED CODE ###

h, w, k = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())

sum = [[0] * (w+1) for _ in range(h+1)]
for i in range(h):
    for j in range(w):
        sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + (1 if s[i][j] == '1' else 0)

ans = h + w - 2
for ptn in range(1<<h-1):
    cand = 0

    sep = [0]
    for i in range(h-1):
        if((ptn >> i) & 1):
            sep.append(i+1)
            cand += 1
    sep.append(h)

    left = 0
    for pos in range(w):
        cur = []
        for i in range(len(sep)-1):
            cur.append(sum[sep[i+1]][pos+1] - sum[sep[i+1]][left] - sum[sep[i]][pos+1] + sum[sep[i]][left])
        if max(cur) > k:
            if left == pos:
                cand = h * w
                break
            else:
                cand += 1
                left = pos
    ans = cand if cand < ans else ans

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

n, x = map(int, input().split())
ans = n
y, x = n-x, x
while y != x:
  if x > y:
    y, x = x, y
  ans += 2*x
  y, x = y-x, x
ans += x
print(ans)

### FIXED CODE ###

n, x = map(int, input().split())
ans = n
y, x = n-x, x
if x > y:
  y, x = x, y
while True:
  q, r = divmod(y, x)
  if r == 0:
    ans += (2*q-1)*x
    break
  ans += 2*q*x
  y, x = x, r
print(ans)
### BUGGY CODE ###

n = int(input())
s = list(str(n))
s.reverse()
s += ['0']
s = [int(c) for c in s]
m = len(s)

dp = [[10**18, 10**18] for _ in range(len(s)+5)]
# dp[i][0]: 繰り下がりなし
# dp[i][1]: 繰り下がりあり

dp[0][0] = 0

for i in range(m):
    for j in range(2):
        nd = s[i]
        if j == 1:
            nd += 1
        for a in range(10):
            ni = i+1
            nj = 0
            b = a-nd
            if b < 0:
                nj = 1
                b += 10
            dp[ni][nj] = min(dp[ni][nj], dp[i][j]+a+b)
#print(dp)
print(dp[m][0])

### FIXED CODE ###

def main():
    s = list(str(input()))
    s.reverse()
    for i in range(len(s)):
        s[i] = int(s[i])
    s += [0]
    m = len(s)

    dp = [[10**7, 10**7] for _ in range(len(s)+5)]
    # dp[i][0]: 繰り下がりなし
    # dp[i][1]: 繰り下がりあり

    dp[0][0] = 0

    for i in range(m):
        for j in range(2):
            nd = s[i]
            if j == 1:
                nd += 1
            if dp[i+1][0] >= dp[i][j]+nd:
                dp[i+1][0] = dp[i][j]+nd
            if dp[i+1][1] >= dp[i][j]+10-nd:
                dp[i+1][1] = dp[i][j]+10-nd
    #print(dp)
    print(dp[m][0])

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

def spl1(a):
    delta=[]
    for i in range(len(a)-1):
        delta.append(abs(a[-1]-2*a[i]))
    m=min(delta)
    index=[]
    for i in range(len(delta)):
        if delta[i]==m:
            index.append(i)
    return index
def spl2(a,b):
    delta=[]
    for i in range(len(a)-1):
        delta.append(abs(a[-1]-2*a[i]+b))
    m=min(delta)
    index=[]
    for i in range(len(delta)):
        if delta[i]==m:
            index.append(i)
    return index
N=int(input())
A=list(map(int,input().split()))
h=[0]
for a in A:
    h.append(a+h[-1])
h.pop(0)
ans=10**18
for i in range(N):
    if i>0 and i<N-2:
        for j in spl1(h[:i+1]):
            for k in spl2(h[i+1:],h[i]):
                p=h[j]
                q=h[i]-h[j]
                r=h[k+i+1]-h[i]
                s=h[-1]-h[k+i+1]
                if (max([p,q,r,s])-min([p,q,r,s]))<ans:
                    ans=max([p,q,r,s])-min([p,q,r,s])
print(ans)


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
h=[0]
for a in A:
    h.append(a+h[-1])
h.pop(0)
def spl_l(i,b):
    while abs(h[i]-2*h[b])>abs(h[i]-2*h[b+1]):
        b+=1
    return b
def spl_r(i,b):
    while abs(h[-1]-2*h[b]+h[i])>abs(h[-1]-2*h[b+1]+h[i]):
        b+=1
    return b
def calc(j,i,k):
    pqrs=[h[j],h[i]-h[j],h[k]-h[i],h[-1]-h[k]]
    ans=max(pqrs)-min(pqrs)
    return ans

j=0
k=2
ans=18**20
for i in range(1,N-2):
    j=spl_l(i,j)
    k=spl_r(i,k)
    ans=min(ans,calc(j,i,k))
print(ans)
### BUGGY CODE ###

class ModComb:
    def __init__(self, MAX, mod=10 ** 9 + 7):
        fac = [1, 1]
        finv = [1, 1]
        inv = [0, 1]
        for i in range(2, MAX):
            fac.append(fac[i - 1] * i % mod)
            inv.append(mod - inv[mod % i] * (mod // i) % mod)
            finv.append(finv[i - 1] * inv[i] % mod)
        self.fac, self.finv, self.mod = fac, finv, mod

    def nCk(self, n, k):
        if n < k or n < 0 or k < 0:
            return 0
        fac, finv, mod = self.fac, self.finv, self.mod
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod

mod = 10 ** 9 + 7

r1, c1, r2, c2 = map(int, input().split())

mc = ModComb(r2 + c2 + 10)
def f(i, j):
    return mc.nCk(i + j, i)

print((f(r2 + 1, c2 + 1) - f(r2 + 1, c1) - f(r1, c2 + 1) + f(r1, c1)) % mod)

### FIXED CODE ###

class ModComb:
    def __init__(self, MAX, mod=10 ** 9 + 7):
        fac = [1, 1]
        finv = [1, 1]
        inv = [0, 1]
        for i in range(2, MAX):
            fac.append(fac[i - 1] * i % mod)
            inv.append(mod - inv[mod % i] * (mod // i) % mod)
            finv.append(finv[i - 1] * inv[i] % mod)
        self.fac, self.finv, self.mod = fac, finv, mod

    def nCk(self, n, k):
        if n < k or n < 0 or k < 0:
            return 0
        fac, finv, mod = self.fac, self.finv, self.mod
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod

mod = 10 ** 9 + 7

r1, c1, r2, c2 = map(int, input().split())

mc = ModComb(r2 + c2 + 10)
def f(i, j):
    return mc.nCk(i + j, i)

print((f(r2 + 1, c2 + 1) - f(r2 + 1, c1) - f(r1, c2 + 1) + f(r1, c1)) % mod)
### BUGGY CODE ###

L,R = map(int,input().split())
a=R-L+1
Y=2019

for i in range(L,R+1):
  for j in range(L,R+1):
    if Y>(i*j)%2019 and i!=j:
      Y= (i*j)%2019
print(Y)

### FIXED CODE ###

L,R = map(int,input().split())
a=R-L
Y=2019
if a<2019:
  for i in range(L,R+1):
    for j in range(L,R+1):
      if Y>(i*j)%2019 and i!=j:
        Y= (i*j)%2019
  print(Y)
else:
  print(0)
### BUGGY CODE ###

n=int(input())
a=[int(x) for x in input().split()]
x=1
bb=pow(10,18)
for i in range(n):
    x*=a[i]
if (x>bb):
    print(-1)
else:
    print(x)

### FIXED CODE ###

n=int(input())
a=[int(x) for x in input().split()]
x=1
bb=pow(10,18)
for i in range(n):
    if (a[i]==0):
        print(0)
        exit()
for i in range(n):
    x*=a[i]
    if (x>bb):
        print(-1)
        exit()
print(x)
### BUGGY CODE ###

H,W,K=map(int,input().split())
mod=10**9+7
ans=0
const=1
for i in range(H+W-1,H+W-K,-1):
    const=(const*i)%mod

inv=pow(H+W-1,mod-2,mod)
for i in range(K):
    ans+=(K-i)*(H+W)*const+(K-i)*i*const*inv*2*H*W
    ans%=mod
ans+=K*(H+W)*const
ans%=mod
print(ans)


### FIXED CODE ###

mod=10**9+7
def mul(a,b):
    x,y=a,b
    return (x*y)%mod

H,W,K=map(int,input().split())
mod=10**9+7
ans=0
const=1
for i in range(H+W-1,H+W-K,-1):
    const=(const*i)%mod

inv=pow(H+W-1,mod-2,mod)
temp1=mul(H+W,mul((K*(K+1)//2)%mod,const))
const=mul(const,inv)
u=(K*(K**2-1))//6
u%=mod
temp2=mul(2*H*W,mul(u,const))
ans=(temp1+temp2)%mod
const=mul(const,H+W-1)
ans+=mul(K,mul(H+W,const))
ans%=mod
print(ans)
### BUGGY CODE ###

from collections import Counter
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


N, M = map(int, input().split())
mat = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N)]

ans = N
Q = [set([v for v in range(M)])]
while Q:
    C = Counter()
    sports_cand = Q.pop(0)
    for n in range(N):
        for m in range(M):
            if mat[n][m] in sports_cand:
                C[mat[n][m]] += 1
                break
    tmp = 0
    for key, val in C.most_common():
        if val >= tmp:
            tmp = val
            ans = min(ans, val)
            if len(sports_cand) > 2:
                Q.append(sports_cand-{key})
        else:
            break
print(ans)


### FIXED CODE ###

from collections import Counter
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


N, M = map(int, input().split())
mat = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N)]

ans = N
Q = [set([v for v in range(M)])]
while Q:
    C = Counter()
    sports_cand = Q.pop(0)
    for n in range(N):
        for m in range(M):
            if mat[n][m] in sports_cand:
                C[mat[n][m]] += 1
                break
    tmp = 0
    for key, val in C.most_common():
        if val > tmp:
            tmp = val
            ans = min(ans, val)
            if len(sports_cand) > 2:
                Q.append(sports_cand-{key})
        else:
            break
print(ans)
### BUGGY CODE ###

import queue
import sys 
input=sys.stdin.readline

def main():
    n,m,k=map(int,input().split())
    root={}
    ng={}

    for i in range(n):
        root[i]=[]
        ng[i]=[]
    for i in range(m):
        a,b=map(int,input().split())
        root[a-1].append(b-1)
        root[b-1].append(a-1)
        ng[a-1].append(b-1)
        ng[b-1].append(a-1)
    for i in range(k):
        a,b=map(int,input().split())
        ng[a-1].append(b-1)
        ng[b-1].append(a-1)
    
    Vstd=[]
    v_append=Vstd.append
    checkVst=[False]*n
    num=[0]*n
    ToVst=queue.Queue()
    for i in range(n):
        if checkVst[i]:
            continue
        Vstd=[]
        v_append=Vstd.append
        now=i
        v_append(now)
        checkVst[now]=True

        for kouho in root[now]:
            if checkVst[kouho]:
                continue
            ToVst.put(kouho)
            checkVst[kouho]=True

        while ToVst.empty()==False:
            now=ToVst.get()
            v_append(now)
            checkVst[now]=True
           
            for kouho in root[now]:
                if checkVst[kouho]:
                    continue
                ToVst.put(kouho)
                checkVst[kouho]=True
                
        lengh=len(Vstd)
        for v in Vstd:
            num[v]=lengh-1
            num[v]-=len(set(ng[v])&set(Vstd))
    print(*num)
    #print(" ".join(map(str,num)))
   

if __name__=="__main__":
    main()
    
        

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n,m,k=map(int,input().split())
uf=UnionFind(n)
block={}
for i in range(n):
    block[i]=[i]
for i in range(m):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)
    block[a-1].append(b-1)
    block[b-1].append(a-1)
    
for i in range(k):
    a,b=map(int,input().split())
    block[a-1].append(b-1)
    block[b-1].append(a-1)
ans=[]
#print(block)
for i in range(n):
    res=uf.size(i)
 #   print(res)
    for value in block[i]:
        if uf.same(value,i):
            res-=1
    ans.append(res)
print(*ans)
### BUGGY CODE ###

def E():
    N = int(input())
    A = [int(n) for n in input().split()]
    count = 0
    for i in range(len(A)):
        for j in range(i+1, len(A)):
            if A[j]+A[i] == abs(j-i):
                count += 1
    print(count)

E()

### FIXED CODE ###

from collections import defaultdict
def E():
    N = int(input())
    A = [int(n) for n in input().split()]
    record = defaultdict(int)
    count = 0
    for i in range(len(A)):
        cur = i-A[i]
        count += record[cur]
        record[i+A[i]] += 1
    
    print(count)

E()
### BUGGY CODE ###

N=int(input())
S=list(input())

R=[]
G=[]
B=[]

# リストを作成
for i in range(0,N):
  if S[i]=="R":
    R += [i]
  elif S[i]=="G":
    G += [i]
  else:
    B += [i]

def search(ind, col):
  n=0
  useable_col = ["R","G","B"]
  useable_col.remove(col)
  for i,j in [[0,1],[1,0]]:
    l_col=useable_col[i]
    r_col=useable_col[j]
    if l_col=="R":
      l_col=R
    elif l_col=="G":
      l_col=G
    else:
      l_col=B
    if r_col=="R":
      r_col=R
    elif r_col=="G":
      r_col=G
    else:
      r_col=B
        
    l_useable = [ii for ii in l_col if ii<ind]
    r_useable = [ii for ii in r_col if ii>ind]
    # print(l_useable)
    # print(r_useable)
    l = min(ind, N-1-ind)
    for m in range(1,l+1):
      if ind-m in l_useable and ind+m in r_useable:
        n -= 1
    n += len(l_useable) * len(r_useable)
  return n

n=0
for pivot in range(1,N-1):
  if S[pivot] =="R":
    n += search(pivot, "R")
  elif S[pivot] =="G":
    n += search(pivot, "G")
  else:
    n += search(pivot, "B")

print(n)


### FIXED CODE ###

N=int(input())
S=list(input())

r=0
g=0
b=0

for i in range(N):
  if S[i]=="R":
    r+=1
  elif S[i]=="G":
    g+=1
  else:
    b+=1
    
n=r*g*b

for i in range(N):
  for j in range(i+1,N):
    if S[i]==S[j]:
      continue
    k = 2*j-i
    if k >= N:
      break
    if S[i]==S[k] or S[j]==S[k]:
      continue
    n -= 1
      
print(n)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
masu_size = int(input())
# スペース区切りの整数の入力
takasa_L = list(map(int, input().split()))
# 文字列の入力

counter_L = []
for m in range(0,masu_size):
    #print(m)
    counter = 0

    for h in range(m,masu_size):
        try:
            diff = takasa_L[h] - takasa_L[h+1]
        except:
            counter_L.append(counter)
            break
        if diff >= 0:
            counter +=1
        else:
            counter_L.append(counter)
            break

print(max(counter_L))


### FIXED CODE ###

import copy
n = int(input())
r_L = list(map(int,input().split()))
l_L = copy.deepcopy(r_L)
l_L.reverse()


r_ans,l_ans = 0,0
r_ans_L,l_ans_L = [],[]

for val in range(n-1):
    if r_L[val] >= r_L[val+1]:
        r_ans += 1
    else:
        r_ans_L.append(r_ans)
        r_ans = 0
    



l_ans_L.append(l_ans)
r_ans_L.append(r_ans)

print(max(max(l_ans_L),max(r_ans_L)))
### BUGGY CODE ###

n, p = map(int, input().split())
s = input()

ans = 0
for i in range(n):
    for j in range(i+1, n+1):
        ans += (int(s[i:j]) % p == 0) + 0
print(ans)


### FIXED CODE ###

from collections import defaultdict

n, p = map(int, input().split())
s = input()

if p in (2, 5):
    if p == 2:
        ok_list = [i for i in range(10)][::2]
    else:
        ok_list = [0, 5]
    ans = 0
    for i in range(n):
        if int(s[i]) in ok_list:
            ans += i+1
    print(ans)
else:
    dd = defaultdict(int)
    dd[0] = 1
    prev = 0

    for i in range(n-1, -1, -1):
        d = int(s[i]) * pow(10, n-i, p)
        prev = (prev + d) % p
        dd[prev] += 1

    print(sum(v*(v-1)//2 for v in dd.values()))
### BUGGY CODE ###

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

def calc(n, a, m):
    x = 1
    y = 1
    for i in range(a):
        x = (x*(n-i))%m
        y = (y*(i+1))%m
    return (x*pow(y, m-2, m))%m

m = 10**9+7
if k >= n-1:
    print(calc(2*n-1, n-1, m))
else:
    s = 0
    for i in range(n-k-1):
        s += calc(n-1,i,m)*calc(n,i+1,m)
    print((calc(2*n-1, n-1, m)-s)%m)

### FIXED CODE ###

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

def calc(n,m):
    y = [1]*(n+1)
    for i in range(n):
        y[i+1] = (y[i]*(i+1))%m
        
    return y

def calc2(n,a,m,y):
    x = (y[a]*y[n-a])%m
    return (y[n]*pow(x, m-2, m))%m

m = 10**9+7
y = calc(2*n-1,m)
if k >= n-1:
    print(calc2(2*n-1, n-1, m, y))
else:
    s = 0
    for i in range(n-k-1):
        s += calc2(n-1,i,m,y)*calc2(n,i+1,m,y)
    print((calc2(2*n-1, n-1, m, y)-s)%m)
### BUGGY CODE ###

n, m = map(int, input().split())
for i in range(m//n, 0, -1):
    if not m%i:
        print(i)
        break

### FIXED CODE ###

n, m = map(int, input().split())
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
if is_prime(m):
    print(1)
else:
    for i in range(m//n, 0, -1):
        if not m%i:
            print(i)
            break
### BUGGY CODE ###

N = int(input())
mod = 10 ** 9 + 7

power = 1
for i in range(1, N+1):
  power *= i % mod
  
print(power % mod)

### FIXED CODE ###

N = int(input())
mod = 10 ** 9 + 7

power = 1
for i in range(1, N+1):
  power *= i
  power %= mod
  
print(power % mod)
### BUGGY CODE ###

n = int(input())
ll = list(map(int,input().split()))
mm = []
pp = n
i = 0
for i in range(n):
    try:
        mm.append(str(ll[-1-2*i]))
        ll[-1-2*i] = '-1'
    except:
        pass

    
for i in range(len(ll)):
    if ll[i] != '-1':
        mm.append(str(ll[i]))
    else:
        None
        
sss = ''
for i in range(len(mm)):
    if i != 0:
        sss = sss + ' ' + mm[i]
    else:
        sss = sss + mm[i]
        
print(sss)

### FIXED CODE ###

n = int(input())
ll = list(map(int,input().split()))
mm = []
pp = n
i = 0
for i in range(n):
    try:
        mm.append(str(ll[-1-2*i]))
        ll[-1-2*i] = '-1'
    except:
        pass

    
for i in range(len(ll)):
    if ll[i] != '-1':
        mm.append(str(ll[i]))
    else:
        None
        
sss = ''
for i in mm:
    print(i, end= ' ')
### BUGGY CODE ###

n, m = map(int, input().split())
gate = []
for i in range(m):
    gate.append(list(map(int, input().split())))

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

for l, r in gate:
    for i in range(l, r+1):
        card[i-1] += 1
print(card.count(m))

### FIXED CODE ###

n, m = map(int, input().split())
L_max, R_min = map(int, input().split())
for i in range(m-1):
    L, R = map(int, input().split())
    L_max = max(L_max, L)
    R_min = min(R_min, R)

print(max(R_min - L_max + 1, 0))
### BUGGY CODE ###

from collections import defaultdict

N = int(input())
S = input()

B = 10 ** 9 + 7
ans = 0
for l in range(1, N + 1):
    t = B ** l
    
    # First hash
    ah = 0
    bh = 0
    for i in range(l):
        ah = ah * B + ord(S[i])
        bh = bh * B + ord(S[i])
        
    # Roll
    ctr = defaultdict(list)
    for i in range(N - l + 1):
        if not ctr[ah] or ctr[ah][-1] + l <= i:
            ctr[ah].append(i)
        
        if i < N - l:
            ah = ah * B + ord(S[i + l]) - ord(S[i]) * t

    # Check appearance number
    if max(map(len, ctr.values())) >= 2:
        ans = l

print(ans)


### FIXED CODE ###

N = int(input())
S = input()

def z_algorithm(s):
    n = len(s)
    res = [0] * n
    i = 1
    j = 0
    while i < n:
        while i + j < n and s[j] == s[i + j]:
            j += 1
            
        res[i] = j
        if j == 0:
            i += 1
            continue

        
        k = 1
        while i + k < n and k + res[k] < j:
            res[i + k] = res[k]
            k += 1
        
        i += k
        j -= k
        
    return res


res = 0
for i in range(N):
    lcp = z_algorithm(S[i:])
    for j in range(N - i):
        res = max(res, min(lcp[j], j))
        
print(res)
### BUGGY CODE ###

s = list(input())

a_ind = [i for i, v  in enumerate(s) if v == "A"]
z_ind = [i for i, v in enumerate(s) if v == "Z"]
z_ind = [i for i in z_ind if i > min(a_ind)]

ans = z_ind[-1] - a_ind[0] + 1

print(ans)

### FIXED CODE ###

s = list(input())

a_ind = [i for i, v  in enumerate(s) if v == "A"]
z_ind = [i for i, v in enumerate(s) if v == "Z"]


ans = z_ind[-1] - a_ind[0] + 1

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

import numpy as np
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))
for j in range(1, min(k+1, 50)):
    tmp = np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        tmp[max(0, i - a[i])] += 1
        tmp[min(i + a[i] + 1, n)] -= 1
    tmp = np.cumsum(tmp)
    a = tmp[:n]
print(*a)

### FIXED CODE ###

import numpy as np
from numba import jit
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))
@jit
def imos(a):
    tmp = np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        tmp[max(0, i - a[i])] += 1
        tmp[min(i + a[i] + 1, n)] -= 1
    tmp = np.cumsum(tmp)
    return tmp[:n]

for j in range(1, min(k+1, 50)):
    a = imos(a)
print(*a)
### BUGGY CODE ###

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

b=[0]*n

for i in range(n-1,-1,-1):
    for j in range(i,n):
        if not sum(b[i+1:n:i+1]) %2 and a[j]==1:
            b[i] = 1 

print(sum(b))
print(" ".join([str(i)  for i in b if i== 1]))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline

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

b=[0]*n

for i in range(n-1,-1,-1):
    if sum(b[i:n:i+1]) %2 and a[i] == 0:
        b[i] = 1 
    elif not sum(b[i:n:i+1]) %2 and a[i] == 1:
        b[i] = 1 


print(sum(b))
print(" ".join([str(k+1)  for k,v in enumerate(b)  if v== 1]))
### BUGGY CODE ###

from fractions import gcd
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
List=list(map(lambda x:int(x/2),map(int, set(input().split()))))

def main():
    LCM=1

    for i in List:
        LCM*=i/gcd(LCM,i)

    for i in List:
        if LCM//i%2==0:
            print(0)
            exit()

    print(int(M/(LCM*2)+M%(LCM*2)//LCM))


if __name__ == '__main__':
    main()


### FIXED CODE ###

from fractions import gcd
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
List=list(map(lambda x:int(x)//2,map(int, set(input().split()))))

def main():
    LCM=1

    for i in List:
        LCM*=i//gcd(LCM,i)

    for i in List:
        if LCM//i%2==0:
            print(0)
            exit()

    print(int(M//(LCM*2)+M%(LCM*2)//LCM))


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

n, k = list(map(int, input().split()))
tele = list(map(int, input().split()))
loc = 1
act = [[0]*n for i in range(n)]
count = 1
log = []
log.append(loc)
while True:
  newloc=tele[loc-1]
  log.append(newloc)
  #print(newloc)
  if act[loc-1][newloc-1] == 0:
    act[loc-1][newloc-1] =count
    act[newloc-1][loc-1] =count
  else:
    loop=count-act[loc-1][newloc-1]
    loopstart=act[loc-1][newloc-1]
    break
  count+=1
  loc=newloc

if k <= loopstart:
  ans=log[k]
else:
  num = (k-(loopstart-1)) % loop 
  ans=log[loopstart-1+num]
#print(loop)
#print(loopstart)
#print(count)
#print(act)
#print(log)
print(ans)
    
  

### FIXED CODE ###

n, k = list(map(int, input().split()))
tele = list(map(int, input().split()))
loc = 1
act = [-1]*n
act[0]=0
count = 1
log = []
log.append(loc)
flg = True
while True:
  newloc=tele[loc-1]
  if count ==k:
    print(newloc)
    flg = False
  log.append(newloc)
  #print(newloc)
  if act[newloc-1] == -1:
    act[newloc-1] =count
  else:
    loop=count-act[newloc-1]
    loopstart=act[newloc-1]
    break
  count+=1
  loc=newloc

  

if flg:
  num = (k-loopstart) % loop 
  ans=log[loopstart+num]
  print(ans)

#print(loopstart)
#print(log)
#print(log[loopstart])
#print(num)