public class MyList {
    private Node head;

    public MyList() {
        this.head = null;
    }

    public void myRemove(int startIndex, int endIndex){
        startIndex--;
        for(int i = startIndex; i < endIndex; i++){
            this.remove(startIndex);
        }
    }

    public int size(){
        int count = 0;
        Node node = head;
        while(node != null){
            node = node.getNext();
            count++;
        }
        return count;
    }

    public void add(int value){
        Node node = head;
        if(node == null){
            head = new Node(value);
            return;
        }
        while(node.getNext() != null){
            node = node.getNext();
        }
        node.setNext(new Node(value));
    }

    public int get(int index){
        int i = 0;
        Node node = head;
        while(node.getNext() != null && i < index){
            node = node.getNext();
            i++;
        }
        return node.getValue();
    }

    public void remove(int index){
        if(index == 0 && head != null){
            head = head.getNext();
            return;
        }
        int i = 0;
        Node node = head;
        while(node.getNext() != null && i+1 < index){
            node = node.getNext();
            i++;
        }
        try{
            node.setNext(node.getNext().getNext());
        }catch(Exception ex){
            node.setNext(null);
        }
    }
}