jiahuimbzuai/CoQuIR huggingface dataset:
//  [rust]
#![allow(non_snake_case)]
use proconio::{input, fastout};
use proconio::marker::Usize1;

#[fastout]
fn main() {
    input!{
        R:usize, C:usize, K:usize,
        mut items: [(Usize1, Usize1, i64); K] 
    }
    items.sort();
    items.push((R, C, 0));
    let mut idx = 0;
    let mut prv = vec![vec![0i64; 4]; C];
    let mut nxt = vec![vec![0i64; 4]; C];
    let mut v: i64 = 0;
    let mut f: bool;
    for i in 0..R {
        for j in 0..C {
            f = false;
            let &t = prv[j].iter().max().unwrap();
            if items[idx].0 == i && items[idx].1 == j {
                f = true;
                v = items[idx].2;
                idx += 1;
                // println!("{} {} {}", i, j, v);
            }
            for k in 0..4{
                nxt[j][k] = t;
                if j > 0 && nxt[j][k] < nxt[j-1][k] {
                    nxt[j][k] = nxt[j-1][k];
                }
                if f && k > 0{
                    if nxt[j][k] < t + v {
                        nxt[j][k] = t + v;
                    }
                    let p = if j > 0 {nxt[j-1][k-1]} else {0};
                    if nxt[j][k] < p + v {
                        nxt[j][k] = p + v;
                    } 
                }
            }
        }
        std::mem::swap(&mut prv, &mut nxt);
        // println!("{:?}", prv)
    }
    println!("{}", prv[C-1].iter().max().unwrap())
}
//  [swift]
#if os(Linux)
import Glibc
#else
import Darwin.C
#endif

let INPUT = stdin

var buffer: UnsafeMutablePointer<CChar>?
var bufferCapacity: Int32 = 0

func getsToBuffer(size: Int32) -> UnsafeMutablePointer<CChar> {
    if bufferCapacity < size {
        buffer?.deallocate()
        buffer = UnsafeMutablePointer.allocate(capacity: Int(size))
        bufferCapacity = size
    }
    return fgets(buffer!, size, INPUT)
}
func getIntFromBuffer(_ ptr: inout UnsafeMutablePointer<CChar>) -> Int {
    var minus = false
    var x: Int?
    while true {
        switch ptr.pointee {
        case 0x2D:
            assert(!minus && x == nil)
            minus = true
        case let d where (0x30...0x39).contains(d):
            x = (x ?? 0)*10 + Int(d)-0x30
        default:
            if x != nil { return minus ? -x! : x! }
        }
        ptr += 1
    }
}
func getInt() -> Int {
    var xPtr = getsToBuffer(size: 24)
    return getIntFromBuffer(&xPtr)
}
func getIntPair() -> (Int, Int) {
    var xPtr = getsToBuffer(size: 2*24)
    let x1 = getIntFromBuffer(&xPtr)
    let x2 = getIntFromBuffer(&xPtr)
    return (x1, x2)
}
func getIntTriplet() -> (Int, Int, Int) {
    var xPtr = getsToBuffer(size: 2*24)
    let x1 = getIntFromBuffer(&xPtr)
    let x2 = getIntFromBuffer(&xPtr)
    let x3 = getIntFromBuffer(&xPtr)
    return (x1, x2, x3)
}
func getInts(count: Int) -> [Int] {
    var xPtr = getsToBuffer(size: Int32(count) * 24)
    var a = [Int]()
    a.reserveCapacity(count)
    for _ in 0..<count { a.append(getIntFromBuffer(&xPtr)) }
    return a
}

//=============================================================================

struct Table {
    private var data: [Int]
    private let d1, d2, d3: Int
    private let s1, s2: Int
    init(_ d1: Int, _ d2: Int, _ d3: Int) {
        self.d1 = d1
        self.d2 = d2
        self.d3 = d3
        s1 = d2 * d3
        s2 = d3
        data = [Int](repeating: 0, count: d1*d2*d3)
    }
    subscript(i: Int, j: Int, k: Int) -> Int {
        get { data[i*s1 + j*s2 + k] }
        set { data[i*s1 + j*s2 + k] = newValue }
    }
}

let (R, C, K) = getIntTriplet()
var items = Table(R+1, C+1, 1)
for _ in 0..<K {
    let (r, c, v) = getIntTriplet()
    items[r, c, 0] = v
}

var dp = Table(R+1, C+1, 4)

for i in 1...R {
    for j in 1...C {
        let item = items[i, j, 0]
        let maxUp = max(dp[i-1, j, 0], dp[i-1, j, 1], dp[i-1, j, 2], dp[i-1, j, 3])
        dp[i, j, 0] = maxUp
        dp[i, j, 1] = maxUp + item
        for k in 0...3 { dp[i, j, k] = max(dp[i, j, k], dp[i, j-1, k]) }
        for k in 1...3 { dp[i, j, k] = max(dp[i, j, k], dp[i, j-1, k-1] + item)}
    }
}

