Subtract sum from second array elements one by one and check it 's present in array first  or not
for ( int j = 0 ; j < m ; j ++ ) if ( s . find ( x - arr2 [ j ] ) != s . end ( ) ) cout << x - arr2 [ j ] << " ▁ " << arr2 [ j ] << endl ; }