<s> import pygame <EOL> import sys <EOL> import mmap <EOL> def read_ppm_header ( fp , filename ) : <EOL> magic_number = fp . readline ( ) <EOL> comment = fp . readline ( ) <EOL> dimensions = fp . readline ( ) <EOL> maxval = fp . readline ( ) <EOL> headersize = len ( magic_number ) + len ( comment ) + len ( dimensions ) + len ( maxval ) <EOL> w , h = int ( dimensions . split ( "<STR_LIT:U+0020>" ) [ <NUM_LIT:0> ] ) , int ( dimensions . split ( "<STR_LIT:U+0020>" ) [ <NUM_LIT:1> ] ) <EOL> return ( w , h ) , headersize <EOL> def process_image ( h , filename ) : <EOL> f = open ( filename , "<STR_LIT>" ) <EOL> dimensions , headersize = read_ppm_header ( f , filename ) <EOL> map = mmap . mmap ( f . fileno ( ) , <NUM_LIT:0> ) <EOL> image = pygame . image . frombuffer ( buffer ( map , headersize ) , dimensions , '<STR_LIT>' ) <EOL> w = h * image . get_width ( ) // image . get_height ( ) <EOL> return pygame . transform . smoothscale ( image , ( w , h ) ) <EOL> def main ( argv ) : <EOL> pygame . init ( ) <EOL> h = pygame . display . Info ( ) . current_h * <NUM_LIT:4> // <NUM_LIT:5> <EOL> pygame . display . set_mode ( ( h * <NUM_LIT:16> // <NUM_LIT:9> , h ) ) <EOL> pygame . display . set_caption ( "<STR_LIT>" ) <EOL> while True : <EOL> a , b = sys . stdin . readline ( ) , sys . stdin . readline ( ) <EOL> if not a or not b : <EOL> break <EOL> screen = pygame . display . get_surface ( ) <EOL> screen . fill ( ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> sys . stdout . write ( a + b ) <EOL> sys . stdout . flush ( ) <EOL> img_a , img_b = process_image ( h , a . strip ( ) ) , process_image ( h , b . strip ( ) ) <EOL> w2 = screen . get_width ( ) // <NUM_LIT:2> <EOL> epsilon = screen . get_width ( ) // <NUM_LIT:200> <EOL> screen . blit ( img_a , ( w2 - img_a . get_width ( ) - epsilon , <NUM_LIT:0> ) ) <EOL> screen . blit ( img_b , ( w2 + epsilon , <NUM_LIT:0> ) ) <EOL> pygame . display . set_caption ( "<STR_LIT>" % ( a . strip ( ) , b . strip ( ) ) ) <EOL> pygame . display . update ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( sys . argv ) </s>
