Language: C++

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
def dump(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

# 5
# 3 5 2 1 4
def cum(i):
    res = 0
    while i>0:
        res += bit[i]
        i -= i&-i
    return res

def add(i, x):
    while i<=N:
        bit[i] += x
        i += i&-i

def pos(a):
    return i

def solve():
    global N,A,bit
    N = int(input())
    A = list(map(int, input().split()))
    bit = [0]*(N+1)

    B = list(set(A))
    B.sort()
    B = [-1] + B

    res = 0
    for i in range(N):
        j = bisect_left(B, A[i])
        res += cum(j)
        add(j, 1)

    print(N*(N-1)//2-res)

    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
    except:
        pass
    solve()
# vim: set foldmethod=marker:}}}



Compiler output:
a.cc:1:2: error: invalid preprocessing directive #!
    1 | #!/usr/bin/env python
      |  ^
a.cc:2:3: error: invalid preprocessing directive #-
    2 | # -*- coding: utf-8 -*-
      |   ^
a.cc:4:13: error: stray '#' in program
    4 | import sys  # {{{
      |             ^
a.cc:21:3: error: invalid preprocessing directive #}
   21 | # }}}
      |   ^
a.cc:23:3: error: invalid preprocessing directive #pre
   23 | # pre-defined{{{
      |   ^~~
a.cc:28:60: error: stray '#' in program
   28 | ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
      |                                                            ^
a.cc:40:11: warning: multi-character character constant [-Wmultichar]
   40 |     print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
      |           ^~~~
a.cc:40:41: warning: trigraph ??' ignored, use -trigraphs to enable [-Wtrigraphs]
   40 |     print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
a.cc:40:39: warning: multi-character character constant [-Wmultichar]
   40 |     print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
      |                                       ^~~~~
a.cc:40:46: warning: multi-character character constant [-Wmultichar]
   40 |     print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
      |                                              ^~~~~~
a.cc:41:3: error: invalid preprocessing directive #}
   41 | # }}}
      |   ^
a.cc:43:19: error: stray '#' in program
   43 | def local_input():# {{{
      |                   ^
a.cc:48:36: warning: multi-character literal with 16 characters exceeds 'int' size of 4 bytes
   48 |     inputfile = parentdir.joinpath('test/sample-1.in')
      |                                    ^~~~~~~~~~~~~~~~~~
a.cc:51:3: error: invalid preprocessing directive #}
   51 | # }}}
      |   ^
a.cc:5:5: error: "5" is not a valid filename
    5 | import os
      |     ^
a.cc:41:27: error: stray '#' in program
   41 | # }}}
      |                           ^
a.cc:47:3: error: invalid preprocessing directive #vim
   47 |     parentdir = Path(os.path.dirname(__file__)).parent
      |   ^ ~
a.cc:4:1: error: 'import' does not name a type
    4 | import sys  # {{{
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'