#include <cstddef>
#include <iostream>
#include <numeric>
#include <stdexcept>
#include <vector>
long long dot(const std::vector<int>& a,const std::vector<int>& b) {
    if(a.size()!=b.size()) throw std::invalid_argument("shape");
    long long sum=0; std::size_t i=0;
    for(;a.size()-i>=4;i+=4)
        for(std::size_t lane=0;lane<4;++lane) sum+=static_cast<long long>(a[i+lane])*b[i+lane];
    for(;i<a.size();++i) sum+=static_cast<long long>(a[i])*b[i];
    return sum;
}
int main() {
    for(std::size_t n=0;n<=9;++n) {
        std::vector<int> a(n,2),b(n,3);
        if(dot(a,b)!=static_cast<long long>(n)*6) throw std::runtime_error("tail");
    }
    bool rejected=false;
    try {
        const auto unexpected=dot({1},{});
        std::cout<<"unexpected mismatched dot="<<unexpected<<'\n';
        return 1;
    } catch(const std::invalid_argument&){rejected=true;}
    if(!rejected || dot({1,2,3,4,5},{2,3,4,5,6})!=70) throw std::runtime_error("dot");
    std::cout<<"dot=70 tail=1\n";
}