print(max(dp[R, C, 0], dp[R, C, 1], dp[R, C, 2], dp[R, C, 3]))
//  [swift]
struct Scanner {
    private var elements = [String]()
    private var index = 0

    mutating func peek() -> String {
        while elements.count == index {
            elements = readLine()!.split(separator: " ").map(String.init)
            index = 0
        }
        return elements[index]
    }

    mutating func next() -> String {
        let value = peek()
        index += 1
        return value
    }

    mutating func nextInt() -> Int {
        return Int(next())!
    }

    mutating func nextDouble() -> Double {
        return Double(next())!
    }
}

var scanner = Scanner()
let R = scanner.nextInt()
let C = scanner.nextInt()
let K = scanner.nextInt()

struct Array2D<Element> {
    let n1: Int
    let n2: Int
    private var elements: [Element]

    init(repeating: Element, _ n1: Int, _ n2: Int) {
        self.n1 = n1
        self.n2 = n2
        self.elements = [Element](repeating: repeating, count: n1 * n2)
    }

    subscript(i: Int, j: Int) -> Element {
        get {
            elements[i * n2 + j]
        }
        set {
            elements[i * n2 + j] = newValue
        }
    }
}

struct Array3D<Element> {
    let n1: Int
    let n2: Int
    let n3: Int
    private var elements: [Element]

    init(repeating: Element, _ n1: Int, _ n2: Int, _ n3: Int) {
        self.n1 = n1
        self.n2 = n2
        self.n3 = n3
        self.elements = [Element](repeating: repeating, count: n1 * n2 * n3)
    }

    subscript(i: Int, j: Int, k: Int) -> Element {
        get {
            elements[(i * n2 + j) * n3 + k]
        }
        set {
            elements[(i * n2 + j) * n3 + k] = newValue
        }
    }
}

infix operator ++=: AssignmentPrecedence

extension Int {
    static func ++= (lhs: inout Int, rhs: Int) {
        if lhs < rhs {
            lhs = rhs
        }
    }
}



var V = Array2D(repeating: 0, R, C)
for _ in 0 ..< K {
    let r = scanner.nextInt() - 1
    let c = scanner.nextInt() - 1
    V[r, c] = scanner.nextInt()
}

var dp = Array3D<Int>(repeating: Int.min, R, C, 5)
dp[0, 0, 0] = 0
dp[0, 0, 1] = V[0, 0]

for i in 0 ..< R {
    for j in 0 ..< C {
        for k in 0 ... 3 {
            if i + 1 < R {
                dp[i + 1, j, 0] ++= dp[i, j, k]
                dp[i + 1, j, 1] ++= dp[i, j, k] + V[i + 1, j]
            }

            if j + 1 < C {
                dp[i, j + 1, k] ++= dp[i, j, k]
                dp[i, j + 1, k + 1] ++= dp[i, j, k] + V[i, j + 1]
            }
        }
    }
}

let answer = (0 ... 3).map { dp[R - 1, C - 1, $0] }.max()!
print(answer)
//  [typescript]
import * as fs from "fs";

let [line1, ...lines] = fs.readFileSync("/dev/stdin", "utf8").trim().split('\n');

let [R, C, K] = line1.split(' ').map(Number);
let table: number[][] = new Array(R).fill([]).map(() => new Array(C).fill(0));

for(let i=0; i<K; i++) {
    let [r, c, v] = lines[i].split(" ").map(Number);
    table[r-1][c-1] = v;
}

let dp1 = new Array(C).fill(Number.NEGATIVE_INFINITY);
let dp2 = new Array(C).fill(Number.NEGATIVE_INFINITY);
let dp3 = new Array(C).fill(Number.NEGATIVE_INFINITY);
let old_row = new Array(C).fill(Number.NEGATIVE_INFINITY);

for(let i=0; i<R; i++) {
    dp1[0] = table[i][0];
    dp2[0] = Number.NEGATIVE_INFINITY;
    dp3[0] = Number.NEGATIVE_INFINITY;
    for(let j=0; j<C; j++) {
        if (j>0) {
            dp3[j] = Math.max(dp3[j-1], dp2[j-1]+table[i][j]);
            dp2[j] = Math.max(dp2[j-1], dp1[j-1]+table[i][j]);
            dp1[j] = dp1[j-1];
        }
        dp1[j] = Math.max(dp1[j], table[i][j], old_row[j]+table[i][j]);
        old_row[j] = Math.max(dp1[j], dp2[j], dp3[j]);
    }
}

console.log(old_row[C-1]);
//  [python]
#######################################
import numpy as np

