Four Elements from GeeksForGeeks
When to use Assert
Generally assert() is a debugging tool. The GeekforGeeks website itself warns against using it in certain cases.

If the NODEBUG compilation flag is used in the file the assertion is removed.

It might be better to use if statements and write the output to std::cerr. That would provide a much more meaningful error message.

Reduce Complexity, Follow SRP
The Single Responsibility Principle states that every module or class should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility.


  Robert C. Martin expresses the principle as follows:
          A class should have only one reason to change.


While this is primarily targeted at classes in object oriented languages it applies to functions and subroutines well.

The more separate functions there are the easier it is to understand or read the code. This also makes it easier for any programmer to maintain or debug the code.

The main() function could be broken up into at multiple functions. The main() function should generally just control the program and handle any exceptions that get to that point.

An example of a decent main() function for this program might be:

int main() {
    int t;
    std::cin &gt;&gt; t;
    assert(t &gt;= 1 &amp;&amp; t &lt;= 100);
    int x;

    while (t--)
    {
        std::vector&lt;int&gt; vec = getTestCase(x);

        std::cout &lt;&lt; ((executeTestCase(vec, x)) ? 1 : 0) &lt;&lt; std::endl;
    }

    return 0;
}


The first function that might be of use is an test case input function.

std::vector&lt;int&gt; getTestCase(int &amp;x)
{
    int n;
    std::cin &gt;&gt; n;
    assert(n &gt;= 1 &amp;&amp; n &lt;= 100);
    std::vector&lt;int&gt; vec(n);
    for (int i = 0; i &lt; n; i++)
    {
        int val;
        std::cin &gt;&gt; val;
        vec.push_back(val);
    }    

    std::cin &gt;&gt; x;

    return vec;
}


The second function that might be of use would be a that finds if there are values that meet the proper conditions.

bool executeTestCase(std::vector&lt;int&gt; vec, int x)
{
    bool found = false;
    int sum = 0;
    int n = vec.size();

    for (int i = 0; i &lt; n - 3; i++)
    {
        for (int j = i + 1; j &lt; n - 2; j++)
        {
            for (int k = j + 1; k &lt; n - 1; k++)
            {
                for (int l = k + 1; l &lt; n; l++)
                {
                    sum = vec[i] + vec[j] + vec[k] + vec[l];
                    if (sum == x)
                    {
                        found = true;
                        break;
                    }
                }
            }
        }
    }    

    return found;
}


Improve Performance
Since the code is using a C++ container class, it might be possible to use iterators to improve performance. Once the code is broken up into functions and compiled -O3 it can be profiled to find where any bottlenecks exist.