Submission details
Task:Optimal sort
Sender:aalto26hm_035
Submission time:2026-10-26 16:56:46 +0200
Language:C++ (C++20)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#5ACCEPTED0.00 sdetails
#6ACCEPTED0.00 sdetails
#7ACCEPTED0.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.00 sdetails
#10ACCEPTED0.01 sdetails
#11ACCEPTED0.00 sdetails
#12ACCEPTED0.00 sdetails
#13ACCEPTED0.00 sdetails
#14ACCEPTED0.00 sdetails
#15ACCEPTED0.00 sdetails
#16ACCEPTED0.00 sdetails
#17ACCEPTED0.00 sdetails
#18ACCEPTED0.00 sdetails
#19ACCEPTED0.00 sdetails
#20ACCEPTED0.00 sdetails
#21ACCEPTED0.00 sdetails
#22ACCEPTED0.00 sdetails
#23ACCEPTED0.00 sdetails
#24ACCEPTED0.00 sdetails
#25ACCEPTED0.00 sdetails
#26ACCEPTED0.00 sdetails
#27ACCEPTED0.00 sdetails
#28ACCEPTED0.00 sdetails
#29ACCEPTED0.00 sdetails
#30ACCEPTED0.00 sdetails
#31ACCEPTED0.00 sdetails
#32ACCEPTED0.00 sdetails
#33ACCEPTED0.00 sdetails
#34ACCEPTED0.00 sdetails
#35ACCEPTED0.00 sdetails
#36ACCEPTED0.00 sdetails
#37ACCEPTED0.00 sdetails
#38ACCEPTED0.00 sdetails
#39ACCEPTED0.00 sdetails
#40ACCEPTED0.00 sdetails
#41ACCEPTED0.00 sdetails
#42ACCEPTED0.00 sdetails
#43ACCEPTED0.00 sdetails
#44ACCEPTED0.00 sdetails
#45ACCEPTED0.00 sdetails
#46ACCEPTED0.00 sdetails
#47ACCEPTED0.00 sdetails
#48ACCEPTED0.00 sdetails
#49ACCEPTED0.00 sdetails
#50ACCEPTED0.00 sdetails
#51ACCEPTED0.01 sdetails
#52ACCEPTED0.01 sdetails
#53ACCEPTED0.01 sdetails
#54ACCEPTED0.01 sdetails
#55ACCEPTED0.01 sdetails
#56ACCEPTED0.01 sdetails
#57ACCEPTED0.01 sdetails
#58ACCEPTED0.01 sdetails
#59ACCEPTED0.01 sdetails
#60ACCEPTED0.01 sdetails
#61--details
#62--details
#63--details
#64--details
#65--details
#66--details
#67--details
#68--details
#69--details
#70--details

Code

#include <iostream>
#include <vector>
#include <functional>
#include <set>
#include <algorithm>
#include <stack>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <limits>
#include <queue>
#include <math.h>

typedef long long LL;

std::tuple<LL> readLL1(){
    LL a;
    std::cin >> a;
    return {a};
}
std::tuple<LL,LL> readLL2(){
    LL a, b;
    std::cin >> a >> b;
    return {a,b};
}
std::tuple<LL,LL,LL> readLL3(){
    LL a, b, c;
    std::cin >> a >> b >> c;
    return {a,b,c};
}

std::vector<LL> readVecLL(LL n){
    std::vector<LL> arr(n);
    for (LL i = 0; i < n; i++){
        LL a;
        std::cin >> a;
        arr[i] = a;
    }
    return arr;
}
std::vector<std::string> readVecStr(LL n){
    std::vector<std::string> arr(n);
    for (LL i = 0; i < n; i++){
        std::string a;
        std::cin >> a;
        arr[i] = a;
    }
    return arr;
}

std::vector<long long> readVecLong(LL n){
    std::vector<long long> arr(n);
    for (LL i = 0; i < n; i++){
        long long a;
        std::cin >> a;
        arr[i] = a;
    }
    return arr;
}