def cout(*args):
  arglist = []
  for arg in args:
    if hasattr(arg, "__iter__"):
      arglist.extend(arg)
    else:
      arglist.append(arg)
      
  arglist = list(map(str, arglist))
  print(" ".join(arglist))
#######################################
n = int(input())
a = np.array(list(map(int, input().split())))
ret = np.zeros(n+1, dtype="int")
tmp = list(range(n+1))
ret2 = []

for i in reversed(list(range(n))): 
  if sum(ret[::i+1][1:])%2 != a[i]:
    ret[i+1] = 1
    ret2.append(i+1)

print(sum(ret[1:]))
ret2 = sorted(ret2)
cout(ret2)
//  [python]
import numpy as np
N = int(input())
A = [int(x) for x in input().split()]
solls = np.zeros(N+1)
A.insert(0,0)
solls[N//2+1:] = A[N//2+1:]

for i in range(N//2,0,-1):
    s = 0
    for j in range(2*i,N+1,i):
        s = s+solls[j]
    if (s%2 == 0)and(A[i] == 1):
        solls[i] = 1
    if (s%2 == 1)and(A[i] == 0):
        solls[i] = 1

s = 0
ls = []
for i in range(N+1):
    if solls[i] == 1:
        ls.append(i)
        s = s+1

print(s)
print(*ls)
//  [python]
import numpy as np

def main():
    n = int(input())
    a = np.zeros([n], dtype=int)
    # box = np.array(range(1,n+1))
    a = list(map(int, input().split(" ")))
    b = np.zeros_like(a)

    for i in range(n//2, n):
        if a[i] == 1:
            b[i] = 1

    for i in range(1,n//2+1)[::-1]:
        if np.sum(b[i-1::i])%2 != a[i-1]:
            b[i-1] = 1

    ball = np.where(b==1)[0]
    print(len(ball))
    for i in ball:
        print(i+1, end=" ")
        
if __name__ == "__main__":
    main()
//  [java]
import java.util.*;
import java.lang.*;

class MathLib{
    public static long divCeil(long a, long b){
        return (a+b-1)/a;
    }

    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static long lcm(long a, long b){
        return (a/gcd(a,b))*b;
    }

    public static LinkedList<Long> divisors(long N){
        LinkedList<Long> ans = new LinkedList<>();
        for(long n = (long)(Math.sqrt(N)+2); n>0; n--){
            if(n*n>N) continue;
            else if(n*n==N) ans.add(n);
            else if(N%n==0){
                ans.addFirst(n);
                ans.addLast(N/n);
            }
        }
        return ans;
    }
}
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        for(int n=1; n<=N; n++) A[n]=sc.nextInt();

        int[] balls = new int[N+1];
        Arrays.fill(balls,0);

        TreeSet<Integer> ans = new TreeSet<>();

        for(int n=N; n>0; n--){
            if(balls[n]%2!=A[n]){
                ans.add(n);
                for(long d:MathLib.divisors(n)) balls[(int)d]++;
            }
        }

        System.out.println(ans.size());
        while(!ans.isEmpty()){
            System.out.print(ans.pollFirst());
            if(ans.isEmpty()) System.out.println();
            else System.out.print(" ");
        }

    }
}
//  [java]

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; ++i) {
            a[i] = scanner.nextInt();
        }
        int[] box = new int[n + 1];
        Map<Integer, List<Integer>> number = new HashMap<>();
        for (int i = 1; i <= n; ++i) {
            number.put(i, new ArrayList<>());
        }
        for (int i = 1; i <= n; ++i) {
            for (int k = 1; k * i <= n; ++k) {
                number.get(k * i).add(i);
            }
        }
        for (int i = n; i >= 1; --i) {
            box[i] = a[i] % 2;
            for (int k : number.get(i)) {
                a[k] = Math.abs(a[k] % 2 - box[i] % 2);
            }
        }

        int count = 0;
        for (int i = 1; i <= n; ++i) {
            if (box[i] == 1) {
                ++count;
            }
        }
        System.out.println(count);
        for (int i = 1; i <= n; ++i) {
            if (box[i] == 1) {
                System.out.print(i + " ");
            }
        }
        System.out.println();

    }
}
//  [java]

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; ++i) {
            a[i] = scanner.nextInt();
        }
        int[] box = new int[n + 1];
        Map<Integer, List<Integer>> number = new HashMap<>();
        for (int i = 1; i <= n; ++i) {
            number.put(i, new ArrayList<>());
        }
        for (int i = 1; i <= n; ++i) {
            for (int k = 1; k * i <= n; ++k) {
                number.get(k * i).add(i);
            }
        }
        for (int i = n; i >= 1; --i) {
            box[i] = a[i] % 2;
            for (int k : number.get(i)) {
                a[k] = Math.abs(a[k] % 2 - box[i] % 2);
            }
        }

        int count = 0;
        for (int i = 1; i <= n; ++i) {
            if (box[i] == 1) {
                ++count;
            }
        }
        System.out.println(count);
        for (int i = 1; i <= n; ++i) {
            if (box[i] == 1) {
                System.out.print(i + " ");
            }
        }
        System.out.println();

    }
}
//  [cpp]
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	int n; cin >> n;
	vector<int> a(n+1), b(n+1,0);
	rep(i,n) cin >> a[i+1];
	int ans = 0;
	for(int i=n; i>0; i--){
		int t = 0;
		for(int j=i+i; j<=n; j+=i){
			//cerr << j << endl;
			if(b[j]){
				t = !t;
			}
		}
		cerr << t << a[i] << endl;
		if(t != a[i]){
			b[i] = 1;
			ans++;
		}
	}
	cout << ans << endl;
	print(b);
	rep(i,n){
		if(b[i+1]){
			cout << i+1 << ' ';
		}
	}
}
//  [cpp]
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int N;
    read(N);
    vector<int> a(N + 1);
    for(int i = 1; i <= N; i++){
        read(a[i]);
    }
    map<int, int> mp;
    for(int i = N; i >= 1; i--){
        mp[i] = a[i];
        for(int j = 2 * i; j <= N; j += i){
            mp[i] += mp[j];
        }
        mp[i] %= 2;
    }
    vector<int> b;
    for(auto it = mp.begin(); it != mp.end(); it++){
        if(it->second) b.push_back(it->first);
    }
    write(b.size());
    write_vec(b, ' ');
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//
//  [c]
#include<stdio.h>
int n,a[200001],yak[200001][300],yac[200001]={0};
int hab[200001]={0},b[200000]={0};

