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

import java.util.Scanner;

public class MainA {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int d = sc.nextInt();
		if (d < 10) {
			System.out.println(0);
			return;
		}

		int count = 0;
		for (int j = 1; j <= m; j++) {
			for (int i = 10; i <= d; i++) {
				int d1 = i / 10;
				int d2 = i % 10;

				if (j == d1 * d2) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
}


Compiler output:
Main.java:3: error: class MainA is public, should be declared in a file named MainA.java
public class MainA {
       ^
1 error
Language: C++

#include <stdio.h>

int main()
{
  	int cnt;
	int M,D,m,d,df,ds;
  	scanf("%d %d\n", &M, &D);
  	
  	cnt = 0;
  	for(m=4;m<M;m++){ 
  		for(d=22;d<D;d++){
     		df = i / 10;
      		ds = i % 10;
      		if (df * ds == m)
             cnt++;
    	}  
  	}
  	printf("%d\n", cnt);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:22: error: 'i' was not declared in this scope
   12 |                 df = i / 10;
      |                      ^
Language: C++

// #include <stdio.h>
// #include <string.h>
//#include <iostream>
#include <utility>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <map>
#include <string>
#include <set>

using namespace std;
typedef pair<int, int> XY;// Pair型変数の宣言
    
int main()
{
  	int Nmax = 100000;
    char String[Nmax];
    int N;
    int i,j,k;
    int len;   // 文字列の長さ
    int flag=0;
    int t[Nmax];
    int x[Nmax];
    int y[Nmax];
    int M,D;
    int count = 0;
    int d1,d10;
    int d,m;
 /*   
    // int型スタック
    stack<int> stack;   
    stack.push(777);
    stack.push(778);
    stack.push(779);
  
	int tmpsl = stack.top();  // LAST要素の参照
 // 	int tpmsf = stack.back(); // FIRST要素の参照
 //	printf("%d %d \n",tmpsl,tmpsf);
    stack.pop();// LAST要素の削除（取出しではない）
 // 	if( stack.empty() == true) printf("empty stack\n");
     
    // int型キュー
    queue<int> que;
  	que.push(999);
  	que.push(998);   
  	que.push(997);    
  	int tmpqs = que.front(); // FIRST要素の参照
  	int tmpqe = que.back();  // LAST要素の参照
 //	printf("%d %d \n",tmpqs,tmpqe);
  	que.pop();  // FIRST要素の削除（取出しではない）
  //	if( que.empty() == true) printf("empty que\n");
    
    // ２次元座標を扱うキュー
    queue<XY> xyque; // ２次元座標型変数のキュー
  	XY p; 
  	xyque.pop();	// FIRST要素の削除。キューが空のときは削除が予約されて次のPOPが即削除される
  	xyque.push( XY(5,5) );
    xyque.push( XY(5,5) );
   	p = xyque.front();  // FIRST要素からのコピー
 // 	printf("%d %d\n", p.first, p.second);
  	
    
  que.back();
  //  sort(&(que.front()), &(que.back()));
        
 */   
      
    // 入力読込
    // 文字列
 //   scanf("%s", String);   
    
    // 数列
    scanf("%d %d", &M,&D);
//    for(i=1;i<=N;i++){
//        scanf("%d %d %d",&t[i],&x[i],&y[i]);
//    }
    
    // 文字列の長さをチェック
    // 文字列は配列の0からlen-1に格納されてる
//    len = strlen( String );
//  	printf("%d\n",len);
    
    for(m=1;m<=M;m++){
        for(d=1;d<=D;d++){
            d1 = d%10;
            d10 = d/10;
            if((m == d1*d10) && (d1>=2) && (d2 >=2)  count++;
        }
    }
    
    
    // 結果出力
    printf("%d",count);
/*    
    if(flag == -1)
        printf("NO \n");
    else
        printf("YES \n");
  */      
  
  return 0;
   
}

Compiler output:
a.cc: In function 'int main()':
a.cc:89:45: error: 'd2' was not declared in this scope; did you mean 'd'?
   89 |             if((m == d1*d10) && (d1>=2) && (d2 >=2)  count++;
      |                                             ^~
      |                                             d
a.cc:90:9: error: expected primary-expression before '}' token
   90 |         }
      |         ^
a.cc:89:62: error: expected ')' before '}' token
   89 |             if((m == d1*d10) && (d1>=2) && (d2 >=2)  count++;
      |               ~                                              ^
      |                                                              )
   90 |         }
      |         ~                                                     
a.cc:90:9: error: expected primary-expression before '}' token
   90 |         }
      |         ^
Language: C

#include<stdio.h>
#include<string.h>

int main(void){

	int a = 0;
	int b = 0;
	int c = 0;
    int i = 0;
    int j = 0;

	scanf("%d", &a);
	scanf("%d", &b);
  
  	for(i = 1; i =< a; i++){
      for(j = 1; j <= b; j++){
        if(b % 10 >= 2 && b / 10 >= 2 && (b % 10) * (b / 10) == a){
          c++;
        }
      }
    }
	printf("%d", c);

	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:15:23: error: expected expression before '<' token
   15 |         for(i = 1; i =< a; i++){
      |                       ^
Language: C

#include<stdio.h>
#include<string.h>

int main(void){

	int a = 0;
	int b = 0;
	int c = 0;
    int i = 0;
    int j = 0;

	scanf("%d", &a);
	scanf("%d", &b);
  
  	for(i = 1; i =< a; i++){
      for(j = 1;j <= b; j++){
        if(b % 10 >= 2 && b / 10 >= 2 && (b % 10)  *(b / 10) == a){
          c++;
        }
      }
    }
	printf("%d", c);

	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:15:23: error: expected expression before '<' token
   15 |         for(i = 1; i =< a; i++){
      |                       ^
Language: C++

m,d=gets.split.map(&:to_i)
n=0
1.upto(m){|i|1.upto(d){|j|
  n+=1 if m==(d%10)*(d/10)
}}
p n


Compiler output:
a.cc:1:1: error: 'm' does not name a type
    1 | m,d=gets.split.map(&:to_i)
      | ^
a.cc:6:1: error: 'p' does not name a type
    6 | p n
      | ^
Language: C++

# A, B = [int(i) for i in input().split(" ")]
# A = int(input())

M, D = [int(i) for i in input().split(" ")]
ans = 0
for i in range(1, M+1):
    for j in range(22, D+1):
        d1 = j % 10
        d2 = j // 10
        if d1 >= 2 and d2 >= 2 and d1 * d2 == i:
            ans += 1
print(ans)


Compiler output:
a.cc:1:3: error: invalid preprocessing directive #A
    1 | # A, B = [int(i) for i in input().split(" ")]
      |   ^
a.cc:2:3: error: invalid preprocessing directive #A
    2 | # A = int(input())
      |   ^
a.cc:4:1: error: 'M' does not name a type
    4 | M, D = [int(i) for i in input().split(" ")]
      | ^
Language: C++

#include
using namespace std;
int main(){
int month;
int day;
cin>>month;
cin>>day;

int cnt=0;
for(int i=1;i<=month;i++){
for(int j=22;j<=day;j++){
int upper=j/10;
int lower=j%10;
if(upper>=2&&lower>=2&&upper*lower==i){
cnt++;
}
}
}

cout< return(0);
}

Compiler output:
a.cc:1:9: error: #include expects "FILENAME" or <FILENAME>
    1 | #include
      |         ^
a.cc: In function 'int main()':
a.cc:6:1: error: 'cin' was not declared in this scope
    6 | cin>>month;
      | ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #include
a.cc:20:1: error: 'cout' was not declared in this scope
   20 | cout< return(0);
      | ^~~~
a.cc:20:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:20:7: error: expected primary-expression before 'return'
   20 | cout< return(0);
      |       ^~~~~~
Language: C++

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
  int m = inputValue();
  int d = inputValue();
  int count = 0;
  rep(i,1,m)
  {
    rep(j,1,d)
    {
      int a = d/10;
      int b = d%10;
      if (m == a*b)
      {
        count++;
      }
    }
  }
  cout << count;
    return 0;
}

Compiler output:
a.cc:55:12: error: macro "rep" passed 3 arguments, but takes just 2
   55 |   rep(i,1,m)
      |            ^
a.cc:13:9: note: macro "rep" defined here
   13 | #define rep(i,n) repd(i,0,n)
      |         ^~~
a.cc:57:14: error: macro "rep" passed 3 arguments, but takes just 2
   57 |     rep(j,1,d)
      |              ^
a.cc:13:9: note: macro "rep" defined here
   13 | #define rep(i,n) repd(i,0,n)
      |         ^~~
a.cc: In function 'int main(int, const char**)':
a.cc:55:3: error: 'rep' was not declared in this scope
   55 |   rep(i,1,m)
      |   ^~~
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < (N); X++)
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ceilint(A, B) ((A) + (B - 1)) / (B)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

int main(){

    int m,d;

    int ans = 0;

    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= d; j++){
            int d1 = j / 10;
            int d2 = j % 10;

            if(m == d1 * d2) ans++
        }
    }

    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:35: error: expected ';' before '}' token
   23 |             if(m == d1 * d2) ans++
      |                                   ^
      |                                   ;
   24 |         }
      |         ~
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>
#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 m,d;
    cin>>m>>d;
    int cnt=0;
    for(int i=0;i<m;i++){
        for(int j=0;j<d;j++){
            int m=i+1;
            int d=j+1;
            if(d%10>=2&&d/10>=2&&(d%10)*(d/10)==m)cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}



Compiler output:
a.cc:20:17: error: 'LLONG_MAX' was not declared in this scope
   20 | 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 | #define int long long
Language: C++

誓って全力を尽くして戦います。

Compiler output:
a.cc:1:1: error: extended character 。 is not valid in an identifier
    1 | 誓って全力を尽くして戦います。
      | ^
a.cc:1:1: error: '\U00008a93\U00003063\U00003066\U00005168\U0000529b\U00003092\U00005c3d\U0000304f\U00003057\U00003066\U00006226\U00003044\U0000307e\U00003059\U00003002' does not name a type
    1 | 誓って全力を尽くして戦います。
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

n, k = map(int, input().split())
a = list(map(int, input().split()))
total_1 = 0
for i in range (n - 1):
    for j in range (i, n):
        if a[i] > a[j]:
            total_1 += 1
total_2 = 0
for i in range (n):
    for j in range (i):
        if a[i] > a[j]:
            total_2 += 1
def factorial(n):
    total = 0
    while(n > 0):
        total += n
        n -= 1
    return total

print(total_1 * K + total_2 * factorial(K - 1))

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n, k = map(int, input().split())
      | ^
Language: C++

#include <iostream>
#include <queue>
#include<algorithm>
#define intt long long

const intt NUM = 1000000007;

intt factorial(intt n) {
	intt total = 0;
	while (n > 0) {
		total += n % NUM;
		--n;
		total%= NUM;a
	}
	return total;
}

int main(){
	intt N, K; std::cin >> N >> K;
	std::vector<intt> A(N);
	for (auto& r : A) { std::cin >> r; }
	intt initi = 0;
	intt initi2 = 0;
	for (intt i = 0; i < N - 1; ++i)
		for (int j = i + 1; i < N; ++i)
			if (A[i] > A[j]) {
				++initi; initi %= NUM;}
	std::reverse(A.begin(), A.end());
	for (intt i = 0; i < N - 1; ++i)
		for (intt j = i + 1; i < N; ++i)
			if (A[i] > A[j]) { ++initi2; initi2 %= NUM; }
	initi2 += initi;
	std::cout << ((((initi * K)%NUM) + ((factorial(K - 1) * initi2)%NUM)) % NUM) << std::endl;


	return 0;
}

Compiler output:
a.cc: In function 'long long int factorial(long long int)':
a.cc:13:29: error: 'a' was not declared in this scope
   13 |                 total%= NUM;a
      |                             ^
Language: C++

#include <iostream>
#include <queue>
#define intt long long

const intt NUM = 1000000007;

intt factorial(intt n) {
	intt total = 0;
	while (n > 0) {
		total += n % NUM;
		--n;
		total%= NUM;
	}
	return total;
}

int main(){
	intt N, K; std::cin >> N >> K;
	std::vector<intt> A(N);
	for (auto& r : A) { std::cin >> r; }
	intt initi = 0;
	intt initi2 = 0;
	for (intt i = 0; i < N - 1; ++i)
		for (int j = i + 1; i < N; ++i)
			if (A[i] > A[j]) {
				++initi; initi %= NUM;}
	std::reverse(A.begin(), A.end());
	for (intt i = 0; i < N - 1; ++i)
		for (intt j = i + 1; i < N; ++i)
			if (A[i] > A[j]) { ++initi2; initi2 %= NUM; }
	initi2 += initi;
	std::cout << ((((initi * K)%NUM) + ((factorial(K - 1) * initi2)%NUM)) % NUM) << std::endl;


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:14: error: 'reverse' is not a member of 'std'
   27 |         std::reverse(A.begin(), A.end());
      |              ^~~~~~~
Language: C++

#include <iostream>
#include <queue>
#define intt long long

const intt NUM = 1000000007;

intt factorial(intt n) {
	intt total = 0;
	while (n > 0) {
		total += n % NUM;
		--n;
		total% NUM;
	}
	return total;
}

int main(){
	intt N, K; std::cin >> N >> K;
	std::vector<intt> A(N);
	for (auto& r : A) { std::cin >> r; }
	intt initi = 0;
	intt initi2 = 0;
	for (intt i = 0; i < N - 1; ++i)
		for (int j = i + 1; i < N; ++i)
			if (A[i] > A[j]) {
				++initi; initi %= NUM;}
	std::reverse(A.begin(), A.end());
	for (intt i = 0; i < N - 1; ++i)
		for (intt j = i + 1; i < N; ++i)
			if (A[i] > A[j]) { ++initi2; initi2 %= NUM; }
	initi2 += initi;
	std::cout << ((((initi * K)%NUM) + ((factorial(K - 1) * initi2)%NUM)) % NUM) << std::endl;


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:14: error: 'reverse' is not a member of 'std'
   27 |         std::reverse(A.begin(), A.end());
      |              ^~~~~~~
Language: C++

#define rep1(i,n) for (int i=1; i<=(int)(n); i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fst first
#define scd second
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  ll n, k; cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll ans = 0, M = 1e9+7;
  ll kp = (k*(k+1) % M) / 2;
  ll km = (k*(k-1) % M) / 2;
  rep(i,n) {
    ll ac = 0, c = 0;
    rep(j,n) {
      if (a[i] > a[j]) {
        if (j > i) c++;
        ac++;
      }
    }
    ll rt = (c * k) % M;
    ll mt = (ac * (km)) % M;
    ans = (ans + (rt + mt) % M) % M;
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc:9:11: error: 'pair' does not name a type
    9 | using P = pair<int, int>;
      |           ^~~~
a.cc: In function 'int main()':
a.cc:12:12: error: 'cin' was not declared in this scope
   12 |   ll n, k; cin >> n >> k;
      |            ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #define rep1(i,n) for (int i=1; i<=(int)(n); i++)
a.cc:13:3: error: 'vector' was not declared in this scope
   13 |   vector<ll> a(n);
      |   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | #define rep1(i,n) for (int i=1; i<=(int)(n); i++)
a.cc:13:12: error: expected primary-expression before '>' token
   13 |   vector<ll> a(n);
      |            ^
a.cc:13:14: error: 'a' was not declared in this scope
   13 |   vector<ll> a(n);
      |              ^
a.cc:14:7: error: 'i' was not declared in this scope
   14 |   rep(i,n) cin >> a[i];
      |       ^
a.cc:14:3: error: 'rep' was not declared in this scope; did you mean 'rep1'?
   14 |   rep(i,n) cin >> a[i];
      |   ^~~
      |   rep1
a.cc:30:3: error: 'cout' was not declared in this scope
   30 |   cout << ans << endl;
      |   ^~~~
a.cc:30:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:30:18: error: 'endl' was not declared in this scope
   30 |   cout << ans << endl;
      |                  ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #define rep1(i,n) for (int i=1; i<=(int)(n); i++)
Language: C++

#define ALL(obj) (obj).begin(), (obj).end()
#define fst first
#define scd second
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  ll n, k; cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll ans = 0, M = 1e9+7;
  ll kp = ((k*(k+1) % M) / 2) % M;
  ll km = ((k*(k-1) % M) / 2) % M;
  rep(i,n) {
    ll ac = 0, c = 0;
    rep(j,n) {
      if (a[i] > a[j]) {
        ac++;
        if (j > i) c++;
      }
    }
    ans = (ans + (((c * kp) % M) + ((ac -c) * km) % M) % M) % M;
  }
  cout << ans % M << endl;
  return 0;
}

Compiler output:
a.cc:7:11: error: 'pair' does not name a type
    7 | using P = pair<int, int>;
      |           ^~~~
a.cc: In function 'int main()':
a.cc:10:12: error: 'cin' was not declared in this scope
   10 |   ll n, k; cin >> n >> k;
      |            ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #define ALL(obj) (obj).begin(), (obj).end()
a.cc:11:3: error: 'vector' was not declared in this scope
   11 |   vector<ll> a(n);
      |   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | #define ALL(obj) (obj).begin(), (obj).end()
a.cc:11:12: error: expected primary-expression before '>' token
   11 |   vector<ll> a(n);
      |            ^
a.cc:11:14: error: 'a' was not declared in this scope
   11 |   vector<ll> a(n);
      |              ^
a.cc:12:7: error: 'i' was not declared in this scope
   12 |   rep(i,n) cin >> a[i];
      |       ^
a.cc:12:3: error: 'rep' was not declared in this scope
   12 |   rep(i,n) cin >> a[i];
      |   ^~~
a.cc:26:3: error: 'cout' was not declared in this scope
   26 |   cout << ans % M << endl;
      |   ^~~~
a.cc:26:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:26:22: error: 'endl' was not declared in this scope
   26 |   cout << ans % M << endl;
      |                      ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #define ALL(obj) (obj).begin(), (obj).end()
Language: C

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);
    
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    
    ll ans = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i+1; j < n; j++) if (a[i] > a[j]) ans++;
    }
    ans = ans * k % MOD;

    sort(a.begin(), a.end());

    ll cnt = 0;
    for (int i = 0; i < n; i++) {
        auto itr = lower_bound(a.begin(), a.end(), a[i]);
        cnt += itr - a.begin();
        cnt %= MOD;
    }

    ll t = k * (k - 1) / 2 % MOD;
    ans += cnt * t % MOD;
    cout << ans % MOD << endl;
}

Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define mod 1000000007
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n';
#define no cout<<"No"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  t,i,x,y,j,n,k,ans,cnt=0;
    string s;
    cin>>n>>k;
    ll a[n];
    for(i=0; i<n; i++)
        cin>>a[i];
    for(i=0; i<n; i++)
    {
        for(j=i+1; j<n; j++)
        {
            if(a[i]>a[j])
                cnt++;
        }
    }
    ans=cnt*(k%mod);
    cnt=0;
    for(i=0; i<n; i++)
    for(j=0; j<n; j++)
            if(a[i]>a[j])
                cnt++;
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define mod 1000000007
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n';
#define no cout<<"No"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  t,i,x,y,j,n,k,ans,cnt=0;
    string s;
    cin>>n>>k;
    ll a[n];
    for(i=0; i<n; i++)
        cin>>a[i];
    for(i=0; i<n; i++)
    {
        for(j=i+1; j<n; j++)
        {
            if(a[i]>a[j])
                cnt++;
        }
    }
    ans=cnt*(k%mod);
    cnt=0;
    for(i=0; i<n; i++)
    for(j=0; j<n; j++)
            if(a[i]>a[j])
                cnt++;

      k=(k*(k-1)/2%mod);
    ans+=cnt%mod*k;
    cout<<ans%mod<<endl;
    return 0;
}