std::vector<std::tuple<LL,LL>> readVecTup2(LL n){
    std::vector<std::tuple<LL,LL>> arr(n);
    for (LL i = 0; i < n; i++){
        LL a, b;
        std::cin >> a;
        std::cin >> b;
        arr[i] = {a,b};
    }
    return arr;
}

std::vector<std::tuple<LL,LL,LL>> readVecTup3(LL n){
    std::vector<std::tuple<LL,LL,LL>> arr(n);
    for (LL i = 0; i < n; i++){
        LL a, b, c;
        std::cin >> a;
        std::cin >> b;
        std::cin >> c;
        arr[i] = {a,b,c};
    }
    return arr;
}
std::vector<std::tuple<double,double,double>> readVecTup3Dup(LL n){
    std::vector<std::tuple<double,double,double>> arr(n);
    for (LL i = 0; i < n; i++){
        double a, b, c;
        std::cin >> a;
        std::cin >> b;
        std::cin >> c;
        arr[i] = {a,b,c};
    }
    return arr;
}
std::vector<std::tuple<LL,LL,LL,LL>> readVecTup4(LL n){
    std::vector<std::tuple<LL,LL,LL,LL>> arr(n);
    for (LL i = 0; i < n; i++){
        LL a, b, c,d;
        std::cin >> a;
        std::cin >> b;
        std::cin >> c;
        std::cin >> d;
        arr[i] = {a,b,c,d};
    }
    return arr;
}

void printNewLine(){std::cout << "\n";}
template<typename T, typename... Ts>
std::tuple<Ts...> tail(std::tuple<T,Ts...> as){
    return std::apply([](T &a, Ts... b){return std::make_tuple(b...);},as);
}

template<typename T>
void print(T a){std::cout << std::setprecision(19) << a;}
template<typename... T>
void println(T... a);

template<typename T, typename Ts>
void print(std::tuple<T,Ts> a){
    print(std::get<0>(a));
    print(" ");
    print(std::get<1>(a));
}

template<typename T, typename... Ts>
void print(std::tuple<T,Ts...> a){
    print(std::get<0>(a));
    print(" ");
    print(tail(a));
}

template<typename T>
void print(const std::vector<T> &arr, LL width = -1){
    if (width == -1) width = arr.size();
    for (LL i = 0; i < (LL)arr.size(); i++){
        print(arr[i]);
        if (i+1 == (LL)arr.size()) continue;
        if ((i%width) == width-1) printNewLine();
        if ((i%width) != width-1) print(" ");
    }    
}
template<typename... T>
void println(T... a){print(a...);printNewLine();}



template<typename T>
void sorted(std::vector<T> &arr){
    std::sort(arr.begin(),arr.end(),[](const T &a, const T &b){ return a < b; });
}


template<typename T>
std::set<T> toSet(const std::vector<T> &vec){
    std::set<T> c;
    for (T a : vec){ c.emplace(a);}
    return c;
}

template<typename T, typename N>
std::vector<N> map(const std::vector<T> &a, const std::function<N(T)> &transform){
    std::vector<N> b(a.size());
    LL i = 0;
    for (T x : a){
        b[i] = transform(x);
        i++;
    }
    return b;
}

template<typename N, typename M, typename R>
std::vector<R> zip(const std::vector<N> &a, const  std::vector<M> &b, const std::function<R(N,M)> &transform){
    LL n = std::min(a.size(),b.size());
    std::vector<R> res(n);
    for (LL i = 0; i < n; i++){
        res[i] = transform(a[i],b[i]);
    }
    return res;
}

template<typename T, typename N>
std::vector<N> convertVec(const std::vector<T> &a){
    std::vector<N> b(a.size());
    LL i = 0;
    for (T x : a){
        b[i] = x;
        i++;
    }
    return b;
}
template<typename T>
std::vector<T> reverse(const std::vector<T> &a){
    std::vector<T> b(a.size());
    LL i = 0;
    for (T x : a){
        b[a.size()-1-i] = x;
        i++;
    }
    return b;
}



