This post was originally written on Codeforces; relevant discussion can be found here.

As of May 2024, the bug has been fixed in GCC 14, but has not been ported to Codeforces yet.

MikeMirzayanov added a new compiler in response to the bug mentioned here. However, it does not come without a catch.

Namely, any pragma that is of the form #pragma GCC target(...) would NOT work with this new compiler. The issue is well-known by people who use up-to-date compilers but there has not been much progress towards a fix.

One of the ways to fix it is to add the target pragma AFTER the STL includes. This should make your code compile, but a lot of code would simply not be optimized, so use it at your own risk.

The other way is to use g++-12, but risk a TLE due to the linked post (it’s easy to write hacks for most problems). Fortunately, there is a fix for this hack, but, echoing the words of the post author, use that at your own risk.

For completeness, the first two of these don’t compile on g++-13 but the last one does.

#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <vector>
int main() { std::vector<int> a; }
#pragma GCC target("avx")
#include <vector>
int main() { std::vector<int> a; }
#pragma GCC optimize("O3")
#include <vector>
#pragma GCC target("avx")
int main() { std::vector<int> a; }