Language: Java

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (ll)1000000007

int main()
{
    int N;
    ll K;
    cin >> N >> K;
    int A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    ll c = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (i != j)
            {
                if (A[j] > A[i])
                {
                    c++;
                }
            }
        }
    }
    ll count = 0;
    for (int i = N - 1; i >= 0; i--)
    {
        for (int j = i - 1; j >= 0; j--)
        {

            if (A[j] > A[i])
            {
                count++;
            }
        }
    }
    ll ans = 0;
    ll k = K;
    K = K * (K - 1)/2 % INF;
    ans = k * count % INF + K * c % INF;
    cout << ans % INF << endl;
}


Compiler output:
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:3: error: class, interface, enum, or record expected
typedef long long ll;
^
Main.java:4: error: illegal character: '#'
#define INF (ll)1000000007
^
Main.java:4: error: class, interface, enum, or record expected
#define INF (ll)1000000007
        ^
Main.java:9: error: unnamed classes are a preview feature and are disabled by default.
    ll K;
    ^
  (use --enable-preview to enable unnamed classes)
Main.java:10: error: class, interface, enum, or record expected
    cin >> N >> K;
    ^
Main.java:11: error: class, interface, enum, or record expected
    int A[N];
    ^
Main.java:12: error: class, interface, enum, or record expected
    for (int i = 0; i < N; i++)
    ^
Main.java:12: error: class, interface, enum, or record expected
    for (int i = 0; i < N; i++)
                    ^
Main.java:12: error: class, interface, enum, or record expected
    for (int i = 0; i < N; i++)
                           ^
Main.java:15: error: class, interface, enum, or record expected
    }
    ^
Main.java:17: error: class, interface, enum, or record expected
    for (int i = 0; i < N; i++)
    ^
Main.java:17: error: class, interface, enum, or record expected
    for (int i = 0; i < N; i++)
                    ^
Main.java:17: error: class, interface, enum, or record expected
    for (int i = 0; i < N; i++)
                           ^
Main.java:19: error: class, interface, enum, or record expected
        for (int j = 0; j < N; j++)
                        ^
Main.java:19: error: class, interface, enum, or record expected
        for (int j = 0; j < N; j++)
                               ^
Main.java:26: error: class, interface, enum, or record expected
                }
                ^
Main.java:31: error: class, interface, enum, or record expected
    for (int i = N - 1; i >= 0; i--)
    ^
Main.java:31: error: class, interface, enum, or record expected
    for (int i = N - 1; i >= 0; i--)
                        ^
Main.java:31: error: class, interface, enum, or record expected
    for (int i = N - 1; i >= 0; i--)
                                ^
Main.java:33: error: class, interface, enum, or record expected
        for (int j = i - 1; j >= 0; j--)
                            ^
Main.java:33: error: class, interface, enum, or record expected
        for (int j = i - 1; j >= 0; j--)
                                    ^
Main.java:39: error: class, interface, enum, or record expected
            }
            ^
Main.java:44: error: class, interface, enum, or record expected
    K = K * (K - 1)/2 % INF;
    ^
Main.java:45: error: class, interface, enum, or record expected
    ans = k * count % INF + K * c % INF;
    ^
Main.java:46: error: class, interface, enum, or record expected
    cout << ans % INF << endl;
    ^
Main.java:47: error: class, interface, enum, or record expected
}
^
28 errors