template<typename T, typename R>
R reduce(const std::vector<T> &arr, R init, const std::function<R(const R,const T)> &transform){
    R current = init;
    for (LL idx = 0; idx < (LL)arr.size(); idx++){
        current = transform(current,arr[idx]);
    };
    return current;
}
template<typename T>
T max(const std::vector<T> &arr){return reduce(arr, arr[0], static_cast<std::function<T(const T,const T)>>(static_cast<const T& (*)(const T&, const T&)>(std::max<T>)));}
template<typename T>
T min(const std::vector<T> &arr){return reduce(arr, arr[0], static_cast<std::function<T(const T,const T)>>(static_cast<const T& (*)(const T&, const T&)>(std::min<T>)));}

template<typename T>
std::function<T(const T,const T)> add(){return [](T a,T b){return a+b;};}
template<typename T>
std::function<T(const T,const T)> modAdd(T mod){return [mod](T a,T b){return (((a+b)%mod)+mod)%mod;};}
template<typename T, typename R>
std::function<R(const R,const T)> mulAdd(R mul){return [mul](R a,T b){return a+b*mul;};}
template<typename T>
T sum(const std::vector<T> &arr){return reduce(arr, 0, add<T>());}
template<typename T>
T avg(const std::vector<T> &arr){return reduce(arr, 0.0, mulAdd<double,T>(1.0/arr.size()));}

template<typename T>
T binarySearch(T min, T max, const std::function<bool(T)> &leq){
    if (min == max) return max;
    T guess = (min+max)/2;
    if (leq(guess)){
        return binarySearch(min,guess,leq);
    }else{
        return binarySearch(guess+1,max,leq);
    }
}

template<typename T>
T binarySearchDecending(T min, T max, const std::function<bool(T)> &leq){
    std::function<bool(T)> gt = [leq](T x){
        return !leq(x);
    };
    return binarySearch(min,max+1, gt)-1;
}

template<typename T>
std::vector<T> cloneVec(std::vector<T> a){return a;}

template<typename T>
std::vector<T> padding(const std::vector<T> &initial, T num, LL start, LL end){
    std::vector<T> arr(start+initial.size()+end);
    for (LL i = 0; i < start; i++){
        arr[i] = num;
    }
    for (LL i = 0; i < (LL)initial.size(); i++){
        arr[start+i] = initial[i];
    }
    for (LL i = 0; i < end; i++){
        arr[start+initial.size()+i] = num;
    }
    return arr;
}

template<typename T>
LL findMax(LL start, LL end, const std::function<T(LL)> &maxHeuristic){
    T initialGuess = maxHeuristic(start);
    LL index = start;
    for (LL i = start; i <= end; i++){
        if (initialGuess < maxHeuristic(i)){
            initialGuess = maxHeuristic(i);
            index = i;
        }
    }
    return index;
}

template<typename T>
void operateOnMax(LL start, LL end, const std::function<T(LL)> &maxHeuristic, const std::function<void(LL)> &found){
    found(findMax(start,end,maxHeuristic));
}

template<typename T>
void stackOperate(std::vector<T> init, const std::function<std::vector<T>(T)> operate){
    std::stack<T> stack;
    for (auto x : init){
        stack.push(x);
    }
    while (!stack.empty()){
        T next = stack.top();
        stack.pop();
        std::vector<T> nextSteps = operate(next);
        for (T a : nextSteps){
            stack.push(a);
        }
    }
}

template<typename T>
void queueOperate(std::vector<T> init, const std::function<std::vector<T>(T)> operate){
    std::queue<T> que;
    for (auto x : init){
        que.push(x);
    }
    while (!que.empty()){
        T next = que.front();
        que.pop();
        std::vector<T> nextSteps = operate(next);
        for (T a : nextSteps){
            que.push(a);
        }
    }
}

