criyle/codenet-compile-errors huggingface dataset:
Language: C

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(int argc, char const *argv[])
{
	int N,K;
	scanf("%d %d",&N,&K);
	int *A=(int*)malloc(N*sizeof(int));
	for(int i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	int count=0;
	int number=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if (A[i]>A[j])
			{
				count++;
				if(j<i) number++;
			}
		}
	}
	printf("%d",((count*K*(K+1)/2)-number*K)%(pow(10,9)+7));
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:23:49: error: invalid operands to binary % (have 'int' and 'double')
   23 |         printf("%d",((count*K*(K+1)/2)-number*K)%(pow(10,9)+7));
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
      |                                       |                    |
      |                                       int                  double
Language: C

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(int argc, char const *argv[])
{
	int N,K;
	scanf("%d %d",&N,&K);
	int *A=(int*)malloc(N*sizeof(int));
	for(int i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	int A[2]={2,1};
	int count=0;
	int number=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if (A[i]>A[j])
			{
				count++;
				if(j<i) number++;
			}
		}
	}
	printf("%d",((count*K*(K+1)/2)-number*K)%(pow(10,9)+7));
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:12:13: error: conflicting types for 'A'; have 'int[2]'
   12 |         int A[2]={2,1};
      |             ^
main.c:8:14: note: previous definition of 'A' with type 'int *'
    8 |         int *A=(int*)malloc(N*sizeof(int));
      |              ^
main.c:24:49: error: invalid operands to binary % (have 'int' and 'double')
   24 |         printf("%d",((count*K*(K+1)/2)-number*K)%(pow(10,9)+7));
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
      |                                       |                    |
      |                                       int                  double
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ll long long

int main() {
	ll N, K;
	cin >> N >> K;

	vector<ll> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	ll count1 = 0, count2 = 0;

	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			if (A[i] > A[j]) count1++;
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (A[i] > A[j]) count2++;
		}
	}

  ll ans = 0;
  ll temp = 1e9 + 7;
  ans = (K - 1) * K) / 2;
  ans %= temp;
  ans *= count2;
  ans %= temp;
  ans += count1 * K;
  ans %= temp;
  cout << ans << endl;


}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:20: error: expected ';' before ')' token
   32 |   ans = (K - 1) * K) / 2;
      |                    ^
      |                    ;
Language: C++

#include<iostream>
long n,k,a,i,j,m=1e9+7,v[];main(){for(std::cin>>n>>k;i++<n;)for(j=0;j++<n;v[i]>v[j]?(a+=k*(k-1)/2+(i<j)*k)%=m:0)i-1||std::cin>>v[j];std::cout<<a;}

Compiler output:
a.cc:2:24: error: storage size of 'v' isn't known
    2 | long n,k,a,i,j,m=1e9+7,v[];main(){for(std::cin>>n>>k;i++<n;)for(j=0;j++<n;v[i]>v[j]?(a+=k*(k-1)/2+(i<j)*k)%=m:0)i-1||std::cin>>v[j];std::cout<<a;}
      |                        ^
