Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<malloc.h>
#define MAX_SIZE 100005
int N_box, M_que;
struct DLLNode{
	int data;
	struct DLLNode * left;
	struct DLLNode * right;
};

struct Arr{
	int data;
	struct DLLNode* add;
};

//struct Arr list[MAX_SIZE];
struct DLLNode list[MAX_SIZE];

void swap(int n1, int n2){
	struct Arr *tmp = (struct Arr*) malloc(sizeof(Arr));
	tmp->add = list[n1].add;
	tmp->data = list[n1].data;
	list[n1].add =list[n2].add;
	list[n1].data =list[n2].data;
	list[n2].add = tmp->add;
	list[n2].data = tmp->data;
	free(tmp);
}

void pushfront(struct DLLNode** head, struct DLLNode** tail, int n1, int n2){
	if (*head == list[n1].add && list[n1].add->right != NULL)
		*head = list[n1].add->right;
	if (*head == list[n2].add)
		*head = list[n1].add;
	if (list[n1].add->right != NULL)
		list[n1].add->right->left = list[n1].add->left;
	if (list[n1].add->left != NULL)
		list[n1].add->left->right = list[n1].add->right;
	list[n1].add->right = list[n2].add;
	list[n1].add->left = list[n2].add->left;
	if (list[n2].add->left != NULL)
		list[n2].add->left->right = list[n1].add;
	list[n2].add->left = list[n1].add;
}

void pushback(struct DLLNode** head, struct DLLNode** tail, int n1, int n2){
	if (*head == list[n1].add && list[n1].add->right != NULL)
		*head = list[n1].add->right;
	if (*tail == list[n2].add)
		*tail = list[n1].add;
	if (list[n1].add->left != NULL)
		list[n1].add->left->right = list[n1].add->right;
	if (list[n1].add->right != NULL)
		list[n1].add->right->left = list[n1].add->left;
	list[n1].add->left = list[n2].add;
	list[n1].add->right = list[n2].add->right;
	if (list[n2].add->right != NULL)
		list[n2].add->right->left = list[n1].add;
	list[n2].add->right = list[n1].add;
}


int main(void){
	int tc, T;
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	scanf("%d", &T);
	for (tc = 1; tc <= T; tc++){
		struct DLLNode *head = NULL, *tail = NULL;

		scanf("%d %d", &N_box, &M_que);
		for (int i = 0; i < N_box; i++){
			list[i + 1].data = i + 1;
			list[i + 1].left = NULL;
			list[i + 1].right = NULL;
			if (head == NULL && tail == NULL){
				head = n;
				tail = n;
			}
			else{
				struct DLLNode  *tmp = head;
				while (tmp->right != NULL){
					tmp = tmp->right;
				}
				tmp->right = n;
				n->left = tmp;
				tail = n;
			}
		}
		struct DLLNode  *tmp = head;
		int flag = 0;
		for (int i = 0; i < M_que; i++){
			int case_id, n1, n2;
			scanf("%d", &case_id);
			switch (case_id){
			case 1:{
				scanf("%d %d", &n1, &n2);
				if (list[n2].add->left == list[n1].add){
					if (flag % 2 == 0)
						pushfront(&head, &tail, n1, n2);
					else
						pushfront(&head, &tail, n2, n1);
				}
				tmp = head;
				while (tmp != NULL){
					printf("%d", tmp->data);
					tmp = tmp->right;
				}
				printf("\n");
				break;
			}
			case 2:{
				scanf("%d %d", &n1, &n2);
				if (list[n2].add->right != list[n1].add)
				{
					if (flag % 2 == 0)
						pushback(&head, &tail, n1, n2);
					else
						pushback(&head, &tail, n2, n1);
				}
				tmp = head;
				while (tmp != NULL){
					printf("%d", tmp->data);
					tmp = tmp->right;
				}
				printf("\n");
				break;
			}
			case 3:{
				scanf("%d %d", &n1, &n2);
				swap(n1, n2);
				tmp = head;
				while (tmp != NULL){
					printf("%d", tmp->data);
					tmp = tmp->right;
				}
				printf("\n");
				break;
			}
			case 4:{
				flag++;
				break;
			}
			default:
				return 0;
			}

		}
		long long sum = 0;
		tmp = head;
		while (tmp != NULL){
			printf("%d", tmp->data);
			tmp = tmp->right;
		}
		printf("\n");
		tmp = head;
		//printf("** %d **",flag);
		if (flag % 2 == 0){
			while (tmp != NULL){
				sum += tmp->data;
				if (tmp->right != NULL)
					tmp = tmp->right->right;
				else
					tmp = tmp->right;
			}
		}
		else{
			tmp = tail;
			while (tmp != NULL){
				sum += tmp->data;
				if (tmp->left != NULL)
					tmp = tmp->left->left;
				else
					tmp = tmp->left;
			}
		}

		printf("#%d %lld\n", tc, sum);
	}
	return 0;
}