template<typename T>
void priorityQueueOperate(std::vector<T> init, const std::function<std::vector<T>(T)> operate){
    std::priority_queue<T> que;
    for (auto x : init){
        que.push(x);
    }
    while (!que.empty()){
        T next = que.top();
        que.pop();
        std::vector<T> nextSteps = operate(next);
        for (T a : nextSteps){
            que.push(a);
        }
    }
}

template<typename T>
void recursiveVectorSplit(LL start, LL end, LL distl, LL distr, const std::function<T(LL)> &maxHeuristic, const std::function<void(LL)> &found){
    if (start == end){
        return found(start);
    }else if (end < start){
        return;
    }
    std::tuple<LL,LL> range = {start,end};
    std::function<std::vector<std::tuple<LL,LL>>(std::tuple<LL,LL>)> splitter = [distl, distr,&maxHeuristic,&found](std::tuple<LL,LL> range){
        auto [start,end] = range;
        LL idx = findMax(start, end, maxHeuristic);
        found(idx);
        std::vector<std::tuple<LL,LL>> next;
        if (idx+distl+1 <= end){
            next.push_back({idx+distl+1,end});
        }
        if (start <= idx-distr-1){
            next.push_back({start, idx-distr-1});
        }
        return next;
    };
    stackOperate({range},splitter);
}


template<typename T>
std::vector<T> dynamicallyComputableList(LL n, std::function<T(std::vector<T>&,LL)> next){
    std::vector<T> arr(n);
    for (LL i = 0; i < n; i++){
        arr[i] = next(arr,i);
    }
    return arr;
}
template<typename T>
LL indexOfBinarySearch(const std::vector<T> &arr, const T &find){
    return binarySearch((LL)0,(LL)arr.size()-1,(std::function<bool(LL)>)[&arr, &find](LL guess){return find <= arr[guess];});
}

template<typename T>
std::unordered_map<T, LL> indexCompress(const std::vector<T> &arr){
    std::unordered_map<T, LL> compressed;
    LL i = 0;
    for (T x : arr){
        if (compressed.find(x) != compressed.end()) compressed[x] = i++;
    }
    return compressed;
}   

template<typename... Ts>
std::tuple<std::vector<std::tuple<LL,Ts...>>, std::vector<LL>> edgeIndexing(int n, std::vector<std::tuple<LL,Ts...>> edges){
    sorted(edges);
    std::vector<LL> edgeIndex(n+1);
    {
        LL j = 0;
        for (LL i = 0; i < (LL)edges.size(); i++) {
            auto a = std::get<0>(edges[i]);
            while (j <= a){
                edgeIndex[j++] = i;
            }
        }
        while (j < n){
            edgeIndex[j++] = edges.size();
        }
        edgeIndex[n] = edges.size(); 
    }
    return {edges,edgeIndex};
}


