Language: C++

//VS2015エラー回避用
#define _CRT_SECURE_NO_WARNINGS 0 
//include
#include<stdio.h>
#include<stdlib.h>
//関数プロトタイプ宣言
void probremA(void);
void probremB(void);
void probremC(void);
void probremD(void);

//メイン関数
int main(void) {
	//A問題
	//probremA();

	//B問題
	probremB();

	//C問題
	//probremC();

	//D問題
	//probremD();

//	getchar();
//	getchar();
	//終了
	return 0;
}
//A問題
void probremA(void) {
	
	char s[1001];	//入力文字列
	int pos[4] = {0,0,0,0};		//場所：N,S,E,W
	int count = 0;	//ループ用カウンタ
	//入力処理
	scanf("%s", s);

	//個数の計算
	while(s[count]!='\0') {
		//
		if (s[count] == 'N') {
			pos[0]=1;
		}else if (s[count] == 'S') {
			pos[1]=1;
		}else if (s[count] == 'E') {
			pos[2]=1;
		}else if (s[count] == 'W') {
			pos[3]=1;
		}
		//カウンタを増やす
		count++;
	}
	//出力処理
	if (pos[0] == 1 && pos[1] == 1 && pos[2] == 1 && pos[3] == 1) {
		printf("Yes");
	}else if (pos[0] == 1 && pos[1] == 1 && pos[2] == 0 && pos[3] == 0) {
		printf("Yes");
	}else if (pos[0] == 0 && pos[1] == 0 && pos[2] == 1 && pos[3] == 1) {
		printf("Yes");
	}else {
		printf("No");
	}
	
	return;
}
//B問題
void probremB(void) {
	long n = 0;
	long *a;
	long pairs=0;
	//入力処理
	scanf("%d", &n);
	//メモリ確保
	a = (long*)malloc(sizeof(long)*n);
	//入力処理2
	long* lp;
	lp = a;
	for (long i = 0; i < n; i++) {
		scanf("%ld", lp);
		lp++;
	}


	//計算過程
	if (n >= 2) {
		if (a[0] > 0 && a[1] > 0) {
			long temp = 0;
			temp = a[0] <= a[1] ? a[0] : a[1];
			pairs += temp;
			a[0] -= temp;
			a[1] -= temp;
		}
		if (a[0] > 0) {
			long temp = 0;
			temp = a[0] / 2;
			pairs += temp;
			a[0] -= temp*2;
		}
		for (long i = 1; i < n - 1; i++) {
			if (a[i - 1] > 0 && a[i] > 0) {
				long temp = 0;
				temp = a[i - 1] <= a[i] ? a[i - 1] : a[i];
				pairs += temp;
				a[i - 1] -= temp;
				a[i] -= temp;
			}
			if (a[i + 1] > 0 && a[i] > 0) {
				long temp = 0;
				temp = a[i + 1] <= a[i] ? a[i + 1] : a[i];
				pairs += temp;
				a[i + 1] -= temp;
				a[i] -= temp;
			}
			if (a[i] > 0) {
				long temp = 0;
				temp = a[i] / 2;
				pairs += temp;
				a[i] -= temp*2;
			}
		}
		if (a[n - 1] > 0 && a[n - 2] > 0) {
			long temp = 0;
			temp = a[n - 2] <= a[n - 1] ? a[n - 2] : a[n - 1];
			pairs += temp;
			a[n - 2] -= temp;
			a[n - 1] -= temp;
		}
		if (a[n - 1] > 0) {
			long temp = 0;
			temp = a[n - 1] / 2;
			pairs += temp;
			a[n - 1] -= temp*2;
		}	
	}
	//サイズが1の時
	else {
		pairs = (long)(a[0] / 2);
	}
	//出力処理
	printf("%ld", pairs);
	//メモリ開放
	free(a);
	//終了
	return;
}
//C問題
void probremC(void) {
	long n = 0;
	long *a;
	long ope1 = 0;
	//入力処理
	scanf("%d", &n);
	//メモリ確保
	a = (long*)malloc(sizeof(long)*n);
	//入力処理2
	long* lp;
	lp = a;
	for (long i = 0; i < n; i++) {
		scanf("%ld", lp);
		lp++;
	}

	//出力処理
	printf("%ld", pairs);
	//メモリ開放
	free(ope1);
	//終了
	return;
}
//D問題
void probremD(void) {
	return;
}


Compiler output:
a.cc: In function 'void probremC()':
a.cc:166:23: error: 'pairs' was not declared in this scope
  166 |         printf("%ld", pairs);
      |                       ^~~~~
a.cc:168:14: error: invalid conversion from 'long int' to 'void*' [-fpermissive]
  168 |         free(ope1);
      |              ^~~~
      |              |
      |              long int
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/stdlib.h:36,
                 from a.cc:5:
/usr/include/stdlib.h:687:25: note:   initializing argument 1 of 'void free(void*)'
  687 | extern void free (void *__ptr) __THROW;
      |                   ~~~~~~^~~~~