a.cc:2:28: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    2 | long n,k,a,i,j,m=1e9+7,v[];main(){for(std::cin>>n>>k;i++<n;)for(j=0;j++<n;v[i]>v[j]?(a+=k*(k-1)/2+(i<j)*k)%=m:0)i-1||std::cin>>v[j];std::cout<<a;}
      |                            ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll n;
    ll k;
    cin >> n >> k;
    ll a[2005];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll c1 = 0;
    ll c2 = 0;
    for (int i = 0; i < n - 1; i++){
        for (int j = i + 1; j < n; j++){
            if (a[i] > a[j]) c1++;
        }
    }
    
    for (int i = 0; i < n;i++){
        for (int g = 0; g < n;g++){
            if (a[i] > a[g]) c2++;
        }
    }
    ll c = 1000000007;
    cout << ((c1*k) + (((k*(k-1)/2%c*c2)))%c << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:46: error: invalid operands of types 'll' {aka 'long long int'} and '<unresolved overloaded function type>' to binary 'operator<<'
   26 |     cout << ((c1*k) + (((k*(k-1)/2%c*c2)))%c << endl;
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
a.cc:26:53: error: expected ')' before ';' token
   26 |     cout << ((c1*k) + (((k*(k-1)/2%c*c2)))%c << endl;
      |             ~                                       ^
      |                                                     )
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    long long k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long c1 = 0;
    long long c2 = 0;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            if (a[i] > a[j]) c1++;
        }
        for (int g = 0; g < n;g++){
            if (a[i] > a[g]) c2++;
        }
    }
    long long mod = 1000000007;
    cout << (c1*k%c + k*(k-1)%mod*c2%c/2)%mod << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:19: error: 'c' was not declared in this scope; did you mean 'c2'?
   22 |     cout << (c1*k%c + k*(k-1)%mod*c2%c/2)%mod << endl;
      |                   ^
      |                   c2
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1000000007
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll a[4444];
ll cnt[2222];
ll memo[2222];
signed main() {
	ll n, k, ans = 0;
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			if (a[i] > a[j])memo[a[i]]++;
		}
	}
	rep(i, n) {
		rep(j, n) {
			if (a[i] > a[j])cnt[a[i]]++;
		}
	}
	rep(i, 2001) {
		ans += (((memo[i] % inf) * (k % inf)) % inf + ((cnt[i] % inf) * (((k - 1)* k / 2) % inf)) %inf)
	}
	cout << ans % inf << endl;
	ggr
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:112: error: expected ';' before '}' token
   52 |                 ans += (((memo[i] % inf) * (k % inf)) % inf + ((cnt[i] % inf) * (((k - 1)* k / 2) % inf)) %inf)
      |                                                                                                                ^
      |                                                                                                                ;
   53 |         }
      |         ~
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1000000007
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll a[4444];
ll cnt[2222];
ll memo[2222];
signed main() {
	ll n, k, ans = 0;
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			if (a[i] > a[j])memo[a[i]]++;
		}
	}
	rep(i, n) {
		rep(j, n) {
			if (a[i] > a[j])cnt[a[i]]++;
		}
	}
	rep(i, 2001) {
		ans += (memo[i] * k % inf + cnt[i] * (k - 1) * k/2 % inf)) % inf;
		ans %= inf;
	}
	cout << ans % inf << endl;
	ggr
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:74: error: expected ';' before ')' token
   52 |                 ans += (memo[i] * k % inf + cnt[i] * (k - 1) * k/2 % inf)) % inf;
      |                                                                          ^
      |                                                                          ;
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int rest=1000000007;
int main(){
int n,k;
cin>>n>>k;
vector<int> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
long long sum=0;
for(int i=1;i<n;i++){
for(j=0;j<i;j++){
if(a[n-1-i]>a[n-1-j]) sum++;
}
}
long long tmp;
tmp=(k-1)*k/2;
tmp%=rest;
tmp=tmp*n*(n-1)/2;
tmp%=rest;
long long ans;
ans=sum*k+tmp;
ans%=rest;
cout<<ans<<endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:5: error: 'j' was not declared in this scope
   14 | for(j=0;j<i;j++){
      |     ^
Language: C++

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> B(N);
    long long ans1 = 0;
    long long ans2 = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> B[i];
    }
    for (int i = 0; i < N - 1; ++i)
    {
        for (int j = i + 1; j < N; j++)
        {
            if (B[i] > B[j])
            {
                ans1++;
            }
        }
    }

    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            if (B[i] < B[j])
            {
                ans2++;
            }
        }
    }
    long long md = (long long)(1e9 + 7);
    //cout << ans1 << ans2 << endl;
    long long ans = K + ans1 % md;
    ans += ans2 * (K * (K - 1) / 2) % md);
    ans %= md;
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:41: error: expected ';' before ')' token
   39 |     ans += ans2 * (K * (K - 1) / 2) % md);
      |                                         ^
      |                                         ;
Language: C++

#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <limits>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int INF = LLONG_MAX/3;
const int MOD = 1000000007;
signed main(){
    int n,k;
    cin>>n>>k;
    int a[2000];
    for(int i=0;i<n;i++)cin>>a[i];
    int s=k*(k+1)/2%MOD;
    int ans=0;
    for(int i=0;i<n;i++){
        int cnta=0;
        int cntal=0;
        for(int j=0;j<n;j++){
            if(i==j)continue;
            else if(j<i){
                if(a[j]<a[i]){
                    cnta++;
                    cntal++;
                }
            }else{
            if(a[j]<a[i]){
                    cntal++;
                }
            }
        }
        ans+=cntal*s%MOD-cnta*k;
        if(ans<0)ans+=MOD;
        ans%=MOD;
    }
    if(ans<0)ans+=MOD;
    cout<<ans<<endl;
    return 0;
}



Compiler output:
a.cc:21:17: error: 'LLONG_MAX' was not declared in this scope
   21 | const int INF = LLONG_MAX/3;
      |                 ^~~~~~~~~
a.cc:15:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   14 | #include <unordered_map>
  +++ |+#include <climits>
   15 | #include <limits>
Language: C

#include<stdio.h>
int main(){
  int N,K;
    scanf("%d %d",&N,&K);
    int A[N];
  int B[N*K];
  for(int i=0;i<N;i++){ 
    sncaf("%d",A[i]);
    for(int k=0;k<K;k++){
      B[i+k*N] = A[i]:
    }
  }
  
  int ans;
  for(int i=0;i<N*K;i++){
    for(int j=i;j<N*K;j++){
      if(B[i]>B[j]) ans++;
    }
  }
  
  printf("%d",ans);
  
 return 0; 
}

Compiler output:
main.c: In function 'main':
main.c:8:5: error: implicit declaration of function 'sncaf'; did you mean 'sscanf'? [-Wimplicit-function-declaration]
    8 |     sncaf("%d",A[i]);
      |     ^~~~~
      |     sscanf
main.c:10:22: error: expected ';' before ':' token
   10 |       B[i+k*N] = A[i]:
      |                      ^
      |                      ;
Language: C++

#include <vector>
#define ll long long
using namespace std;
 
ll mod=1000000007;
 