int main(){
	int i,m=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	for(i=1;i<=n;i++){
		int j,f=0;
		yak[i][yac[i]++]=1;
		if(i==1)continue;
		for(j=2;j*j<=i;j++){
			if(i%j==0){
				yak[i][yac[i]++]=j;
			}
		}
		for(j=0;j<yac[i];j++){
			if(yak[i][j]*yak[i][j]!=i)yak[i][yac[i]+j]=i/yak[i][j];
			else f=1;
		}
		yac[i]*=2;
		if(f==1)yac[i]--;
	}
	for(i=n;i>0;i--){
		if(hab[i]%2!=a[i]%2){
			b[m++]=i;
			int j;
			for(j=0;j<yac[i];j++)hab[yak[i][j]]++;
		}
	}
	if(hab[1]%2!=a[1]%2)puts("-1");
	else{
		printf("%d\n",m);
		for(i=0;i<m;i++)printf("%d ",b[i]);
		puts("");
	}
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdint.h>
#include <math.h>

int main()
{
	int n;
	scanf("%d", &n);
	int32_t a[n], ans[n], cnt = 0;
	for(int i = 0 ; i < n ; i++)
	{
		ans[i] = 0;
		scanf("%d", &a[i]);
	}
	for(int i = n - 1 ; i >= 0 ; i--)
	{
		if(a[i] == 1)
		{
			ans[cnt++] = i + 1;
			for(int j = 1 ; j <= sqrt(i + 1) ; j++)
			{
				if(!((i + 1) % j))
				{
					if(((i + 1) / j) == j)
						a[j - 1] ^= 1;
					else
					{
						a[(i + 1) / j - 1] ^= 1;
						a[j - 1] ^= 1;
					}
				}
			}
		}
	}
	printf("%d\n", cnt);
	if(cnt != 0)
	{
		for(int i = cnt - 1 ; i >= 0 ; i--)
			printf("%d ", ans[i]);
		printf("\n");
	}
}
//  [c]
#include <stdio.h>
#include <math.h>

int divisor(int num,int d[])
{
	int i,j=0,c[(int)sqrt(num)+10],k,e=0;
	int castle=0;
	for(i=1;i<=(int)sqrt(num);i++)
	{
		if(num%i==0)
		{
			d[j] = i;j++;
			if(i != num/i){
				c[e] = num/i;
				e++;
			}
		}
	}
	k = e;
	for(i = j; i < j+e;i++)
	{
		k--;
		d[i] = c[k];
	}
	/*
	for(i = 0; i < j+e; i++)
	{
		printf("d[%d] = %d\n",i,d[i]);
	}
	*/
	return (e+j);
}

int main(void)
{
	int N;
	scanf("%d",&N);
	int i,a[N+1],b[N+1],ans[N+1],M=0,c[N+1],kate,j;
	for(i=1; i < N+1 ; i++)
	{
		scanf("%d",&a[i]);
		c[i] = 0;		b[i] = 0;		ans[i] = 0;
	}
	
	for(i=N; i > 0; i--)
	{
		kate = 0;
		if(a[i] == 0 && b[i] % 2 == 1)
		{
			kate = divisor(i,c);
			ans[i] = 1;
		}
		else if(a[i] == 1 && b[i] % 2 == 0)
		{
			kate = divisor(i,c);
			ans[i] = 1;
		}
		for(j = 0; j < kate; j++)
		{
			b[c[j]]++;
		}
	}
	for(i = 1; i < N+1; i++)
	{
		if(ans[i] == 1) M++;
	}
	
	printf("%d\n",M);
	for(i = 1; i < N+1; i++)
	{
		if(ans[i] == 1) printf("%d ",i);
	}
	return 0;
}
//  [javascript]
function main(input){
  input = input.split("\n");
  var n = parseInt(input[0]);

  var a = input[1].split(" ").map(x => parseInt(x))

  //console.log(a);


  var tama = [];
  var answer = [];
  var hanbun = Math.floor(n / 2);

// tamaは0が値なしになる
  for (var i = n; i > hanbun; i--){
    tama[i] = a[i-1];
    if (tama[i] == 1) {
      answer.push(i);
    }
  }

  for (var i = hanbun; i>0; i--){
    var hantei = a[i-1];
    for (var j = 2; i*j <= n; j++){
      hantei += tama[i*j];
    }
    tama[i] = hantei%2;
    if (tama[i] == 1) {
      answer.push(i);
    }
  }

//console.log(tama);
//console.log(answer);

console.log(answer.length);
for (var i = 0; i < answer.length; i++) {
  process.stdout.write(answer[i]+" ");
}



}
 
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
'use strict'

const divisors = n => {
  let dest = []
  for (let i = 1; i < Math.floor(Math.pow(n, 0.5) + 1); i++) {
    if (n % i === 0) {
      dest.push(i)
      if (Math.floor(n / i) !== i) {
        dest.push(Math.floor(n / i))
      }
    }
  }
  return dest.sort((a, b) => a - b)
}

function main(inp) {
  inp = inp.trim().split('\n')
  const N = Number(inp.shift())
  inp = inp[0].split(' ').map(n => Number(n));
  inp.unshift(0)

  let ans = []
  let allBalls = new Array(N+1).fill(0)

  for (let i = N; i > 0; i--) {
    if (inp[i] > 1) return console.log(-1)
    if (allBalls[i] % 2 !== inp[i]) {
      ans.push(i)
      
      let arr = divisors(i)
      for (let j = 0; j < arr.length; j++) {
        allBalls[arr[j]]++
      }
    }
  }
  if (ans.length) {
    console.log(ans.length)
    console.log(ans.reverse().join(' '))
  } else {
    console.log(0)
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0]-0;
  var A=input[1].split(' ').map(e=>{
    return e-0;
  });
  A.unshift(0);
  var ret=new Array(N+1);
  var temp=0;
  var pointer;
  for(var i=N;i>=1;i--){
    pointer=i*2;
    temp=0;
    while(pointer<=N){
      temp=(ret[pointer]+temp)%2;
      pointer+=i;
    }
    ret[i]=(temp+A[i])%2;
  }
  ret.shift();
  var ans=ret.reduce((acc,cur)=>{
    return acc+cur;
  });
  console.log(ans);
  ret.forEach((e,i)=>{
    if(e===1){
      console.log(i+1);
    }
  });

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sat Jul 20 21:17:55 2019
//
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := range arr {
		fmt.Scan(&arr[i])
	}
	arr = append([]int{0}, arr...)

	bs := make([]int, len(arr))
	for i := n; i > 0; i-- {
		num := 0
		for j := i; j <= n; j += i {
			if j%i == 0 {
				num += bs[j]
			}
		}
		if arr[i] != num%2 {
			bs[i] = 1
		}
	}
	ans := make([]int, 0)
	for i := 1; i <= n; i++ {
		if bs[i] == 1 {
			ans = append(ans, i)
		}
	}

	fmt.Println(len(ans))
	for i := range ans {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Print(ans[i])
	}
	fmt.Println()
}
//  [ruby]
n = gets.chomp.to_i
a_arr = gets.chomp.split(" ").map(&:to_i)

hash = {}
(1..n).each do |a|
  tmp_a = a + a
  while tmp_a <= n do
    hash[a] ||= []
    hash[a] << tmp_a
    tmp_a += a
  end
end

b_arr = []
hash2 = {}
while n > 0 do
  n /= 2
  a_arr[n..-1].each_with_index do |a, i|
    num = n + i + 1
    count = (hash[num] || []).map{|map_n| hash2[map_n].to_i }.inject(&:+).to_i
    if a == 1 then
      if count % 2 == 1 then
        hash2[num] = 0
      else
        hash2[num] = 1
        b_arr << num
      end
    else
      if count % 2 == 1 then
        hash2[num] = 1
        b_arr << num
      else
        hash2[num] = 0
      end
    end
  end
  a_arr = a_arr[0..(n-1)]
end

puts b_arr.length
if b_arr.length > 0 then
  puts b_arr.reverse.join(" ")
end
//  [ruby]
n = gets.to_i
a = gets.split.map(&:to_i)
p = []
n.pred.downto(0) do |i|
  unless a[i].zero?
    p << i + 1
    u = 1
    v = i + 1
    while u * u <= v
      if v % u == 0
        a[u - 1] ^= 1
        unless u == v / u
          a[v / u - 1] ^= 1
        end
      end
      u += 1
    end
  end
end
if p.size > 0
  puts p.size
  puts p.join(' ')
else
  puts '0'
end
//  [ruby]
N = gets.chomp.to_i
A = [nil] + gets.chomp.split(" ").map(&:to_i)

mid_i = N / 2 + 1
result = {}
(N).downto(mid_i) do |i|
  result[i] = A[i]
end

indexes = (1..(mid_i - 1)).map do |i|
  (2..(N / i)).map { |v| v * i }
end

(mid_i - 1).downto(1) do |i|
  v = indexes[i-1].map {|j| result[j] }.inject(&:+) % 2
  result[i] = (A[i] ^ v)
end
n = result.values.inject(&:+)
puts n
puts result.select { |k, v| v == 1 }.keys.join(" ") if n > 0
//  [rust]
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
       mut b:[i64;n],
    }
    let mut a = vec![0];
    a.append(&mut b);
    dbg!(&a);
    /*



    */
    let mut anss = vec![false; n + 1];
    let mut r = vec![false; n + 1];
    let mut z = vec![];
    for i in (1..=n).rev() {
        let j = divisor(i);
        // if ((a[i] == 1) ^ anss[i]) {}
        if ((a[i] == 1) ^ anss[i]) {
            // iを入れないといけない
            for divs in j {
                anss[divs] = !anss[divs];
            }
            z.push(i);
        }
    }
    println!("{}", z.len());
    for &x in z.iter() {
        println!("{}", x);
    }
}
pub fn divisor(n: usize) -> Vec<usize> {
    let mut res = Vec::new();
    for i in (1..).take_while(|x| x * x <= n) {
        if n % i == 0 {
            res.push(i);
            if i != n / i {
                res.push(n / i);
            }
        }
    }
    res.sort();
    res
}
//  [rust]
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let a: Vec<usize> = (0..n).map(|_| read()).collect();

    let mut b: Vec<usize> = vec![0; n];
    let mut sum: Vec<usize> = vec![0; n];
    for i in (0..n).rev() {
        let ai = a[i] % 2;
        let sumi = sum[i] % 2;
        if ai == sumi {
            b[i] = 0;
        } else {
            b[i] = 1;
        }
        let mut j = 1;
        while j * j <= (i+1) {
            if (i+1) % j == 0 {
                sum[j-1] += b[i];
                if j != (i+1)/j {
                    sum[(i+1)/j-1] += b[i];
                }
            }
            j += 1;
        }
    }
    let mut cnt = 0;
    for i in 0..n {
        if b[i] > 0 {
            cnt += 1;
        }
    }
    println!("{}", cnt);
    for i in 0..n {
        if b[i] > 0 {
            println!("{}", i+1);
        }
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}
//  [rust]
use std::collections::HashSet;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn factors(n: usize) -> Vec<usize> {
    let mut f = HashSet::new();
    for i in 1..n {
        if i * i > n {
            break;
        }
        if n % i == 0 {
            f.insert(i);
            f.insert(n / i);
        }
    }
    let mut f = f.iter().map(|&v| v).collect::<Vec<_>>();
    f.sort();
    f
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut count = 0;
    let mut b = Vec::with_capacity(n);
    let mut c = vec![0; n];
    for i in (0..n).rev() {
        let k = i + 1;
        if c[i] % 2 != a[i] {
            count += 1;
            b.push(k);
            for f in factors(k) {
                c[f - 1] += 1;
            }
        }
    }
    b.reverse();
    println!("{}", count);
    for bi in b {
        println!("{}", bi);
    }
}
//  [typescript]
import * as fs from 'fs';