template<typename T>
std::tuple<std::vector<T>, std::vector<LL>> shortestPathDirected(const LL n, std::vector<std::tuple<LL, LL, T>> edgesInit, LL start){
    //assumes all paths are between 0 <= c < n
    //assumes 0 indexing
    std::vector<LL> path(n);
    std::vector<bool> edgeUpdated(n);
    std::vector<T> distance(n);
    for (LL i = 0; i < n; i++) path[i] = i;
    for (LL i = 0; i < n; i++) edgeUpdated[i] = true;
    edgeUpdated[start] = false;
    for (LL i = 0; i < n; i++) distance[i] = std::numeric_limits<T>::max()/4;
    distance[start] = 0;
    auto [edges,edgeIndex] = edgeIndexing(n,edgesInit);
    std::function<std::vector<std::tuple<LL,LL>>(std::tuple<LL,LL>)> func = [&distance,&edgeIndex,&edges,&path,&edgeUpdated](std::tuple<LL,LL> propagateW){
        auto& [weight,propagate] = propagateW;
        std::vector<std::tuple<LL,LL>> next;
        if (distance[propagate] != -weight) return next;
        if (edgeUpdated[propagate]) return next;
        for (LL i = edgeIndex[propagate]; i < edgeIndex[propagate+1]; i++){
            auto& [a, b, w] = edges[i];
            if (distance[a]+w < distance[b]){
            //if (std::min(distance[a],w) > distance[b]){
                next.push_back({-(distance[a]+w),b});
                //next.push_back({std::min(distance[a],w),b});
                distance[b] = std::min(distance[a],w);
                path[b] = a;
                edgeUpdated[b] = false;
            }
        }
        edgeUpdated[propagate] = true;
        return next;
    };
    priorityQueueOperate((std::vector<std::tuple<LL,LL>>){{0,start}},func);
    //for (LL i = 0; i < n; i++) {
    //    bool changed = false;
    //    for (auto& e : edges) {
    //        auto& [a, b, w] = e;
    //        if (!changed) {changed = (distance[b] != std::min(distance[b], distance[a]+w));}
    //        if (distance[a]+w < distance[b]){
    //            distance[b] = distance[a]+w;
    //            path[b] = a;
    //        }
    //    }
    //    if (!changed) break;
    //    if (changed && i == n){
    //        return std::tuple((std::vector<T>){},(std::vector<LL>){});
    //    }
    //}
    return std::tuple(distance,path);
}

std::vector<LL> pathFromPathMap(std::vector<LL> &map, LL goal){
    std::stack<LL> fullPath;
    fullPath.push(goal);
    while (map[fullPath.top()] != fullPath.top()){
        fullPath.push(map[fullPath.top()]);
    }
    std::vector<LL> p;
    while (!fullPath.empty()){
        p.push_back(fullPath.top());
        fullPath.pop();
    }
    return p;
}


template<typename T>
std::tuple<std::vector<T>, std::vector<LL>> shortestPath(const LL n, std::vector<std::tuple<LL, LL, T>> &edgesMessy, LL start){
    std::vector<std::tuple<LL, LL, T>> edges;
    for (auto e : edgesMessy){
        auto [a,b,t] = e;
        edges.push_back({a,b,t});
        edges.push_back({b,a,t});
    }
    return shortestPathDirected(n, edges, start);
}



template<typename T>
std::vector<T> range(const std::vector<T> &a, LL from, LL to){
    std::vector<T> b;
    for (LL i = from; i < to; i++){
        b.push_back(a[i]);
    }
    return b;
}