Compiler output:
a.cc: In function 'void swap(int, int)':
a.cc:22:29: error: 'struct DLLNode' has no member named 'add'
   22 |         tmp->add = list[n1].add;
      |                             ^~~
a.cc:24:18: error: 'struct DLLNode' has no member named 'add'
   24 |         list[n1].add =list[n2].add;
      |                  ^~~
a.cc:24:32: error: 'struct DLLNode' has no member named 'add'
   24 |         list[n1].add =list[n2].add;
      |                                ^~~
a.cc:26:18: error: 'struct DLLNode' has no member named 'add'
   26 |         list[n2].add = tmp->add;
      |                  ^~~
a.cc: In function 'void pushfront(DLLNode**, DLLNode**, int, int)':
a.cc:32:31: error: 'struct DLLNode' has no member named 'add'
   32 |         if (*head == list[n1].add && list[n1].add->right != NULL)
      |                               ^~~
a.cc:32:47: error: 'struct DLLNode' has no member named 'add'
   32 |         if (*head == list[n1].add && list[n1].add->right != NULL)
      |                                               ^~~
a.cc:33:34: error: 'struct DLLNode' has no member named 'add'
   33 |                 *head = list[n1].add->right;
      |                                  ^~~
a.cc:34:31: error: 'struct DLLNode' has no member named 'add'
   34 |         if (*head == list[n2].add)
      |                               ^~~
a.cc:35:34: error: 'struct DLLNode' has no member named 'add'
   35 |                 *head = list[n1].add;
      |                                  ^~~
a.cc:36:22: error: 'struct DLLNode' has no member named 'add'
   36 |         if (list[n1].add->right != NULL)
      |                      ^~~
a.cc:37:26: error: 'struct DLLNode' has no member named 'add'
   37 |                 list[n1].add->right->left = list[n1].add->left;
      |                          ^~~
a.cc:37:54: error: 'struct DLLNode' has no member named 'add'
   37 |                 list[n1].add->right->left = list[n1].add->left;
      |                                                      ^~~
a.cc:38:22: error: 'struct DLLNode' has no member named 'add'
   38 |         if (list[n1].add->left != NULL)
      |                      ^~~
a.cc:39:26: error: 'struct DLLNode' has no member named 'add'
   39 |                 list[n1].add->left->right = list[n1].add->right;
      |                          ^~~
a.cc:39:54: error: 'struct DLLNode' has no member named 'add'
   39 |                 list[n1].add->left->right = list[n1].add->right;
      |                                                      ^~~
a.cc:40:18: error: 'struct DLLNode' has no member named 'add'
   40 |         list[n1].add->right = list[n2].add;
      |                  ^~~
a.cc:40:40: error: 'struct DLLNode' has no member named 'add'
   40 |         list[n1].add->right = list[n2].add;
      |                                        ^~~
a.cc:41:18: error: 'struct DLLNode' has no member named 'add'
   41 |         list[n1].add->left = list[n2].add->left;
      |                  ^~~
a.cc:41:39: error: 'struct DLLNode' has no member named 'add'
   41 |         list[n1].add->left = list[n2].add->left;
      |                                       ^~~
a.cc:42:22: error: 'struct DLLNode' has no member named 'add'
   42 |         if (list[n2].add->left != NULL)
      |                      ^~~
a.cc:43:26: error: 'struct DLLNode' has no member named 'add'
   43 |                 list[n2].add->left->right = list[n1].add;
      |                          ^~~
a.cc:43:54: error: 'struct DLLNode' has no member named 'add'
   43 |                 list[n2].add->left->right = list[n1].add;
      |                                                      ^~~
a.cc:44:18: error: 'struct DLLNode' has no member named 'add'
   44 |         list[n2].add->left = list[n1].add;
      |                  ^~~