export class Reader {
    lines: string[];
    currentLine: number;

    constructor() {
        this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        this.currentLine = 0;
    }

    readLine(): string {
        return this.lines[this.currentLine++];
    }

    readInt(): number {
        return Number(this.readLine());
    }

    readInts(): number[] {
        return this.readLine().split(" ").map(Number);
    }
}

let reader: Reader = new Reader();
let N = reader.readInt();
let A: number[] = reader.readInts();
let B: number[] = new Array(N).fill(0);
let count = 0;

for(let i=N-1; i>=0; i--) {
	let S = 0;
	for(let j=2*i+1; j<N; j+=i+1) {
		S += B[j];
	}
	if (S%2 == A[i]%2) {
		B[i] = 0;
	} else {
		B[i] = 1;
		count += 1;
	}
}
console.log(count);
for(let i=0; i<N; i++) {
	if (B[i] == 1) {
		console.log(i+1);
	}
}
//  [python]
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    a,b,c = LI()
    if c-b == b-a:
        return 'YES'
    return 'NO'



print(main())
//  [python]
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,c = inpl()
print('YES' if b-a == c-b else 'NO')
//  [python]
import sys
import numpy as np

a, b, c = (int(i) for i in input().split(" "))

if b - a == c - b:
	print("YES")
else:
	print("NO")
