Language: C++

#include<bits/stdc++.h>
using namespace std;

#define MOD (1000000007)
//Data-type
#define ui unsigned int
#define ll long long int

//print or debug
#define d(str) cerr<<#str<<" : "<<str<<'\n'
#define p(str) cerr<<#str
#define o(str) cerr<<str
#define wspc "\n\t "

//big data
#define mul(a,b) ((a%MOD)*(b%MOD))%MOD
#define sum(a,b) ((a%MOD)+(b%MOD))%MOD

//vector
#define pb(x) push_back(x)
#define pop emplace_back()
#define erase(v,x)  v.erase(v.begin()+x)
#define all(s) ((s).begin(),(s).end())

//Math
#define _pow(a,b) (power((ll)a,(ll)b))
#define pow2(n) (1LL<<n)
#define gcd(a,b) (__gcd(a,b))
#define lcm(a,b) ((a*b)/gcd(a,b))
#define log(n,b) (log(n)/log(b))
#define min(a,b) (a>b?b:a)
#define max(a,b) (a<b?b:a)
#define PI (2*acos(0.0))

//Loops
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define rloop(i,l,r) for(int i=r;i>l;i--)

//file-paths
#define inputfile "D:\\Dhruv\\Codes\\input.txt"
#define outputfile "D:\\Dhruv\\Codes\\output.txt"
#define debugfile "D:\\Dhruv\\Codes\\debug.txt"
#define testcasefile "D:\\Dhruv\\Codes\\testcase.txt"

//Bit-manipulation
#define setbit(x,n) x|=(1LL<<n)
#define clearbit(x,n) x&=~(1LL<<n)
#define givebit(x,n) (a&(1LL<<n)!=0)

//Other
#define fast ios_base::sync_with_stdio(0)
#define fill(a,b) memset(a,b,sizeof(a))
#define arr_sort(a,n) stable_sort(a,a+n)
#define _sort(a) stable_sort(a.begin(),a.end())
#define test int t=0;\
             cin>>t;\
             while(t--)

#define print(a) cout<<#a<<" : ";\
                 for(auto val : a)\
                     cerr<<val<<" ";\
                 wspc[0]

#define scan(a) for(auto &val : a)\
                        cin>>val;


template<typename T> 
void printList(initializer_list<T> list) 
{ 
    p(name : );
    for(auto value : list)
        cerr<<" "<<value;
    p(\n);
}


/*

template <typename T>
bool is_in(const T& v, std::initializer_list<T> list)
{
    return (find(begin(list),end(list),v)!=end(list));
}

template<typename T>
constexpr  bool is_in(T t, T v) {
  return t == v;
}

template<>
constexpr  bool is_in(const char* t, const char* v) {
  return std::strcmp(t,v);
}

template<typename T, typename... Args>
constexpr bool is_in(T t, T v, Args... args) {
  return  t==v || is_in(t,args...);
}

*/

int main()
{
   

    //p(Coding...\n);
    fast;
    int n,k;
    test
    {
        cin>>n>>k;
        vector<int> a(n);
        scan(a);

        int b1,b,c=0;
        rep(i,n)
        {
            b1=b=0;
            rep(j,n)
            {
                if(a[i]>a[j])
                    b1++;
            }
            loop(j,i+1,n)
            {
                if(a[i]>a[j])
                    b++;
            }
            c+=sum(mul(b,k) , mul(b1,mul(k,(k-1))/2);
        }
        cout<<c<<wspc[0];
    }
    return 0;
}

Compiler output:
a.cc:137:2: error: unterminated argument list invoking macro "sum"
  137 | }
      |  ^
a.cc: In function 'int main()':
a.cc:132:16: error: 'sum' was not declared in this scope
  132 |             c+=sum(mul(b,k) , mul(b1,mul(k,(k-1))/2);
      |                ^~~
a.cc:132:19: error: expected '}' at end of input
  132 |             c+=sum(mul(b,k) , mul(b1,mul(k,(k-1))/2);
      |                   ^
a.cc:120:9: note: to match this '{'
  120 |         {
      |         ^
a.cc:132:19: error: expected '}' at end of input
  132 |             c+=sum(mul(b,k) , mul(b1,mul(k,(k-1))/2);
      |                   ^
a.cc:113:5: note: to match this '{'
  113 |     {
      |     ^
a.cc:132:19: error: expected '}' at end of input
  132 |             c+=sum(mul(b,k) , mul(b1,mul(k,(k-1))/2);
      |                   ^
a.cc:106:1: note: to match this '{'
  106 | {
      | ^