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
#include<bits/stdc++.h>

using namespace std;


int main() {
    std::ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    vector<long long> tab;
    vector<long long> result;
    vector<long long> pref;
    int n; cin >> n;
    result.resize(n);
    tab.resize(n);
    pref.resize(n + 1);
    for (int i = 0; i < n; i++)
        cin >> tab[i];
    result[0] = tab[0];
    for (int i = 1; i < n; i++)
        result[i] = tab[i] - tab[i-1];
    pref[0] = 0;
    for (int i = 1; i <= n; i++)
        pref[i] = pref[i - 1] + result[i - 1];
    bool flag = true;
    for(int i = 0; i < n; i++) {
        for(int q = i; q < n; q++) {
            if((pref[q + 1] - pref[i]) > tab[q - i])
                flag = false;
        }
    }
    if(flag) {
        cout << "TAK\n";
        cout << n << "\n";
        for(int i = 0; i < n; i++)
            cout << result[i] << " ";
    }
    else
        cout << "NIE\n";
}