Language: C++

#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif
 
#define forn(i,k,n) for(ll i=(k); i<(n); i++)
 
const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)
 
#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }
 
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;
 
void solve() {
	cini(k);
	cini(n);
	vi a(n);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
 
	int ma = 0;
	int prev = 0;
	for (int i = 0; i < n; i++) {
		ma = max(ma, abs(prev - a[i]));
		prev = a[i];
	}
 
	ma = max(ma, k - a.back() + a[0]);
 
	ll ans = k - ma;
	cout << ans << endl;
 
}
 
int main() {
	cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	solve();
}
 

Compiler output:
a.cc:3:2: error: #else without #if
    3 | #else
      |  ^~~~
a.cc:4:9: warning: "log" redefined
    4 | #define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
      |         ^~~
a.cc:2:9: note: this is the location of the previous definition
    2 | #define log(args...)
      |         ^~~
a.cc:12:2: error: #endif without #if
   12 | #endif
      |  ^~~~~
a.cc:5:6: error: variable or field 'logf' declared void
    5 | void logf(istream_iterator<string> it) {
      |      ^~~~
a.cc:5:11: error: 'istream_iterator' was not declared in this scope
    5 | void logf(istream_iterator<string> it) {
      |           ^~~~~~~~~~~~~~~~
a.cc:5:28: error: 'string' was not declared in this scope
    5 | void logf(istream_iterator<string> it) {
      |                            ^~~~~~
a.cc:5:36: error: 'it' was not declared in this scope; did you mean 'int'?
    5 | void logf(istream_iterator<string> it) {
      |                                    ^~
      |                                    int
a.cc:8:6: error: variable or field 'logf' declared void
    8 | void logf(istream_iterator<string> it, T a, Args ... args) {
      |      ^~~~
a.cc:8:11: error: 'istream_iterator' was not declared in this scope
    8 | void logf(istream_iterator<string> it, T a, Args ... args) {
      |           ^~~~~~~~~~~~~~~~
a.cc:8:28: error: 'string' was not declared in this scope
    8 | void logf(istream_iterator<string> it, T a, Args ... args) {
      |                            ^~~~~~
a.cc:8:36: error: 'it' was not declared in this scope; did you mean 'int'?
    8 | void logf(istream_iterator<string> it, T a, Args ... args) {
      |                                    ^~
      |                                    int
a.cc:8:42: error: expected primary-expression before 'a'
    8 | void logf(istream_iterator<string> it, T a, Args ... args) {
      |                                          ^
a.cc:8:50: error: expected primary-expression before '...' token
    8 | void logf(istream_iterator<string> it, T a, Args ... args) {
      |                                                  ^~~
a.cc:16:19: error: 'acos' was not declared in this scope
   16 | const double PI = acos(-1);
      |                   ^~~~
a.cc:29:9: error: 'pair' does not name a type
   29 | typedef pair<int, int> pii;
      |         ^~~~
a.cc:30:9: error: 'pair' does not name a type
   30 | typedef pair<double, double> pdd;
      |         ^~~~
a.cc:31:9: error: 'vector' does not name a type
   31 | typedef vector<double> vd;
      |         ^~~~~~
a.cc:32:9: error: 'vector' does not name a type
   32 | typedef vector<bool> vb;
      |         ^~~~~~
a.cc:33:9: error: 'vector' does not name a type
   33 | typedef vector<int> vi;
      |         ^~~~~~
a.cc:34:9: error: 'vector' does not name a type
   34 | typedef vector<vi> vvi;
      |         ^~~~~~
a.cc:35:9: error: 'vector' does not name a type
   35 | typedef vector<vvi> vvvi;
      |         ^~~~~~
a.cc:36:9: error: 'vector' does not name a type
   36 | typedef vector<string> vs;
      |         ^~~~~~
a.cc:37:9: error: 'vector' does not name a type
   37 | typedef vector<ll> vll;
      |         ^~~~~~
a.cc: In function 'void solve()':
a.cc:21:24: error: 'cin' was not declared in this scope; did you mean 'cind'?
   21 | #define cini(i) int i; cin>>i;
      |                        ^~~
a.cc:40:9: note: in expansion of macro 'cini'
   40 |         cini(k);
      |         ^~~~
a.cc:42:9: error: 'vi' was not declared in this scope
   42 |         vi a(n);
      |         ^~
a.cc:45:24: error: 'a' was not declared in this scope
   45 |                 cin >> a[i];
      |                        ^
a.cc:52:41: error: 'a' was not declared in this scope
   52 |                 ma = max(ma, abs(prev - a[i]));
      |                                         ^
a.cc:52:30: error: 'abs' was not declared in this scope
   52 |                 ma = max(ma, abs(prev - a[i]));
      |                              ^~~
a.cc:52:22: error: 'max' was not declared in this scope; did you mean 'ma'?
   52 |                 ma = max(ma, abs(prev - a[i]));
      |                      ^~~
      |                      ma
a.cc:56:26: error: 'a' was not declared in this scope; did you mean 'ma'?
   56 |         ma = max(ma, k - a.back() + a[0]);
      |                          ^
      |                          ma
a.cc:56:14: error: 'max' was not declared in this scope; did you mean 'ma'?
   56 |         ma = max(ma, k - a.back() + a[0]);
      |              ^~~
      |              ma
a.cc:59:9: error: 'cout' was not declared in this scope
   59 |         cout << ans << endl;
      |         ^~~~
a.cc: In function 'int main()':
a.cc:64:9: error: 'cin' was not declared in this scope; did you mean 'cind'?
   64 |         cin.tie(nullptr);
      |         ^~~
      |         cind
a.cc:65:14: error: 'std::ios' has not been declared
   65 |         std::ios::sync_with_stdio(false);
      |              ^~~