Harryxun/stf_run huggingface dataset:
K  = int(input())
n = 0
n1 = 0
n2 = 0
n3 = 0
n4 = 0
n5 = 0


#Kが500以下の場合、斜め作戦にする
if K <= 500:
   n = K
   mat = [[0 for n1 in range(K)] for n2 in range(K)]
   for n1 in range(K):
      for n2 in range(K-n1):
         mat[n1][n1+n2] = n2+1
   for n1 in range(K):
      for n2 in range(n1):
         mat[n1][n2] = K+n2-n1+1

#Kが500以上の場合、斜めに1マスずつしのびこませる   
else:
   n = 500
   mat = [[0 for n1 in range(500)] for n2 in range(500)]
   for n1 in range(500):
      for n2 in range(500-n1):
         mat[n1][n1+n2] = n2+1
   for n1 in range(500):
      for n2 in range(n1):
         mat[n1][n2] = 500+n2-n1+1










#行列の出力かんがえとく 
print(n)

if K <= 500:
out = ""
for n1 in range(K):
   out = ""   
   for n2 in range(K):
      out = out + " " + str(mat[n1][n2])
   print(out)
#Kが500以上の場合、斜めに1マスずつしのびこませる   
else:
out = ""
for n1 in range(500):
   out = ""   
   for n2 in range(500):
      out = out + " " + str(mat[n1][n2])
   print(out)





### FIXED CODE ###

K  = int(input())
n = 0
n1 = 0
n2 = 0
n3 = 0
n4 = 0
n5 = 0


#Kが500以下の場合、斜め作戦にする
if K <= 499:
   n = K
   mat = [[0 for n1 in range(K)] for n2 in range(K)]
   for n1 in range(K):
      for n2 in range(K-n1):
         mat[n1][n1+n2] = n2+1
   for n1 in range(K):
      for n2 in range(n1):
         mat[n1][n2] = K+n2-n1+1

#Kが500以上の場合、斜めに1マスずつしのびこませる   
else:
   n = 500
   mat = [[0 for n1 in range(500)] for n2 in range(500)]
   for n1 in range(500):
      for n2 in range(500-n1):
         mat[n1][n1+n2] = n2+1
   for n1 in range(500):
      for n2 in range(n1):
         mat[n1][n2] = 500+n2-n1+1

   #Kが500以上の場合のギザギザ部分
   for n2 in range(K-500):
      for n1 in range(250):
          kari = n1*2+n2
          if kari >= 500:
             kari = kari-500
          mat[n1*2][kari] = n2+501


#行列の出力かんがえとく 
print(n)

if K <= 500:
   out = ""
   for n1 in range(K):
      out = ""   
      for n2 in range(K):
         out = out + " " + str(mat[n1][n2])
      print(out)
   
#Kが500以上の場合、斜めに1マスずつしのびこませる   
else:
   out = ""
   for n1 in range(500):
       out = ""   
       for n2 in range(500):
          out = out + " " + str(mat[n1][n2])
       print(out)
int(input())
h=list(map(int,input().split()))
inf=float("inf")
dp=[(inf) for i in range(n)]
dp[0]=0

for i in range(1,n):
    if i==1:
        dp[i]=dp[i-1]+abs(h[i]-h[i-1])
    else:
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
inf=float("inf")
dp=[(inf) for i in range(n)]
dp[0]=0

for i in range(1,n):
    if i==1:
        dp[i]=dp[i-1]+abs(h[i]-h[i-1])
    else:
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])
num_problems = int(input())
a = input()
seconds_per = a.split()
for i in seconds_per:
  total += int(i)
drinks = int(input())
for i in range(drinks):
  b = input()
  c = b.split()
  question = int(c[0])
  change = int(c[1])
  new = total-int(seconds_per[question-1]) + change
  print(new)


  

### FIXED CODE ###

num_problems = input()
a = input()
total = 0
seconds_per = a.split()
for i in seconds_per:
  total += int(i)
