UVA 10474 - “Where is the marble?”
You are mixing C with C++. I know these contests like speed, but it is usually unnecessary.
1. Prefer streams over scanf.
This means you can change this code:
    scanf(&quot;%d %d&quot;, &amp;numMarbles, &amp;numQueries);

Into this:
    std::cin &gt;&gt; numMarbles &gt;&gt; numQueries ;

2. Use the C++11 auto keyword when possible.
You have a C++11 tag, so I assume you have C++11 available.
You can change this:
std::vector&lt;int&gt;::const_iterator itr = std::lower_bound(marbles.begin(), marbles.end(),aMarble);

To this:
auto itr = std::lower_bound(marbles.begin(), marbles.end(),aMarble);

3. Make sure the iterator does not point past the end when you dereference it.
In this line: if(*itr == aMarble), you dereference the iterator. If aMarble is not in marbles, then std::lower_bound() will return marbles.end(). It is undefined behavior to dereference marbles.end(). Always check for this condition.
So change this line:
if(*itr == aMarble)

To this:
if (iter != marbles.end () &amp;&amp; *itr == aMarble)

4. Prefer pre-increment over post-increment.
You have:
case1++;

In the case an int, it doesn't really matter. Your compiler will optimize this correctly. But if you had a complicated object, then you would be creating an unnecessary copy here. So:
++case1;

Would be a better habit to get into.
5. Encapsulate input and output with an Object.
You could create an object that represents a single unit of input. Something like this:
struct Input
{
    int nMarbles ;
    int nQueries ;
    static int caseNumber ;

    std::vector &lt;int&gt; marbles ;
    std::vector &lt;int&gt; queries ;

    Input () ;
    void Clear () ;

    friend auto operator&gt;&gt; (std::istream &amp;is, Input &amp;input) -&gt; std::istream&amp; ;
    friend auto operator&lt;&lt; (std::ostream &amp;os, const Input &amp;input) -&gt; std::ostream&amp; ;
};

Then you could implement the member and friend functions like this:
int Input::caseNumber = 0 ;

Input::Input () : nMarbles (), nQueries ()
{
} 

void Input::Clear ()
{
    nMarbles = 0 ;
    nQueries = 0 ;
    marbles.clear () ;
    queries.clear () ;
}

auto operator&gt;&gt; (std::istream&amp; is, Input &amp;input) -&gt; std::istream&amp;
{
    ++Input::caseNumber ;

    is &gt;&gt; input.nMarbles &gt;&gt; input.nQueries ;
        
    if (input.nMarbles == 0 &amp;&amp; input.nQueries == 0) {
        is.setstate (std::ios::failbit) ;
        return is ;
    }

    auto begin = std::istream_iterator &lt;int&gt; (is) ;
    std::copy_n (begin, input.nMarbles, std::back_inserter (input.marbles)) ;
    
    begin = std::istream_iterator &lt;int&gt; (is) ;
    std::copy_n (begin, input.nQueries, std::back_inserter (input.queries)) ;

    return is ;
}

auto operator&lt;&lt; (std::ostream &amp;os, Input &amp;input) -&gt; std::ostream&amp;
{
    os &lt;&lt; &quot;CASE# &quot; &lt;&lt; Input::caseNumber &lt;&lt; &quot;:&quot; &quot;\n&quot; ;

    auto &amp;marbles = input.marbles ;

    std::sort (std::begin (marbles), std::end (marbles)) ;
    
    for (int query : input.queries) {
        auto iter = std::lower_bound (std::begin (marbles), std::end (marbles), query) ;

        if (iter != std::end (marbles) &amp;&amp; *iter == query) {
            os &lt;&lt; query &lt;&lt; &quot; found at &quot; &lt;&lt; (std::distance (std::begin (marbles), iter) + 1) &lt;&lt; &quot;\n&quot; ;
        }

        else {
            os &lt;&lt; query &lt;&lt; &quot; not found&quot; &quot;\n&quot; ;
        }
    }

    return os ;
}

Then your driver would look like this:
int main ()
{
    Input input ;

    while (std::cin &gt;&gt; input) {
        std::cout &lt;&lt; input ;
        input.Clear () ;
    }

    return 0 ;
}

With the above code, I got an accepted answer with a runtime of 0.212 units on your website. So streams are more than fast enough for this particular challenge.