//  [java]
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if ((b - a) == (c - b)){
            System.out.print("YES");
        }
        else System.out.print("NO");
    }
}
//  [java]
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int a=stdIn.nextInt(),b=stdIn.nextInt(),c=stdIn.nextInt();
		System.out.print(a-b==b-c?"YES":"NO");
	}
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int a,b,c;cin>>a>>b>>c;
  string ans="NO";
  if(b-a==c-b)ans="YES";
  cout(ans);
  
  return 0;
}
//  [cpp]
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int a,b,c;
	cin>>a>>b>>c;
	if (2*b == a+c){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}
//  [c]
# include"stdio.h"
int main(){
     int a,b,c;
     scanf("%d %d %d",&a,&b,&c);
     if((b-a)==(c-b))
         printf("YES\n");
     else printf("NO\n");
}
//  [c]
#include <stdio.h>
int main()
{
    int a,b,c,x,y;
    scanf("%d %d %d", &a, &b, &c);
    x=b-a;
    y=c-b;

    if(x==y)
    {
        printf("YES");
    }
    else{
        printf("NO");
    }
    return 0;
}
//  [c]
#include <stdio.h>

int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (b - a == c - b) printf("YES\n");
	else printf("NO\n");
	fflush(stdout);
	return 0;
}
//  [javascript]
function main (s) {
    s=s.split(" ");
	for(var i=0;i<3;i++)s[i]=parseInt(s[i]);
	console.log((s[1]-s[0]==s[2]-s[1])?"YES\n":"NO\n");
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main( input ){

    input = input.split( ' ' )

    var a = Number( input[0] )
    var b = Number( input[1] )
    var c = Number( input[2] )

    if( b - a === c - b ){
        console.log( 'YES' )
    } else {
        console.log( 'NO' )
    }

}

Main( require( 'fs' ).readFileSync( '/dev/stdin', 'utf8' ) )
//  [javascript]
const main = stdin => {
  const input = stdin.trim().split('\n')
  const [a, b, c] = input[0].split(' ').map(x => parseInt(x))
  if (b - a === c - b) {
    console.log('YES')
  } else {
    console.log('NO')
  }
}
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))
//  [go]
package main