drinks = int(input())
for i in range(drinks):
  b = input()
  c = b.split()
  question = int(c[0])
  change = int(c[1])
  new = total-int(seconds_per[question-1]) + change
  print(new)
n = int(input())
l = list(map(int,input().split()))

for i in range(n):
    l[i] = l[i] - i-1
print(sorted(l))
if n % 2 == 1:
    print(sum(list(map(lambda x: x-l[((n//2)+1)],l))))
else:
    print(max(sum(list(map(lambda x: x-l[(n//2)],l))),sum(list(map(lambda x: x-l[((n//2)+1)],l)))))


### FIXED CODE ###

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

for i in range(n):
    l[i] = l[i] - i-1
l.sort()
if n % 2 == 1:
    print(sum(list(map(lambda x: abs(x-l[((n//2))]),l))))
else:
    print(min(sum(list(map(lambda x: abs(x-l[(n//2)-1]),l))),sum(list(map(lambda x: abs(x-l[(n//2)]),l)))))
#B
from functools import reduce

n = int(input())
a = list(map(int,input().split()))
flg = True
MAX = 10 ** 18
cnt = 1
a.sort()
result = reduce(lambda ans, x:ans * x, a)
if result > MAX:
    flg = False
    break
        
if flg:
    print(result)
else:
    print(-1)

### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
    
main()
a, b, c = int(input().split)
if a == c : print(b)
elif a == b : print(c)
else : print(a)


### FIXED CODE ###

a, b, c = input().split()
if a == c : print(b)
elif a == b : print(c)
else : print(a)
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from queue import Queue


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


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


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


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
	n = INT()
	a = LIST()
	p = 0
	q = 0
	l = []
	temp = 0

	if a[0] < a[1]:
		sign = 1
	elif a[0] > a[1]:
		sign = -1
	else:
		sign = 0

	for i in range(n-1):
		if a[i] < a[i+1] and sign == -1:
			p += 1
			sign = 1
			# print("a")
			if temp == 0:
				q += 1
				temp = 1

		elif a[i] > a[i+1] and sign == 1:
			q += 1
			sign = -1
			# print("b")
			if temp == 0:
				p += 1
				temp = 1


	# print(p, q)
	print(max(p, q) + 1)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from queue import Queue


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


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


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


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    n = INT()
    a = LIST()

    ans = 0

    if n == 1:
        print(1)
        exit()

    if a[0] < a[1]:
        sign = 1
    elif a[0] > a[1]:
        sign = -1
    else:
        sign = 0

    for i in range(n-1):
        if a[i] < a[i+1] and sign == -1:
            ans += 1
            sign = 0

        elif a[i] > a[i+1] and sign == 1:
            ans += 1
            sign = 0

        elif sign == 0:
            if a[i] < a[i+1]:
                sign = 1
            elif a[i] > a[i+1]:
                sign = -1

    print(ans + 1)


if __name__ == '__main__':
    main()
n,m,x=map(int,input().split())
a=[0]*(n+1)
for i in input().split(): a[int(i)]=1
print(min(sum(a[x:n]),sum(a[0:x]))

### FIXED CODE ###

n,m,x=map(int,input().split())
a=[0]*(n+1)
for i in input().split(): a[int(i)]=1
print(min(sum(a[x:n]),sum(a[0:x])))
while True:
   h,w = map(int, raw_input().split())
   if h == w == 0:
       break
   ret += '#'*w+'\n'
   ret += ('#' + '.' * (w-2) + '#\n') * (h - 2)
   ret += '#'*w+'\n\n'
print ret,

### FIXED CODE ###

while True:
   h,w = map(int, raw_input().split())
   if h == w == 0:
       break
   ret = '#'*w+'\n'
   ret += ('#' + '.' * (w-2) + '#\n') * (h - 2)
   ret += '#'*w+'\n\n'
   print ret,
W, H, x, y, r = map(int, input().split())

if x - r >= 0 and x + r <= W and y - r >= 0 and y + r <= H:
    print("Yes")
else:
    print("No")

### FIXED CODE ###


W, H, x, y, r = map(int, input().split())


if x - r >= 0 and x + r <= W and y - r >= 0 and y + r <= H:
    print("Yes")
else:
    print("No")
str = input()
flg=0
for n in range(0,len(str)-2):
  if(str[n]==str[n+1]):
    print(n+1,n+2)
    flg =1
    break
  elif (str[n]==str[n+2]):
    print(n+1,n+3)
    flg=1
    break
if flg =0:
  print(-1,-1)

### FIXED CODE ###

str = input()
flg=0
for n in range(0,len(str)-2):
  if(str[n]==str[n+1]):
    print(n+1,n+2)
    flg =1
    break
  elif (str[n]==str[n+2]):
    print(n+1,n+3)
    flg=1
    break
if flg ==0:
  if str[len(str)-2]== str[len(str)-1]:
    print(len(str)-1,len(str))
  else:
    print(-1,-1)
# coding: utf-8
# Here your code



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

result_1 = 0
before_sum =a[0]
after_sum =a[0]

for i in range(1,N):
    before_sum = after_sum
    after_sum = before_sum + a[i]
    if before_sum * after_sum > 0:
        if after_sum < 0:
            result_1 += 1 - after_sum
            after_sum = 1
        elif after_sum > 0:
            result_1 += 1 + after_sum
            after_sum = -1
    elif before_sum * after_sum == 0:
        result_1 += 1
        if before_sum < 0:
            after_sum = 1
        else:
            after_sum = -1

before_sum =int(-a[0]/abs(a[0]))
after_sum =before_sum
result_2 = 1 + abs(before_sum)


for i in range(1,N):
    before_sum = after_sum
    after_sum = before_sum + a[i]
    if before_sum * after_sum > 0:
        if after_sum < 0:
            result_2 += 1 - after_sum
            after_sum = 1
        elif after_sum > 0:
            result_2 += 1 + after_sum
            after_sum = -1
    elif before_sum * after_sum == 0:
        result_2 += 1
        if before_sum < 0:
            after_sum = 1
        else:
            after_sum = -1

print(min(result_1,result_2-1))


### FIXED CODE ###

# coding: utf-8
# Here your code

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

result_1 = 0
before_sum = a[0]

if a[0] <= 0:
    before_sum = 1
    result_1 += 1 + abs(a[0])

after_sum = before_sum

for i in range(1,N):
    before_sum = after_sum
    after_sum = before_sum + a[i]
    if i % 2 == 0:
        if after_sum <= 0:
            result_1 += 1 + abs(after_sum)
            after_sum = 1
    else:
        if after_sum >= 0:
            result_1 += 1 + abs(after_sum)
            after_sum = -1

result_2 = 0
before_sum = a[0]

if a[0] >= 0:
    before_sum = -1
    result_2 += 1 + abs(a[0])

after_sum = before_sum

for i in range(1,N):
    before_sum = after_sum
    after_sum = before_sum + a[i]
    if i % 2 == 1:
        if after_sum <= 0:
            result_2 += 1 + abs(after_sum)
            after_sum = 1
    else:
        if after_sum >= 0:
            result_2 += 1 + abs(after_sum)
            after_sum = -1

print(min(result_1,result_2))
x, a, b = map(int, input().split)
if a >= b:
    print('delicious')
elif x + a < b:
    print('dangerous')
else:
    print('safe')

### FIXED CODE ###

x, a, b = map(int, input().split())
if a >= b:
    print('delicious')
elif x + a < b:
    print('dangerous')
else:
    print('safe')
n , k = map(int, input().split())
print(n//(k-1))

### FIXED CODE ###

n = int(input())
l = list(str(n))
s = 0
for i in l:
    s += int(i)
if n>=s and n%s == 0:
    print('Yes')
else:
    print('No')
k, x, y, n = map(int, input().split())

if n <= k:
    print(n * x)
else:
    print(k*x+(n-k)*y)
# 演算子の左右に空白を入れる！

### FIXED CODE ###

N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if N <= K:
    print(N * X)
else:
    print(K * X + (N - K) * Y)
#爆弾を置く行；対象が最多の行
#爆弾を置く列；最多の行を除いたグリッドで、対象が最多の列
#答え；まず行方向に爆破し、残ったグリッドで列方向に爆破して合算する

#import statistics
H, W, M = map(int, input().split())#行数H、列数W、爆弾数M
lh = []#対象物の行座標リスト
lw = []#対象物の列座標リスト＿
lw2 = []#列座標リストから爆破済みの対象物の列座標を除いたリスト
ans = 0#爆破数
#対象物の座標を行と列で分けてリスト化
for i in range(M):
    bh, bw = map(int, input().split())
    lh.append(bh - 1)#行方向
    lw.append(bw - 1)#列方向

#最頻値が複数の場合、以下の式だとエラーになる
#hmode = statistics.mode(lh)#対象物が最多の行
hmode = max(lh, key = lh.count)#対象物が最多の行
ans += lh.count(hmode)#行方向の爆破最大数

#爆破済みの対象物を除いた新しい列座標リストを作る
for i in range(M):
    if lh[i] != hmode:
        lw2.append(lw[i])
wmode = max(lw2, key = lw2.count)
ans += lw2.count(wmode)#列方向の爆破最大数

print(ans)


### FIXED CODE ###


import sys
from collections import Counter

H, W, M = map(int, sys.stdin.readline().rstrip().split())#行数H、列数W、爆弾数M
hcnt = [0] * H#何行目に何個あるか
wcnt = [0] * W#何列目に何個あるか
bomb = []

for i in range(M):
    bh,bw=map(int,sys.stdin.readline().rstrip().split())
    hcnt[bh - 1] += 1#行方向
    wcnt[bw - 1] += 1#列方向
    bomb.append((bh - 1,bw - 1))
#hcnt [2,1]
#wcnt[1,1,1]
#bomb[[1,1],[0,0],[0,2]]
hmax = max(hcnt)#2
wmax = max(wcnt)#1

crs = 0#hmax and wmax crosspoint
for (i, j) in bomb:
    if hcnt[i] == hmax and wcnt[j] == wmax:
        crs += 1
#all crosspoint has bomb
if crs == Counter(hcnt)[hmax] * Counter(wcnt)[wmax]:
    print(hmax + wmax - 1)
#more than one crosspoint has no bomb
else:
    print(hmax + wmax)
repeat =int(input())
numbers =input().rstrip().split(" ")
#print(numbers)
sum =0
for i in range(repeat):
  sum =sum +1/int(numbers[i])
#print(sum)
answer =1/sum
print(answer)

### FIXED CODE ###

index = int(input())
message =input()
if index>=3200:
  print(message)
else:
  print("red")
def hoge(n):
    if n == 1:
        return 1
    else:
        return n * hoge(n-1)

n = int(input())
s = [sorted(input()) for i in range(n)]

count = 0
c = 0
t = []
for i in range(n - 1):
    if i not in t:
        for j in range(n - i - 2):
            if s[i] == s[j]:
                c += 1
                t.append(j)
        count += hoge(c + 1) // 2
        c = 0
    
print(count)

### FIXED CODE ###

n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]

ans, d = 0, {}
for i in range(n):
    if s[i] in d.keys():
        ans += d[s[i]]
        d[s[i]] = d[s[i]] + 1
    else:
        d[s[i]] = 1
print(ans)
import sys
sys.setrecursionlimit(2147483647)


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

import math
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] //math.gcd(ans, a[i])

cnt=0
i=1
tmp=ans
while 1:
    #print(tmp)
    if tmp%2==0 and (tmp//2)%2==1:
        if (tmp//2)%2<=m:
            cnt+=1
        else:
            break
    
    if tmp//2>m:
        break
    i+=1
    tmp=ans*i

print(cnt)






### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

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

cnt=1
while (a[0]%(2**cnt))==0:
    cnt+=1

cnt-=1
for item in a[1:]:
    if item%(2**cnt)!=0:
        print(0)
        exit()
    if (item//(2**cnt))%2==0:
        print(0)
        exit()


import fractions
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] //fractions.gcd(ans, a[i])

if ans%2==1:
    print(0)
    exit()

if ans//2>m:
    print(0)
    exit()

ans=ans//2

print((((m//ans)*(-1))//2)*(-1))
from collections import defaultdict
import itertools
d = defaultdict(int)
x='MARCH'
for i in range(5):
  d[x[i]]=i+1
x=[0]*5
def sub(a,b):
  return abs(a[0]-b[0])+abs(a[1]-b[1])

H,W,D=map(int,input().split())
A=[list(map(int,input().split())) for i in range(H)]
N=H*W
P=[0]*(N)
for h in range(H):
  for w in range(W):
    P[A[h][w]-1]=(h,w)

X=[]
for d in range(D):
  p=P[(d+D)%(D+1)::D]
  n=len(p)
  _=[sub(p[(i+1)%n],p[i]) for i in range(n)]
  X.append(_)
Q=int(input())
for q in range(Q):
  l,r=map(int,input().split())
  if l>r:
    r+=N
  g=l%D
  ans=0
  for i in range(l,r,D):
    ans+=X[g][(i%N)//D]
  print(ans)

### FIXED CODE ###

from collections import defaultdict
import itertools
d = defaultdict(int)
x='MARCH'
for i in range(5):
  d[x[i]]=i+1
x=[0]*5
def sub(a,b):
  return abs(a[0]-b[0])+abs(a[1]-b[1])

H,W,D=map(int,input().split())
A=[list(map(int,input().split())) for i in range(H)]
N=H*W
P=[0]*(N)
for h in range(H):
  for w in range(W):
    P[A[h][w]-1]=(h,w)
X=[]
for d in range(D):
  _=[0]+[sub(P[i%N],P[i-D]) for i in range(d+D,N+D,D)]
  cumsum = list(itertools.accumulate(_))
  X.append(cumsum)

Q=int(input())
for q in range(Q):
  l,r=map(int,input().split())
  l,r=l-1,r-1
  g=l%D
  if l>r:
    r+=N
    ans=X[g][-1]-X[g][l//D]
    ans+=X[g][r//D]-X[g][0]
  else:
    ans=X[g][r//D]-X[g][l//D]
  
  print(ans)
import numpy as np
ans=10**9
a=np.array([0,0,0])
b=np.array([0,0,0])
c=np.array([0,0,0])
s=[]
t=[]
N,C=map(int,input().split())
for i in range(C):
    s.append(list(map(int,input().split())))
for i in range(N):
    t.append(list(map(int,input().split())))
for j in range(N):
    for i in range(N):
        if (i+j)%3==0:
            a+=np.array(s[t[i][j]-1])
        elif (i+j)%3==1:
            b+=np.array(s[t[i][j]-1])
        else:
            c+=np.array(s[t[i][j]-1])
from itertools import permutations
for i,j,k in list(permutations([0,1,2])):
    p=a[i]+b[j]+c[k]
    ans=min(ans,p)
print(ans)    

            
    

### FIXED CODE ###

import numpy as np
N,C=map(int,input().split())
ans=10**9
a=np.array([0]*C)
b=np.array([0]*C)
c=np.array([0]*C)
s=[]
t=[]
for i in range(C):
    s.append(list(map(int,input().split())))
for i in range(N):
    t.append(list(map(int,input().split())))
for j in range(N):
    for i in range(N):
        if (i+j)%3==0:
            a+=np.array(s[t[i][j]-1])
        elif (i+j)%3==1:
            b+=np.array(s[t[i][j]-1])
        else:
            c+=np.array(s[t[i][j]-1])
from itertools import permutations
for i,j,k in permutations(range(C),3):
    p=a[i]+b[j]+c[k]
    ans=min(p,ans)
print(ans)
n,r = map(int,input().split())

if n >=10:
  print(r)
else:
  print(r+100*(10−n))

### FIXED CODE ###

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

if n >=10:
  print(r)
else:
  print(r+100*(10-n))
N,M = map(int,input())
A = [input() for _ in range(N)]
B = [input() for _ in range(N)]
ans = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    for k in range(i,i+M):
      for l in range(j,j+M):
        if A[k][l] != B[k][l]:
          break
        if A[k][l] == B[k][l] and k == i+M-1 and l == j+M-1:
          ans = 1
    else:
      continue
    break
if ans == 0:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

N,M = map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
ans = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    for k in range(i,i+M):
      for l in range(j,j+M):
        if A[k][l] != B[k-i][l-j]:
          break
        if A[k][l] == B[k-i][l-j] and k == i+M-1 and l == j+M-1:
          ans = 1
      else:
        continue
      break

if ans == 0:
  print("No")
else:
  print("Yes")
n = int(input())
T = [[] for _ in range(n)]
for _ in range(n-1):
    u,v,w = map(int,input().split())
    u -= 1
    v -= 1
    w %= 2
    T[u].append((v,w))
    T[v].append((u,w))

ans = [0]*n
def dfs(u,p=-1,c=0):
    for v,w in T[u]:
        if v == p: continue
        if w: c = (c+1)%2
        ans[v] = c
        dfs(v,u,c)
dfs(0)

print("\n".join(map(str,ans)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
n = int(input())
T = [[] for _ in range(n)]
for _ in range(n-1):
    u,v,w = map(int,input().split())
    u -= 1
    v -= 1
    w %= 2
    T[u].append((v,w))
    T[v].append((u,w))

ans = [0]*n
def dfs(u,p=-1,c=0):
    for v,w in T[u]:
        if v == p: continue
        nc = (c+1)%2 if w else c 
        ans[v] = nc
        dfs(v,u,nc)
dfs(0)

print("\n".join(map(str,ans)))
import sys

def jump(k: int, h, res):
    if ( k == 0 ):
        return 0

    if ( res[k] == -1 ):
        res[k] = jump(k - 1, h, res) + abs(h[k] - h[k - 1])
        if k >= 2:
            res[k] = min(res[k], jump(k - 2, h, res) + abs(h[k] - h[k - 2]))

    return res[k]

def main():
    lines = []
    for line in sys.stdin:
        lines.append([int(i) for i in line.strip().split(' ')])

    n = int(lines[0][0])
    h = lines[1]
    res = [ -1 for i in range(n)]
    print(jump(n-1, h, res))


if __name__ == '__main__':
    main()

### FIXED CODE ###

def calc_cost(h):
    if (len(h) == 0):
        return 0

    cost = [None] * len(h)
    cost[0] = 0
    for i in range(1, len(h)):
        cost[i] = cost[i-1] + abs(h[i] - h[i-1])
        if i>1:
            cost[i] = min(cost[i], cost[i-2] + abs(h[i] - h[i-2]))

    return cost[len(h)-1]

if __name__ == "__main__":
    n = int(input())
    h = list(map(int, input().split(" ")))
    res = calc_cost(h)
    print(res)
while True:
    count = 0
    num = [int(i) for i in input().split("")]
    if num[0] == 0:
        break
    for n in num:
        count += n
    print(count)
     

### FIXED CODE ###

while True:
    x = input()
    if x == "0":
        break
    num = [int(i) for i in x]
    print(sum(num))
h, w = map(int, input().split())
s = [['.']*(w+2)] + [['.']+list(input())+['.'] for _ in range(w)] + [['.']*(w+2)]
for i in range(1, w+1):
    for j in range(1, w+1):
        if s[i][j] == '.': continue
        if s[i-1][j] == '.' and s[i][j-1] == '.' and s[i][j+1] == '.' and s[i+1][j] == '.':
            print('No')
            exit()
print('Yes')

### FIXED CODE ###

H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
 
flag = False
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            if (j-1 >= 0 and s[i][j-1] == '.') and (j+1 < W and s[i][j+1] == '.') and (i-1 >= 0 and s[i-1][j] == '.') and (i+1 < H and s[i+1][j] == '.'):
                print('No')
                flag = True
                break
    if flag:
        break
else:
    print('Yes')
a,b = map(int,input().split())
if a//k != b//k:
    print("OK")
else:
    print("NG")

### FIXED CODE ###

k = int(input())
a,b = map(int,input().split())
if a//k != b//k:
    print("OK")
elif a%k == 0:
    print("OK")
else:
    print("NG")
def get_new_lucas(l_i_1, l_i_2):
    """
    get a new Lucas number L_i

    l_i_1: L_(i-1),
    l_i_2: L_(i-2)
    """
    return l_i_1 + l_i_2


def main():
    n = int(input())
    tmp_l_i_1 = 1
    tmp_l_i_2 = 2
    for i in range(1, n):
        if i == 1:
            new_lucas_num = get_new_lucas(tmp_l_i_1, tmp_l_i_2)
        else:
            new_lucas_num = get_new_lucas(tmp_l_i_1, tmp_l_i_2)
        tmp_l_i_2 = tmp_l_i_1
        tmp_l_i_1 = new_lucas_num
        
    print(new_lucas_num)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def get_new_lucas(l_i_1, l_i_2):
    """
    get a new Lucas number L_i

    l_i_1: L_(i-1),
    l_i_2: L_(i-2)
    """
    return l_i_1 + l_i_2


def main():
    n = int(input())
    tmp_l_i_1 = 1
    tmp_l_i_2 = 2
    for i in range(n):
        if i == 0:
            new_lucas_num = 1
        if i >= 1:
            new_lucas_num = get_new_lucas(tmp_l_i_1, tmp_l_i_2)
            tmp_l_i_2 = tmp_l_i_1
            tmp_l_i_1 = new_lucas_num
        
    print(new_lucas_num)


if __name__ == '__main__':
    main()
N,M = map(int,input().split())
X = list(map(int,input().split()))
x = []
count = 0
ans = 0
X.sort()
if N >= M:
  print(0)
for i in range(M-1):
  x.append(abs(X[i]-X[i+1]))
xx = sorted(x,reverse=True)
for j in range(N//2):
  xx.pop(j)
ans = xx[-1] - xx[0]
print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
X = list(map(int,input().split()))
x = []
ans = 0
X.sort()
if N >= M:
  print(0)
  exit()
for i in range(M-1):
  x.append(abs(X[i]-X[i+1]))
xx = sorted(x,reverse=True)
for j in range(N-1):
  xx[j] = 0
ans = sum(xx)
print(ans)
N = int(input())
arr = map(int, input().split())
for i in range(n//2, 0, -1): # n // 2 より大きい場合はarrの値そのままでよい。
  arr[i] = sum(arr[i::i]) % 2 # それ以外はパリティをあわせる。
  ans = [i for i, j in enumerate(arr) if j == 1]
print(len(ans))
print(*ans)

### FIXED CODE ###

def main():
    n = int(input())
    A = [0] + list(map(int, input().rstrip().split()))
    for i in range(n // 2, 0, -1):  # second half: no multiples
        A[i] = sum(A[i::i]) % 2
    ans = [i for i, j in enumerate(A) if j]
    print(len(ans))  # all cells: [1] -> len() (much faster than sum())
    print(*ans)


if __name__ == "__main__":
    main()