Harryxun/stf_run huggingface dataset:
n, m = map(int, input().split())
A, B = [], []

for i in range(n):
    A.append(input())

for i in range(m):
    B.append(input())

def is_contain(i, b_pos):
    containing = True
    for a_i in range(i+1, i+m):
        if A[a_i][b_pos:(b_pos+len(B))] != B[a_i]:
            containing = False
    return containing

if n < m or len(A) < len(B):
    print("No")
    exit()

for i in range(n - m + 1):
    lineA = A[i]
    lineB = B[i%m]
    lineB_pos = lineA.find(lineB)
    if lineB_pos >= 0:
        if is_contain(i, lineB_pos):
            print("Yes")
            exit()

print("No")

### FIXED CODE ###

n, m = map(int, input().split())
A, B = [], []

for i in range(n):
    A.append(input())

for i in range(m):
    B.append(input())

def is_contain(i, b_pos):
    containing = True
    for k in range(1, m):
        if A[i+k][b_pos:(b_pos+len(B))] != B[k]:
            containing = False
    return containing

if n < m or len(A) < len(B):
    print("No")
    exit()

for i in range(n - m + 1):
    lineA = A[i]
    lineB = B[0]
    lineB_pos = lineA.find(lineB)
    if lineB_pos >= 0:
        if is_contain(i, lineB_pos):
            print("Yes")
            exit()

print("No")
import collections
n=int(input())
v=list(map(int,input().split()))

li1=[]
li2=[]

for i in range(n):
    if i%2==0:
        li1.append(v[i])
    else:
        li2.append(v[i])

li1=collections.Counter(li1).most_common()
li2=collections.Counter(li2).most_common()

if li1[0][0]!=li2[0][0]:
    print(n-li1[0][1]-li2[0][1])