import "fmt"

func main() {
	var (
		a, b, c int
	)

	fmt.Scan(&a, &b, &c)

	if b-a == c-b {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}
//  [go]
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if b-a == c-b {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

// UnionFind 構造体 for tree
type UnionFind struct {
	par []int
}

/*コンストラクタ*/
func newUnionFind(N int) *UnionFind {
	u := new(UnionFind)
	u.par = make([]int, N)
	for i := range u.par {
		u.par[i] = -1
	}
	return u
}
func (u UnionFind) root(x int) int {
	if u.par[x] < 0 {
		return x
	}
	u.par[x] = u.root(u.par[x])
	return u.par[x]
}
func (u UnionFind) unite(x int, y int) {
	xr := u.root(x)
	yr := u.root(y)
	if xr == yr {
		return
	}
	u.par[yr] += u.par[xr]
	u.par[xr] = yr
}
func (u UnionFind) same(x, y int) bool {
	if u.root(x) == u.root(y) {
		return true
	}
	return false
}
func (u UnionFind) size(x int) int {
	return -u.par[u.root(x)]
}

var mod int = 1000000007

type pair struct {
	fi int
	se int
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	//予備
	a := iScan()
	b := iScan()
	c := iScan()

	if b-a == c-b {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
//  [ruby]
require 'prime'
include Math
def max(a,b);                    a > b ? a : b                            end
def min(a,b);                    a < b ?  a : b                           end
def swap(a,b);                   a, b = b, a                              end
def gif;                         gets.to_i                                end
def gsf;                         gets.chomp                               end
def gi;                          gets.split.map(&:to_i)                   end
def gs;                          gets.chomp.split.map(&:to_s)             end
def gc;                          gets.chomp.split('')                     end
def pr(num);                     num.prime_division                       end
def putall(obj);                 obj.each{|o| puts(o)}                    end
def array(size,init=nil);        Array.new(size){init}                    end
def darray(size1,size2,init=nil);Array.new(size1){Array.new(size2){init}} end
def rep(num);                    num.times {|i|yield(i)}                  end
def repl(st,en);                 st.upto(en) {|i|yield(i)}                end


a,b,c = gi

puts b-a == c-b ? 'YES' : 'NO'
//  [ruby]
a,b,c=gets.split.map(&:to_i)
puts b-a==c-b ? 'YES' : 'NO'
//  [ruby]
a, b, c = gets.split.map(&:to_i)
puts b - a == c - b ? "YES" : "NO"
//  [rust]
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:isize,
    b:isize,
    c:isize,
    }
    println!("{}",if b-a==c-b{"YES"}else{"NO"})
}
//  [rust]
use proconio::input;

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
    };
    let ans = b - a == c - b;
    println!("{}", if ans { "YES" } else { "NO" });
}
//  [rust]
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: isize = iterator.next().unwrap().parse().unwrap();
    let b: isize = iterator.next().unwrap().parse().unwrap();
    let c: isize = iterator.next().unwrap().parse().unwrap();

    return if b - a == c - b {
        "YES".to_string()
    } else {
        "NO".to_string()
    };
}
//  [swift]
import Foundation