int main() {
	ll N, K;
	cin >> N >> K;
	vector<int> a(N);
	for(int i=0; i<N; ++i) cin >> a[i];
	ll ans=0, sum=(K*(K-1)/2)%mod;
	for(int i=0; i<N; ++i){
	    ll bef=0, aft=0;
	    for(int j=0; j<N; ++j){
	        if(a[i]>a[j]){
	            if(j<i) ++bef;
	            else ++aft;
	        }
	    }
	    ans=(ans+(aft*K)%mod+((bef+aft)*sum)%mod)%mod;
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'cin' was not declared in this scope
    9 |         cin >> N >> K;
      |         ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <vector>
  +++ |+#include <iostream>
    2 | #define ll long long
a.cc:23:9: error: 'cout' was not declared in this scope
   23 |         cout << ans << endl;
      |         ^~~~
a.cc:23:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:23:24: error: 'endl' was not declared in this scope
   23 |         cout << ans << endl;
      |                        ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include <vector>
  +++ |+#include <ostream>
    2 | #define ll long long
Language: C++

#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
using namespace std;
const ll MOD = 1e9 + 7

long long modinv(long long a){//a ÷ b mod. MOD の求め方 : a * modinv(b) % MOD
    long long b = MOD, u = 1, v = 0;
    while(b){
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if(u < 0) u += MOD;
    return u;
}
 
int main(){
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	int counta = 0;
	int countb = 0;
	for(int i=0;i<n;i++){
		cin >> p.at(i);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(p.at(i) > p.at(j)){
				counta++;
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(p.at(i) > p.at(j)){
				countb++;
			}
		}
	}
	long long int ans1 = (k % MOD*(k-1) % MOD * modinv(2))%1000000007;
	long long int ans2 = counta * ans1;
	long long int ans3 = countb*k%1000000007;
	long long int ans = (ans2 + ans3)%1000000007;
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc:7:7: error: 'll' does not name a type
    7 | const ll MOD = 1e9 + 7
      |       ^~
a.cc: In function 'int main()':
a.cc:46:35: error: 'MOD' was not declared in this scope
   46 |         long long int ans1 = (k % MOD*(k-1) % MOD * modinv(2))%1000000007;
      |                                   ^~~
a.cc:46:53: error: 'modinv' was not declared in this scope
   46 |         long long int ans1 = (k % MOD*(k-1) % MOD * modinv(2))%1000000007;
      |                                                     ^~~~~~
Language: C++

#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
using namespace std;
const ll MOD = 1e9 + 7;

long long modinv(long long a){//a ÷ b mod. MOD の求め方 : a * modinv(b) % MOD
    long long b = MOD, u = 1, v = 0;
    while(b){
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if(u < 0) u += MOD;
    return u;
}
 
int main(){
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	int counta = 0;
	int countb = 0;
	for(int i=0;i<n;i++){
		cin >> p.at(i);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(p.at(i) > p.at(j)){
				counta++;
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(p.at(i) > p.at(j)){
				countb++;
			}
		}
	}
	long long int ans1 = (k % MOD*(k-1) % MOD * modinv(2))%1000000007;
	long long int ans2 = counta * ans1;
	long long int ans3 = countb*k%1000000007;
	long long int ans = (ans2 + ans3)%1000000007;
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc:7:7: error: 'll' does not name a type
    7 | const ll MOD = 1e9 + 7;
      |       ^~
a.cc: In function 'long long int modinv(long long int)':
a.cc:10:19: error: 'MOD' was not declared in this scope
   10 |     long long b = MOD, u = 1, v = 0;
      |                   ^~~
a.cc:15:9: error: 'u' was not declared in this scope
   15 |         u -= t * v;
      |         ^
a.cc:15:18: error: 'v' was not declared in this scope
   15 |         u -= t * v;
      |                  ^
a.cc:18:5: error: 'u' was not declared in this scope
   18 |     u %= MOD;
      |     ^
a.cc: In function 'int main()':
a.cc:46:35: error: 'MOD' was not declared in this scope
   46 |         long long int ans1 = (k % MOD*(k-1) % MOD * modinv(2))%1000000007;
      |                                   ^~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
using It = vector<int>::iterator;
using ll = long long;

int const M = 1e9 + 7;

int merge(It b, It e, It w) {
  It mid = next(b, distance(b, e) / 2);
  It in1 = b;
  It in2 = mid;
  It out = w;
  int r = 0;
  while(in1 != mid && in2 != e) {
      if (*in1 <= *in2) {
          *out++ = *in1++;
      }
      else {
          r += distance(in1, mid);
          *out++ = *in2++;
      }
  }
  copy(in1, mid, prev(e, distance(in1, mid)));
  copy(w, out, b);
  return r;
}
         
int mergesort(It b, It e, It w) {
    auto d = distance(b, e);
    if (d < 2)
        return 0;
    It mid = next(b, d / 2);
    return mergesort(b, mid, w) + mergesort(mid, e, w) + merge(b, e, w);
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    int k;
    cin >> n >> k;
    vector<int> a(n), temp(n);
    for (int& x : a) {
        cin >> x;
    }
    int r = mergesort(begin(a), end(a), begin(temp));
    int p = 0, c = n * (n - 1) / 2 , l = 1;
    for (int x : a) {
        if (x == p) {
            l++;
        }
        else {
            c -= l * (l - 1) / 2;
            p = x;
            l = 1;
        }
    }
    cout << ((ll)r * k + (ll)k * (k - 1) / 2 % M * (c - l * (l - 1) / 2) % M << '\n';
    return 0;
}
             

Compiler output:
a.cc: In function 'int main()':
a.cc:61:85: error: expected ')' before ';' token
   61 |     cout << ((ll)r * k + (ll)k * (k - 1) / 2 % M * (c - l * (l - 1) / 2) % M << '\n';
      |             ~                                                                       ^
      |                                                                                     )
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
using It = vector<int>::iterator;
using ll = long long;

int const M = 1e9 + 7;

int merge(It b, It e, It w) {
  It mid = next(b, distance(b, e) / 2);
  It in1 = b;
  It in2 = mid;
  It out = w;
  int r = 0;
  while(in1 != mid && in2 != e) {
	  if (*in1 <= *in2) {
		  *out++ = *in1++;
	  }
	  else {
		  r += distance(in1, mid);
		  *out++ = *in2++;
	  }
  }
  copy(in1, mid, prev(e, distance(in1, mid)));
  copy(w, out, b);
  return r;
}
         
int mergesort(It b, It e, It w) {
	auto d = distance(b, e);
	if (d < 2)
		return 0;
    It mid = next(b, d / 2);
    return mergesort(b, mid, w) + mergesort(mid, e, w) + merge(b, e, w);
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	int k;
	cin >> n >> k;
	vector<int> a(n), temp(n);
	for (int& x : a) {
		cin >> x;
	}
    int r = mergesort(begin(a), end(a), begin(temp));
	int p = 0, c = n * (n - 1) / 2 , l = 1;
	for (int x : a) {
		if (x == p) {
			l++;
		}
		else {
			c -= l * (l - 1) / 2;
			p = x;
			l = 1;
		}
	}
    c -= l * (l - 1) // 2
	cout << ((ll)r * k + (ll)k * (k - 1) / 2 % M * c) % M << '\n';
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:21: error: expected ';' before 'cout'
   61 |     c -= l * (l - 1) // 2
      |                     ^
      |                     ;
   62 |         cout << ((ll)r * k + (ll)k * (k - 1) / 2 % M * c) % M << '\n';
      |         ~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 1000000007;
ll add(ll k)
{
    return (k * (k + 1) / 2) % mod;
}

ll main()
{
    ll n, k, ans = 0;
    cin >> n >> k;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    rep(i,n)
    {
        rep(j,n)
        {
            if (i == j)
                continue;

            if (v[i] > v[j])
            {
                if (i < j)
                {
                    (ans += add(k))%=mod;
                }
                else
                {
                    (ans += add(k - 1))%=mod;
                }
            }
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc:11:1: error: '::main' must return 'int'
   11 | ll main()
      | ^~
Language: C++

#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;
const long long MOD = 1000000007;
long long A[2000];
map <long long, long long> smaller_num;
int main(){
    int N;
    long long K;
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    long long flip_no_one = 0;
    for(int i = 0; i < N - 1; i++){
        for(int j = i + 1; j < N; j++){
            if(A[i] > A[j]){
                flip_no_one ++;
            }
        }
    }

    for(int i = 0; i < N; i++){
        if(smaller_num.find(A[i]) != smaller_num.end()){
            continue;
        }
        smaller_num[A[i]] = 0;
        for(int j = 0; j < N; j++){
            if(A[i] > A[j]){
                smaller_num[A[i]]++;
            }
        }
    }

S
    long long ans = (flip_no_one * K) % MOD;
    for(int i = 0; i < N; i++){
        long long tmp_times = ((K * (K - 1)) / 2) % MOD;
        long long tmp = (smaller_num[A[i]] * tmp_times) % MOD;
        ans = (ans + tmp) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:1: error: 'S' was not declared in this scope
   46 | S
      | ^
a.cc:51:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   51 |         ans = (ans + tmp) % MOD;
      |         ^~~
      |         abs
a.cc:53:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   53 |     cout << ans << endl;
      |             ^~~
      |             abs
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

typedef vector<int> vi;
ll mod = 1000000007;


int main(){
    ll n, l, m;
    ll k, ans = 0;
    cin >> n >> k;
    vi a(n);
    rep(i, n){
        cin >> a[i];
    }
    l = 0;
    m = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            if(a[i]>a[j]){
                l++;
                if(i<j){
                    m++;
                }
            }
        }
    }
    ans = (k * m ) % mod + k * l * (k-1) / 2) % mod;
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:45: error: expected ';' before ')' token
   30 |     ans = (k * m ) % mod + k * l * (k-1) / 2) % mod;
      |                                             ^
      |                                             ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N,K;
  cin>>N>>K;
  vector<ll>A(N);
  vector<ll>C(N);
  
  rep(i,N){
    cin>>A[i];
    C[i]=A[i];
    }
  ll ans=0;
  
  
  rep(i,N){//現在の回転範囲
    vector<ll>a(N-i);//a[i]の後のうちこれより小さいものの数
  
    for(ll j=i;j<N;j++){
     a.pusu_back(A[j]);
    }
    sort(all(a));
      
    ans+=(lower_bound(a.begin(),a.end(),A[i])-a.begin())*K;
  ans%=mod;
  }
  ll ans2=0;
 sort(all(C));//現在の後の場所
  rep(i,N){
 
 ans2+=(lower_bound(all(C),C[i])-C.begin())*K*(K-1)/2;
    ans2%=mod;
  }

  


  cout<<(ans+ans2)%mod<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:64:8: error: 'class std::vector<long long int>' has no member named 'pusu_back'; did you mean 'push_back'?
   64 |      a.pusu_back(A[j]);
      |        ^~~~~~~~~
      |        push_back
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

ll mod = 1000000007;


int main(){
    ll n, l, m;
    ll k, ans = 0;
    cin >> n >> k;
    vi a(n);
    rep(i, n){
        cin >> a[i];
    }
    l = 0;
    m = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            if(a[i]>a[j]){
                l++;
                if(i<j){
                    m++;
                }
            }
        }
    }
    ans = (k * m + k * l * (k - 1) / 2)%mod;
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'vi' was not declared in this scope
   13 |     vi a(n);
      |     ^~
a.cc:15:16: error: 'a' was not declared in this scope
   15 |         cin >> a[i];
      |                ^
a.cc:21:16: error: 'a' was not declared in this scope
   21 |             if(a[i]>a[j]){
      |                ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    ll n, l, m;
    ll k, ans = 0;
    cin >> n >> k;
    vi a(n);
    rep(i, n){
        cin >> a[i];
    }
    l = 0;
    m = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            if(a[i]>a[j]){
                l++;
                if(i<j){
                    m++;
                }
            }
        }
    }
    ans = (k * m + k * l * (k - 1) / 2)%mod;
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'vi' was not declared in this scope
   10 |     vi a(n);
      |     ^~
a.cc:12:16: error: 'a' was not declared in this scope
   12 |         cin >> a[i];
      |                ^
a.cc:18:16: error: 'a' was not declared in this scope
   18 |             if(a[i]>a[j]){
      |                ^
a.cc:26:41: error: 'mod' was not declared in this scope; did you mean 'modf'?
   26 |     ans = (k * m + k * l * (k - 1) / 2)%mod;
      |                                         ^~~
      |                                         modf
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int n;
  cin >> n;
  int64_t k;
  cin >> k;
  int64_t mod = 1000000007;
  
  vector<int64_t> cont1(n);
  
  for(int i = 0 ; i < n ; i++){
    cin >> cont1.at(i);
  }
  
  vector<int64_t> cont2(n);
  vector<int64_t> cont3(n);
  
  for(int i = 0 ; i < n ; i++){
    
    for(int j = i+1 ; j < n ; j++){
      if(i == j){
        continue;
      }
        if(cont1.at(i) > cont1.at(j)){
          cont2.at(i)++;
        }
    }
  }
  
  for(int i = 0 ; i < n ; i++){
    
    for(int j = 0 ; j < n ; j++){
      if(i == j){
        continue;
      }
        if(cont1.at(i) > cont1.at(j)){
          cont3.at(i)++;
        }
    }
  }
  int64_t sum = 0; 
  for(int i = 0 ; i < n ; i++){
    sum +=  (k*cont2.at(i) + cont3.at(i)*( ((k-1)*k/2) % mod) ) )% mod;
    sum % mod;
  }
  cout << sum % mod << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:64: error: expected ';' before ')' token
   45 |     sum +=  (k*cont2.at(i) + cont3.at(i)*( ((k-1)*k/2) % mod) ) )% mod;
      |                                                                ^~
      |                                                                ;
Language: C

#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ull i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}
 
int main() {
  ull N, K; cin >> N >> K;
  vector<ull> A(N); rep(i, N) cin >> A[i];
  ull cnt = 0;
  rep(i, N){for(ull j=i+1; j<N; ++j){ if(A[i] > A[j]) {++cnt;}}}
  ull cnt2 = 0;
  if(K >= 2){rep(i,N){rep(j,N){if(A[i]>A[j]){++cnt2;}}}}
  ull ans = cnt*K+cnt2*K*(K-1)/2;
  cout << ans%MOD << endl;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <stdio.h>

#define mod 1000000007

int main(void)
{
	int n, a[2000], all[2000], right[2000];
	long long int k, sum;
	scanf("%d %lld", &n, &k);
	int i, j, left, count;
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);

	for (i = 0; i < n; i++)
	{
		count = 0;
		for (j = 0; j < i; j++)
		{
			if (a[j] < a[i])
				count++;
		}
		left = count;
		for (j = i + 1; j < n; j++)
		{
			if (a[j] < a[i])
				count++;
		}
		all[i] = count;
		right[i] = count - left;
	}

	sum = 0;
	for (i = 0; i < n; i++)
	{
		sum = (sum + (k * right[i]) % mod + (((k * (k - 1) / 2) % mod) * all[i]) % mod;
	}

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


Compiler output:
main.c: In function 'main':
main.c:35:95: error: expected ')' before ';' token
   35 |                 sum = (sum + (k * right[i]) % mod + (((k * (k - 1) / 2) % mod) * all[i]) % mod;
      |                       ~                                                                       ^
main.c:35:96: error: expected ';' before '}' token
   35 |                 sum = (sum + (k * right[i]) % mod + (((k * (k - 1) / 2) % mod) * all[i]) % mod;
      |                                                                                                ^
      |                                                                                                ;
   36 |         }
      |         ~
Language: C++

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

int main() {
	long long n, k; cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	
    long long ans = 0;
	for (int i = 0; i < n; ++i) {
        long long tmp = 0, tmp1 = 0;
		for (int j = 0; j < n; ++j) {
			if (a[i] > a[j]){
                tmp1 += 1
                if(i<j){
                    tmp += 1
                }
            }
            ans += ((tmp * k) % MOD + (tmp1 * ((k * (k - 1) / 2) % MOD))) % MOD
		}
	}
	cout << ans % MOD << endl;

	return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:15:26: error: expected ';' before 'if'
   15 |                 tmp1 += 1
      |                          ^
      |                          ;
   16 |                 if(i<j){
      |                 ~~        
a.cc:21:17: error: expected ';' before '}' token
   21 |                 }
      |                 ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <utility>
#include <map>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;


int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
   //vector<int> b(n);
    for(ll i=0;i<n;i++)
    {  cin>>a[i];}
    
    ll ans=0;
    ll cntt=0;
    ll cnta=0;
    for(ll i=0;i<n;i++)
    {
        if(a[i]==1)
            continue;
        for(ll j=0;j<n;j++)
        {
            if(a[i]>a[j]&&i<j)
            {
                cnta++;
                cntt++;
            }
            else if(a[i]>a[j]&&i>j)
            {
                cntt++;
            }
        }
       
        ans+=((cnta+cnta+(k-1)*cntt)*k/2)%1000000007;
        ans%=1000000007;
        //ans+=cnta*k+(k+k*k)*cntt/2;
    //    ans+=k*(2*cnta+(k-1)*cntt)/2;
        cnta=0;
        cntt=0;
    }
    
    cout<<ans%=1000000007<<endl;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:54:26: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   54 |     cout<<ans%=1000000007<<endl;
      |                ~~~~~~~~~~^~~~~~
Language: C++

#include <stdio.h>

#define a 1000000000+7

void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}

int main(){
    long long N,K;
    long long counta=0,ct=0;
    long long  ans=0;
    scanf("%lld%lld",&N,&K);
    long long A[N],count[N];
    for(int i=0;i<N;i++){
        count[i]=1; 
    }
    for(int i=0;i<N;i++){
        scanf("%lld",&A[i]);
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<i;j++){
            if(A[i]<A[j]){
                ct++;
            }
        }
    }
    quick_sort(A,0,N-1);
    for(int i=0;i<N;i++){
            if(A[i]==A[i+1]){
                count[counta]++;
            }else{
                counta++;
            }
    }
    long long eq=0;
    for(int i=0;i<counta;i++){
        eq=eq+(count[i]*count[i])%a;
    }
    ans=((N*N)%a-eq+ct)%a;
    ans*=((K/2)*(K-1))%a;
    printf("%lld",ans%a);
        return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:66:16: error: cannot convert 'long long int*' to 'int*'
   66 |     quick_sort(A,0,N-1);
      |                ^
      |                |
      |                long long int*
a.cc:37:22: note:   initializing argument 1 of 'void quick_sort(int*, int, int)'
   37 | void quick_sort (int array[], int left, int right) {
      |                  ~~~~^~~~~~~
Language: C

#include <stdio.h>
#define mod 1000000007

//逆元の練習

int main(void){
  int i,j;
  int n;
  long long k;
  int a[2000];
  long long ans=0;
  ll gyakugen2;

  scanf("%d %lld", &n, &k);
  int R[n];
  int L[n];
  //R[n]はa[n]の右にあるa[n]より小さい値

  for(i=0; i<n; i++){
    scanf("%d", &a[i]);
  }

  for(i=0; i<n; i++){
    R[i]=0;
    L[i]=0;
    //R[i],L[i]を求める
    //L[i]
    for(j=0; j<i; j++){
      if(a[j]<a[i]){
        L[i]++;
      }
    }
    //R[i]
    for(j=i+1; j<n; j++){
      if(a[j]<a[i]){
        R[i]++;
      }
    }
    // printf("L=%d R=%d\n", L[i], R[i]);
    //R[i]*(k+(k-1)+...+1)
    //右を見て

    //1÷2(mod 1000000007)
    // x*2=1000000008≡1
    gyakugen2=1000000008/2;

    ans+=(R[i]*(k%mod)*((k+1)%mod)*gyakugen2)%mod;
    // ans+=(R[i]*(((k*(k+1))/2)%mod))%mod;
    ans%=mod;
    ans+=(L[i]*(k%mod)*((k-1)%mod)*gyakugen2)%mod;
    // ans+=(L[i]*(((k*(k-1))/2)%mod))%mod;
    ans%=mod;
  }
  ans%=mod;
  printf("%lld\n", ans);

  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:12:3: error: unknown type name 'll'
   12 |   ll gyakugen2;
      |   ^~
Language: Java

import java.util.*;

class Main{
    static long MOD = 1_000_000_000 + 7;
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        long k = stdIn.nextLong();
        int a[] = new int [n*2];
        for(int i = 0; i < n; i++){
            a[i] = stdIn.nextInt();
            a[i+n] = a[i];
        }
        long ans = 0;

        long b[] = new long [n];
        long c[] = new long [n];
        for(int i = 0;  i < n; i++){
            for(int j = i+1; j < n + i; j++){
                if(a[i] > a[j]){
                    b[i]++; 
                    if(j >= n){
                        c[i]++;
                    }
                } 
            }
        }

        
        for(int i = 0; i < n; i++){
            ans += (b[i]*((((k+1)*k)/2)%MOD- c[i]*k))%MOD;
            ans = ans % MOD;
        }
        System.out.println(ans);
    }

Compiler output:
Main.java:35: error: reached end of file while parsing
    }
     ^
1 error
Language: Java

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		long K = nextLong();
		int[] A = nextIntArray(N);

		long bef = 0;
		long aft = 0;
		for(int i=0;i<N;i++) {
			for(int j = 0; j<N;j++) {
				if(A[i]>A[j])bef++;
				else aft++;
			}
		}
		long b = K*(K+1)/2%Mod;
		long c = K*(K-1)/2%Mod;
		long ans = bef*b%Mod+aft*c%Mod;
		out.println(ans%Mod);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

Compiler output:
Main.java:2: error: cannot find symbol
	static final PrintStream out = System.out;
	             ^
  symbol:   class PrintStream
  location: class Main
Main.java:3: error: cannot find symbol
	static final Scanner sc = new Scanner(System.in);
	             ^
  symbol:   class Scanner
  location: class Main
Main.java:3: error: cannot find symbol
	static final Scanner sc = new Scanner(System.in);
	                              ^
  symbol:   class Scanner
  location: class Main
3 errors
Language: C

#include <stdio.h>
#define mod 1000000007

int main(void){
  int i,j;
  int n;
  long long k;
  int a[2000];
  long long ans=0;

  scanf("%d %lld", &n, &k);
  int R[n];
  int L[n];
  //R[n]はa[n]の右にあるa[n]より小さい値

  for(i=0; i<n; i++){
    scanf("%d", &a[i]);
  }

  for(i=0; i<n; i++){
    R[i]=0;
    L[i]=0;
    //R[i],L[i]を求める
    //L[i]
    for(j=0; j<i; j++){
      if(a[j]<a[i]){
        L[i]++;
      }
    }
    //R[i]
    for(j=i+1; j<n; j++){
      if(a[j]<a[i]){
        R[i]++;
      }
    }
    // printf("L=%d R=%d\n", L[i], R[i]);
    //R[i]*(k+(k-1)+...+1)
    //右を見て

    // ans+=(R[i]*(k%mod)*((k+1)%mod)/2)%mod;
    ans+=(R[i]*((k*((k+1)/2)%mod)%mod;
    ans%=mod;
    // ans+=(L[i]*(k%mod)*((k-1)%mod)/2)%mod;
    ans+=(L[i]*((k*(k-1))/2)%mod)%mod;
    ans%=mod;
  }
  ans%=mod;
  printf("%lld\n", ans);

  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:41:38: error: expected ')' before ';' token
   41 |     ans+=(R[i]*((k*((k+1)/2)%mod)%mod;
      |                ~                     ^
main.c:45:14: error: expected ')' before '}' token
   45 |     ans%=mod;
      |              ^
      |              )
   46 |   }
      |   ~           
main.c:41:10: note: to match this '('
   41 |     ans+=(R[i]*((k*((k+1)/2)%mod)%mod;
      |          ^
main.c:45:14: error: expected ';' before '}' token
   45 |     ans%=mod;
      |              ^
      |              ;
   46 |   }
      |   ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
    long long N, K, BK;

    cin >> N >> K;
    const long long MN = 1000000007;
    long long inv2 = modinv (2, MN)

    K = K % MN;
    if ( K > 0 ){
        BK = K - 1;
    }
    else
    {
        BK = MN - 1;
    }
    

    vector<int> A(N);
    for ( int i = 0; i < N; i++ ) cin >> A.at(i);


    long long ans = 0LL;
    long long ans1, ans2;

    // K = 1での転倒

    ans1 = 0LL;

    for ( int i = 0; i < N - 1; i++ ){
        for ( int j = i + 1; j < N; j++ ){
            if ( A.at(i) > A.at(j) ){
                ans1++;
            }
        }
    }
	

    ans1 = ( ans1 * K ) % MN;


    // K > 2での転倒

    ans2 = 0LL; 

    for ( int i = 0; i < N; i++ ){
        for ( int j = 0; j < N; j++ ){
            if ( A.at(i) > A.at(j) ){
                ans2++;
            }
        }
    }

    BK = ( ( K * BK ) % MN ) * inv2;
    BK %= MN;

    ans2 = ans2 * BK;
    ans2 = ans2 % MN;

    ans =  (ans1 + ans2) % MN;

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:5: error: expected ',' or ';' before 'K'
   22 |     K = K % MN;
      |     ^
Language: C++

#include <iostream>
#include <vector>
#define rep0(i, n) for(int i=0; i<(int)(n);i++)
typedef int64_t lint;
using namespace std;

int main(){
    lint n, k;
    cin >> n >> k;
    vector<lint> a(n);
    rep0(i, n){
        cin >> a[i];
    }

    lint ans = 0;
    for (int i = 0; i < n; ++i) {
    {

        for (int j = 0; j < n; ++j) {
        {
            lint left = 0;
            lint right = 0;
            if(a[i] > a[j]){
                if(i > j)left ++ ;
                if(i < j)right ++ ;
            }
            ans += (k * (k - 1) * (right + left))/2 + k * right;
            ans %= 1000000007;
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:2: error: expected '}' at end of input
   32 | }
      |  ^
a.cc:16:33: note: to match this '{'
   16 |     for (int i = 0; i < n; ++i) {
      |                                 ^
a.cc:32:2: error: expected '}' at end of input
   32 | }
      |  ^
a.cc:7:11: note: to match this '{'
    7 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <vector>
#define rep0(i, n) for(int i=0; i<(int)(n);i++)
typedef int64_t lint;
using namespace std;

int main(){
    lint n, k;
    cin >> n >> k;
    vector<lint> a(n);
    rep0(i, n){
        cin >> a[i];
    }

    lint ans = 0;
    for (int i = 0; i < n; ++i) {
    {
        lint left = 0;
        lint right = 0;
        for (int j = 0; j < n; ++j) {
        {
            if(a[i] > a[j]){
                if(i > j)left ++ ;
                if(i < j)right ++ ;
            }
        }
        //ans += (left + right) * k * (k - 1) / 2 + right * k;
        ans += (k * (k - 1) * (right + left))/2 + k * right;
        ans %= 1000000007;
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:2: error: expected '}' at end of input
   32 | }
      |  ^
a.cc:16:33: note: to match this '{'
   16 |     for (int i = 0; i < n; ++i) {
      |                                 ^
a.cc:32:2: error: expected '}' at end of input
   32 | }
      |  ^
a.cc:7:11: note: to match this '{'
    7 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef unsigned long long ull;
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  long N,K;
  in(N,K);
  vector<long>A(N);
  ins(A);
  long ans=0,mod=1e9+7;
  rep(i,N){
    long f=0,b=0;
    rep(j,N){
      if(i==j)continue;
      if(i>j&&A[i]>A[j])f++;
      if(i<j&&A[i]>A[j])b++;
    }
    ans+=K*(K-1)%mod*(b+k)%mod+b*K%mod;
    ans%=mod;
  }
  out(ans);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Compiler output:
a.cc:2:9: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
    2 | #include<boost/multiprecision/cpp_int.hpp>
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

int main() {
int N;
  int K,c=0;
  cin>>N>>K;

  vector<int> A(N);
  vector<int> B(N*K);
 
    for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
 for(int j=0;j<K;j++){
  for(int i=0;i<N;i++){
   
    B.at(i+j*N)=A.at(i);
 }
 }
   for(int i=0;i<N*K;i++){
    for(int j=0;j<N*K;j++){
      
      if(B.at(i)>B.at(j)){
        c++;
      }
    }
  }
  int r=1000000000+7
  cout<<c%r<<endl;
      
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:3: error: expected ',' or ';' before 'cout'
   30 |   cout<<c%r<<endl;
      |   ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
#define mod 1000000007; 
 
 long long  accumulate(long long k){
  long long  times;
  times=k(k+1)/2;
  return times%mod;
 }
 
int main(){
 long long  n,k,count,count2,ans;
  count=0;
  count2=0;
  vector<long long > num;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    long long  tmp;
    cin>>tmp;
    num.push_back(tmp);
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(num[i]>num[j]){
        count++;
      }else if(num[i]<num[j]){
        count2++;
      }
    }
  }
  ans=(count*accumulate(k)+count2*accumulate(k-1))%mod;
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'long long int accumulate(long long int)':
a.cc:8:10: error: 'k' cannot be used as a function
    8 |   times=k(k+1)/2;
      |         ~^~~~~
Language: C++

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

int main() {
int N;
  int K,c=0;
  cin>>N>>K;

  vector<int> A(N);
  vector<int> B(N*K);
 
    for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
 for(int j=0;j<K;j++){
  for(int i=0;i<N;i++){
   
    B.at(i+j*N)=A.at(i);
 }
 }
   for(int i=0;i<N*K;i++){
    for(int j=i+1;j<N*K;j++){
      if(B.at(i)>B.at(j)){
        c++;
      }
    }
  }
  int r=1000000000+7
  cout<<c%r<<endl;
      
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:3: error: expected ',' or ';' before 'cout'
   29 |   cout<<c%r<<endl;
      |   ^~~~
Language: C++

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

int main() {
int N;
  int64_t K,c=0;
  cin>>N>>K;

  vector<int> A(N);
  vector<int64_t> B(N*K);
 
    for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
 for(int j=0;j<K;j++){
  for(int i=0;i<N;i++){
   
    B.at(i+j*N)=A.at(i);
 }
 }
   for(int i=0;i<N*K;i++){
    for(int j=i+1;j<N*K;j++){
      if(B.at(i)>B.at(j)){
        c++;
      }
    }
  }
  int64_t r=1000000000+7
  cout<<c%r<<endl;
      
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:3: error: expected ',' or ';' before 'cout'
   29 |   cout<<c%r<<endl;
      |   ^~~~