      k=(k*(k-1)/2%mod);
    ans+=cnt%mod*k;
    cout<<ans%mod<<endl;
    return 0;
}





Compiler output:
a.cc: In function 'int main()':
a.cc:60:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   60 | int main()
      |         ^~
a.cc:60:9: note: remove parentheses to default-initialize a variable
   60 | int main()
      |         ^~
      |         --
a.cc:60:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:61:1: error: a function-definition is not allowed here before '{' token
   61 | {
      | ^
Language: C++

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


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

Compiler output:
a.cc: In function 'int main()':
a.cc:22:34: error: 'l' was not declared in this scope
   22 |     ans+=(2*a+d*(k-1))*k/2; ans%=l;
      |                                  ^
a.cc:24:8: error: 'l' was not declared in this scope
   24 |   ans%=l; cout<<ans<<endl;
      |        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
long double tentou(vector<int>&a, int n){
  long double tmp = 0;
  //n^2のバブルソートでも間に合ってくさ
  for(int i=0; i<n-1; i++){
    for(int j=i+1;j<n;j++){
      if(a[i]>a[j])tmp++;
    }
  }
  return tmp;
}
long double hutuu(vector<int>&a, int n){
  long double tmp = 0;
  for(int i=0;i<n;i++)a.push_back(a[i]);

  for(int i=0; i<2*n-1; i++){
    for(int j=i+1;j<2*n;j++){
      if(a[i]>a[j])tmp++;
    }
  }
  return tmp;
}
int main(){
  int n;
  long double k;
  cin >> n >> k;
  vector<int>a(n);
  for(int i=0; i<n;i++)cin >> a[i];
  long double res;
  long double tmp = tentou(a,n);
  long double tmp2 = hutuu(a,n);

  tmp2 = tmp2 - 2*tmp;
  res = (tmp*k%MOD + (tmp2*(k*(k-1)%MOD))%MOD/2)%MOD;
  cout << res << endl;


  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:15: error: invalid operands of types 'long double' and 'int' to binary 'operator%'
   36 |   res = (tmp*k%MOD + (tmp2*(k*(k-1)%MOD))%MOD/2)%MOD;
      |          ~~~~~^
      |             |
      |             long double
a.cc:36:36: error: invalid operands of types 'long double' and 'int' to binary 'operator%'
   36 |   res = (tmp*k%MOD + (tmp2*(k*(k-1)%MOD))%MOD/2)%MOD;
      |                             ~~~~~~~^
      |                              |
      |                              long double
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(i,a,b) for(lli i=a;i<b;i++)
#define f0(a,b) for(lli i=a;i<b;i++)
#define fn(b,a) for(lli i=b;i>a;i--)
#define dbg(x); cout<<"\n"<<#x<<": "<<x;
#define ret return
#define pb push_back
#define pf push_front
#define mp make_pair
#define sq(a) (a)*(a)
#define fs first
#define sc second
#define el "\n"
#define brk break
#define cont continue
#define all(a) a.begin(),a.end()
#define E9 1e9 + 7
#define E5 100007
#define INF 1e18+7
typedef long long int lli;  //  e-18 to e18
typedef vector<int> vi;
typedef set<int> si;
typedef string str;
typedef map<int,int> mii;
typedef vector<long long int> vll;
typedef pair<long long int,long long int> pll;
typedef vector<vector<long long int>> vvll;
int a[2700];
void solve(){
  	int n,k;
    cin >> n >> k; 
	for(int i = 1; i <= n; i++) cin >> a[i]; 
	int ans = 0, K = (k * (k + 1) / 2) % E9, KK = (k * (k - 1) / 2) % E9; 
	for(int i = 1; i <= n; i++) {
		int l = 0, r = 0; 
		for(int j = 1; j < i; j++) l += (a[j] > a[i]); 
		for(int j = i + 1; j <= n; j++) r += (a[j] > a[i]); 
		ans = (ans + l * K % E9 + r * KK % E9) % E9; 
	}
	cout << ans << el; 
}
int main(){
    fastIO();
    lli t(1);
    // cin>>t;
    while(t--) solve();
    ret 0; 
}

// compilation flags

// normal
//      g++ -std=c++17 -O2 -Wall a.cpp -o a
// fast running time
//      g++ -O2 -std=c++17 -Wno-unused-result -Wshadow -Wall -o a a.cpp
// check for mistakes
//      g++ -std=c++17 -Wshadow -Wall -o a a.cpp -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g

// use digit separator for better readbility e.g. 10000000 (base 10 - decimal) =  1'000'0'000' (separate at every 3 digits)
// 0b0101000 (base 2 - binary ) =  0b010'1000' (separate at every 4 digits-nibble)
// integer literals - suffixes and prefixes e.g. 0b1010 = binary - prefix for base of number
// 0x9A01 = hexadecimal
// 0733 = octal
// 153 = decimal
// 1645241684131 ll =  suffix for data type here long long int lly for others
// use M_PI for value of pi
// and check function defination for every new function used

// snippets

//     int n,k;
//     cin>>n>>k;
//     vi a(n);
//     f0(0,n) cin>>a[i];


Compiler output:
a.cc: In function 'void solve()':
a.cc:35:44: error: invalid operands of types 'int' and 'double' to binary 'operator%'
   35 |         int ans = 0, K = (k * (k + 1) / 2) % E9, KK = (k * (k - 1) / 2) % E9;
      |                          ~~~~~~~~~~~~~~~~~ ^
      |                                       |
      |                                       int
a.cc:40:36: error: invalid operands of types 'int' and 'double' to binary 'operator%'
   40 |                 ans = (ans + l * K % E9 + r * KK % E9) % E9;
      |                              ~~~~~ ^
      |                                |
      |                                int
a.cc:40:47: error: 'KK' was not declared in this scope; did you mean 'K'?
   40 |                 ans = (ans + l * K % E9 + r * KK % E9) % E9;
      |                                               ^~
      |                                               K
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(i,a,b) for(lli i=a;i<b;i++)
#define f0(a,b) for(lli i=a;i<b;i++)
#define fn(b,a) for(lli i=b;i>a;i--)
#define dbg(x); cout<<"\n"<<#x<<": "<<x;
#define ret return
#define pb push_back
#define pf push_front
#define mp make_pair
#define sq(a) (a)*(a)
#define fs first
#define sc second
#define el "\n"
#define brk break
#define cont continue
#define all(a) a.begin(),a.end()
#define E9 1e9 + 7
#define E5 100007
#define INF 1e18+7
typedef long long int lli;  //  e-18 to e18
typedef vector<int> vi;
typedef set<int> si;
typedef string str;
typedef map<int,int> mii;
typedef vector<long long int> vll;
typedef pair<long long int,long long int> pll;
typedef vector<vector<long long int>> vvll;
int a[2700];
void solve(){
  	int n,k;
    cin >> n >> k; 
	for(int i = 1; i <= n; i++) cin >> a[i]; 
	int ans = 0, K = (k * (k + 1) / 2) % mod, KK = (k * (k - 1) / 2) % mod; 
	for(int i = 1; i <= n; i++) {
		int l = 0, r = 0; 
		for(int j = 1; j < i; j++) l += (a[j] > a[i]); 
		for(int j = i + 1; j <= n; j++) r += (a[j] > a[i]); 
		ans = (ans + l * K % mod + r * KK % mod) % mod; 
	}
	cout << ans; 
}
int main(){
    fastIO();
    lli t(1);
    // cin>>t;
    while(t--) solve();
    ret 0; 
}

// compilation flags

// normal
//      g++ -std=c++17 -O2 -Wall a.cpp -o a
// fast running time
//      g++ -O2 -std=c++17 -Wno-unused-result -Wshadow -Wall -o a a.cpp
// check for mistakes
//      g++ -std=c++17 -Wshadow -Wall -o a a.cpp -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g

// use digit separator for better readbility e.g. 10000000 (base 10 - decimal) =  1'000'0'000' (separate at every 3 digits)
// 0b0101000 (base 2 - binary ) =  0b010'1000' (separate at every 4 digits-nibble)
// integer literals - suffixes and prefixes e.g. 0b1010 = binary - prefix for base of number
// 0x9A01 = hexadecimal
// 0733 = octal
// 153 = decimal
// 1645241684131 ll =  suffix for data type here long long int lly for others
// use M_PI for value of pi
// and check function defination for every new function used

// snippets

//     int n,k;
//     cin>>n>>k;
//     vi a(n);
//     f0(0,n) cin>>a[i];


Compiler output:
a.cc: In function 'void solve()':
a.cc:35:46: error: 'mod' was not declared in this scope; did you mean 'modf'?
   35 |         int ans = 0, K = (k * (k + 1) / 2) % mod, KK = (k * (k - 1) / 2) % mod;
      |                                              ^~~
      |                                              modf
a.cc:40:48: error: 'KK' was not declared in this scope; did you mean 'K'?
   40 |                 ans = (ans + l * K % mod + r * KK % mod) % mod;
      |                                                ^~
      |                                                K
Language: C++

#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 ll n,k ;
 cin >> n>> k ;
 vector<ll> A(n) ;
 rep(i,n) cin >> A[i] ;
 //sortしてない
 vector<ll> migi(n) ;
 rep(i,n-1){
   rep2(j,i+1,n-1){
     if(A[i]>A[j]) migi[i]  ++ ;
   }
 }
 ll migisum=0 ;
 rep(i,n) migisum+=migi[i] ;
 veotor<ll> mog(n) ;
 rep(i,n){
   rep(j,n) if(A[i]>A[j]) mog[i] ++ ;
 }
 ll mogsum =0 ;
 rep(i,n) mogsum+=mog[i] ;
 ll gm= mogsum*k*(k-1)/2 ;
 
 cout <<(migisum*k+gm)%1000000007ll<<endl ;
     return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:2: error: 'veotor' was not declared in this scope
   28 |  veotor<ll> mog(n) ;
      |  ^~~~~~
a.cc:28:11: error: expected primary-expression before '>' token
   28 |  veotor<ll> mog(n) ;
      |           ^
a.cc:28:13: error: 'mog' was not declared in this scope; did you mean 'log'?
   28 |  veotor<ll> mog(n) ;
      |             ^~~
      |             log
Language: C++

#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 ll n,k ;
 cin >> n>> k ;
 vector<ll> A(n) ;
 rep(i,n) cin >> A[i] ;
 //sortしてない
 vector<ll> migi(n) ;
 rep(i,n-1){
   rep2(j,i+1,n-1){
     if(A[i]>A[j]) migi[i]  ++ ;
   }
 }
 ll migisum=0 ;
 rep(i,n) migisum+=migi[i] ;
 vector<ll> mog(n) ;
 rep(i,n){
   rep(j,n) if(A[i]>A[j]) mog[i] ++ ;
 }
 ll mogsum =0 ;
 rep(i,n) mogsum+=mog[i] ;
 ll gm= mogsum*k*(k-1)2 ;
 
 cout <<(migisum*k+gm)%1000000007ll<<endl ;
     return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:23: error: expected ',' or ';' before numeric constant
   34 |  ll gm= mogsum*k*(k-1)2 ;
      |                       ^
Language: C++

#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 ll n,k ;
 cin >> n>> k ;
 vector<ll> A(n) ;
 rep(i,n) cin >> A[i] ;
 //sortしてない
 vector<ll> migi(n) ;
 rep(i,n-1){
   rep2(j,i+1,n-1){
     if(A[i]>A[j]) migi[i]  ++ ;
   }
 }
 ll migisum=0 ;
 rep(i,n) migisum+=migi[i] ;
 veotor<ll> mog(n) ;
 rep(i,n){
   rep(j,n) if(A[i]>A[j]) mog[i] ++ ;
 }
 ll mogsum =0 ;
 rep(i,n) mogsum+=mog[i] ;
 ll gm= mogsum*k*(k-1)2 ;
 
 cout <<(migisum*k+gm)%1000000007ll<<endl ;
     return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:2: error: 'veotor' was not declared in this scope
   28 |  veotor<ll> mog(n) ;
      |  ^~~~~~
a.cc:28:11: error: expected primary-expression before '>' token
   28 |  veotor<ll> mog(n) ;
      |           ^
a.cc:28:13: error: 'mog' was not declared in this scope; did you mean 'log'?
   28 |  veotor<ll> mog(n) ;
      |             ^~~
      |             log
a.cc:34:23: error: expected ',' or ';' before numeric constant
   34 |  ll gm= mogsum*k*(k-1)2 ;
      |                       ^
Language: C++

#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 ll n,k ;
 cin >> n>> k ;
 vector<ll> A(n) ;
 rep(i,n) cin >> A[i] ;
 //sortしてない
 vector<ll> migi(n) ;
 rep(i,n-1){
   rep2(j,i+1;n-1){
     if(A[i]>A[j]) migi[i]  ++ ;
   }
 }
 ll migisum=0 ;
 rep(i,n) migisum+=migi[i] ;
 ll gm=k*(k-1)*n*(n-1)/4 ;
 cout <<migisum*k+gm<<endl ;
     return 0;
}

Compiler output:
a.cc:22:18: error: macro "rep2" requires 3 arguments, but only 2 given
   22 |    rep2(j,i+1;n-1){
      |                  ^
a.cc:6:9: note: macro "rep2" defined here
    6 | #define rep2(i,n,m) for(long long i=n;i<=m;i++)
      |         ^~~~
a.cc: In function 'int main()':
a.cc:22:4: error: 'rep2' was not declared in this scope
   22 |    rep2(j,i+1;n-1){
      |    ^~~~
Language: C++

#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 ll n,k ;
 cin >> n>> k ;
 vector<ll> A(n) ;
 rep(i,n) cin >> A[i] ;
 //sortしてない
 vector<ll> migi(n) ;
 rep(i,n-1){
   rep2(j,j=i+1;n-1){
     if(A[i]>A[j]) migi[i]  ++ ;
   }
 }
 ll migisum=0 ;
 rep(i,n) migisum+=migi[i] ;
 ll gm=k*(k-1)*n*(n-1)/4 ;
 cout <<migisum*k+gm<<endl ;
     return 0;
}

Compiler output:
a.cc:22:20: error: macro "rep2" requires 3 arguments, but only 2 given
   22 |    rep2(j,j=i+1;n-1){
      |                    ^
a.cc:6:9: note: macro "rep2" defined here
    6 | #define rep2(i,n,m) for(long long i=n;i<=m;i++)
      |         ^~~~
a.cc: In function 'int main()':
a.cc:22:4: error: 'rep2' was not declared in this scope
   22 |    rep2(j,j=i+1;n-1){
      |    ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

power(int a,int x){
	if(x==0) return 1;
	int y=power(a,x/2);
	y=(y*y)%M;
	if(x%2==1) return((a*y)%M);
	return y;
}

int32_t main(){
	IOS;
	int n,k;
	cin>>n>>k;
	int a[n];
	int ans=0;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++){
		int x=0;
		int y=0;
		for(int j=i+1;j<n;j++) if(a[j]<a[i]) x++;
		for(int j=0;j<n;j++) if(a[j]<a[i]) y++;
		ans=(ans+(x*k)%M)%M;
		ans=(ans+(y*((k*(k-1)%M)*power(2,M-2)%M)%M)%M)%M;
	}
	cout<<ans<<endl;
}

Compiler output:
a.cc:18:1: error: ISO C++ forbids declaration of 'power' with no type [-fpermissive]
   18 | power(int a,int x){
      | ^~~~~
Language: C++

#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;


int main(){
    long long int n, k;
    cin >> n >> k;
    vector<long long int> a(2*n);
    for(long long int i=0;i<n;i++) cin >> a[i];
    for(long long int i=n;i<2*n;i++) a[i] = a[i-n];

    long long int res = 0;

    // aの中にある転倒数
    for(long long int i=0;i<n-1;i++){
        for(long long int j=i+1;j<n;j++){
            if(a[i] > a[j]) {
                res++;
            }
        }
    }

    //aを跨いで存在する転倒数
    long long int res1 = 0;
    for(long long int i=0;i<n;i++){
        for(long long int j=n;j<2*n;j++){
            if(a[i] > a[j]){
                res1++;
            }
        }
    }
    long long int ans = (k*res)%1000000007 + 0.5*(((res1*k)%1000000007)*(k-1))%1000000007

    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:79: error: invalid operands of types 'double' and 'int' to binary 'operator%'
   41 |     long long int ans = (k*res)%1000000007 + 0.5*(((res1*k)%1000000007)*(k-1))%1000000007
      |                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
      |                                                 |                              |
      |                                                 double                         int
Language: C++

#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;


int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(2*n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=n;i<2*n;i++) a[i] = a[i-n];

    long long int res = 0;

    // aの中にある転倒数
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(a[i] > a[j]) {
                res++;
            }
        }
    }
    res *= k;
    //aを跨いで存在する転倒数

    long long int tmp = 0;
    for(int i=0;i<n;i++){
        for(int j=n;j<2*n;j++){
            if(a[i] > a[j]){
                tmp++;
            }
        }
    }
    tmp *= k*(k-1)/2;

    cout << (res + tmp)%(pow(10, 9) + 7) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:24: error: invalid operands of types 'long long int' and '__gnu_cxx::__promote<double>::__type' {aka 'double'} to binary 'operator%'
   44 |     cout << (res + tmp)%(pow(10, 9) + 7) << endl;
      |             ~~~~~~~~~~~^~~~~~~~~~~~~~~~~
      |                  |                  |
      |                  long long int      __gnu_cxx::__promote<double>::__type {aka double}
Language: C++

#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;


int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(2*n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=n;i<2*n;i++) a[i] = a[i-n];

    long long int res = 0;

    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(a[i] > a[j]) {
                res++;
            }
        }
    }
    res *= k;

    int tmp = 0;
    for(int i=0;i<n;i++){
        for(int j=n;j<2*n;j++){
            if(a[i] > a[j]){
                tmp++;
            }
        }
    }
    long long tmp *= k*(k-1)/2;

    cout << (res + tmp)%(pow(10, 9) + 7) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:19: error: expected initializer before '*=' token
   40 |     long long tmp *= k*(k-1)/2;
      |                   ^~
a.cc:42:24: error: invalid operands of types 'long long int' and '__gnu_cxx::__promote<double>::__type' {aka 'double'} to binary 'operator%'
   42 |     cout << (res + tmp)%(pow(10, 9) + 7) << endl;
      |             ~~~~~~~~~~~^~~~~~~~~~~~~~~~~
      |                  |                  |
      |                  long long int      __gnu_cxx::__promote<double>::__type {aka double}
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;
const ll MOD = 1e9+7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    for (int i=0;i<N;i++) cin >> A[i];
    //内部転倒数を数える
    ll p = 0;
    for (int i=0;i<N-1;i++){
        for (int j=i+1;j<N;j++){
            if (A[i]>A[j]) {
                p++;
                p %= MOD;
            }
        }
    }
    //外部転倒数を数える
    ll q=0;
    for (int i=0;i<N;i++){
        for (int j=0;j<N;j++){
            if (A[j] > A[i]){
                q++;
                q %= MOD;
            }
        }
    }
    ll ans = (p*K)%MOD;
    ans += (((q*K)%MOD)*(K-1))%MOD)/2;
    ans %= MOD;
    cout << ans << "\n";
}

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = (ll)(1e9 + 7);
int main()
{
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    ll sum = 0, sum2 = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<ll> cnts(n, 0);
    ll suma = 0;
    for (int i = 1; i < n; i++)
    {
        int cnt = 0;
        for (int j = 0; j < n; j++)
        {
            if (a[i] > a[j])
                cnt++;
        }
        sum += cnt;
    }
    vector<int> cnts2(n, 0);
    ll sumb = 0;
    for (int i = 0; i < n; i++)
    {
        int cnt = 0;
        for (int j = i + 1; j < n; j++)
        {
            if (a[i] > a[j])
                cnt++;
        }
        sum2 += cnt;
    }
    ll cnt = 0;
    ll cntkmin1 = (k * (k - 1) / 2) % MOD;
    ll cntkmin2 = k % MOD;
    cnt = (sum2 * k % MOD + sum * cntmin1 % MOD);
    cout << cnt << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:35: error: 'cntmin1' was not declared in this scope; did you mean 'cntkmin1'?
   43 |     cnt = (sum2 * k % MOD + sum * cntmin1 % MOD);
      |                                   ^~~~~~~
      |                                   cntkmin1
Language: C++

#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(ll i=0;i< (n);i++)
#define rep1(i,n) for(ll i=1;i<= (n);i++)
using namespace std;
typedef long long ll;
const static ll MOD = (1e+9)+7;

ll modcross(ll a,ll k){
    if(k == 0)return 0;
    if(k % 2 == 1)return (a + modcross(a,k-1)) % MOD;
    ll t = modcross(a,k/2) % MOD;
    return (t * 2) % MOD; 
}

ll main(){
    ll n,k;cin>>n>>k;
    vector<ll> A(n,0);rep(i,n)cin>>A[i];
    ll ans = 0;
    for(ll i = 0;i<n-1;i++){
        for(ll j = i+1;j<n;j++){
            if(A[i]>A[j])ans += (k*(k+1))/2 % MOD ;
            if(A[i]<A[j])ans += (k*(k-1))/2 % MOD;
            ans %= MOD;
        }
    }
    cout<<ans%MOD<<endl;
    return 0;
}

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

#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
    ll n,k;
    cin>>n>>k;
    ll a[2000];
    rep(i,0,n) cin>>a[i];

    ll inside=0;
    rep(i,0,n-1)
    rep(j,i+1,n){
      if(a[i]>a[j]) inside++;
    }

    ll outside=0;
    rep(i,0,n)
    rep(j,0,n){
      if(a[i]>a[j]) outside++;
    }

    //ll ans=(inside*k)%inf;

    //ans+=((k*(k-1)/2)%inf)*(outside);

    ll ans=inside*k;
    ans%=inf;

    ans+=outside*((k*(k-1)/2)%inf);
    ans%=inf;
    cout<<ans<<endl;


    //cout<<ans%inf<<endl;
    //cout<<inside<<' '<<outside;

Compiler output:
a.cc: In function 'int main()':
a.cc:45:21: error: expected '}' at end of input
   45 |     cout<<ans<<endl;
      |                     ^
a.cc:18:11: note: to match this '{'
   18 | int main(){
      |           ^
Language: C++



#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define oset tree<long long, null_type,less_equal<long long>, rb_tree_tag,tree_order_statistics_node_update>
using ll = long long;
ll mod=1e9+7;




int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    while(t--){
        ll n,k,i;
        cin>>n>>k;
        oset s,s2;
        ll a[n+2];
        for(i=0;i<n;i++){
            cin>>a[i];
            s2.insert(a[i]);
        }
        
        ll bigonR[n+2],bigger[n+2];
        for(i=0;i<n;i++){
            bigger[i] = s2.order_of_key(a[i]);
        }
        
        
        for(i=n-1;i>=0;i--){
            bigonR[i]=s.order_of_key(a[i]);
            s.insert(a[i]);
            
        }
        ll sum=0;
        for(i=0;i<n;i++){
            // cout << bigger[i] << ' ' << bigonR[i] << "\n";
            ll kk = (k * (k - 1)) / 2;
            kk %= mod;
            sum += ((bigger[i] * kk) % mod);
            sum %= mod;
            sum += ((bigonR[i] * k) % mod);
            sum %= mod;
        }
        cout << sum;
        cout<<"\n";
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:53:6: error: expected '}' at end of input
   53 |     }
      |      ^
a.cc:15:12: note: to match this '{'
   15 | int main() {
      |            ^