Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <sstream>

using namespace std;

static const int none = -1;

struct linkItem
{
	int key = none;
	int nextIdx = -1;
	int prevIdx = -1;
};

struct order
{
	int kind = none;
	int key = none;
};

class dblLinkLst
{
public:
	dblLinkLst() {
	}

	~dblLinkLst() {
	}

	void insertItem(int insKey) {

		int nextLnk = none;
		for (int i = lLen - 1;i >= 0;i--) {
			if (plst[i].key != none) {
				plst[i].prevIdx = plst.size();

				nextLnk = i;
				break;
			}
		}

		linkItem tmp;
		tmp.key = insKey;
		tmp.nextIdx = nextLnk;

		plst.push_back(tmp);

		lLen = plst.size();

	}

	void deleteItem(int delKey) {

		linkItem lnk;
		int thisIdx = 0;
		lnk.key = none;
		for (int i = lLen - 1;i >= 0;i--) {
			if (plst[i].key != none) {
				lnk = plst[i];
				thisIdx = i;
				break;
			}
		}

		if (lnk.key != none) {
			while (true) {
				if (lnk.key == delKey) {
					if (lnk.prevIdx > none)	plst[lnk.prevIdx].nextIdx = lnk.nextIdx;
					if (lnk.nextIdx > none)	plst[lnk.nextIdx].prevIdx = lnk.prevIdx;

					plst[thisIdx].key = none;
					break;
				}

				if (lnk.nextIdx == none) break;

				thisIdx = lnk.nextIdx;
				lnk = plst[thisIdx];
			}
		}
		return;
	}

	void deleteFirst() {
		linkItem lnk;
		int thisIdx = 0;

		for (int i = lLen - 1;i >= 0;i--) {
			if (plst[i].key != none) {
				lnk = plst[i];
				thisIdx = i;
				break;
			}
		}

		if (lnk.key != none) {
			if (lnk.nextIdx > none)	plst[lnk.nextIdx].prevIdx = none;
			plst[thisIdx].key = none;
		}
		return;
	}

	void deleteLast() {
		linkItem lnk;
		int thisIdx = 0;
		for (int i = 0;i < lLen;i++) {
			if (plst[i].key != none) {
				lnk = plst[i];
				thisIdx = i;
				break;
			}
		}

		if (lnk.key != none) {
			if (lnk.prevIdx > none)	plst[lnk.prevIdx].nextIdx = none;
			plst[thisIdx].key = none;
		}

		return;
	}

	string printKeys() {
		string out;
		linkItem lnk;
		lnk.key = none;
		for (int i = lLen - 1;i > 0;i--) {
			if (plst[i].key != none) {
				lnk = plst[i];
				break;
			}
		}

		if (lnk.key != none) {
			while (lnk.nextIdx > none)
			{
				out += to_string(lnk.key) + " ";
				lnk = plst[lnk.nextIdx];
			}
			out += to_string(lnk.key);
		}

		return out;
	}

private:

	vector<	linkItem> plst;
	int lLen = 0;
	int frontIdx = 0;
};



int main() {

	int n;
	cin >> n;
	cin.ignore();

	int ttl = 0;
	dblLinkLst dbl;
	vector<order> ords;

	for (int i = 0; i < n; i++) {
		string cm, ln2;
		char com[20];
		int key = 0;

		scanf_s("%s%d", com, &key);
			   		 
		order ord;
		ord.key = key;

		if (com[0] == 'i') {
			ord.kind = 0;
		}
		else if (com[0] == 'd') {

			if (strlen(com) > 6) {
				if (com[6] == 'F') {
					ord.kind = 2;
				}
				else if (com[6] == 'L') {
					ord.kind = 3;
				}
			}
			else {

				ord.kind = 1;
			}
		}
		ords.push_back(ord);

	}

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

		switch (ords[i].kind)
		{

		case 0:
			dbl.insertItem(ords[i].key);
			break;
		case 1:
			dbl.deleteItem(ords[i].key);
			break;
		case 2:
			dbl.deleteFirst();
			break;
		case 3:
			dbl.deleteLast();
			break;

		default:
			break;
		}
			}
	string ans = dbl.printKeys();
	cout << ans << endl;
	

	return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:174:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
  174 |                 scanf_s("%s%d", com, &key);
      |                 ^~~~~~~
      |                 scanf
a.cc:184:29: error: 'strlen' was not declared in this scope
  184 |                         if (strlen(com) > 6) {
      |                             ^~~~~~
a.cc:8:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    7 | #include <sstream>
  +++ |+#include <cstring>
    8 |