a.cc:44:39: error: 'struct DLLNode' has no member named 'add'
   44 |         list[n2].add->left = list[n1].add;
      |                                       ^~~
a.cc: In function 'void pushback(DLLNode**, DLLNode**, int, int)':
a.cc:48:31: error: 'struct DLLNode' has no member named 'add'
   48 |         if (*head == list[n1].add && list[n1].add->right != NULL)
      |                               ^~~
a.cc:48:47: error: 'struct DLLNode' has no member named 'add'
   48 |         if (*head == list[n1].add && list[n1].add->right != NULL)
      |                                               ^~~
a.cc:49:34: error: 'struct DLLNode' has no member named 'add'
   49 |                 *head = list[n1].add->right;
      |                                  ^~~
a.cc:50:31: error: 'struct DLLNode' has no member named 'add'
   50 |         if (*tail == list[n2].add)
      |                               ^~~
a.cc:51:34: error: 'struct DLLNode' has no member named 'add'
   51 |                 *tail = list[n1].add;
      |                                  ^~~
a.cc:52:22: error: 'struct DLLNode' has no member named 'add'
   52 |         if (list[n1].add->left != NULL)
      |                      ^~~
a.cc:53:26: error: 'struct DLLNode' has no member named 'add'
   53 |                 list[n1].add->left->right = list[n1].add->right;
      |                          ^~~
a.cc:53:54: error: 'struct DLLNode' has no member named 'add'
   53 |                 list[n1].add->left->right = list[n1].add->right;
      |                                                      ^~~
a.cc:54:22: error: 'struct DLLNode' has no member named 'add'
   54 |         if (list[n1].add->right != NULL)
      |                      ^~~
a.cc:55:26: error: 'struct DLLNode' has no member named 'add'
   55 |                 list[n1].add->right->left = list[n1].add->left;
      |                          ^~~
a.cc:55:54: error: 'struct DLLNode' has no member named 'add'
   55 |                 list[n1].add->right->left = list[n1].add->left;
      |                                                      ^~~
a.cc:56:18: error: 'struct DLLNode' has no member named 'add'
   56 |         list[n1].add->left = list[n2].add;
      |                  ^~~
a.cc:56:39: error: 'struct DLLNode' has no member named 'add'
   56 |         list[n1].add->left = list[n2].add;
      |                                       ^~~
a.cc:57:18: error: 'struct DLLNode' has no member named 'add'
   57 |         list[n1].add->right = list[n2].add->right;
      |                  ^~~
a.cc:57:40: error: 'struct DLLNode' has no member named 'add'
   57 |         list[n1].add->right = list[n2].add->right;
      |                                        ^~~
a.cc:58:22: error: 'struct DLLNode' has no member named 'add'
   58 |         if (list[n2].add->right != NULL)
      |                      ^~~
a.cc:59:26: error: 'struct DLLNode' has no member named 'add'
   59 |                 list[n2].add->right->left = list[n1].add;
      |                          ^~~
a.cc:59:54: error: 'struct DLLNode' has no member named 'add'
   59 |                 list[n2].add->right->left = list[n1].add;
      |                                                      ^~~
a.cc:60:18: error: 'struct DLLNode' has no member named 'add'
   60 |         list[n2].add->right = list[n1].add;
      |                  ^~~
a.cc:60:40: error: 'struct DLLNode' has no member named 'add'
   60 |         list[n2].add->right = list[n1].add;
      |                                        ^~~
a.cc: In function 'int main()':
a.cc:78:40: error: 'n' was not declared in this scope
   78 |                                 head = n;
      |                                        ^
a.cc:86:46: error: 'n' was not declared in this scope
   86 |                                 tmp->right = n;
      |                                              ^
a.cc:99:46: error: 'struct DLLNode' has no member named 'add'
   99 |                                 if (list[n2].add->left == list[n1].add){
      |                                              ^~~
a.cc:99:68: error: 'struct DLLNode' has no member named 'add'
   99 |                                 if (list[n2].add->left == list[n1].add){
      |                                                                    ^~~
a.cc:115:46: error: 'struct DLLNode' has no member named 'add'
  115 |                                 if (list[n2].add->right != list[n1].add)
      |                                              ^~~
a.cc:115:69: error: 'struct DLLNode' has no member named 'add'
  115 |                                 if (list[n2].add->right != list[n1].add)
      |                                                                     ^~~