#NEWLINE# def andrew( S ) : #NEWLINE# #INDENT# 'Convex hull by Andrew\n\n    :param S: list of points as coordinate pairs\n    :requires: S has at least 2 points\n    :returns: list of points of the convex hull\n    :complexity: `O(n log n)`\n    ' #NEWLINE# S . sort ( ) #NEWLINE# top = [ ] #NEWLINE# bot = [ ] #NEWLINE# for p in S : #NEWLINE# #INDENT# while ( ( len ( top ) >= 2 ) and ( not left_turn ( p , top [ ( - 1 ) ] , top [ ( - 2 ) ] ) ) ) : #NEWLINE# #INDENT# top . pop ( ) #NEWLINE# #UNINDENT# top . append ( p ) #NEWLINE# while ( ( len ( bot ) >= 2 ) and ( not left_turn ( bot [ ( - 2 ) ] , bot [ ( - 1 ) ] , bot ) ) ) : #NEWLINE# #INDENT# bot . pop ( ) #NEWLINE# #UNINDENT# bot . append ( p ) #NEWLINE# #UNINDENT# return ( bot [ : ( - 1 ) ] + top [ : 0 : ( - 1 ) ] )