#include <iostream>
#include <vector>
using namespace std;
template <typename T>
class SequenceList {
private:
vector<T> elements;
public:
int length() const {
return elements.size();
}
void insertElement(int index, const T& element) {
if (index >= 0 && index <= length()) {
elements.insert(elements.begin() + index, element);
} else {
throw out_of_range("Index out of range");
}
}
void deleteElement(int index) {
if (index >= 0 && index < length()) {
elements.erase(elements.begin() + index);
} else {
throw out_of_range("Index out of range");
}
}
void display() const {
for (const T& element : elements) {
cout << element << " ";
}
cout << endl;
}
};
int main() {
SequenceList<int> intList;
intList.insertElement(0, 10);
intList.insertElement(1, 20);
intList.insertElement(2, 30);
cout << "Length: " << intList.length() << endl;
intList.display();
SequenceList<string> stringList;
stringList.insertElement(0, "Apple");
stringList.insertElement(1, "Banana");
stringList.insertElement(2, "Orange");
cout << "Length: " << stringList.length() << endl;
stringList.display();
return 0;
}