template<typename T>
bool forall(const std::vector<T> &a, std::function<bool(T)> &test){
    bool res = true;
    for (auto v : a){
        res = res & test(v);
    }
    return res;
}
int main() {
    auto [n] = readLL1();
    auto nums = readVecLL(n);
    auto nums2 = nums;
    sorted(nums2);
    int count = 0;
    for (int i = 0; i < n; i++){
        if (nums[i] == nums2[i]) continue;
        for (int j = i+1; j < n; j++){
            if (nums[i] == nums2[j] && nums[j] == nums2[i]){
                std::swap(nums[i],nums[j]);
                count+=1;
                break;
            }
        }
        if (nums[i] == nums2[i]) continue;
        for (int j = i+1; j < n; j++){
            if (nums[j] == nums2[i]){
                std::swap(nums[i],nums[j]);
                count+=1;
                break;
            }
        }
    }
    //for (int i = 0; i < n; i++){
    //    if (nums[i] != nums2[i]){
    //        count+=1;
    //    }
    //}
    //if (count >0) count--;
    println(count);
    return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
1
14 

correct output
0

user output
0

Test 2

Verdict: ACCEPTED

input
2
18 1 

correct output
1

user output
1

Test 3

Verdict: ACCEPTED

input
2
3 8 

correct output
0

user output
0

Test 4

Verdict: ACCEPTED

input
3
6 13 8 

correct output
1

user output
1

Test 5

Verdict: ACCEPTED

input
3
8 6 14 

correct output
1

user output
1

Test 6

Verdict: ACCEPTED

input
3
19 11 5 

correct output
1

user output
1

Test 7

Verdict: ACCEPTED

input
4
17 15 16 13 

correct output
1

user output
1

Test 8

Verdict: ACCEPTED

input
4
16 8 12 19 

correct output
2

user output
2

Test 9

Verdict: ACCEPTED

input
4
13 18 5 15 

correct output
3

user output
3

Test 10

Verdict: ACCEPTED

input
4
20 18 11 17 

correct output
3

user output
3

Test 11

Verdict: ACCEPTED

input
5
17 12 15 13 11 

correct output
2

user output
2

Test 12

Verdict: ACCEPTED

input
5
15 20 9 1 19 

correct output
4

user output
4

Test 13

Verdict: ACCEPTED

input
5
1 11 9 19 4 

correct output
2

user output
2

Test 14

Verdict: ACCEPTED

input
5
17 2 15 6 12 

correct output
4

user output
4

Test 15

Verdict: ACCEPTED

input
5
4 18 20 11 19 

correct output
3

user output
3

Test 16

Verdict: ACCEPTED

input
5
2 5 8 17 18 

correct output
0

user output
0

Test 17

Verdict: ACCEPTED

input
5
19 5 7 17 18 

correct output
4

user output
4

Test 18

Verdict: ACCEPTED

input
5
2 5 9 7 16 

correct output
1

user output
1

Test 19

Verdict: ACCEPTED

input
5
8 20 1 18 5 

correct output
2

user output
2

Test 20

Verdict: ACCEPTED

input
5
10 8 11 3 1 

correct output
4

user output
4

Test 21

Verdict: ACCEPTED

input
10
8 18 15 13 6 12 9 17 2 11 

correct output
6

user output
6

Test 22

Verdict: ACCEPTED

input
10
5 7 1 19 9 20 8 3 2 15 

correct output
9

user output
9

Test 23

Verdict: ACCEPTED

input
10
5 11 10 7 4 14 19 1 9 13 

correct output
8

user output
8

Test 24

Verdict: ACCEPTED

input
10
17 12 2 3 18 15 9 6 11 1 

correct output
9

user output
9

Test 25

Verdict: ACCEPTED

input
10
18 13 20 12 4 5 19 15 14 11 

correct output
7

user output
7

Test 26

Verdict: ACCEPTED

input
10
18 8 17 2 10 13 16 5 19 20 

correct output
7

user output
7

Test 27

Verdict: ACCEPTED

input
10
3 5 18 19 17 2 1 20 8 7 

correct output
8

user output
8

Test 28

Verdict: ACCEPTED

input
10
9 7 16 5 20 2 10 15 11 6 

correct output
7

user output
7

Test 29

Verdict: ACCEPTED

input
10
17 8 11 20 18 5 16 9 1 13 

correct output
8

user output
8

Test 30

Verdict: ACCEPTED

input
10
5 10 11 2 1 7 3 9 18 8 

correct output
9

user output
9

Test 31

Verdict: ACCEPTED

input
100
567896598 831327091 483130123 ...

correct output
95

user output
95

Test 32

Verdict: ACCEPTED

input
100
253498609 556362063 442153869 ...

correct output
95

user output
95

Test 33

Verdict: ACCEPTED

input
100
833824080 874174469 536879893 ...

correct output
96

user output
96

Test 34

Verdict: ACCEPTED

input
100
55262494 701594610 766185388 6...

correct output
98

user output
98

Test 35

Verdict: ACCEPTED

input
100
385222461 258813232 585406893 ...

correct output
95

user output
95

Test 36

Verdict: ACCEPTED

input
100
528427003 520690782 556647080 ...

correct output
92

user output
92

Test 37

Verdict: ACCEPTED

input
100
845689539 115595477 723524474 ...

correct output
95

user output
95

Test 38

Verdict: ACCEPTED

input
100
566683130 399845016 457901037 ...

correct output
98

user output
98

Test 39

Verdict: ACCEPTED

input
100
401801721 431563805 933290530 ...

correct output
95

user output
95

Test 40

Verdict: ACCEPTED

input
100
941909102 224913296 697438766 ...

correct output
97

user output
97

Test 41

Verdict: ACCEPTED

input
200
444811497 903431470 720091934 ...

correct output
191

user output
191

Test 42

Verdict: ACCEPTED

input
200
336536656 534840541 835789078 ...

correct output
194

user output
194

Test 43

Verdict: ACCEPTED

input
200
395789335 866736363 824087376 ...

correct output
195

user output
195

Test 44

Verdict: ACCEPTED

input
200
238325464 289089504 743727937 ...

correct output
192

user output
192

Test 45

Verdict: ACCEPTED

input
200
718880754 431102449 403271411 ...

correct output
197

user output
197

Test 46

Verdict: ACCEPTED

input
200
97225921 989421484 860498340 2...

correct output
194

user output
194

Test 47

Verdict: ACCEPTED

input
200
296729043 504301807 26318971 8...

correct output
193

user output
193

Test 48

Verdict: ACCEPTED

input
200
903692950 776814822 973264570 ...

correct output
196

user output
196

Test 49

Verdict: ACCEPTED

input
200
290066783 874736248 463312759 ...

correct output
192

user output
192

Test 50

Verdict: ACCEPTED

input
200
973107823 90258367 557823872 1...

correct output
194

user output
194

Test 51

Verdict: ACCEPTED

input
1000
592912152 847045692 284064425 ...

correct output
990

user output
990

Test 52

Verdict: ACCEPTED

input
1000
407810678 616563051 942898335 ...

correct output
990

user output
990

Test 53

Verdict: ACCEPTED

input
1000
618641025 671935409 944035992 ...

correct output
993

user output
993

Test 54

Verdict: ACCEPTED

input
1000
366766968 558964810 539824828 ...

correct output
994

user output
994

Test 55

Verdict: ACCEPTED

input
1000
307827860 66173733 860833950 9...

correct output
994

user output
994

Test 56

Verdict: ACCEPTED

input
1000
249869917 995683003 692483481 ...

correct output
991

user output
991

Test 57

Verdict: ACCEPTED

input
1000
955687818 719718081 43478262 6...

correct output
990

user output
990

Test 58

Verdict: ACCEPTED

input
1000
734196441 465297605 360643915 ...

correct output
992

user output
992

Test 59

Verdict: ACCEPTED

input
1000
851978986 549468516 638503725 ...

correct output
988

user output
988

Test 60

Verdict: ACCEPTED

input
1000
310014536 901327171 160589368 ...

correct output
992

user output
992

Test 61

Verdict:

input
100000
614666693 269733332 88642683 5...

correct output
99989

user output
(empty)

Test 62

Verdict:

input
100000
272940982 811925955 61591592 5...

correct output
99992

user output
(empty)

Test 63

Verdict:

input
100000
620599476 742651279 318143272 ...

correct output
99989

user output
(empty)

Test 64

Verdict:

input
100000
848936553 838116035 936109023 ...

correct output
99983

user output
(empty)

Test 65

Verdict:

input
100000
480849086 599714294 875965742 ...

correct output
99984

user output
(empty)

Test 66

Verdict:

input
100000
888068198 739874627 942196434 ...

correct output
99987

user output
(empty)

Test 67

Verdict:

input
100000
169827791 713679537 698075748 ...

correct output
99986

user output
(empty)

Test 68

Verdict:

input
100000
636712086 376507123 906440322 ...

correct output
99987

user output
(empty)

Test 69

Verdict:

input
100000
300349845 13933235 833947124 8...

correct output
99985

user output
(empty)

Test 70

Verdict:

input
100000
200888519 710864746 665880694 ...

correct output
99985

user output
(empty)