HTML & JS
import java.io.*;
import java.util.*;
import java.math.*;
public class Main{
	public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        long a,b=0,c=0,d=0;
        a= sc.nextLong();
        b=a;
        long sum = a*(a+1)/2;
        long div = sum/2;
        long sd = 0;
        List<Long> l = new ArrayList<>();
        while(true){
            if(div>b){
            div-=a;
            l.add((long)a);
            sd+=a;
            a--;
            }else{
               l.add(div);
               sd+=div;
               break;
            }
        }
        System.out.println(Math.abs(sum-sd-sd));
        System.out.print(l.size()+" ");
        for(int i=0;i<l.size();i++){
            System.out.print(l.get(i)+" ");
        }
        }
    }

Generated URL:

Output:

1
2 6 4 
Report Bug