class Stack(T) {
    private DList!(T) _dlist;
    private ulong _size;

    this(T[] ary) {
        _dlist = DList!(T)(ary);
        _size = ary.length;
    }

    this() {
        _dlist = DList!(T)();
        _size = 0;
    }

    void push(T x) {
        _dlist.insertBack(x);
        _size++;
    }

    T pop() {
        T x = _dlist.back;
        _dlist.removeBack();
        _size--;
        return x;
    }

    @property T top() {
        return _dlist.back;
    }

    @property ulong size() {
        return _size;
    }

    @property bool empty() {
        return _dlist.empty;
    }
}