Code:
==8945== Memcheck, a memory error detector
==8945== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==8945== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==8945== Command: ./s datasets/outputDir-1k/outputDir-1k/ datasets/1k-sample-queries.txt
==8945==
edw0 0
edw2
edw4
174 280 3
174 => 280, 3 21, 1 194, 1 211, 1 251, 1 320, 1 434, 1 631, 1 699, 1 785, 1 812, 1 980, 1 0, 0 1, 0 2, 0 10, 0 11, 0 22, 0 38, 0 63, 0 64, 0 65, 0 66, 0 67, 0
edw5
edw6
edw7
==8945== Invalid read of size 4
==8945== at 0x40A2BE5: std::_Rb_tree_increment(std::_Rb_tree_node_base*) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==8945== by 0x805CB61: query_3::Query3::Execute(int, int, std::string) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x8049A99: main (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== Address 0x449e3e4 is 12 bytes inside a block of size 24 free'd
==8945== at 0x402ACFC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==8945== by 0x8063332: __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<unsigned int, int> > >::deallocate(std::_Rb_tree_node<std::pair<unsigned int, int> >*, unsigned int) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x8062C91: std::_Rb_tree<std::pair<unsigned int, int>, std::pair<unsigned int, int>, std::_Identity<std::pair<unsigned int, int> >, query_3::classcomp, std::allocator<std::pair<unsigned int, int> > >::_M_put_node(std::_Rb_tree_node<std::pair<unsigned int, int> >*) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x806206B: std::_Rb_tree<std::pair<unsigned int, int>, std::pair<unsigned int, int>, std::_Identity<std::pair<unsigned int, int> >, query_3::classcomp, std::allocator<std::pair<unsigned int, int> > >::_M_destroy_node(std::_Rb_tree_node<std::pair<unsigned int, int> >*) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x806113F: std::_Rb_tree<std::pair<unsigned int, int>, std::pair<unsigned int, int>, std::_Identity<std::pair<unsigned int, int> >, query_3::classcomp, std::allocator<std::pair<unsigned int, int> > >::_M_erase_aux(std::_Rb_tree_const_iterator<std::pair<unsigned int, int> >) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x805F46D: std::_Rb_tree<std::pair<unsigned int, int>, std::pair<unsigned int, int>, std::_Identity<std::pair<unsigned int, int> >, query_3::classcomp, std::allocator<std::pair<unsigned int, int> > >::erase(std::_Rb_tree_const_iterator<std::pair<unsigned int, int> >) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x80626ED: std::_Rb_tree<std::pair<unsigned int, int>, std::pair<unsigned int, int>, std::_Identity<std::pair<unsigned int, int> >, query_3::classcomp, std::allocator<std::pair<unsigned int, int> > >::_M_erase_aux(std::_Rb_tree_const_iterator<std::pair<unsigned int, int> >, std::_Rb_tree_const_iterator<std::pair<unsigned int, int> >) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x8061332: std::_Rb_tree<std::pair<unsigned int, int>, std::pair<unsigned int, int>, std::_Identity<std::pair<unsigned int, int> >, query_3::classcomp, std::allocator<std::pair<unsigned int, int> > >::erase(std::_Rb_tree_iterator<std::pair<unsigned int, int> >, std::_Rb_tree_iterator<std::pair<unsigned int, int> >) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x805F4B8: std::_Rb_tree<std::pair<unsigned int, int>, std::pair<unsigned int, int>, std::_Identity<std::pair<unsigned int, int> >, query_3::classcomp, std::allocator<std::pair<unsigned int, int> > >::erase(std::pair<unsigned int, int> const&) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x805DF61: std::set<std::pair<unsigned int, int>, query_3::classcomp, std::allocator<std::pair<unsigned int, int> > >::erase(std::pair<unsigned int, int> const&) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x805CB07: query_3::Query3::Execute(int, int, std::string) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x8049A99: main (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945==
==8945== Invalid read of size 4
==8945== at 0x40A2BFB: std::_Rb_tree_increment(std::_Rb_tree_node_base*) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==8945== by 0x805CB61: query_3::Query3::Execute(int, int, std::string) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x8049A99: main (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== Address 0x449e3dc is 4 bytes inside a block of size 24 free'd
==8945== at 0x402ACFC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==8945== by 0x8063332: __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<unsigned int, int> > >::deallocate(std::_Rb_tree_node<std::pair<unsigned int, int> >*, unsigned int) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x8062C91: std::_Rb_tree<std::pair<unsigned int, int>, std::pair<unsigned int, int>, std::_Identity<std::pair<unsigned int, int> >, query_3::classcomp, std::allocator<std::pair<unsigned int, int> > >::_M_put_node(std::_Rb_tree_node<std::pair<unsigned int, int> >*) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x806206B: std::_Rb_tree<std::pair<unsigned int, int>, std::pair<unsigned int, int>, std::_Identity<std::pair<unsigned int, int> >, query_3::classcomp, std::allocator<std::pair<unsigned int, int> > >::_M_destroy_node(std::_Rb_tree_node<std::pair<unsigned int, int> >*) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x806113F: std::_Rb_tree<std::pair<unsigned int, int>, std::pair<unsigned int, int>, std::_Identity<std::pair<unsigned int, int> >, query_3::classcomp, std::allocator<std::pair<unsigned int, int> > >::_M_erase_aux(std::_Rb_tree_const_iterator<std::pair<unsigned int, int> >) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x805F46D: std::_Rb_tree<std::pair<unsigned int, int>, std::pair<unsigned int, int>, std::_Identity<std::pair<unsigned int, int> >, query_3::classcomp, std::allocator<std::pair<unsigned int, int> > >::erase(std::_Rb_tree_const_iterator<std::pair<unsigned int, int> >) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x80626ED: std::_Rb_tree<std::pair<unsigned int, int>, std::pair<unsigned int, int>, std::_Identity<std::pair<unsigned int, int> >, query_3::classcomp, std::allocator<std::pair<unsigned int, int> > >::_M_erase_aux(std::_Rb_tree_const_iterator<std::pair<unsigned int, int> >, std::_Rb_tree_const_iterator<std::pair<unsigned int, int> >) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x8061332: std::_Rb_tree<std::pair<unsigned int, int>, std::pair<unsigned int, int>, std::_Identity<std::pair<unsigned int, int> >, query_3::classcomp, std::allocator<std::pair<unsigned int, int> > >::erase(std::_Rb_tree_iterator<std::pair<unsigned int, int> >, std::_Rb_tree_iterator<std::pair<unsigned int, int> >) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x805F4B8: std::_Rb_tree<std::pair<unsigned int, int>, std::pair<unsigned int, int>, std::_Identity<std::pair<unsigned int, int> >, query_3::classcomp, std::allocator<std::pair<unsigned int, int> > >::erase(std::pair<unsigned int, int> const&) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x805DF61: std::set<std::pair<unsigned int, int>, query_3::classcomp, std::allocator<std::pair<unsigned int, int> > >::erase(std::pair<unsigned int, int> const&) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x805CB07: query_3::Query3::Execute(int, int, std::string) (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945== by 0x8049A99: main (in /home/samaras/DIT/SIGMOD/code+answers/s)
==8945==
edw0 1
edw2
edw4
280 812 3
280 => 174, 3 812, 3 232, 2 361, 2 194, 1 251, 1 264, 1 320, 1 429, 1 434, 1 522, 1 629, 1 631, 1 655, 1 693, 1 706, 1 0, 0 1, 0 2, 0 10, 0 11, 0 21, 0 22, 0 38, 0
edw5
edw6
edw7
edw0 2
edw2
edw4
361 812 4
361 => 812, 4 270, 2 280, 2 38, 1 232, 1 333, 1 350, 1 405, 1 583, 1 629, 1 633, 1 706, 1 721, 1 761, 1 782, 1 0, 0 1, 0 2, 0 10, 0 11, 0 21, 0 22, 0 63, 0 64, 0
edw5
edw6
edw7
361|812 174|280 280|812 % common interest counts 4 3 3
==8945==
==8945== HEAP SUMMARY:
==8945== in use at exit: 0 bytes in 0 blocks
==8945== total heap usage: 42,537 allocs, 42,537 frees, 1,404,865 bytes allocated
==8945==
==8945== All heap blocks were freed -- no leaks are possible
==8945==
==8945== For counts of detected and suppressed errors, rerun with: -v
==8945== ERROR SUMMARY: 6 errors from 2 contexts (suppressed: 0 from 0)