Language: C++

#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=3000;
const int MAXSWAP=3000;
const int MOD=1000000007;
const int INV2=(MOD+1)/2;
void inc(int &a,int b) { if((a+=b)>=MOD) a-=MOD; }
int combine(int a,int b) { return (ll)(a+b)*INV2%MOD; }

int n,nswap;
int sval[MAXN];
int swapidx[MAXSWAP][2];

int pless[MAXN][MAXN];
int acopy[2][MAXN];
int bcopy[2][MAXN];

int solve() {
	REP(i,n) REP(j,n) pless[i][j]=sval[i]<sval[j]?1:0;
	REP(k,nswap) {
		int a=swapidx[k][0],b=swapidx[k][1];
		REP(i,n) acopy[0][i]=pless[a][i],acopy[1][i]=pless[i][a];
		REP(i,n) bcopy[0][i]=pless[b][i],bcopy[1][i]=pless[i][b];
		pless[a][b]=pless[b][a]=combine(acopy[0][b],bcopy[0][a]);
		REP(j,n) if(j!=a&&j!=b) pless[a][j]=pless[b][j]=combine(acopy[0][j],bcopy[0][j]);
		REP(i,n) if(i!=a&&i!=b) pless[i][a]=pless[i][b]=combine(acopy[1][i],bcopy[1][i]);
	}
	int ret=0; REP(i,n) FOR(j,i+1,n) inc(ret,pless[j][i]); REP(i,nswap) ret=(ll)ret*2%MOD; return ret;
}

void run() {
	scanf("%d%d",&n,&nswap);
	REP(i,n) scanf("%d",&sval[i]);
	REP(i,nswap) REP(j,2) scanf("%d",&swapidx[i][j]),--swapidx[i][j];
	printf("%d\n",solve());
}

int main() {
	run();
	return 0;
}


Compiler output:
a.cc:46:18: error: 'int bcopy [2][3000]' redeclared as different kind of entity
   46 | int bcopy[2][MAXN];
      |                  ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from a.cc:5:
/usr/include/strings.h:38:13: note: previous declaration 'void bcopy(const void*, void*, size_t)'
   38 | extern void bcopy (const void *__src, void *__dest, size_t __n)
      |             ^~~~~
a.cc: In function 'int solve()':
a.cc:53:33: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   53 |                 REP(i,n) bcopy[0][i]=pless[b][i],bcopy[1][i]=pless[i][b];
      |                                 ^
a.cc:53:36: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   53 |                 REP(i,n) bcopy[0][i]=pless[b][i],bcopy[1][i]=pless[i][b];
      |                                    ^
a.cc:53:37: error: assignment of read-only location '*(bcopy + ((sizetype)i))'
   53 |                 REP(i,n) bcopy[0][i]=pless[b][i],bcopy[1][i]=pless[i][b];
      |                          ~~~~~~~~~~~^~~~~~~~~~~~
a.cc:53:57: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   53 |                 REP(i,n) bcopy[0][i]=pless[b][i],bcopy[1][i]=pless[i][b];
      |                                                         ^
a.cc:53:60: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   53 |                 REP(i,n) bcopy[0][i]=pless[b][i],bcopy[1][i]=pless[i][b];
      |                                                            ^
a.cc:53:61: error: assignment of read-only location '*(bcopy + (((sizetype)i) + 1))'
   53 |                 REP(i,n) bcopy[0][i]=pless[b][i],bcopy[1][i]=pless[i][b];
      |                                                  ~~~~~~~~~~~^~~~~~~~~~~~
a.cc:54:68: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   54 |                 pless[a][b]=pless[b][a]=combine(acopy[0][b],bcopy[0][a]);
      |                                                                    ^
a.cc:54:71: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   54 |                 pless[a][b]=pless[b][a]=combine(acopy[0][b],bcopy[0][a]);
      |                                                                       ^
a.cc:54:71: error: invalid conversion from 'void (*)(const void*, void*, size_t) noexcept' {aka 'void (*)(const void*, void*, long unsigned int) noexcept'} to 'int' [-fpermissive]
   54 |                 pless[a][b]=pless[b][a]=combine(acopy[0][b],bcopy[0][a]);
      |                                                             ~~~~~~~~~~^
      |                                                                       |
      |                                                                       void (*)(const void*, void*, size_t) noexcept {aka void (*)(const void*, void*, long unsigned int) noexcept}
a.cc:38:23: note:   initializing argument 2 of 'int combine(int, int)'
   38 | int combine(int a,int b) { return (ll)(a+b)*INV2%MOD; }
      |                   ~~~~^
a.cc:55:92: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   55 |                 REP(j,n) if(j!=a&&j!=b) pless[a][j]=pless[b][j]=combine(acopy[0][j],bcopy[0][j]);
      |                                                                                            ^
a.cc:55:95: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   55 |                 REP(j,n) if(j!=a&&j!=b) pless[a][j]=pless[b][j]=combine(acopy[0][j],bcopy[0][j]);
      |                                                                                               ^
a.cc:55:95: error: invalid conversion from 'void (*)(const void*, void*, size_t) noexcept' {aka 'void (*)(const void*, void*, long unsigned int) noexcept'} to 'int' [-fpermissive]
   55 |                 REP(j,n) if(j!=a&&j!=b) pless[a][j]=pless[b][j]=combine(acopy[0][j],bcopy[0][j]);
      |                                                                                     ~~~~~~~~~~^
      |                                                                                               |
      |                                                                                               void (*)(const void*, void*, size_t) noexcept {aka void (*)(const void*, void*, long unsigned int) noexcept}
a.cc:38:23: note:   initializing argument 2 of 'int combine(int, int)'
   38 | int combine(int a,int b) { return (ll)(a+b)*INV2%MOD; }
      |                   ~~~~^
a.cc:56:92: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   56 |                 REP(i,n) if(i!=a&&i!=b) pless[i][a]=pless[i][b]=combine(acopy[1][i],bcopy[1][i]);
      |                                                                                            ^
a.cc:56:95: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   56 |                 REP(i,n) if(i!=a&&i!=b) pless[i][a]=pless[i][b]=combine(acopy[1][i],bcopy[1][i]);
      |                                                                                               ^
a.cc:56:95: error: invalid conversion from 'void (*)(const void*, void*, size_t) noexcept' {aka 'void (*)(const void*, void*, long unsigned int) noexcept'} to 'int' [-fpermissive]
   56 |                 REP(i,n) if(i!=a&&i!=b) pless[i][a]=pless[i][b]=combine(acopy[1][i],bcopy[1][i]);
      |                                                                                     ~~~~~~~~~~^
      |                                                                                               |
      |                                                                                               void (*)(const void*, void*, size_t) noexcept {aka void (*)(const void*, void*, long unsigned int) noexcept}
a.cc:38:23: note:   initializing argument 2 of 'int combine(int, int)'
   38 | int combine(int a,int b) { return (ll)(a+b)*INV2%MOD; }
      |                   ~~~~^