extension String {
    var argi: [Int] { return self.characters.split(" ").map { Int(String($0))! } }
}

let inp=readLine()!.argi

let a=inp[0]
let b=inp[1]
let c=inp[2]

if (b-a)==(c-b){
    print("YES")
}
else{
    print("NO")
}
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [a, b, c] = input[0].map(Number);

  return b - a === c - b ? "YES" : "NO";
};

console.log(main(read()));
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [a, b, c] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const res = _ => {
  if (b - a === c - b) return 'YES'
  return 'NO'
}

console.log(res())
//  [typescript]
var input: string = require('fs').readFileSync('/dev/stdin', 'utf8');
var inputLines: string[] = input.trim().split("\n");
var parts = inputLines[0].split(" ");

var a = parseInt(parts[0]);
var b = parseInt(parts[1]);
var c = parseInt(parts[2]);

console.log(b - a == c - b ? "YES" : "NO");
//  [python]
s = input().strip()
l = len(s)
d, a = {}, {}
for i, c in enumerate(s):
    if c in d:
        d[c] = max(d[c], i - a[c])
    else:
        d[c] = i
    a[c] = i + 1
for c, v in d.items():
    d[c] = max(v, l - a[c])
print(min(d.values()))
//  [python]
s = input()

ans = len(s) // 2

for c in [chr(i + 97) for i in range(26)]:
    if c not in s:
        continue
    ma = 0
    for part in s.split(c):
        ma = max(ma, len(part))
    ans = min(ans, ma)

japaripark = ans
print(japaripark)
//  [python]
s=str(input())
ans=int(len(s)/2)

for i in range(97, 97+26):
  if chr(i) in s:
    ct= s.count(chr(i))
    place=[0]*ct
    for j in range(ct-1):
      place[0]=s.find(chr(i))+1
      place[j+1]=s[place[j]:].find(chr(i))+place[j]+1
    haba=max(len(s)-place[ct-1],place[0]-1)
    for j in range(ct-1):
      haba=max(haba,place[j+1]-place[j]-1)
    ans=min(ans,haba)

print(ans)
//  [python]
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

arr=list(ss())
mat=list(Counter(arr))
ans=10**100
for i in mat:
    tmp=deepcopy(arr)
    p=0
    while len(Counter(tmp))!=1:
        aa=[]
        for j in range(len(tmp)-1):
            if tmp[j] ==i or tmp[j+1]==i:
                aa.append(i)
            else:
                aa.append(tmp[j])
        tmp=deepcopy(aa)
        p+=1
    ans=min(ans,p)
print(ans)
//  [python]
s = input()
min_change = 100
for char in 'abcdefghijklmnopqrstuvwxyz':
    absence = 0
    max_absence = 0
    for i in s:
        if i != char:
            absence += 1
        else:
            max_absence = max(max_absence,absence)
            absence = 0
    max_absence = max(max_absence,absence)
    min_change = min(min_change,max_absence)
print(min_change)
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	static final int INF = (int)1e9+7;
	char[] s;
	int N;

	public void solve(){
		s = next().toCharArray();
		N = s.length;

		int ans = INF;

		for(int i = 0;i < 26;i++){

			List<Integer> list = new ArrayList<>();
			list.add(-1);
			for(int j = 0;j < N;j++){
				if(s[j] == 'a' + i){
					list.add(j);
				}
			}

			if(list.size() == 1)continue;

			int max = 0;
			for(int j = 0;j < list.size()-1;j++){
				max = Math.max(max,list.get(j+1)-list.get(j)-1);
			}
			max = Math.max(max,N - list.get(list.size()-1)-1);
			ans = Math.min(ans,max);
		}

		out.println(ans == INF ? 0 : ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}