1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <bits/stdc++.h>

#include "teatr.h"
#include "message.h"

using namespace std;

vector <int> A, B, Nieparzyste;

int main(){
    int id = MyNodeId();
    if(id != 0) return 0;
    
    int n = GetN();
  //  int n;
//cin >> n;    
    for(int i = 0; i < n; i++){
        A.push_back(GetElement(i));        
        //int x; cin >> x; A.push_back(x);    
    }

    for(int i = 1; i <= n; i++){
        B.push_back(0);
        Nieparzyste.push_back(0);
    }
    int ile_zer = 0;
    while (ile_zer < n){
        for (int i = 0; i < n; i++)
            Nieparzyste[i] = 0;
        ile_zer = 0;
        for(int i = 0; i < n; i++){
             if (A[i] % 2 != 0)
                Nieparzyste[A[i]] = Nieparzyste[A[i]] + 1;
             else{
                B[i] = B[i] + Nieparzyste[A[i] + 1];
            }
 A[i] /= 2;
             if (A[i] == 0)
                ile_zer++;
        }
//cout << ile_zer << "\n";
    }
    
    long long result = 0;
    for(int i = 0; i < n; i++)
        result += B[i];

    cout << result << "\n";
    return 0;
    
}