else:
    if len(li1)==1 and len(li2)==1:
        print(n//2)
    elif len(li1)==1:
        print(n-li1[0][1]-li2[1][1])
    elif len(li2)==1:
        print(n-li1[1][1]-li2[0][1])
    else:
        print(min(n-li1[0][1]-li2[1][1]),n-li1[1][1]-li2[0][1])



### FIXED CODE ###

import collections
n=int(input())
v=list(map(int,input().split()))

li1=[]
li2=[]

for i in range(n):
    if i%2==0:
        li1.append(v[i])
    else:
        li2.append(v[i])

li1=collections.Counter(li1).most_common()
li2=collections.Counter(li2).most_common()

if li1[0][0]!=li2[0][0]:
    print(n-li1[0][1]-li2[0][1])
else:
    if len(li1)==1 and len(li2)==1:
        print(n//2)
    elif len(li1)==1:
        print(n-li1[0][1]-li2[1][1])
    elif len(li2)==1:
        print(n-li1[1][1]-li2[0][1])
    else:
        print(min(n-li1[0][1]-li2[1][1],n-li1[1][1]-li2[0][1]))
# coding: utf-8
import numpy as np
N = int(input())

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

v2=np.array(v)
c2=np.array(c)

v2[np.argsort(v2)]
c2[np.argsort(c2)]

x = v2[-1] + v2[-2]
y = c2[-1] + c2[-2]
print(x-y)


### FIXED CODE ###

# coding: utf-8
# Your code here!
V=[]
C=[]

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

li = input().split()

while(i<N):
    V.append(int(li[i]))
    i=i+1

i=0
li2=0
li2=input().split()

while(i<N):
    C.append(int(li2[i]))
    i = i+1
    
i=0

while(i<N):
    if(V[i]>C[i]):
        ans = ans + V[i] - C[i]
    i = i+1

print(ans)
#!/usr/bin python3
# -*- coding: utf-8 -*-

mod = 10**9+7               # mod素数
N = 1000002                   # 出力の制限
g1 = [1]*(N+1)              # 元テーブル
g2 = [1]*(N+1)              # 逆元テーブル
for i in range( 2, N + 1 ): # 準備
    g1[i] = ( g1[i-1] * i ) % mod
    g2[i] = ( g2[i-1] * pow(i,mod-2,mod) ) % mod

def nCr(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

def main():
#    mod = 10**9+7
    K = int(input())
    S = input()
    Nk = len(S)
    ret = 0
    pw25 = 1
    pw26 = pow(26,K,mod)
    inv26 = pow(26,mod-2,mod)
    for i in range(K+1):
        ret += nCr(i+Nk-1,i,mod) * pw25 * pw26
        ret %= mod
        pw25 = (pw25*25)%mod
        pw26 = (pw26*inv26)%mod

    print(ret)

if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    mod = 10**9+7
    K = int(input())
    S = input()
    Nk = len(S)
    ret = 0
    nCk = 1
    pw25 = 1
    pw26 = pow(26,K,mod)
    inv26 = pow(26,mod-2,mod)
    for i in range(K+1):
        ret += nCk * pw25 * pw26
        ret %= mod
        nCk *= (i+Nk) * pow(i+1,mod-2,mod)
        nCk %= mod
        pw25 = (pw25*25)%mod
        pw26 = (pw26*inv26)%mod

    print(ret)

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

def main():
    import sys
    def I(): return int(sys.stdin.readline())
    def LI(): return list(map(int,sys.stdin.readline().split()))

    n = I()
    V = []
    W = []
    m = min(n, 1 << 10)
    maxL = 10**5
    dp = [[0]*(maxL + 1) for _ in range(m + 1)]
    
    for i in range(1, m+1):
        v, w = LI()
        for j in range(maxL+1):
            if j < w:
                dp[i][j] = dp[i>>1][j]
            else:
                dp[i][j] = max(dp[i>>1][j], dp[i>>1][j - w] + v)
        V.append(v)
        W.append(w)
    
    q = I()
    for i in range(q):
        v, L = LI()
        if v <= m:
            print(dp[v][L])
            continue
        cnt = 0
        tmp = v
        v_ = []
        w_ = []
        while tmp > m:
            v_.append(V[tmp-1])
            w_.append(W[tmp-1])
            tmp >>= 1
            cnt += 1
        ret = dp[tmp][L]
        v_tmp = [0] * (1 << cnt)
        w_tmp = [0] * (1 << cnt)
        for b in range(1, 1 << cnt):
            lsb = b & -b
            l = lsb.bit_length()
            w_tmp[b] = w_tmp[b - lsb] + w_[l-1]
            if w_tmp[b] <= L:
                v_tmp[b] = v_tmp[b - lsb] + v_[l-1]
                ret = max(ret, v_tmp[b] + dp[tmp][L - w_tmp[b]])
        print(ret)
    return

if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3

def main():
    import sys
    def I(): return int(sys.stdin.readline())
    def LI(): return list(map(int,sys.stdin.readline().split()))

    n = I()
    V = []
    W = []

    maxL = 10**5
    m = min(n, 1 << 10)
    dp = [[0]*(maxL + 1)]
    
    for i in range(n):
        v, w = LI()
        if i <= m:
            d_ = dp[(i+1)>>1][:]
            for j in range(w, maxL+1)[::-1]:
                d_[j] = max(d_[j], d_[j - w] + v)
            dp.append(d_)
        V.append(v)
        W.append(w)
    
    q = I()
    for i in range(q):
        v, L = LI()
        if v <= m:
            print(dp[v][L])
            continue
        cnt = 0
        v_ = []
        w_ = []
        while v > m:
            v_.append(V[v-1])
            w_.append(W[v-1])
            v >>= 1
            cnt += 1
        ret = dp[v][L]
        v_tmp = [0] * (1 << cnt)
        w_tmp = [0] * (1 << cnt)
        for b in range(1, 1 << cnt):
            lsb = b & -b
            l = lsb.bit_length()
            w_t = w_tmp[b - lsb] + w_[l-1]
            w_tmp[b] = w_t
            if w_t <= L:
                v_t = v_tmp[b - lsb] + v_[l-1]
                v_tmp[b] = v_t
                ret = max(ret, v_t + dp[v][L - w_t])
        print(ret)
    return

if __name__ == "__main__":
    main()
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
D=dict()
C=[]
for i in set(A):
    D[i]=0
for i in A:
    D[i]+=1
ans=0
for i in D.keys():
    if D[i]==max(D.values()):
        C.append(i)
C=sorted(C)
print(*C,sep='\n')

### FIXED CODE ###

N=int(input())
A=[input() for i in range(N)]

from collections import Counter
counter=Counter(A)
m=max(counter.values())
C=[]
for i,value in counter.items():
    if value==m:
        C.append(i)
C=sorted(C)
print(*C,sep='\n')
a,b = map(int,input().split())
c = a//b
d = a//(b//2)
if b % 2 == 0:
	print(c**3 + d**3)
else:
	print(c**3)

### FIXED CODE ###

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

if b%2 != 0:
  print(pow(a//b,3))
else:
  print(pow(a//b,3)+pow(((a+b//2)//b),3))
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline




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


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

N=int(input())

x= [np.array(acinput())for i in range(N)]
#x = [acinput() for i in range(N)]
#print(tmp)
#x=sorted(tmp)

import itertools as it

#es=10**10

dc={}

for cb in it.combinations(x,2):
    d=cb[0]-cb[1]
    try:
        d=tuple(d)
        dc[d]+=1
    except:
        dc[d]=1
    continue

    dc[d[0],d[1]]+=1
    count=0
    
    for cb2 in it.combinations(x, 2):
        d2=cb2[0]-cb2[1]
        if np.all(d==d2):
            count+=1
    
    res=min(res,N-count)

#print(dc)    
print(N-max(dc.values()))
    
    


### FIXED CODE ###


import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline




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


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

N=int(input())

x= [np.array(acinput())for i in range(N)]
#x = [acinput() for i in range(N)]
#print(tmp)
#x=sorted(tmp)

import itertools as it

from collections import defaultdict
#es=10**10

#dc={}
dc=defaultdict(int)

for cb in it.combinations(x,2):
    d=cb[0]-cb[1]
    d2=tuple(-d)
    d=tuple(d)
    dc[d]+=1
    dc[d2]+=1

#print(dc)    
if N==1:
    print(1)
else:
    print(N-max(dc.values()))
#ずっとre
from functools import reduce
from itertools import combinations
from fractions import gcd

def get_gcd(number_list):
    return reduce(gcd, number_list)

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

skipped = list(map(list, combinations(Numbers, 5)))

gcd_list = [get_gcd(skipped) for i in range(N)]
    
print(int(max(gcd_list)))

### FIXED CODE ###

from functools import reduce
from itertools import combinations
from fractions import gcd

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


Left = [0] * (N + 1)
Right = [0] * (N + 1)

for i in range(N):
    Left[i + 1] = gcd(Left[i], A[i])
    Right[N - i - 1] = gcd(Right[N - i], A[N - i - 1])
ans = 0
for i in range(N):
    ans = max(ans, gcd(Left[i], Right[i + 1]))
    
print(ans)
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
idx=1
li=[]
idx_li=[1]
flag=False
for i in range(k):
    idx=a[idx-1]
    if idx in idx_li:
        flag=True
        break
    idx_li.append(idx)
if flag:
    #non_loop=idx_li[:idx_li.index(idx)]
    loop = idx_li[idx_li.index(idx):]
    
    size=len(loop)
    print(loop[(k-(len(idx_li)-len(non_loop)))%size])
else:
    print(idx)

### FIXED CODE ###

n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
idx=1
idx_li=[]
ord_=[-1]*n
flag=False
for i in range(k):
    idx_li.append(idx)
    ord_[idx-1]=1
    idx=a[idx-1]
    if ord_[idx-1]==1:
        flag=True
        break
if flag:
    #non_loop=idx_li[:idx_li.index(idx)]
    loop = idx_li[idx_li.index(idx):]
    
    size=len(loop)
    print(loop[(k-(len(idx_li)-len(loop)))%size])
else:
    print(idx)
n, k = map(int, input.split())
if n % k:
  print(1)
else:
  print(0)

### FIXED CODE ###

n, k = map(int, input().split())
if n % k:
  print(1)
else:
  print(0)
list_a=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
c=input()
print(l[l.index(c)+1])

### FIXED CODE ###

list_a=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
c=input()
print(list_a[list_a.index(c)+1])
N = int(input())
ll = []
for i in range(3):
    l = [int(x) for x in input().split()]
    ll.append(l)
if l[0][0] - l[0][1] != l[1][0] - l[1][1] or l[2][0] - l[2][1] != l[1][0] - l[1][1]:
    print("No")
    exit()
if l[0][2] - l[0][1] != l[1][2] - l[1][1] or l[2][2] - l[2][1] != l[1][2] - l[1][1]:
    print("No")
    exit()
if l[0][0] - l[1][0] != l[0][1] - l[1][1] or l[0][2] - l[1][2] != l[0][1] - l[1][1]:
    print("No")
    exit()
if l[2][0] - l[1][0] != l[2][1] - l[1][1] or l[2][2] - l[1][2] != l[2][1] - l[1][1]:
    print("No")
    exit()
print("Yes")

### FIXED CODE ###

l = []
for i in range(3):
    ll = [int(x) for x in input().split()]
    l.append(ll)
if l[0][0] - l[0][1] != l[1][0] - l[1][1] or l[2][0] - l[2][1] != l[1][0] - l[1][1]:
    print("No")
    exit()
if l[0][2] - l[0][1] != l[1][2] - l[1][1] or l[2][2] - l[2][1] != l[1][2] - l[1][1]:
    print("No")
    exit()
if l[0][0] - l[1][0] != l[0][1] - l[1][1] or l[0][2] - l[1][2] != l[0][1] - l[1][1]:
    print("No")
    exit()
if l[2][0] - l[1][0] != l[2][1] - l[1][1] or l[2][2] - l[1][2] != l[2][1] - l[1][1]:
    print("No")
    exit()
print("Yes")
x = []
while(1):
    inp = int(input())
    if inp !=0:
        x.append(inp)
    else:
        x.append(inp)
        break
print(x)
j=0
while(1):
    if(x[j]!=0):
        print("Case {} : {}".format(i,x[j]))
        j+=1
    else:
        break


### FIXED CODE ###

x = []
while(1):
    inp = int(input())
    if inp !=0:
        x.append(inp)
    else:
        x.append(inp)
        break

j=0
while(1):
    if(x[j]!=0):
        print("Case {}: {}".format(j+1,x[j]))
        j+=1
    else:
        break
N = int(input())

num = [int(input()) for i in range(N)]

for i in num:

    sum = 1/i

answer = 1 / sum

print(int(answer))


### FIXED CODE ###

N = int(input())

num = map(int,input().split())
sum = 0
for i in num:

    sum += 1/i

answer = 1 / sum

print(answer)
a = int(input())
lis = list(map(int,input().split()))

ans = list(set(lis))

if a == len(ans):
    print("YES")
else:
    print("NO")

### FIXED CODE ###

s,t = map(str,input().split())
a,b = map(int,input().split())
u = str(input())

if u == s:
    a = a-1
else:
    b = b-1

print(a, b)
N = input()
Nlen = len(N)
N = int(N)

def f(i, n, T, F, S):
  if i >= Nlen:
    return 1 if n <= N and T > 0 and F > 0 and S > 0 else 0
  n *= 10
  cnt = 0
  if n == 0:
    cnt += f(i+1, n, T  , F  , S  )
  cnt += f(i+1, n+3, T+1, F  , S  )
  cnt += f(i+1, n+5, T  , F+1, S  )
  cnt += f(i+1, n+7, T  , F  , S+1)

print(f(0, 0, 0, 0, 0))


### FIXED CODE ###

N = input()
Nlen = len(N)
N = int(N)

def f(i, n, T, F, S):
  if i >= Nlen:
    return 1 if n <= N and T > 0 and F > 0 and S > 0 else 0
  n *= 10
  cnt = 0
  if n == 0:
    cnt += f(i+1, n, T  , F  , S  )
  cnt += f(i+1, n+3, T+1, F  , S  )
  cnt += f(i+1, n+5, T  , F+1, S  )
  cnt += f(i+1, n+7, T  , F  , S+1)
  return cnt

print(f(0, 0, 0, 0, 0))
s = input()

for i in range(1,len(s)):
  if s[i] == s[i-1]:
    print('Bad')
    sys.exit()

print('Good')

### FIXED CODE ###

import sys

s = input()

for i in range(1,len(s)):
  if s[i] == s[i-1]:
    print('Bad')
    sys.exit()

print('Good')
def irohas_obsession(N: int, K: int, D: list) -> int:
    # D に含まれない最小の値
    min_not_d = min(d for d in range(10) if d not in D)

    # 数字を各桁に分解する。
    nums = []
    while N > 0:
        nums = [N % 10] + nums
        N //= 10

    # 上位の桁から見ていって最初に D に含まれる数字を探す。
    # convert_idx = len(nums)
    for i, n in enumerate(nums):
        if n not in D:
            # 変換の必要がない
            continue

        convert_idx = i
        break
    # print(convert_idx)
    for i in range(convert_idx, -1, -1):
        n = nums[i]
        for d in range(n, 10):
            # 変換先が n 以上 9 以下
            if d in D:
                # NG
                continue

            nums[i] = d
            break
        else:
            # 変換先が n 未満
            for d in range(n, 10):
                if d in D:
                    # NG
                    continue

                nums[i] = d

            # 上位の桁に繰り上がりを伝搬
            if i > 0:
                nums[i - 1] += 1
            else:
                nums = [min_not_d] + nums

    # 残りの桁は D に含まれない最小の値に変換する。
    nums = [min_not_d if n in D else n for n in nums]

    ret = 0
    digit = 1
    # print(nums)
    for n in reversed(nums):
        ret += n * digit
        digit *= 10

    return ret


if __name__ == "__main__":
    N, K = map(int, input().split())
    D = [int(s) for s in input().split()]
    ans = irohas_obsession(N, K, D)
    print(ans)


### FIXED CODE ###

def irohas_obsession(N: int, K: int, D: list) -> int:
    # D に含まれない最小の値
    min_not_d = min(d for d in range(10) if d not in D)
    min_not_d_and_not_zero = min(d for d in range(10) if d not in D and d != 0)

    # 数字を各桁に分解する。
    nums = []
    while N > 0:
        nums = [N % 10] + nums
        N //= 10

    # 上位の桁から見ていって最初に D に含まれる数字を探す。
    convert_idx = -1
    for i, n in enumerate(nums):
        if n not in D:
            # 変換の必要がない
            continue

        convert_idx = i
        break
    # print(convert_idx)
    for i in range(convert_idx, -1, -1):
        n = nums[i]
        if n > 9:
            n %= 10
            if i > 0:
                nums[i - 1] += 1
            else:
                nums = [min_not_d_and_not_zero] + nums

        for d in range(n, 10):
            # 変換先が n 以上 9 以下
            if d in D:
                # NG
                continue

            nums[i] = d
            break
        else:
            # 変換先が n 未満
            for d in range(n, 10):
                if d in D:
                    # NG
                    continue

                nums[i] = d

            # 上位の桁に繰り上がりを伝搬
            if i > 0:
                nums[i - 1] += 1
            else:
                nums = [min_not_d_and_not_zero] + nums

    # 残りの桁は D に含まれない最小の値に変換する。
    nums = [min_not_d if n in D else n for n in nums]

    ret = 0
    digit = 1
    # print(nums)
    for n in reversed(nums):
        ret += n * digit
        digit *= 10

    return ret


if __name__ == "__main__":
    N, K = map(int, input().split())
    D = [int(s) for s in input().split()]
    ans = irohas_obsession(N, K, D)
    print(ans)
print(str(input(N))[::2])

### FIXED CODE ###

print(str(input())[::2])
n = int(input())
d = sorted(list(map(int,input().split())))

print(d[2//n+2]-d[2//n+1])




### FIXED CODE ###

n = int(input())
d = sorted(list(map(int,input().split())))

print(d[n//2]-d[n//2-1])
n=int(input())
li=[int(input()) for i in range(n)]
li_set=list(set(li))        #重複したものを一つにまとめる
print(len(li_s))

### FIXED CODE ###

n=int(input())
li=[int(input()) for i in range(n)]
li_set=list(set(li))        #重複したものを一つにまとめる
print(len(li_set))
a,b,c = map(int,input().split())
L = [a,b,c]
M = L.sorted()
print(int(str(M[2])+str(M[1]))+int(M[0]))

### FIXED CODE ###

a,b,c = (map(int,input().split()))
L = [a,b,c]
M = L.sort()

print(L[-1]*10 + L[0] + L[1])
N,M = [ int(it) for it in input().split() ]
li = [ [ int(it) for it in input().split() ] for i in range(M) ]
li = [ (a-1,b-1,c) for a,b,c in li ]

dw = [ [] for i in range(N) ]


for a,b,c in li:
  dw[a].append( (b,c) )

NOT = 1e+10 -1 
  
cost = [NOT]*N
cost[0]=0
cosli = []
for i in range(1000):
  chk = [0]*N
  now = 0
  pop=[now]
  for i in range(N):
    now = pop.pop()
    chk[now]=1
    for b,c in dw[now]:
      if ( cost[b] == NOT ):
        cost[b] = cost[now] + c
      else:
        cost[b] = max(cost[now] + c,cost[b])
      if (chk[b]==0):
        pop.append(b)
  cosli.append( cost[N-1] )  

if ( cosli[-1] != cosli[-2] ):
  print ("inf")
else:
  print (cosli[-1])

### FIXED CODE ###

N,M = [ int(it) for it in input().split() ]
li = [ [ int(it) for it in input().split() ] for i in range(M) ]
li = [ (a-1,b-1,c) for a,b,c in li ]

dw = [ [] for i in range(N) ]


for a,b,c in li:
  dw[a].append( (b,c) )

NOT = 1e+16 -1 
  
cost = [NOT]*N
cost[0]=0
cosli = []
for i in range(1000):
  chk = [0]*N
  now = 0
  pop=[now]
  for i in range(N):
    if (len(pop)==0):
      break
    now = pop.pop()
    chk[now]=1
    for b,c in dw[now]:
      if ( cost[b] == NOT ):
        cost[b] = cost[now] + c
      else:
        cost[b] = max(cost[now] + c,cost[b])
      if (chk[b]==0):
        pop.append(b)
  cosli.append( cost[N-1] )  

if ( cosli[-1] != cosli[-2] ):
  print ("inf")
else:
  print (cosli[-1])
N,X = map(int, input().split())
L = [x for x in map(int, input().split())]
accumL = [sum(L[:x]) <= X for x in range(len(L)+1)]
if accumL[-1] == True:
  print(N + 1)
else:
  print(accumL.index(False))

### FIXED CODE ###

X,A = map(int, input().split())
if X < A:
  print(0)
else:
  print(10)
a = input()
b = input()

print(int(a) * int(b))
print((sum(int(a),int(b)) * 2)

### FIXED CODE ###

[a, b] = [int(x) for x in input().split()]
print(a * b ,(a + b) * 2)
N, K = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]

dp = [0] * N
for i in range(1, N):
    L = []
    for j in range(max(0, i-K), i):　
        L.append(dp[j] + abs(H[i] - H[j]))
    dp[i] = min(L)

print(dp[-1])

### FIXED CODE ###

def func():
    N, K = [int(i) for i in input().split()]
    H = [int(i) for i in input().split()]
    
    dp = [0]*N
    for i in range(1, N):
        L = []
        for j in range(max(0, i-K), i):
            L.append(dp[j] + abs(H[i] - H[j]))
        dp[i] = min(L)

    print(dp[-1])
    
if __name__=="__main__":
    func()
import sys
import math
import numpy as np
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    s = L()
    cnt = 0
    def f(x):
        tgt = [x[0],x[1],x[2]]
        now = 0
        global n
        for i in range(n):
            if s[i] == tgt[now]:now += 1
            if now == 3:return True
        return False
    for i in range(1000):
        if len(str(i)) == 1:
            t = "00"+str(i)
        elif len(str(i)) == 2:
            t = "0"+str(i)
        else:t = str(i)
        if f(t):cnt += 1
    print(cnt)

### FIXED CODE ###

if __name__ == "__main__":
    n = int(input())
    s = list(input())
    cnt = 0
    def f(x):
        tgt = [x[0],x[1],x[2]]
        now = 0
        global n
        for i in range(n):
            if s[i] == tgt[now]:now += 1
            if now == 3:return True
        return False
    for i in range(1000):
        if len(str(i)) == 1:
            t = "00"+str(i)
        elif len(str(i)) == 2:
            t = "0"+str(i)
        else:t = str(i)
        if f(t):cnt += 1
    print(cnt)
n=int(input())
a=list(map(int,input().split()))
ans=0

plus=[0]*1000000
minus=[0]*1000000

for i in range(n):
  ene=i+1
  pin=a[i]
  pl,mi=ene+pin,ene-pin
  plus[pl]+=1
  minus[mi]+=1
  
for i in range(1000000):
  ans+=plus[i]*minus[i]
  

print(ans)


### FIXED CODE ###

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

plus=[0]*1000000
minus=[0]*1000000

for i in range(n):
  ene=i+1
  pin=a[i]
  pl,mi=ene+pin,ene-pin
  if 0<=pl<1000000:
    plus[pl]+=1
  if 0<=mi<1000000:
    minus[mi]+=1
  
for i in range(1000000):
  ans+=plus[i]*minus[i]
  

print(ans)