l = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] ans = 0 for i in l : ans + = sum ( i ) print ( " Yes " if ans / 3 = = ( l [ 0 ] [ 0 ] + l [ 1 ] [ 1 ] + l [ 2 ] [ 2 ] ) else " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a = c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] b = c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] string = " Yes " for i in range ( 3 ) : x = c [ 1 ] [ i ] - c [ 0 ] [ i ] if x ! = a : string = " No " y = c [ 2 ] [ i ] - c [ 0 ] [ i ] if y ! = b : string = " No " print ( string ) if _ _ name _ _ = = ' _ _ main _ _ ' : c = [ [ ] , [ ] , [ ] ] for i in range ( 3 ) : c [ i ] = list ( map ( int , input ( ) . split ( ) ) ) ans = " Yes " for i in range ( 2 ) : d0 = c [ 0 ] [ 2 ] - c [ 0 ] [ i ] d1 = c [ 1 ] [ 2 ] - c [ 1 ] [ i ] d2 = c [ 2 ] [ 2 ] - c [ 2 ] [ i ] if d0 ! = d1 or d0 ! = d2 : ans = " No " print ( ans ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] for n in range ( 0 , 2 ) : x = C [ 0 ] [ 2 ] - C [ 0 ] [ n ] y = C [ 1 ] [ 2 ] - C [ 1 ] [ n ] z = C [ 2 ] [ 2 ] - C [ 2 ] [ n ] if x ! = y or y ! = z : print ( ' No ' ) exit ( ) else : print ( ' Yes ' ) import sys input = sys . stdin . buffer . readline A = [ 0 , None , None ] B = [ None , None , None ] bl = True for i in range ( 3 ) : C = [ int ( x ) for x in input ( ) . split ( ) ] for j , c in enumerate ( C ) : if A [ i ] is None : A [ i ] = c - B [ j ] if B [ j ] is None : B [ j ] = c - A [ i ] if A [ i ] + B [ j ] ! = c : bl = False answer = ' Yes ' if bl else ' No ' print ( answer ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] b = [ c [ 0 ] [ 0 ] - 0 , c [ 0 ] [ 1 ] - 0 , c [ 0 ] [ 2 ] - 0 ] a = [ c [ 0 ] [ 0 ] - b [ 0 ] , c [ 1 ] [ 0 ] - b [ 0 ] , c [ 2 ] [ 0 ] - b [ 0 ] ] for i in range ( 3 ) : for j in range ( 3 ) : if a [ i ] + b [ j ] ! = c [ i ] [ j ] : print ( ' No ' ) exit ( 0 ) print ( ' Yes ' ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] p = C [ 0 ] [ 1 ] - C [ 0 ] [ 0 ] q = C [ 0 ] [ 2 ] - C [ 0 ] [ 1 ] b1 , b2 , b3 = 0 , 0 , 0 for i in range ( - 200 , 201 ) : b2 = i b3 = q - b2 b1 = b2 - p if C [ 0 ] [ 0 ] - b1 = = C [ 0 ] [ 1 ] - b2 and C [ 0 ] [ 0 ] - b1 = = C [ 0 ] [ 2 ] - b3 : if C [ 1 ] [ 0 ] - b1 = = C [ 1 ] [ 1 ] - b2 and C [ 1 ] [ 0 ] - b1 = = C [ 1 ] [ 2 ] - b3 : if C [ 2 ] [ 0 ] - b1 = = C [ 2 ] [ 1 ] - b2 and C [ 2 ] [ 0 ] - b1 = = C [ 2 ] [ 2 ] - b3 : print ( " Yes " ) ; exit ( ) print ( " No " ) cs = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ i - j for i , j in zip ( cs [ 0 ] , cs [ 1 ] ) ] b = [ i - j for i , j in zip ( cs [ 1 ] , cs [ 2 ] ) ] print ( ' Yes ' if a [ 0 ] = = a [ 1 ] = = a [ 2 ] and b [ 0 ] = = b [ 1 ] = = b [ 2 ] else ' No ' ) import sys def I ( ) : return int ( sys . stdin . readline ( ) ) def MI ( ) : return map ( int , sys . stdin . readline ( ) . split ( ) ) def LI ( ) : return list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) c = [ ] for _ in range ( 3 ) : c . append ( LI ( ) ) a1 _ range = min ( c [ 0 ] ) for a1 in range ( a1 _ range + 1 ) : a = [ 0 ] * 3 b = [ 0 ] * 3 a [ 0 ] = a1 b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] flag = True for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = a [ i ] + b [ j ] : flag = False break if not flag : break if flag : print ( " Yes " ) sys . exit ( ) print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ None , None , None ] b = [ None , None , None ] a [ 0 ] = 0 b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = a [ i ] + b [ j ] : print ( " No " ) exit ( ) print ( " Yes " ) import sys input = sys . stdin . readline N = 3 x = [ 0 for i in range ( N ) ] y = [ 0 for i in range ( N ) ] c = [ [ 0 for i in range ( N ) ] for i in range ( N ) ] for i in range ( N ) : c1 , c2 , c3 = map ( int , input ( ) . split ( ) ) c [ i ] [ 0 ] = c1 c [ i ] [ 1 ] = c2 c [ i ] [ 2 ] = c3 x [ 0 ] = 0 for i in range ( N ) : y [ i ] = c [ 0 ] [ i ] - x [ 0 ] x [ 1 ] = c [ 1 ] [ 0 ] - y [ 0 ] x [ 2 ] = c [ 2 ] [ 0 ] - y [ 0 ] flag = True for i in range ( N ) : for j in range ( N ) : numx = x [ i ] numy = y [ j ] if not numx + numy = = c [ i ] [ j ] : flag = False if flag : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] print ( " Yes " if c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 0 ] [ 2 ] and c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 0 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 0 ] [ 2 ] else " No " ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) N = 101 for i in range ( N ) : a1 = i b1 = c11 - a1 b2 = c12 - a1 b3 = c13 - a1 a2 = c21 - b1 a3 = c31 - b1 if c22 = = a2 + b2 and c23 = = a2 + b3 and c32 = = a3 + b2 and c33 = = a3 + b3 : print ( ' Yes ' ) else : print ( ' No ' ) c = [ [ int ( i ) for i in input ( ) . split ( ) ] for j in range ( 3 ) ] b2 = c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] b3 = c [ 0 ] [ 2 ] - c [ 0 ] [ 0 ] a2 = c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] a3 = c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] d = 0 for i in range ( 2 ) : if c [ i + 1 ] [ 1 ] - c [ i + 1 ] [ 0 ] = = b2 : d + = 1 if c [ i + 1 ] [ 2 ] - c [ i + 1 ] [ 0 ] = = b3 : d + = 1 for j in range ( 2 ) : if c [ 1 ] [ i + 1 ] - c [ 0 ] [ i + 1 ] = = a2 : d + = 1 if c [ 2 ] [ i + 1 ] - c [ 0 ] [ i + 1 ] = = a3 : d + = 1 if d = = 8 : print ( " Yes " ) else : print ( " No " ) import numpy as np import math import sys from collections import defaultdict input = sys . stdin . readline A = np . array ( ( list ( map ( int , input ( ) . split ( ) ) ) ) ) B = np . array ( ( list ( map ( int , input ( ) . split ( ) ) ) ) ) C = np . array ( ( list ( map ( int , input ( ) . split ( ) ) ) ) ) def kc ( i , a , b , c ) : if a [ i ] - a [ i - 1 ] = = b [ i ] - b [ i - 1 ] = = c [ i ] - c [ i - 1 ] : return True else : return False def kcc ( a , b , c ) : if ( a - b ) [ 0 ] = = ( a - b ) [ 1 ] = = ( a - b ) [ 2 ] and ( b - c ) [ 0 ] = = ( b - c ) [ 1 ] = = ( b - c ) [ 2 ] and ( c - a ) [ 0 ] = = ( c - a ) [ 1 ] = = ( c - a ) [ 2 ] : return True else : return False if kcc ( A , B , C ) and kc ( 0 , A , B , C ) and kc ( 1 , A , B , C ) and kc ( 2 , A , B , C ) : print ( ' Yes ' ) else : print ( ' No ' ) c = [ ] for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) a = [ 0 , 0 , 0 ] b = [ 0 , 0 , 0 ] for i in range ( 3 ) : b [ i ] = c [ i ] [ 0 ] - 0 for i in range ( 3 ) : a [ i ] = c [ 0 ] [ i ] - b [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if a [ j ] + b [ i ] ! = c [ i ] [ j ] : print ( " No " ) exit ( ) print ( " Yes " ) dat = [ ] for _ in range ( 3 ) : dat . append ( list ( map ( int , input ( ) . split ( ) ) ) ) f = True a1 , a2 , a3 , b1 , b2 , b3 = - 1 , - 1 , - 1 , - 1 , - 1 , - 1 a1 = 0 b1 = dat [ 0 ] [ 0 ] b2 = dat [ 0 ] [ 1 ] b3 = dat [ 0 ] [ 2 ] a2 = dat [ 1 ] [ 0 ] - b1 a3 = dat [ 2 ] [ 0 ] - b1 if dat [ 1 ] [ 1 ] ! = a2 + b2 : f = False if dat [ 1 ] [ 2 ] ! = a2 + b3 : f = False if dat [ 2 ] [ 1 ] ! = a3 + b2 : f = False if dat [ 2 ] [ 2 ] ! = a3 + b3 : f = False print ( " Yes " if f else " No " ) c = [ [ 0 ] * 3 for i in range ( 3 ) ] ; for i in range ( 3 ) : s = input ( ) . split ( " " ) ; for j in range ( 3 ) : c [ i ] [ j ] = int ( s [ j ] ) ; if c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 0 ] [ 1 ] and c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 2 ] - c [ 0 ] [ 2 ] and c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 0 ] [ 1 ] and c [ 2 ] [ 2 ] - c [ 0 ] [ 2 ] = = c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] and c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] and c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 2 ] [ 0 ] and c [ 0 ] [ 2 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 2 ] - c [ 1 ] [ 0 ] and c [ 0 ] [ 2 ] - c [ 0 ] [ 0 ] = = c [ 2 ] [ 2 ] - c [ 2 ] [ 0 ] : print ( ' Yes ' ) ; else : print ( ' No ' ) import sys def input ( ) : return sys . stdin . readline ( ) . rstrip ( ) def mi ( ) : return map ( int , input ( ) . split ( ) ) a , b , c = mi ( ) d , e , f = mi ( ) g , h , i = mi ( ) print ( ' Yes ' if g - d = = h - e and h - e = = i - f and d - a = = e - b and e - b = = f - c and g - a = = h - b and h - b = = i - c and a - b = = d - e and d - e = = g - h and b - c = = e - f and e - f = = h - i and a - c = = d - f and d - f = = g - i else ' No ' ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) print ( " Yes " ) if c1 [ 0 ] - c1 [ 1 ] = = c2 [ 0 ] - c2 [ 1 ] = = c3 [ 0 ] - c3 [ 1 ] and c1 [ 1 ] - c1 [ 2 ] = = c2 [ 1 ] - c2 [ 2 ] = = c3 [ 1 ] - c3 [ 2 ] else print ( " No " ) def divisors ( n , sort = False ) : d = [ ] for i in range ( 1 , int ( n * * 0.5 ) + 1 ) : if n % i = = 0 : d . append ( i ) if i ! = n / / i : d . append ( n / / i ) if sort : d . sort ( ) return d C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] if sum ( [ sum ( r ) for r in C ] ) = = 0 : print ( ' Yes ' ) exit ( 0 ) for a0 in divisors ( sum ( C [ 0 ] ) ) : a = [ a0 , None , None ] b = [ None , None , None ] b [ 0 ] = C [ 0 ] [ 0 ] - a [ 0 ] a [ 1 ] = C [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = C [ 2 ] [ 0 ] - b [ 0 ] b [ 1 ] = C [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = C [ 0 ] [ 2 ] - a [ 0 ] ok = True for i in range ( 3 ) : for j in range ( 3 ) : if C [ i ] [ j ] ! = a [ i ] + b [ j ] : ok = False if ok : print ( ' Yes ' ) exit ( 0 ) print ( ' No ' ) c = list p = list ( map ( int , input ( ) . split ( ) ) ) q = list ( map ( int , input ( ) . split ( ) ) ) r = list ( map ( int , input ( ) . split ( ) ) ) c = [ p , q , r ] br = 0 for i in range ( 2 ) : for j in range ( 2 ) : if ( c [ i ] [ j ] + c [ i + 1 ] [ j + 1 ] = = c [ i ] [ j + 1 ] + c [ i + 1 ] [ j ] ) : None else : br + = 1 break if ( br = = 0 ) : print ( " Yes " ) else : print ( " No " ) c = [ ] sum1 = 0 sum2 = 0 for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) sum1 + = sum ( c [ i ] ) sum2 + = c [ i ] [ i ] if sum1 = = sum2 * 3 : print ( ' Yes ' ) else : print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] flg = True s = sum ( c [ 0 ] ) % 3 t = sum ( c [ i ] [ 0 ] for i in range ( 3 ) ) % 3 for i in range ( 1 , 3 ) : if sum ( c [ i ] ) % 3 ! = s : flg = False if sum ( c [ j ] [ i ] for j in range ( 3 ) ) % 3 ! = t : flg = False if flg : print ( " Yes " ) else : print ( " No " ) import numpy as np c = [ ] c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) arr _ c = np . array ( c ) a _ max = np . amax ( arr _ c , axis = 1 ) b _ max = np . amax ( arr _ c , axis = 0 ) a = [ ] b = [ ] for i in range ( 3 ) : if len ( list ( range ( 0 , a _ max [ i ] + 1 , 1 ) ) ) = = 0 : a . append ( [ 0 ] ) else : a . append ( list ( range ( 0 , a _ max [ i ] + 1 , 1 ) ) ) if len ( list ( range ( 0 , b _ max [ i ] + 1 , 1 ) ) ) = = 0 : b . append ( [ 0 ] ) else : b . append ( list ( range ( 0 , b _ max [ i ] + 1 , 1 ) ) ) ans = ' No ' cnt = 0 for a0 in a [ 0 ] : for b0 in b [ 0 ] : if c [ 0 ] [ 0 ] ! = a0 + b0 : continue for a1 in a [ 1 ] : if c [ 1 ] [ 0 ] ! = a1 + b0 : continue for b1 in b [ 1 ] : if c [ 0 ] [ 1 ] ! = a0 + b1 or c [ 1 ] [ 1 ] ! = a1 + b1 : continue for a2 in a [ 2 ] : if c [ 2 ] [ 0 ] ! = a2 + b0 or c [ 2 ] [ 1 ] ! = a2 + b1 : continue for b2 in b [ 2 ] : if c [ 0 ] [ 2 ] ! = a0 + b2 or c [ 1 ] [ 2 ] ! = a1 + b2 or c [ 2 ] [ 2 ] ! = a2 + b2 : continue print ( " Yes " ) exit ( 0 ) print ( ans ) import numpy as np a = np . array ( input ( ) . split ( ) , dtype = ' int ' ) b = np . array ( input ( ) . split ( ) , dtype = ' int ' ) - a c = np . array ( input ( ) . split ( ) , dtype = ' int ' ) - a if np . all ( b = = b [ 0 ] ) and np . all ( c = = c [ 0 ] ) : print ( ' Yes ' ) else : print ( ' No ' ) c = [ ] for _ in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) import numpy as np c _ np = np . array ( c ) flag = True for a1 in range ( max ( c _ np [ 0 ] ) + 1 ) : b = [ x - a1 for x in c _ np [ 0 ] ] a _ tmp = c _ np [ : , 0 ] - b [ 0 ] for i in range ( 2 ) : a = c _ np [ : , i + 1 ] - b [ i + 1 ] if np . allclose ( a _ tmp , a ) : a _ tmp = a else : print ( " No " ) flag = False break else : continue break if flag : print ( " Yes " ) from itertools import product as p c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 for a1 in range ( c [ 0 ] [ 0 ] + 1 ) : a [ 0 ] = a1 b [ 0 ] = c [ 0 ] [ 0 ] - a1 for a2 in range ( c [ 1 ] [ 1 ] + 1 ) : a [ 1 ] = a2 b [ 1 ] = c [ 1 ] [ 1 ] - a2 for a3 in range ( c [ 2 ] [ 2 ] + 1 ) : a [ 2 ] = a3 b [ 2 ] = c [ 2 ] [ 2 ] - a3 for i , j in p ( range ( 3 ) , range ( 3 ) ) : if c [ i ] [ j ] ! = a [ i ] + b [ j ] : break else : print ( ' Yes ' ) exit ( ) print ( ' No ' ) import sys input = sys . stdin . readline d = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] if d [ 0 ] [ 0 ] + d [ 1 ] [ 1 ] + d [ 2 ] [ 2 ] = = d [ 0 ] [ 1 ] + d [ 1 ] [ 2 ] + d [ 2 ] [ 0 ] = = d [ 0 ] [ 2 ] + d [ 1 ] [ 0 ] + d [ 2 ] [ 1 ] : print ( " Yes " ) else : print ( " No " ) lst = [ ] for i in range ( 3 ) : l = list ( map ( int , input ( ) . split ( ) ) ) lst . append ( l ) for i in range ( 1 , 3 ) : diff = lst [ i ] [ 0 ] - lst [ 0 ] [ 0 ] for j in range ( 3 ) : lst [ i ] [ j ] - = diff if lst [ i ] ! = lst [ 0 ] : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] d = set ( ) e = set ( ) for i in range ( 3 ) : d . add ( c [ i ] [ 0 ] - c [ i ] [ 1 ] ) e . add ( c [ i ] [ 1 ] - c [ i ] [ 2 ] ) print ( " Yes " if len ( d ) = = len ( e ) = = 1 else " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] x = C [ 1 ] [ 0 ] - C [ 0 ] [ 0 ] = = C [ 1 ] [ 1 ] - C [ 0 ] [ 1 ] = = C [ 1 ] [ 2 ] - C [ 0 ] [ 2 ] y = C [ 2 ] [ 0 ] - C [ 0 ] [ 0 ] = = C [ 2 ] [ 1 ] - C [ 0 ] [ 1 ] = = C [ 2 ] [ 2 ] - C [ 0 ] [ 2 ] if x and y : print ( ' Yes ' ) else : print ( ' No ' ) lis = [ ] for _ in range ( 3 ) : lis . append ( list ( map ( int , input ( ) . split ( ) ) ) ) flag1 = 0 flag2 = 0 for a1 in range ( 101 ) : b1 = lis [ 0 ] [ 0 ] - a1 b2 = lis [ 0 ] [ 1 ] - a1 b3 = lis [ 0 ] [ 2 ] - a1 for a2 in range ( 101 ) : if a2 + b1 = = lis [ 1 ] [ 0 ] and a2 + b2 = = lis [ 1 ] [ 1 ] and a2 + b3 = = lis [ 1 ] [ 2 ] : flag1 = 1 break else : flag1 = 0 for a3 in range ( 101 ) : if a3 + b1 = = lis [ 2 ] [ 0 ] and a3 + b2 = = lis [ 2 ] [ 1 ] and a3 + b3 = = lis [ 2 ] [ 2 ] : flag2 = 1 break else : flag2 = 0 if flag1 = = 1 and flag2 = = 1 : print ( " Yes " ) exit ( ) print ( " No " ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) f = 0 if not c11 - c12 = = c21 - c22 = = c31 - c32 : f = 1 if not c11 - c13 = = c21 - c23 = = c31 - c33 : f = 1 if not c12 - c13 = = c22 - c23 = = c32 - c33 : f = 1 if not c11 - c21 = = c12 - c22 = = c13 - c23 : f = 1 if not c11 - c31 = = c12 - c32 = = c13 - c33 : f = 1 if not c21 - c31 = = c22 - c32 = = c23 - c33 : f = 1 print ( " Yes " if f = = 0 else " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] max _ 1st _ row = max ( c [ 0 ] ) for a1 in range ( max _ 1st _ row + 1 ) : b = [ ] for col in range ( 3 ) : b . append ( c [ 0 ] [ col ] - a1 ) a2 = c [ 1 ] [ 0 ] - b [ 0 ] if c [ 1 ] [ 1 ] ! = ( a2 + b [ 1 ] ) or c [ 1 ] [ 2 ] ! = ( a2 + b [ 2 ] ) : continue a3 = c [ 2 ] [ 0 ] - b [ 0 ] if c [ 2 ] [ 1 ] ! = ( a3 + b [ 1 ] ) or c [ 2 ] [ 2 ] ! = ( a3 + b [ 2 ] ) : continue print ( ' Yes ' ) exit ( ) print ( ' No ' ) c = [ [ 0 ] * 3 ] * 3 for i in range ( 3 ) : c [ i ] = [ int ( x ) for x in input ( ) . split ( ) ] ans = False if c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] and \ c [ 0 ] [ 0 ] - c [ 0 ] [ 2 ] = = c [ 1 ] [ 0 ] - c [ 1 ] [ 2 ] = = c [ 2 ] [ 0 ] - c [ 2 ] [ 2 ] : ans = True if ans = = True : print ( ' Yes ' ) else : print ( ' No ' ) m = [ [ 0 for i in range ( 3 ) ] for j in range ( 3 ) ] for i in range ( 3 ) : m [ i ] = list ( map ( int , input ( ) . split ( ) ) ) a1 = a2 = a3 = 0 b1 , b2 , b3 = m [ 0 ] a2 = m [ 1 ] [ 0 ] - b1 a3 = m [ 2 ] [ 0 ] - b1 if ( ( m [ 1 ] [ 1 ] ! = a2 + b2 ) or ( m [ 1 ] [ 2 ] ! = a2 + b3 ) or ( m [ 2 ] [ 1 ] ! = a3 + b2 ) or ( m [ 2 ] [ 2 ] ! = a3 + b3 ) ) : print ( ' No ' ) else : print ( ' Yes ' ) def find _ numbers ( grid ) : for a1 in range ( 0 , 101 ) : for a2 in range ( 0 , 101 ) : if ( grid [ 0 ] + grid [ 3 ] + grid [ 6 ] ) - 3 * a1 = = ( grid [ 1 ] + grid [ 4 ] + grid [ 7 ] ) - 3 * a2 : for a3 in range ( 0 , 101 ) : if ( grid [ 0 ] + grid [ 3 ] + grid [ 6 ] ) - 3 * a1 = = ( grid [ 2 ] + grid [ 5 ] + grid [ 8 ] ) - 3 * a3 : return True return False grid = [ ] for _ in range ( 3 ) : grid . extend ( list ( map ( int , input ( ) . split ( ) ) ) ) print ( " Yes " if find _ numbers ( grid ) else " No " ) A = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] ans = 0 for i in range ( 101 ) : b1 = A [ 0 ] [ 0 ] - i b2 = A [ 0 ] [ 1 ] - i b3 = A [ 0 ] [ 2 ] - i a2 _ 1 = A [ 1 ] [ 0 ] - b1 a2 _ 2 = A [ 1 ] [ 1 ] - b2 a2 _ 3 = A [ 1 ] [ 2 ] - b3 a3 _ 1 = A [ 2 ] [ 0 ] - b1 a3 _ 2 = A [ 2 ] [ 1 ] - b2 a3 _ 3 = A [ 2 ] [ 2 ] - b3 if ( a2 _ 1 = = a2 _ 2 ) and ( a2 _ 2 = = a2 _ 3 ) and ( a2 _ 3 = = a2 _ 1 ) and ( a3 _ 1 = = a3 _ 2 ) and ( a3 _ 2 = = a3 _ 3 ) and ( a3 _ 3 = = a3 _ 1 ) : ans + = 0 else : ans + = 1 if ans ! = 0 : print ( ' No ' ) else : print ( ' Yes ' ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 b [ 0 ] , b [ 1 ] , b [ 2 ] = C [ 0 ] [ 0 ] , C [ 0 ] [ 1 ] , C [ 0 ] [ 2 ] a [ 0 ] , a [ 1 ] , a [ 2 ] = 0 , C [ 1 ] [ 0 ] - b [ 0 ] , C [ 2 ] [ 0 ] - b [ 0 ] ans = " Yes " for i in range ( 3 ) : for j in range ( 3 ) : if C [ i ] [ j ] = = ( a [ i ] + b [ j ] ) : pass else : ans = " No " break print ( ans ) def two _ int ( ) : N , K = map ( int , input ( ) . split ( ) ) return N , K def one _ int ( ) : return int ( input ( ) ) def one _ str ( ) : return input ( ) def many _ int ( ) : return list ( map ( int , input ( ) . split ( ) ) ) c1 = many _ int ( ) c2 = many _ int ( ) c3 = many _ int ( ) import numpy as np temp _ array = np . asarray ( [ c1 , c2 , c3 ] ) temp = temp _ array . T same _ flg = True same = c1 [ 0 ] - c2 [ 0 ] for a , b in zip ( c1 [ 1 : ] , c2 [ 1 : ] ) : if a - b ! = same : same _ flg = False same = c1 [ 0 ] - c3 [ 0 ] for a , b in zip ( c1 [ 1 : ] , c3 [ 1 : ] ) : if a - b ! = same : same _ flg = False same = c2 [ 0 ] - c3 [ 0 ] for a , b in zip ( c2 [ 1 : ] , c3 [ 1 : ] ) : if a - b ! = same : same _ flg = False c1 = list ( temp [ 0 ] ) c2 = list ( temp [ 1 ] ) c3 = list ( temp [ 2 ] ) same = c1 [ 0 ] - c2 [ 0 ] for a , b in zip ( c1 [ 1 : ] , c2 [ 1 : ] ) : if a - b ! = same : same _ flg = False same = c1 [ 0 ] - c3 [ 0 ] for a , b in zip ( c1 [ 1 : ] , c3 [ 1 : ] ) : if a - b ! = same : same _ flg = False same = c2 [ 0 ] - c3 [ 0 ] for a , b in zip ( c2 [ 1 : ] , c3 [ 1 : ] ) : if a - b ! = same : same _ flg = False if same _ flg : print ( " Yes " ) else : print ( " No " ) import sys YES = " Yes " NO = " No " def solve ( c : " List [ List [ int ] ] " ) : from itertools import product for a1 , b1 in product ( range ( 101 ) , repeat = 2 ) : a2 = c [ 1 ] [ 0 ] - b1 a3 = c [ 2 ] [ 0 ] - b1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 if a2 < 0 or a3 < 0 or b2 < 0 or b3 < 0 : continue a = [ a1 , a2 , a3 ] b = [ b1 , b2 , b3 ] if all ( ( a [ i ] + b [ j ] ) = = c [ i ] [ j ] for i , j in product ( range ( 3 ) , repeat = 2 ) ) : return YES return NO def main ( ) : def iterate _ tokens ( ) : for line in sys . stdin : for word in line . split ( ) : yield word tokens = iterate _ tokens ( ) c = [ [ int ( next ( tokens ) ) for _ in range ( 3 ) ] for _ in range ( 3 ) ] print ( solve ( c ) ) def test ( ) : import doctest doctest . testmod ( ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) def main ( ) : pc1 , pc2 , pc3 = map ( int , input ( ) . split ( ) ) for i in range ( 2 ) : c1 , c2 , c3 = map ( int , input ( ) . split ( ) ) if ( c1 - pc1 ) = = ( c2 - pc2 ) and ( c2 - pc2 ) = = ( c3 - pc3 ) : pc1 , pc2 , pc3 = c1 , c2 , c3 else : return ' No ' return ' Yes ' print ( main ( ) ) import sys input = sys . stdin . readline c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] for i in range ( 2 ) : for j in range ( 2 ) : if c [ i ] [ j ] - c [ i ] [ j + 1 ] ! = c [ i + 1 ] [ j ] - c [ i + 1 ] [ j + 1 ] : print ( " No " ) exit ( ) if c [ i ] [ j ] - c [ i + 1 ] [ j ] ! = c [ i ] [ j + 1 ] - c [ i + 1 ] [ j + 1 ] : print ( " No " ) exit ( ) print ( " Yes " ) C1 = list ( map ( int , input ( ) . split ( ) ) ) C2 = list ( map ( int , input ( ) . split ( ) ) ) C3 = list ( map ( int , input ( ) . split ( ) ) ) if C1 [ 1 ] + C2 [ 0 ] - C1 [ 0 ] = = C2 [ 1 ] and C1 [ 1 ] + C3 [ 0 ] - C1 [ 0 ] = = C3 [ 1 ] and \ C1 [ 2 ] + C3 [ 0 ] - C1 [ 0 ] = = C3 [ 2 ] and C1 [ 2 ] + C2 [ 0 ] - C1 [ 0 ] = = C2 [ 2 ] : print ( " Yes " ) else : print ( " No " ) a = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] if a [ 0 ] [ 0 ] - a [ 1 ] [ 0 ] = = a [ 0 ] [ 1 ] - a [ 1 ] [ 1 ] = = a [ 0 ] [ 2 ] - a [ 1 ] [ 2 ] and a [ 1 ] [ 0 ] - a [ 2 ] [ 0 ] = = a [ 1 ] [ 1 ] - a [ 2 ] [ 1 ] = = a [ 1 ] [ 2 ] - a [ 2 ] [ 2 ] : print ( " Yes " ) else : print ( " No " ) s = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] def solve ( ) : if not ( s [ 0 ] [ 1 ] - s [ 0 ] [ 0 ] = = s [ 1 ] [ 1 ] - s [ 1 ] [ 0 ] = = s [ 2 ] [ 1 ] - s [ 2 ] [ 0 ] ) : return False if not ( s [ 0 ] [ 2 ] - s [ 0 ] [ 1 ] = = s [ 1 ] [ 2 ] - s [ 1 ] [ 1 ] = = s [ 2 ] [ 2 ] - s [ 2 ] [ 1 ] ) : return False if not ( s [ 1 ] [ 0 ] - s [ 0 ] [ 0 ] = = s [ 1 ] [ 1 ] - s [ 0 ] [ 1 ] = = s [ 1 ] [ 2 ] - s [ 0 ] [ 2 ] ) : return False if not ( s [ 2 ] [ 0 ] - s [ 1 ] [ 0 ] = = s [ 2 ] [ 1 ] - s [ 1 ] [ 1 ] = = s [ 2 ] [ 2 ] - s [ 1 ] [ 2 ] ) : return False return True print ( ' Yes ' if solve ( ) else ' No ' ) s = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] num = s [ 0 ] [ 0 ] ans = " No " for i in range ( num + 1 ) : a _ 1 = num - i b _ 1 = i a _ 2 = s [ 1 ] [ 0 ] - b _ 1 a _ 3 = s [ 2 ] [ 0 ] - b _ 1 b _ 2 = s [ 0 ] [ 1 ] - a _ 1 b _ 3 = s [ 0 ] [ 2 ] - a _ 1 if s [ 1 ] [ 1 ] ! = a _ 2 + b _ 2 : continue if s [ 1 ] [ 2 ] ! = a _ 2 + b _ 3 : continue if s [ 2 ] [ 1 ] ! = a _ 3 + b _ 2 : continue if s [ 2 ] [ 2 ] ! = a _ 3 + b _ 3 : continue ans = " Yes " print ( ans ) C = [ ] for _ in range ( 3 ) : C . append ( list ( map ( int , input ( ) . split ( ) ) ) ) flag = 1 for i in range ( 2 ) : if C [ i + 1 ] [ 0 ] - C [ i ] [ 0 ] ! = C [ i + 1 ] [ 1 ] - C [ i ] [ 1 ] or C [ i + 1 ] [ 1 ] - C [ i ] [ 1 ] ! = C [ i + 1 ] [ 2 ] - C [ i ] [ 2 ] : flag = 0 if C [ 0 ] [ i + 1 ] - C [ 0 ] [ i ] ! = C [ 1 ] [ i + 1 ] - C [ 1 ] [ i ] or C [ 1 ] [ i + 1 ] - C [ 1 ] [ i ] ! = C [ 2 ] [ i + 1 ] - C [ 2 ] [ i ] : flag = 0 if flag : print ( ' Yes ' ) else : print ( ' No ' ) a , b , c = map ( int , input ( ) . split ( ) ) d , e , f = map ( int , input ( ) . split ( ) ) g , h , i = map ( int , input ( ) . split ( ) ) if a - d = = b - e = = c - f and a - g = = b - h = = c - i and a - b = = d - e = = g - h and a - c = = d - f = = g - i : print ( " Yes " ) else : print ( " No " ) d , e , f = [ int ( i ) for i in input ( ) . split ( ) ] x , y , z = [ int ( i ) for i in input ( ) . split ( ) ] s , t , u = [ int ( i ) for i in input ( ) . split ( ) ] b = x - d c = s - d if b + e = = y and b + f = = z and c + e = = t and c + f = = u : print ( ' Yes ' ) else : print ( ' No ' ) C = [ ] for _ in range ( 3 ) : a = list ( map ( int , input ( ) . split ( ) ) ) b = min ( a ) for i in range ( 3 ) : a [ i ] - = b C . append ( a ) if C [ 0 ] = = C [ 1 ] and C [ 1 ] = = C [ 2 ] and C [ 0 ] = = C [ 2 ] : print ( " Yes " ) else : print ( " No " ) List = [ ] for i in range ( 3 ) : List . append ( list ( map ( int , input ( ) . split ( ) ) ) ) a = 0 b = 0 c = 0 flg = True for i in range ( 2 ) : a = List [ 0 ] [ i + 1 ] - List [ 0 ] [ i ] b = List [ 1 ] [ i + 1 ] - List [ 1 ] [ i ] c = List [ 2 ] [ i + 1 ] - List [ 2 ] [ i ] if a ! = b or b ! = c or c ! = a : flg = False a = List [ i + 1 ] [ 0 ] - List [ i ] [ 0 ] b = List [ i + 1 ] [ 1 ] - List [ i ] [ 1 ] c = List [ i + 1 ] [ 2 ] - List [ i ] [ 2 ] if a ! = b or b ! = c or c ! = a : flg = False if flg : print ( " Yes " ) else : print ( " No " ) def read _ h ( typ = int ) : return list ( map ( typ , input ( ) . split ( ) ) ) def read _ v ( n , m = 1 , typ = int ) : return [ read _ h ( ) if m > 1 else typ ( input ( ) ) for _ in range ( n ) ] def main ( ) : c = read _ v ( n = 3 , m = 3 ) a = [ 0 , 0 , 0 ] b = c [ 0 ] for i in ( 1 , 2 ) : a [ i ] = c [ i ] [ 0 ] - b [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = a [ i ] + b [ j ] : print ( ' No ' ) return print ( ' Yes ' ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) c = [ ] for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) if ( c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] ) * 3 = = ( sum ( c [ 0 ] ) + sum ( c [ 1 ] ) + sum ( c [ 2 ] ) ) : print ( ' Yes ' ) else : print ( ' No ' ) import numpy as np row = [ input ( ) . split ( ) for i in range ( 3 ) ] f = np . vectorize ( int ) c = f ( row ) if c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 2 ] [ 2 ] and c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 0 ] [ 2 ] and c [ 0 ] [ 0 ] - c [ 2 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 2 ] [ 1 ] = = c [ 0 ] [ 2 ] - c [ 2 ] [ 2 ] : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for x in range ( 3 ) ] if c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] = = c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] and c [ 0 ] [ 0 ] - c [ 2 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 2 ] [ 1 ] = = c [ 0 ] [ 2 ] - c [ 2 ] [ 2 ] : print ( " Yes " ) else : print ( " No " ) c = [ ] for i in range ( 3 ) : c . append ( [ int ( i ) for i in input ( ) . split ( ) ] ) flag = True if c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] ! = c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] or c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] ! = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] : flag = False elif c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] ! = c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] or c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] ! = c [ 2 ] [ 1 ] - c [ 2 ] [ 2 ] : flag = False elif c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] ! = c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] or c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] ! = c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] : flag = False elif c [ 0 ] [ 0 ] - c [ 2 ] [ 0 ] ! = c [ 0 ] [ 1 ] - c [ 2 ] [ 1 ] or c [ 0 ] [ 0 ] - c [ 2 ] [ 0 ] ! = c [ 0 ] [ 2 ] - c [ 2 ] [ 2 ] : flag = False if flag : print ( " Yes " ) else : print ( " No " ) c = list ( map ( int , open ( 0 ) . read ( ) . split ( ) ) ) a = all ( [ c [ i ] - c [ i + 1 ] = = c [ i + 3 ] - c [ i + 4 ] for i in [ 0 , 1 , 3 , 4 ] ] ) b = all ( [ c [ i ] - c [ i + 3 ] = = c [ i + 1 ] - c [ i + 4 ] for i in [ 0 , 1 , 3 , 4 ] ] ) if a and b : print ( " Yes " ) else : print ( " No " ) c0 = list ( map ( int , input ( ) . split ( ) ) ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) if c0 [ 1 ] - c0 [ 0 ] = = c1 [ 1 ] - c1 [ 0 ] = = c2 [ 1 ] - c2 [ 0 ] and c0 [ 2 ] - c0 [ 0 ] = = c1 [ 2 ] - c1 [ 0 ] = = c2 [ 2 ] - c2 [ 0 ] : print ( ' Yes ' ) else : print ( ' No ' ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] for i in range ( 2 ) : if C [ i + 1 ] [ 0 ] - C [ 0 ] [ 0 ] = = C [ i + 1 ] [ 1 ] - C [ 0 ] [ 1 ] = = C [ i + 1 ] [ 2 ] - C [ 0 ] [ 2 ] : continue else : print ( ' No ' ) exit ( ) for j in range ( 2 ) : if C [ 0 ] [ j + 1 ] - C [ 0 ] [ j ] = = C [ 1 ] [ j + 1 ] - C [ 1 ] [ j ] = = C [ 2 ] [ j + 1 ] - C [ 2 ] [ j ] : continue else : print ( ' No ' ) exit ( ) print ( ' Yes ' ) if _ _ name _ _ = = ' _ _ main _ _ ' : C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] flag = True for i in range ( 2 ) : for ni in range ( i + 1 , 3 ) : for j in range ( 2 ) : if C [ i ] [ j ] - C [ i ] [ j + 1 ] ! = C [ ni ] [ j ] - C [ ni ] [ j + 1 ] : flag = False break for i in range ( 2 ) : for ni in range ( i + 1 , 3 ) : for j in range ( 2 ) : if C [ j ] [ i ] - C [ j + 1 ] [ i ] ! = C [ j ] [ ni ] - C [ j + 1 ] [ ni ] : flag = False break if flag : print ( ' Yes ' ) else : print ( ' No ' ) row0 = list ( map ( int , input ( ) . split ( ) ) ) row1 = list ( map ( int , input ( ) . split ( ) ) ) row2 = list ( map ( int , input ( ) . split ( ) ) ) rows = [ row0 , row1 , row2 ] rowsdiff = [ ] for item in rows : rowsdiff . append ( [ item [ 1 ] - item [ 0 ] , item [ 2 ] - item [ 1 ] ] ) columns = [ [ rows [ 0 ] [ i ] , rows [ 1 ] [ i ] , rows [ 2 ] [ i ] ] for i in range ( 3 ) ] columnsdiff = [ ] for item in columns : columnsdiff . append ( [ item [ 1 ] - item [ 0 ] , item [ 2 ] - item [ 1 ] ] ) Answer = ' Yes ' rowscheck = ( rowsdiff [ 0 ] = = rowsdiff [ 1 ] ) * ( rowsdiff [ 1 ] = = rowsdiff [ 2 ] ) columnscheck = ( columnsdiff [ 0 ] = = columnsdiff [ 1 ] ) * ( columnsdiff [ 1 ] = = columnsdiff [ 2 ] ) if rowscheck * columnscheck ! = 1 : Answer = ' No ' print ( Answer ) c = [ [ int ( cn ) for cn in input ( ) . split ( ) ] for _ in range ( 3 ) ] max _ val = max ( c [ 0 ] ) ans = ' No ' for a1 in range ( max _ val + 1 ) : b = [ c [ 0 ] [ i ] - a1 for i in range ( 3 ) ] correct = True for i in range ( 2 ) : ai _ cand = [ ] for j in range ( 3 ) : cand = c [ i + 1 ] [ j ] - b [ j ] correct = cand > = 0 if correct : ai _ cand . append ( cand ) else : break correct = correct and ( ai _ cand [ 0 ] = = ai _ cand [ 1 ] and ai _ cand [ 1 ] = = ai _ cand [ 2 ] ) if not correct : break if correct : ans = ' Yes ' break print ( ans ) c = [ list ( map ( int , input ( ) . split ( ) ) ) , list ( map ( int , input ( ) . split ( ) ) ) , list ( map ( int , input ( ) . split ( ) ) ) ] if c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] ! = c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] or c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] ! = c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] : print ( ' No ' ) elif c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] ! = c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] or c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] ! = c [ 1 ] [ 2 ] - c [ 2 ] [ 2 ] : print ( ' No ' ) else : print ( ' Yes ' ) import sys import numpy as np N1 = list ( map ( int , input ( ) . split ( ) ) ) N2 = list ( map ( int , input ( ) . split ( ) ) ) N3 = list ( map ( int , input ( ) . split ( ) ) ) temp = [ ] for i in range ( 3 ) : a = N1 [ i ] + N2 [ i ] - 2 * N3 [ i ] temp . append ( a ) temp2 = [ ] temp2 . append ( N1 [ 0 ] + N1 [ 1 ] - 2 * N1 [ 2 ] ) temp2 . append ( N2 [ 0 ] + N2 [ 1 ] - 2 * N2 [ 2 ] ) temp2 . append ( N3 [ 0 ] + N3 [ 1 ] - 2 * N3 [ 2 ] ) if len ( list ( set ( temp ) ) ) = = 1 & len ( list ( set ( temp2 ) ) ) = = 1 : print ( " Yes " ) else : print ( " No " ) def check ( data ) : diff = { } for i in range ( 3 ) : for j in range ( 2 ) : key _ b = " b _ " + str ( j ) + " - " + str ( j + 1 ) delta _ b = data [ i ] [ j + 1 ] - data [ i ] [ j ] if key _ b in diff : if diff [ key _ b ] ! = delta _ b : return False else : diff [ key _ b ] = delta _ b for j in range ( 3 ) : for i in range ( 2 ) : key _ a = " a _ " + str ( i ) + " - " + str ( i + 1 ) delta _ a = data [ i + 1 ] [ j ] - data [ i ] [ j ] if key _ a in diff : if diff [ key _ a ] ! = delta _ a : return False else : diff [ key _ a ] = delta _ a return True data = [ list ( map ( int , input ( ) . rstrip ( ) . split ( ) ) ) for _ in range ( 3 ) ] if check ( data ) : print ( " Yes " ) else : print ( " No " ) L = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] s = True if L [ 1 ] [ 1 ] ! = L [ 1 ] [ 0 ] - L [ 0 ] [ 0 ] + L [ 0 ] [ 1 ] : s = False if L [ 1 ] [ 2 ] ! = L [ 1 ] [ 0 ] - L [ 0 ] [ 0 ] + L [ 0 ] [ 2 ] : s = False if L [ 2 ] [ 1 ] ! = L [ 2 ] [ 0 ] - L [ 0 ] [ 0 ] + L [ 0 ] [ 1 ] : s = False if L [ 2 ] [ 2 ] ! = L [ 2 ] [ 0 ] - L [ 0 ] [ 0 ] + L [ 0 ] [ 2 ] : s = False if s : print ( ' Yes ' ) else : print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] for i in range ( 2 ) : if c [ i ] [ 0 ] - c [ i + 1 ] [ 0 ] = = c [ i ] [ 1 ] - c [ i + 1 ] [ 1 ] and c [ i ] [ 2 ] - c [ i + 1 ] [ 2 ] = = c [ i ] [ 1 ] - c [ i + 1 ] [ 1 ] : continue else : print ( " No " ) exit ( ) print ( " Yes " ) grid = list ( ) for a in range ( 3 ) : a , b , c = map ( int , input ( ) . split ( ) ) grid . append ( [ a , b , c ] ) ans = ' No ' for a1 in range ( 0 , 101 ) : for a2 in range ( 0 , 101 ) : b1 = grid [ 0 ] [ 0 ] - a1 b2 = grid [ 1 ] [ 1 ] - a2 a3 = grid [ 2 ] [ 1 ] - b2 b3 = grid [ 2 ] [ 2 ] - a3 a _ list = [ a1 , a2 , a3 ] b _ list = [ b1 , b2 , b3 ] count = 0 for x in range ( 3 ) : for y in range ( 3 ) : if grid [ x ] [ y ] = = a _ list [ x ] + b _ list [ y ] : count + = 1 if count = = 9 : ans = ' Yes ' break print ( ans ) lst _ c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] lst _ diff _ i = [ ] for i in range ( 3 ) : diff1 = lst _ c [ i ] [ 0 ] - lst _ c [ i ] [ 1 ] diff2 = lst _ c [ i ] [ 1 ] - lst _ c [ i ] [ 2 ] diff3 = lst _ c [ i ] [ 2 ] - lst _ c [ i ] [ 0 ] lst _ diff _ i . append ( [ diff1 , diff2 , diff3 ] ) if lst _ diff _ i [ 0 ] = = lst _ diff _ i [ 1 ] = = lst _ diff _ i [ 2 ] : ans = " Yes " else : print ( " No " ) exit ( ) print ( ans ) ary = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a = [ 0 ] b = [ ] ans = 0 for i in range ( 3 ) : b _ i = ary [ 0 ] [ i ] - a [ 0 ] b . append ( b _ i ) for i in range ( 1 , 3 ) : a _ i = ary [ i ] [ 0 ] - b [ 0 ] a . append ( a _ i ) for i in range ( 3 ) : for j in range ( 3 ) : if ary [ i ] [ j ] = = a [ i ] + b [ j ] : ans + = 1 if ans = = 9 : print ( ' Yes ' ) else : print ( ' No ' ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) if c1 [ 0 ] + c2 [ 1 ] + c3 [ 2 ] = = c1 [ 1 ] + c2 [ 2 ] + c3 [ 0 ] = = c1 [ 2 ] + c2 [ 0 ] + c3 [ 1 ] : print ( " Yes " ) else : print ( " No " ) def main ( ) : arr = [ list ( map ( int , input ( ) . rstrip ( ) . split ( ) ) ) for _ in range ( 3 ) ] memo = [ ] for i , j , k in arr : memo + = [ ( i - j , j - k ) ] print ( " Yes " if len ( set ( memo ) ) = = 1 else " No " ) if _ _ name _ _ = = " _ _ main _ _ " : main ( ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) flag = 0 if c1 [ 0 ] - c1 [ 1 ] ! = c2 [ 0 ] - c2 [ 1 ] or c1 [ 0 ] - c1 [ 1 ] ! = c3 [ 0 ] - c3 [ 1 ] : flag = 1 if c1 [ 0 ] - c1 [ 2 ] ! = c2 [ 0 ] - c2 [ 2 ] or c1 [ 0 ] - c1 [ 2 ] ! = c3 [ 0 ] - c3 [ 2 ] : flag = 1 if c1 [ 2 ] - c1 [ 1 ] ! = c2 [ 2 ] - c2 [ 1 ] or c1 [ 2 ] - c1 [ 1 ] ! = c3 [ 2 ] - c3 [ 1 ] : flag = 1 if c1 [ 0 ] - c2 [ 0 ] ! = c1 [ 1 ] - c2 [ 1 ] or c1 [ 0 ] - c2 [ 0 ] ! = c1 [ 2 ] - c2 [ 2 ] : flag = 1 if c1 [ 0 ] - c3 [ 0 ] ! = c1 [ 1 ] - c3 [ 1 ] or c1 [ 0 ] - c3 [ 0 ] ! = c1 [ 2 ] - c3 [ 2 ] : flag = 1 if c3 [ 0 ] - c2 [ 0 ] ! = c3 [ 1 ] - c2 [ 1 ] or c3 [ 0 ] - c2 [ 0 ] ! = c3 [ 2 ] - c2 [ 2 ] : flag = 1 if flag : print ( ' No ' ) else : print ( ' Yes ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] f = True for j in range ( 2 ) : x = c [ j ] [ 0 ] - c [ j + 1 ] [ 0 ] y = c [ 0 ] [ j ] - c [ 0 ] [ j + 1 ] for i in range ( 3 ) : if c [ j ] [ i ] - c [ j + 1 ] [ i ] ! = x : f = False if c [ i ] [ j ] - c [ i ] [ j + 1 ] ! = y : f = False print ( [ ' No ' , ' Yes ' ] [ int ( f ) ] ) c = list ( list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ) if all ( c [ i ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ i ] [ 1 ] - c [ 0 ] [ 1 ] and c [ i ] [ 1 ] - c [ 0 ] [ 1 ] = = c [ i ] [ 2 ] - c [ 0 ] [ 2 ] for i in [ 1 , 2 ] ) : print ( ' Yes ' ) else : print ( ' No ' ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] A = [ 0 for i in range ( 3 ) ] B _ cand = [ [ 0 for i in range ( 3 ) ] for i in range ( 3 ) ] A [ 0 ] = min ( C [ 0 ] ) A [ 1 ] = min ( C [ 1 ] ) A [ 2 ] = min ( C [ 2 ] ) for i in range ( 3 ) : for j in range ( 3 ) : B _ cand [ i ] [ j ] = C [ i ] [ j ] - A [ i ] if ( B _ cand [ 0 ] = = B _ cand [ 1 ] = = B _ cand [ 2 ] ) : print ( ' Yes ' ) else : print ( ' No ' ) def main ( ) : c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a = [ 0 , 0 , 0 ] b = [ 0 , 0 , 0 ] for i in range ( 0 , 101 ) : a [ 0 ] = i a [ 1 ] = - 1 a [ 2 ] = - 1 b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] for j in range ( 1 , 3 ) : if c [ j ] [ 0 ] - b [ 0 ] ! = c [ j ] [ 1 ] - b [ 1 ] or c [ j ] [ 1 ] - b [ 1 ] ! = c [ j ] [ 2 ] - b [ 2 ] : break a [ j ] = c [ j ] [ 0 ] - b [ 0 ] if j = = 2 and check ( a , b ) : print ( ' Yes ' ) return print ( ' No ' ) def check ( a , b ) : for i in range ( 0 , 3 ) : if a [ i ] > = 0 and b [ i ] > = 0 : continue else : return False return True if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) [ ( a , b , c ) , ( d , e , f ) , ( g , h , i ) ] = [ map ( int , input ( ) . split ( ) ) for i in range ( 3 ) ] q1 = a - b = = d - e = = g - h q2 = a - c = = d - f = = g - i q3 = a - d = = b - e = = c - f q4 = a - g = = b - h = = c - i print ( " Yes " if q1 and q2 and q3 and q4 else " No " ) import sys c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 a = [ c [ 0 ] [ i ] for i in range ( 3 ) ] b = [ c [ i ] [ 0 ] - a [ 0 ] for i in range ( 3 ) ] for i in range ( 3 ) : for j in range ( 3 ) : if a [ j ] + b [ i ] ! = c [ i ] [ j ] : print ( " No " ) sys . exit ( ) print ( " Yes " ) def main ( ) : a = [ [ 0 ] * 3 for i in range ( 3 ) ] a [ 0 ] = list ( map ( int , input ( ) . split ( ) ) ) a [ 1 ] = list ( map ( int , input ( ) . split ( ) ) ) a [ 2 ] = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) : minum = min ( a [ i ] ) for j in range ( 3 ) : a [ i ] [ j ] = a [ i ] [ j ] - minum ans = True for i in range ( 3 ) : if a [ 0 ] [ i ] ! = a [ 1 ] [ i ] or a [ 1 ] [ i ] ! = a [ 2 ] [ i ] : ans = False if ans : print ( ' Yes ' ) else : print ( ' No ' ) main ( ) sa = [ ] cnt = 0 for i in range ( 3 ) : x , y , z = map ( int , input ( ) . split ( ) ) sa . append ( [ x - y , y - z , z - x ] ) for i in range ( 3 ) : if sa [ 0 ] [ i ] = = sa [ 1 ] [ i ] = = sa [ 2 ] [ i ] : cnt + = 1 if cnt = = 3 : print ( ' Yes ' ) else : print ( ' No ' ) c = [ ] c _ diff = [ ] for i in range ( 3 ) : c . append ( [ int ( x ) for x in input ( ) . split ( ) ] ) for i in range ( 3 ) : c _ min = min ( c [ i ] ) c _ diff . append ( [ c [ i ] [ j ] - c _ min for j in range ( 3 ) ] ) if c _ diff [ 0 ] = = c _ diff [ 1 ] = = c _ diff [ 2 ] : print ( ' Yes ' ) else : print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] import sys for a1 in range ( 101 ) : for a2 in range ( 101 ) : for a3 in range ( 101 ) : if c [ 0 ] [ 0 ] - a1 = = c [ 1 ] [ 0 ] - a2 = = c [ 2 ] [ 0 ] - a3 and c [ 0 ] [ 1 ] - a1 = = c [ 1 ] [ 1 ] - a2 = = c [ 2 ] [ 1 ] - a3 and c [ 0 ] [ 2 ] - a1 = = c [ 1 ] [ 2 ] - a2 = = c [ 2 ] [ 2 ] - a3 : print ( ' Yes ' ) sys . exit ( ) print ( ' No ' ) [ ( a , b , c ) , ( d , e , f ) , ( g , h , i ) ] = [ map ( int , input ( ) . split ( ) ) for _ in range ( 3 ) ] print ( " Yes " if a - b = = d - e = = g - h and b - c = = e - f = = h - i else " No " ) a = list ( map ( int , open ( 0 ) . read ( ) . split ( ) ) ) print ( ' Yes ' if a [ 0 ] - a [ 1 ] = = a [ 3 ] - a [ 4 ] = = a [ 6 ] - a [ 7 ] and a [ 1 ] - a [ 2 ] = = a [ 4 ] - a [ 5 ] = = a [ 7 ] - a [ 8 ] and a [ 0 ] - a [ 3 ] = = a [ 1 ] - a [ 4 ] = = a [ 2 ] - a [ 5 ] and a [ 3 ] - a [ 6 ] = = a [ 4 ] - a [ 7 ] = = a [ 5 ] - a [ 8 ] else ' No ' ) c = [ ] for _ in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) a1 , a2 , a3 , b1 , b2 , b3 = 0 , c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] , c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] , c [ 0 ] [ 0 ] , c [ 0 ] [ 1 ] , c [ 0 ] [ 2 ] if c [ 0 ] [ 0 ] = = a1 + b1 and c [ 0 ] [ 1 ] = = a1 + b2 and c [ 0 ] [ 2 ] = = a1 + b3 \ and c [ 1 ] [ 0 ] = = a2 + b1 and c [ 1 ] [ 1 ] = = a2 + b2 and c [ 1 ] [ 2 ] = = a2 + b3 \ and c [ 2 ] [ 0 ] = = a3 + b1 and c [ 2 ] [ 1 ] = = a3 + b2 and c [ 2 ] [ 2 ] = = a3 + b3 : print ( " Yes " ) else : print ( " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] if C [ 0 ] [ 1 ] - C [ 0 ] [ 0 ] = = C [ 1 ] [ 1 ] - C [ 1 ] [ 0 ] = = C [ 2 ] [ 1 ] - C [ 2 ] [ 0 ] and C [ 0 ] [ 2 ] - C [ 0 ] [ 1 ] = = C [ 1 ] [ 2 ] - C [ 1 ] [ 1 ] = = C [ 2 ] [ 2 ] - C [ 2 ] [ 1 ] \ and C [ 1 ] [ 0 ] - C [ 0 ] [ 0 ] = = C [ 1 ] [ 1 ] - C [ 0 ] [ 1 ] = = C [ 1 ] [ 2 ] - C [ 0 ] [ 2 ] and C [ 2 ] [ 0 ] - C [ 1 ] [ 0 ] = = C [ 2 ] [ 1 ] - C [ 1 ] [ 1 ] = = C [ 2 ] [ 2 ] - C [ 1 ] [ 2 ] : print ( " Yes " ) else : print ( " No " ) def main ( ) : C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] b2 _ 1 = C [ 0 ] [ 1 ] - C [ 0 ] [ 0 ] b3 _ 1 = C [ 0 ] [ 2 ] - C [ 0 ] [ 0 ] if ( any ( [ b2 _ 1 ! = C [ x ] [ 1 ] - C [ x ] [ 0 ] for x in [ 1 , 2 ] ] ) or any ( [ b3 _ 1 ! = C [ x ] [ 2 ] - C [ x ] [ 0 ] for x in [ 1 , 2 ] ] ) ) : print ( " No " ) else : print ( " Yes " ) if _ _ name _ _ = = " _ _ main _ _ " : main ( ) def main ( ) : c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) r1max = max ( [ c11 , c12 , c13 ] ) r2max = max ( [ c21 , c22 , c23 ] ) r3max = max ( [ c31 , c32 , c33 ] ) c1max = max ( [ c11 , c21 , c31 ] ) c2max = max ( [ c12 , c22 , c32 ] ) c3max = max ( [ c13 , c23 , c33 ] ) for a1 in range ( 0 , r1max + 1 ) : for a2 in range ( 0 , r2max + 1 ) : for a3 in range ( 0 , r3max + 1 ) : m = max ( [ a1 , a2 , a3 ] ) for b1 in range ( 0 , c1max - m + 1 ) : C11 = a1 + b1 C21 = a2 + b1 C31 = a3 + b1 if C11 = = c11 and C21 = = c21 and C31 = = c31 : for b2 in range ( 0 , c2max - m + 1 ) : C12 = a1 + b2 C22 = a2 + b2 C32 = a3 + b2 if C12 = = c12 and C22 = = c22 and C32 = = c32 : for b3 in range ( 0 , c3max - m + 1 ) : C13 = a1 + b3 C23 = a2 + b3 C33 = a3 + b3 if C13 = = c13 and C23 = = c23 and C33 = = c33 : print ( ' Yes ' ) return print ( ' No ' ) return if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) s = [ ] judge = True for i in range ( 3 ) : s . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in range ( 3 ) : for j in range ( 3 ) : for k in range ( 3 ) : for l in range ( 3 ) : if i ! = k and k ! = l : a = s [ i ] [ j ] + s [ k ] [ l ] b = s [ i ] [ l ] + s [ k ] [ j ] if a ! = b : judge = False break if judge = = True : print ( " Yes " ) else : print ( " No " ) import sys YES = " Yes " NO = " No " def solve ( c : " List [ List [ int ] ] " ) : if ( c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] and c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 2 ] [ 0 ] and c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 1 ] [ 1 ] and c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 2 ] [ 1 ] and c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 0 ] [ 1 ] and c [ 2 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 1 ] [ 1 ] ) : ret = YES else : ret = NO print ( ret ) return def main ( ) : def iterate _ tokens ( ) : for line in sys . stdin : for word in line . split ( ) : yield word tokens = iterate _ tokens ( ) c = [ [ int ( next ( tokens ) ) for _ in range ( 3 ) ] for _ in range ( 3 ) ] solve ( c ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) c = [ [ ] for _ in range ( 3 ) ] for i in range ( 3 ) : c [ i ] = list ( map ( int , ( input ( ) . split ( ) ) ) ) a1 = c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] a2 = c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] b1 = c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] b2 = c [ 0 ] [ 2 ] - c [ 0 ] [ 0 ] if c [ 1 ] [ 1 ] - c [ 0 ] [ 0 ] = = a1 + b1 and c [ 2 ] [ 1 ] - c [ 0 ] [ 0 ] = = a2 + b1 and c [ 1 ] [ 2 ] - c [ 0 ] [ 0 ] = = a1 + b2 and c [ 2 ] [ 2 ] - c [ 0 ] [ 0 ] = = a2 + b2 : print ( " Yes " ) else : print ( " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] x = [ 0 ] * 3 y = [ 0 ] * 3 x [ 0 ] = 0 y [ 0 ] = 0 for i in range ( 3 ) : y [ i ] = C [ 0 ] [ i ] - x [ 0 ] for i in range ( 3 ) : x [ i ] = C [ i ] [ 0 ] - y [ 0 ] ans = True for i in range ( 3 ) : for j in range ( 3 ) : if C [ i ] [ j ] ! = x [ i ] + y [ j ] : ans = False print ( ' Yes ' if ans else ' No ' ) def examC ( ) : C = [ LI ( ) for _ in range ( 3 ) ] ans = " Yes " cur = [ 0 ] * 3 for i in range ( 2 ) : cur [ 0 ] = C [ 0 ] [ i + 1 ] - C [ 0 ] [ i ] cur [ 1 ] = C [ 1 ] [ i + 1 ] - C [ 1 ] [ i ] cur [ 2 ] = C [ 2 ] [ i + 1 ] - C [ 2 ] [ i ] if not cur [ 0 ] = = cur [ 1 ] = = cur [ 2 ] : ans = " No " for i in range ( 2 ) : cur [ 0 ] = C [ i + 1 ] [ 0 ] - C [ i ] [ 0 ] cur [ 1 ] = C [ i + 1 ] [ 1 ] - C [ i ] [ 1 ] cur [ 2 ] = C [ i + 1 ] [ 2 ] - C [ i ] [ 2 ] if not cur [ 0 ] = = cur [ 1 ] = = cur [ 2 ] : ans = " No " print ( ans ) import sys , copy , bisect , itertools , heapq , math from heapq import heappop , heappush , heapify from collections import Counter , defaultdict , deque def I ( ) : return int ( sys . stdin . readline ( ) ) def LI ( ) : return list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) def LSI ( ) : return list ( map ( str , sys . stdin . readline ( ) . split ( ) ) ) def LS ( ) : return sys . stdin . readline ( ) . split ( ) def S ( ) : return sys . stdin . readline ( ) . strip ( ) mod = 10 * * 9 + 7 inf = float ( ' inf ' ) examC ( ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 2 ) : if not ( C [ 0 ] [ i + 1 ] - C [ 0 ] [ i ] = = C [ 1 ] [ i + 1 ] - C [ 1 ] [ i ] = = C [ 2 ] [ i + 1 ] - C [ 2 ] [ i ] ) : print ( ' No ' ) exit ( ) if not ( C [ i + 1 ] [ 0 ] - C [ i ] [ 0 ] = = C [ i + 1 ] [ 1 ] - C [ i ] [ 1 ] = = C [ i + 1 ] [ 2 ] - C [ i ] [ 2 ] ) : print ( ' No ' ) exit ( ) print ( ' Yes ' ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] ans = " No " for i in range ( 0 , 101 ) : a = i b = [ C [ 0 ] [ 0 ] - a , C [ 0 ] [ 1 ] - a , C [ 0 ] [ 2 ] - a ] for j in range ( 1 , 3 ) : v = C [ j ] diff = [ v [ k ] - b [ k ] for k in range ( 3 ) ] if len ( set ( diff ) ) ! = 1 or any ( [ i < 0 for i in diff ] ) : break else : ans = " Yes " break print ( ans ) c _ list = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a _ list = [ 0 ] b _ list = [ ] for c in c _ list [ 0 ] : b = c - a _ list [ 0 ] b _ list . append ( b ) for i in range ( 1 , 3 ) : c = c _ list [ i ] [ 0 ] b = b _ list [ 0 ] a = c - b a _ list . append ( a ) def check ( ) : for i in range ( 3 ) : for j in range ( 3 ) : a = a _ list [ i ] b = b _ list [ j ] c = c _ list [ i ] [ j ] if not c = = a + b : return False return True if check ( ) : print ( " Yes " ) else : print ( " No " ) c = [ ] for _ in range ( 3 ) : c . append ( [ int ( x ) for x in input ( ) . split ( ) ] ) ans = ' Yes ' for i in range ( 3 ) : minv = min ( c [ i ] ) for j in range ( 3 ) : c [ i ] [ j ] = c [ i ] [ j ] - minv for k in range ( 3 ) : if c [ 0 ] [ k ] = = c [ 1 ] [ k ] and c [ 0 ] [ k ] = = c [ 2 ] [ k ] : pass else : ans = ' No ' print ( ans ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] if C [ 1 ] [ 0 ] - C [ 0 ] [ 0 ] = = C [ 1 ] [ 1 ] - C [ 0 ] [ 1 ] = = C [ 1 ] [ 2 ] - C [ 0 ] [ 2 ] and C [ 2 ] [ 0 ] - C [ 0 ] [ 0 ] = = C [ 2 ] [ 1 ] - C [ 0 ] [ 1 ] = = C [ 2 ] [ 2 ] - C [ 0 ] [ 2 ] \ and C [ 0 ] [ 1 ] - C [ 0 ] [ 0 ] = = C [ 1 ] [ 1 ] - C [ 1 ] [ 0 ] = = C [ 2 ] [ 1 ] - C [ 2 ] [ 0 ] and C [ 0 ] [ 2 ] - C [ 0 ] [ 0 ] = = C [ 1 ] [ 2 ] - C [ 1 ] [ 0 ] = = C [ 2 ] [ 2 ] - C [ 2 ] [ 0 ] : print ( " Yes " ) else : print ( " No " ) import sys C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 3 ) : if not ( ( C [ i ] [ 0 ] - C [ ( i + 1 ) % 3 ] [ 0 ] ) = = ( C [ i ] [ 1 ] - C [ ( i + 1 ) % 3 ] [ 1 ] ) = = ( C [ i ] [ 2 ] - C [ ( i + 1 ) % 3 ] [ 2 ] ) ) : print ( ' No ' ) sys . exit ( ) for j in range ( 3 ) : if not ( ( C [ 0 ] [ j ] - C [ 0 ] [ ( j + 1 ) % 3 ] ) = = ( C [ 1 ] [ j ] - C [ 1 ] [ ( j + 1 ) % 3 ] ) = = ( C [ 2 ] [ j ] - C [ 2 ] [ ( j + 1 ) % 3 ] ) ) : print ( ' No ' ) sys . exit ( ) print ( ' Yes ' ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) if c11 + c22 + c33 = = c12 + c23 + c31 = = c13 + c21 + c32 : print ( " Yes " ) else : print ( " No " ) def main ( ) : C = [ [ int ( _ ) for _ in input ( ) . split ( ) ] for i in range ( 3 ) ] if C [ 0 ] [ 0 ] - C [ 0 ] [ 1 ] = = C [ 1 ] [ 0 ] - C [ 1 ] [ 1 ] and C [ 2 ] [ 0 ] - C [ 2 ] [ 1 ] = = C [ 1 ] [ 0 ] - C [ 1 ] [ 1 ] : if C [ 0 ] [ 1 ] - C [ 0 ] [ 2 ] = = C [ 1 ] [ 1 ] - C [ 1 ] [ 2 ] and C [ 2 ] [ 1 ] - C [ 2 ] [ 2 ] = = C [ 1 ] [ 1 ] - C [ 1 ] [ 2 ] : print ( " Yes " ) return print ( " No " ) if _ _ name _ _ = = " _ _ main _ _ " : main ( ) C = [ ] for _ in range ( 3 ) : C . append ( list ( map ( int , input ( ) . split ( ) ) ) ) def f ( ) : for i in range ( 2 ) : if not C [ i + 1 ] [ 0 ] - C [ i ] [ 0 ] = = C [ i + 1 ] [ 1 ] - C [ i ] [ 1 ] = = C [ i + 1 ] [ 2 ] - C [ i ] [ 2 ] : return False for i in range ( 2 ) : if not C [ 0 ] [ i + 1 ] - C [ 0 ] [ i ] = = C [ 1 ] [ i + 1 ] - C [ 1 ] [ i ] = = C [ 2 ] [ i + 1 ] - C [ 2 ] [ i ] : return False return True if f ( ) : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for b1 in range ( 101 ) : a = [ c [ 0 ] [ 0 ] - b1 , c [ 1 ] [ 0 ] - b1 , c [ 2 ] [ 0 ] - b1 ] b = [ b1 , c [ 0 ] [ 1 ] - a [ 0 ] , c [ 0 ] [ 2 ] - a [ 0 ] ] if all ( a [ i ] + b [ j ] = = c [ i ] [ j ] for j in range ( 3 ) for i in range ( 3 ) ) : print ( ' Yes ' ) exit ( ) print ( ' No ' ) C = [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( 3 ) ] D = [ [ ] for _ in range ( 4 ) ] for i in range ( 2 ) : for j in range ( 3 ) : D [ i ] . append ( C [ i + 1 ] [ j ] - C [ i ] [ j ] ) D [ i + 2 ] . append ( C [ j ] [ i + 1 ] - C [ j ] [ i ] ) for d in D : if len ( set ( d ) ) ! = 1 : print ( " No " ) break else : print ( " Yes " ) import itertools import sys import numpy as np import collections c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) ans = [ ] cr1 , cr2 , cr3 = zip ( c1 , c2 , c3 ) for c in [ c1 , c2 , c3 ] : for i , cr in enumerate ( [ cr1 , cr2 , cr3 ] ) : a = sum ( c ) + sum ( cr ) - c [ i ] * 3 ans . append ( a ) print ( ' Yes ' if len ( set ( ans ) ) = = 1 else ' No ' ) X = [ ] for _ in range ( 3 ) : X . append ( list ( map ( int , input ( ) . split ( ' ' ) ) ) ) for i in range ( 3 ) : D = [ ] for j in range ( 3 ) : D . append ( X [ i ] [ j ] - X [ i - 1 ] [ j ] ) if len ( set ( D ) ) > 1 : print ( ' No ' ) break else : print ( ' Yes ' ) A = list ( map ( int , input ( ) . split ( ) ) ) B = list ( map ( int , input ( ) . split ( ) ) ) C = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 101 ) : for j in range ( 101 ) : for h in range ( 101 ) : X = [ a - i for a in A ] Y = [ b - j for b in B ] Z = [ c - h for c in C ] if X = = Y = = Z : print ( ' Yes ' ) exit ( ) print ( " No " ) mat = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] checks = [ [ 0 , 1 ] , [ 0 , 2 ] , [ 1 , 2 ] ] for i , j in checks : if mat [ i ] [ i ] + mat [ j ] [ j ] ! = mat [ i ] [ j ] + mat [ j ] [ i ] : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 2 ) : for j in range ( 2 ) : if c [ i ] [ j ] - c [ i ] [ j + 1 ] = = c [ i + 1 ] [ j ] - c [ i + 1 ] [ j + 1 ] : pass else : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c = list ( list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ) c00 = c [ 0 ] [ 0 ] c11 = c [ 1 ] [ 1 ] c22 = c [ 2 ] [ 2 ] for a0 in range ( c00 + 1 ) : for a1 in range ( c11 + 1 ) : for a2 in range ( c22 + 1 ) : A = [ a0 , a1 , a2 ] B = [ c00 - a0 , c11 - a1 , c22 - a2 ] tmp = [ ] for a in A : row = [ ] for b in B : row . append ( a + b ) tmp . append ( row ) if tmp = = c : print ( ' Yes ' ) exit ( ) print ( ' No ' ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] if C [ 0 ] [ 0 ] - C [ 0 ] [ 1 ] = = C [ 1 ] [ 0 ] - C [ 1 ] [ 1 ] = = C [ 2 ] [ 0 ] - C [ 2 ] [ 1 ] and C [ 0 ] [ 1 ] - C [ 0 ] [ 2 ] = = C [ 1 ] [ 1 ] - C [ 1 ] [ 2 ] = = C [ 2 ] [ 1 ] - C [ 2 ] [ 2 ] \ and C [ 0 ] [ 0 ] - C [ 1 ] [ 0 ] = = C [ 0 ] [ 1 ] - C [ 1 ] [ 1 ] = = C [ 0 ] [ 2 ] - C [ 1 ] [ 2 ] and C [ 1 ] [ 0 ] - C [ 2 ] [ 0 ] = = C [ 1 ] [ 1 ] - C [ 2 ] [ 1 ] = = C [ 1 ] [ 2 ] - C [ 2 ] [ 2 ] : print ( ' Yes ' ) else : print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] d = [ 0 , 0 , 0 ] ans = ' Yes ' for i in range ( 2 ) : for j in range ( 3 ) : d [ j ] = c [ i + 1 ] [ j ] - c [ i ] [ j ] if d [ 0 ] = = d [ 1 ] and d [ 0 ] = = d [ 2 ] : continue else : ans = ' No ' print ( ans ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] a [ 1 ] = c [ 1 ] [ 1 ] - b [ 1 ] a [ 2 ] = c [ 2 ] [ 2 ] - b [ 2 ] f = 0 for i in range ( 3 ) : for j in range ( 3 ) : if a [ i ] + b [ j ] = = c [ i ] [ j ] : f + = 1 if f = = 9 : print ( ' Yes ' ) else : print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] x = [ 0 ] y = [ ] for i in range ( 3 ) : y . append ( c [ 0 ] [ i ] - x [ 0 ] ) for i in range ( 1 , 3 ) : x . append ( c [ i ] [ 0 ] - y [ 0 ] ) ans = True for i in range ( 3 ) : for j in range ( 3 ) : if x [ i ] + y [ j ] ! = c [ i ] [ j ] : ans = False if ans : print ( ' Yes ' ) else : print ( ' No ' ) grid = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] b0 _ 1 = set ( ) b1 _ 2 = set ( ) a0 _ 1 = set ( ) a1 _ 2 = set ( ) for a in range ( 3 ) : b0 _ 1 . add ( grid [ a ] [ 0 ] - grid [ a ] [ 1 ] ) b1 _ 2 . add ( grid [ a ] [ 1 ] - grid [ a ] [ 2 ] ) for b in range ( 3 ) : a0 _ 1 . add ( grid [ 0 ] [ b ] - grid [ 1 ] [ b ] ) a1 _ 2 . add ( grid [ 1 ] [ b ] - grid [ 2 ] [ b ] ) if len ( b0 _ 1 ) = = 1 and len ( b1 _ 2 ) = = 1 and len ( a0 _ 1 ) = = 1 and len ( a1 _ 2 ) = = 1 : print ( ' Yes ' ) else : print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] if ( c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] ) * 2 = = c [ 0 ] [ 1 ] + c [ 0 ] [ 2 ] + c [ 1 ] [ 0 ] + c [ 1 ] [ 2 ] + c [ 2 ] [ 0 ] + c [ 2 ] [ 1 ] : print ( ' Yes ' ) else : print ( ' No ' ) M = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] A = { i : - 1 for i in range ( 3 ) } B = { i : - 1 for i in range ( 3 ) } checker = False for a1 in range ( 100 ) : A [ 0 ] = a1 B [ 0 ] = M [ 0 ] [ 0 ] - a1 B [ 1 ] = M [ 0 ] [ 1 ] - a1 B [ 2 ] = M [ 0 ] [ 2 ] - a1 A [ 1 ] = M [ 1 ] [ 0 ] - B [ 0 ] A [ 2 ] = M [ 2 ] [ 0 ] - B [ 0 ] cnt = 0 for i in range ( 3 ) : for j in range ( 3 ) : if M [ i ] [ j ] = = A [ i ] + B [ j ] : cnt + = 1 if cnt = = 9 : checker = True break if checker : print ( ' Yes ' ) else : print ( ' No ' ) import sys input = sys . stdin . readline sys . setrecursionlimit ( 10 * * 6 ) C = [ ] for i in range ( 3 ) : x = list ( map ( int , input ( ) . split ( ) ) ) C . append ( x ) if ( C [ 0 ] [ 0 ] - C [ 0 ] [ 1 ] = = C [ 1 ] [ 0 ] - C [ 1 ] [ 1 ] and C [ 1 ] [ 0 ] - C [ 1 ] [ 1 ] = = C [ 2 ] [ 0 ] - C [ 2 ] [ 1 ] and C [ 0 ] [ 1 ] - C [ 0 ] [ 2 ] = = C [ 1 ] [ 1 ] - C [ 1 ] [ 2 ] and C [ 1 ] [ 1 ] - C [ 1 ] [ 2 ] = = C [ 2 ] [ 1 ] - C [ 2 ] [ 2 ] ) : print ( ' Yes ' ) else : print ( ' No ' ) num = list ( input ( ) . split ( ) for l in range ( 3 ) ) flg = 0 for i in range ( 0 , 101 ) : d = int ( num [ 0 ] [ 0 ] ) - i e = int ( num [ 1 ] [ 0 ] ) - i f = int ( num [ 2 ] [ 0 ] ) - i b = int ( num [ 0 ] [ 1 ] ) - d c = int ( num [ 0 ] [ 2 ] ) - d if int ( num [ 1 ] [ 1 ] ) = = b + e and int ( num [ 1 ] [ 2 ] ) = = c + e and int ( num [ 2 ] [ 1 ] ) = = b + f and int ( num [ 2 ] [ 2 ] ) = = c + f : flg = 1 if flg : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ ] b = [ ] for i in range ( 3 ) : a . append ( abs ( c [ i ] [ 0 ] - c [ i ] [ 1 ] ) ) a . append ( abs ( c [ i ] [ 1 ] - c [ i ] [ 2 ] ) ) for i in range ( 3 ) : b . append ( abs ( c [ 0 ] [ i ] - c [ 1 ] [ i ] ) ) b . append ( abs ( c [ 1 ] [ i ] - c [ 2 ] [ i ] ) ) if a [ 0 ] = = a [ 2 ] and a [ 2 ] = = a [ 4 ] and b [ 0 ] = = b [ 2 ] and b [ 2 ] = = b [ 4 ] \ and a [ 1 ] = = a [ 3 ] and a [ 3 ] = = a [ 5 ] and b [ 1 ] = = b [ 3 ] and b [ 3 ] = = b [ 5 ] : print ( ' Yes ' ) exit ( ) print ( ' No ' ) import sys import math from collections import defaultdict sys . setrecursionlimit ( 10 * * 7 ) def input ( ) : return sys . stdin . readline ( ) [ : - 1 ] mod = 10 * * 9 + 7 def I ( ) : return int ( input ( ) ) def II ( ) : return map ( int , input ( ) . split ( ) ) def III ( ) : return list ( map ( int , input ( ) . split ( ) ) ) def Line ( N ) : read _ all = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( N ) ] return map ( list , zip ( * read _ all ) ) c = [ ] for _ in range ( 3 ) : c . append ( III ( ) ) for j in range ( 2 ) : if c [ 0 ] [ j + 1 ] - c [ 0 ] [ j ] = = c [ 1 ] [ j + 1 ] - c [ 1 ] [ j ] = = c [ 2 ] [ j + 1 ] - c [ 2 ] [ j ] : pass else : print ( ' No ' ) exit ( ) for i in range ( 2 ) : if c [ i + 1 ] [ 0 ] - c [ i ] [ 0 ] = = c [ i + 1 ] [ 1 ] - c [ i ] [ 1 ] = = c [ i + 1 ] [ 2 ] - c [ i ] [ 2 ] : pass else : print ( ' No ' ) exit ( ) print ( ' Yes ' ) ls = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] def sub ( p , q ) : return p - q for i in range ( len ( ls ) ) : new = [ ls [ i ] [ 0 ] ] * 3 ls [ i ] = list ( map ( sub , ls [ i ] , new ) ) if ( list ( map ( sub , ls [ 0 ] , ls [ 1 ] ) ) = = [ 0 , 0 , 0 ] ) and ( list ( map ( sub , ls [ 0 ] , ls [ 2 ] ) ) = = [ 0 , 0 , 0 ] ) and ( list ( map ( sub , ls [ 2 ] , ls [ 1 ] ) ) = = [ 0 , 0 , 0 ] ) : print ( " Yes " ) else : print ( " No " ) import numpy as np c1 , c2 , c3 = map ( int , input ( ) . split ( ) ) c4 , c5 , c6 = map ( int , input ( ) . split ( ) ) c7 , c8 , c9 = map ( int , input ( ) . split ( ) ) A = np . array ( [ [ 1 , 0 , 0 , 1 , 0 , 0 , c1 ] , [ 1 , 0 , 0 , 0 , 1 , 0 , c2 ] , [ 1 , 0 , 0 , 0 , 0 , 1 , c3 ] , [ 0 , 1 , 0 , 1 , 0 , 0 , c4 ] , [ 0 , 1 , 0 , 0 , 1 , 0 , c5 ] , [ 0 , 1 , 0 , 0 , 0 , 1 , c6 ] , [ 0 , 0 , 1 , 1 , 0 , 0 , c7 ] , [ 0 , 0 , 1 , 0 , 1 , 0 , c8 ] , [ 0 , 0 , 1 , 0 , 0 , 1 , c9 ] ] ) if np . linalg . matrix _ rank ( A ) = = 5 : print ( " Yes " ) else : print ( " No " ) import numpy as np c = np . zeros ( ( 3 , 3 ) ) for i in range ( 3 ) : c [ i , : ] = np . array ( list ( map ( int , input ( ) . split ( ) ) ) ) vert _ sum = np . sum ( c , axis = 0 ) horz _ sum = np . sum ( c , axis = 1 ) for a1 in range ( 101 ) : a2 = ( horz _ sum [ 1 ] - horz _ sum [ 0 ] ) / 3 + a1 a3 = ( horz _ sum [ 2 ] - horz _ sum [ 0 ] ) / 3 + a1 for b1 in range ( 101 ) : b2 = ( vert _ sum [ 1 ] - vert _ sum [ 0 ] ) / 3 + b1 b3 = ( vert _ sum [ 2 ] - vert _ sum [ 0 ] ) / 3 + b1 if ( c [ 0 , 0 ] = = a1 + b1 and c [ 0 , 1 ] = = a1 + b2 and c [ 0 , 2 ] = = a1 + b3 and c [ 1 , 0 ] = = a2 + b1 and c [ 1 , 1 ] = = a2 + b2 and c [ 1 , 2 ] = = a2 + b3 and c [ 2 , 0 ] = = a3 + b1 and c [ 2 , 1 ] = = a3 + b2 and c [ 2 , 2 ] = = a3 + b3 ) : print ( ' Yes ' ) exit ( ) print ( ' No ' ) c = list ( map ( int , input ( ) . split ( ) ) ) c + = list ( map ( int , input ( ) . split ( ) ) ) c + = list ( map ( int , input ( ) . split ( ) ) ) if ( c [ 0 ] - c [ 1 ] = = c [ 3 ] - c [ 4 ] = = c [ 6 ] - c [ 7 ] ) and ( c [ 1 ] - c [ 2 ] = = c [ 4 ] - c [ 5 ] = = c [ 7 ] - c [ 8 ] ) and ( c [ 0 ] - c [ 3 ] = = c [ 1 ] - c [ 4 ] = = c [ 2 ] - c [ 5 ] ) and ( c [ 3 ] - c [ 6 ] = = c [ 4 ] - c [ 7 ] = = c [ 5 ] - c [ 8 ] ) : ans = ' Yes ' else : ans = ' No ' print ( ans ) import sys def solve ( ) : input = sys . stdin . readline C = [ [ int ( c ) for c in input ( ) . split ( ) ] for _ in range ( 3 ) ] possible = True for i in range ( 3 ) : if abs ( C [ i ] [ 0 ] - C [ ( i + 1 ) % 3 ] [ 0 ] ) = = abs ( C [ i ] [ 1 ] - C [ ( i + 1 ) % 3 ] [ 1 ] ) = = abs ( C [ i ] [ 2 ] - C [ ( i + 1 ) % 3 ] [ 2 ] ) : continue else : print ( " No " ) break else : for j in range ( 3 ) : if abs ( C [ 0 ] [ j ] - C [ 0 ] [ ( j + 1 ) % 3 ] ) = = abs ( C [ 1 ] [ j ] - C [ 1 ] [ ( j + 1 ) % 3 ] ) = = abs ( C [ 2 ] [ j ] - C [ 2 ] [ ( j + 1 ) % 3 ] ) : continue else : print ( " No " ) break else : print ( " Yes " ) return 0 if _ _ name _ _ = = " _ _ main _ _ " : solve ( ) X = [ [ int ( a ) for a in input ( ) . split ( ) ] for _ in range ( 3 ) ] f = 0 for i in range ( 1 , 3 ) : for j in range ( 1 , 3 ) : if X [ i ] [ j ] + X [ 0 ] [ 0 ] ! = X [ i ] [ 0 ] + X [ 0 ] [ j ] : print ( " No " ) f = 1 break if f : break else : print ( " Yes " ) c = [ ] for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) ans = True for i in range ( 2 ) : tmp = c [ 0 ] [ i + 1 ] - c [ 0 ] [ i ] for j in range ( 2 ) : if c [ j + 1 ] [ i + 1 ] - c [ j + 1 ] [ i ] ! = tmp : ans = False break for i in range ( 2 ) : tmp = c [ i + 1 ] [ 0 ] - c [ i ] [ 0 ] for j in range ( 2 ) : if c [ i + 1 ] [ j + 1 ] - c [ i ] [ j + 1 ] ! = tmp : ans = False break if ans : print ( " Yes " ) else : print ( " No " ) C = list ( list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ) a = C [ 0 ] [ 0 ] + C [ 1 ] [ 1 ] + C [ 2 ] [ 2 ] b = C [ 0 ] [ 2 ] + C [ 1 ] [ 0 ] + C [ 2 ] [ 1 ] c = C [ 0 ] [ 1 ] + C [ 1 ] [ 2 ] + C [ 2 ] [ 0 ] if a = = b = = c : print ( " Yes " ) else : print ( " No " ) C _ grid = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a1 , a2 , a3 = C _ grid [ 0 ] [ 1 ] - C _ grid [ 0 ] [ 0 ] , C _ grid [ 0 ] [ 2 ] - C _ grid [ 0 ] [ 1 ] , C _ grid [ 0 ] [ 0 ] - C _ grid [ 0 ] [ 2 ] for i in range ( 1 , 3 ) : gyo = C _ grid [ i ] k1 , k2 , k3 = gyo [ 1 ] - gyo [ 0 ] , gyo [ 2 ] - gyo [ 1 ] , gyo [ 0 ] - gyo [ 2 ] if a1 = = k1 and a2 = = k2 and a3 = = k3 : continue else : print ( ' No ' ) exit ( 0 ) a1 , a2 , a3 = C _ grid [ 1 ] [ 0 ] - C _ grid [ 0 ] [ 0 ] , C _ grid [ 2 ] [ 0 ] - C _ grid [ 1 ] [ 0 ] , C _ grid [ 0 ] [ 0 ] - C _ grid [ 2 ] [ 0 ] for i in range ( 1 , 3 ) : k1 , k2 , k3 = C _ grid [ 1 ] [ i ] - C _ grid [ 0 ] [ i ] , C _ grid [ 2 ] [ i ] - C _ grid [ 1 ] [ i ] , C _ grid [ 0 ] [ i ] - C _ grid [ 2 ] [ i ] if a1 = = k1 and a2 = = k2 and a3 = = k3 : continue else : print ( ' No ' ) exit ( 0 ) print ( ' Yes ' ) ls = [ [ int ( x ) for x in input ( ) . split ( ) ] for _ in range ( 3 ) ] flg = " Yes " for i in range ( 2 ) : if ls [ 0 ] [ i ] - ls [ 0 ] [ i + 1 ] = = ls [ 1 ] [ i ] - ls [ 1 ] [ i + 1 ] and ls [ 0 ] [ i ] - ls [ 0 ] [ i + 1 ] = = ls [ 2 ] [ i ] - ls [ 2 ] [ i + 1 ] : pass else : flg = " No " print ( flg ) from collections import deque def resolve ( ) : def all _ same ( a , b , c ) : if a = = b and b = = c : return True return False c = [ ] for _ in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) ans = True if not all _ same ( c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] , c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] , c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] ) : ans = False if not all _ same ( c [ 0 ] [ 0 ] - c [ 2 ] [ 0 ] , c [ 0 ] [ 1 ] - c [ 2 ] [ 1 ] , c [ 0 ] [ 2 ] - c [ 2 ] [ 2 ] ) : ans = False if not all _ same ( c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] , c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] , c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] ) : ans = False if not all _ same ( c [ 0 ] [ 0 ] - c [ 0 ] [ 2 ] , c [ 1 ] [ 0 ] - c [ 1 ] [ 2 ] , c [ 2 ] [ 0 ] - c [ 2 ] [ 2 ] ) : ans = False if ans : print ( ' Yes ' ) else : print ( ' No ' ) if _ _ name _ _ = = " _ _ main _ _ " : resolve ( ) C1 = list ( map ( int , input ( ) . split ( ) ) ) C2 = list ( map ( int , input ( ) . split ( ) ) ) C3 = list ( map ( int , input ( ) . split ( ) ) ) a = 0 b1 , b2 , b3 = C1 [ 0 ] , C1 [ 1 ] , C1 [ 2 ] a1 , a2 , a3 = 0 , C2 [ 1 ] - b2 , C3 [ 1 ] - b2 if C1 [ 0 ] ! = a1 + b1 or C1 [ 1 ] ! = a1 + b2 or C1 [ 2 ] ! = a1 + b3 or C2 [ 0 ] ! = a2 + b1 or C2 [ 1 ] ! = a2 + b2 or C2 [ 2 ] ! = a2 + b3 or C3 [ 0 ] ! = a3 + b1 or C3 [ 1 ] ! = a3 + b2 or C3 [ 2 ] ! = a3 + b3 : print ( " No " ) else : print ( " Yes " ) A = list ( map ( int , input ( ) . split ( ) ) ) x = A [ 1 ] - A [ 0 ] y = A [ 2 ] - A [ 1 ] f = 0 for i in range ( 2 ) : B = list ( map ( int , input ( ) . split ( ) ) ) if B [ 1 ] - B [ 0 ] ! = x or B [ 2 ] - B [ 1 ] ! = y : f = 1 break if f = = 0 : print ( " Yes " ) else : print ( " No " ) l = [ [ int ( i ) for i in input ( ) . split ( ) ] for j in range ( 3 ) ] a = [ 0 ] b = [ ] for i in range ( 3 ) : b . append ( l [ 0 ] [ i ] - a [ 0 ] ) for i in range ( 1 , 3 ) : a . append ( l [ i ] [ 0 ] - b [ 0 ] ) for i in range ( 3 ) : for j in range ( 3 ) : if a [ i ] + b [ j ] ! = l [ i ] [ j ] : print ( " No " ) exit ( ) print ( " Yes " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 3 ) : temp = C [ i ] [ 0 ] C [ i ] = [ j - temp for j in C [ i ] ] if C [ 0 ] = = C [ 1 ] and C [ 1 ] = = C [ 2 ] : print ( " Yes " ) else : print ( " No " ) from collections import defaultdict import sys sys . setrecursionlimit ( 1000000 ) def dfs ( graph , visited , x , c ) : visited [ x ] = c for nx in graph [ x ] : if visited [ nx ] = = c : return False if visited [ nx ] = = 0 and not dfs ( graph , visited , nx , - c ) : return False return True while True : n , m = list ( map ( int , input ( ) . split ( ) ) ) if n = = 0 : break graph = defaultdict ( list ) visited = [ 0 for i in range ( n + 1 ) ] for i in range ( m ) : u , v = list ( map ( int , input ( ) . split ( ) ) ) graph [ u ] . append ( v ) graph [ v ] . append ( u ) f = dfs ( graph , visited , 1 , 1 ) if f = = False : print ( 0 ) else : ans1 , ans2 = 0 , 0 for i in range ( 1 , n + 1 ) : if visited [ i ] > 0 : ans1 + = 1 elif visited [ i ] < 0 : ans2 + = 1 ans = set ( ) if ans1 % 2 = = 0 : ans . add ( ans1 / / 2 ) if ans2 % 2 = = 0 : ans . add ( ans2 / / 2 ) print ( len ( ans ) ) for e in sorted ( ans ) : print ( e ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a2 , a3 = [ ] , [ ] for i in range ( 3 ) : a2 . append ( C [ 0 ] [ i ] - C [ 1 ] [ i ] ) a3 . append ( C [ 0 ] [ i ] - C [ 2 ] [ i ] ) if len ( set ( a2 ) ) = = 1 and len ( set ( a3 ) ) = = 1 : print ( ' Yes ' ) else : print ( ' No ' ) nums = [ ] for i in range ( 3 ) : nums . append ( list ( map ( int , input ( ) . split ( ) ) ) ) subd = [ ] for i in range ( 3 ) : subd . append ( [ nums [ i ] [ 0 ] - nums [ i ] [ 1 ] , nums [ i ] [ 1 ] - nums [ i ] [ 2 ] ] ) for i in range ( 3 ) : subd . append ( [ nums [ 0 ] [ i ] - nums [ 1 ] [ i ] , nums [ 1 ] [ i ] - nums [ 2 ] [ i ] ] ) if subd [ 0 ] = = subd [ 1 ] and subd [ 1 ] = = subd [ 2 ] and subd [ 3 ] = = subd [ 4 ] and subd [ 4 ] = = subd [ 5 ] : print ( " Yes " ) else : print ( " No " ) def resolve ( ) : A = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] B = [ ] for i in range ( 3 ) : C = [ ] for j in range ( 3 ) : C . append ( A [ i ] [ j ] - min ( A [ i ] ) ) B . append ( C ) flag = True for i in range ( 3 ) : if B [ 0 ] [ i ] ! = B [ 1 ] [ i ] or B [ 0 ] [ i ] ! = B [ 2 ] [ i ] : flag = False if flag = = True : print ( " Yes " ) else : print ( " No " ) resolve ( ) ar = [ [ int ( i ) for i in input ( ) . split ( ) ] for j in range ( 3 ) ] if ar [ 0 ] [ 0 ] + ar [ 1 ] [ 1 ] + ar [ 2 ] [ 2 ] = = ar [ 0 ] [ 1 ] + ar [ 1 ] [ 2 ] + ar [ 2 ] [ 0 ] = = ar [ 0 ] [ 2 ] + ar [ 1 ] [ 0 ] + ar [ 2 ] [ 1 ] : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] m = 0 for a1 in range ( 101 ) : b1 = c [ 0 ] [ 0 ] - a1 if b1 > = 0 : if a1 + b1 = = c [ 0 ] [ 0 ] : a2 = c [ 1 ] [ 0 ] - b1 a3 = c [ 2 ] [ 0 ] - b1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 if a2 > = 0 and a3 > = 0 and b2 > = 0 and b3 > = 0 : if a2 + b2 = = c [ 1 ] [ 1 ] and a3 + b2 = = c [ 2 ] [ 1 ] : if a2 + b3 = = c [ 1 ] [ 2 ] and a3 + b3 = = c [ 2 ] [ 2 ] : m = 1 if m = = 1 : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a , b = [ 0 , 0 , 0 ] , [ 0 , 0 , 0 ] for i in range ( 3 ) : b [ i ] = c [ 0 ] [ i ] - a [ 0 ] for j in range ( 1 , 3 ) : a [ j ] = c [ j ] [ 0 ] - b [ 0 ] for i in range ( 1 , 3 ) : for j in range ( 1 , 3 ) : if c [ j ] [ i ] = = a [ j ] + b [ i ] : pass else : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] for i in range ( 2 ) : for j in range ( 2 ) : if c [ i ] [ j ] - c [ i + 1 ] [ j ] ! = c [ i ] [ j + 1 ] - c [ i + 1 ] [ j + 1 ] : print ( " No " ) exit ( ) print ( " Yes " ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) c = list ( map ( int , input ( ) . split ( ) ) ) if a [ 0 ] - b [ 0 ] = = a [ 1 ] - b [ 1 ] = = a [ 2 ] - b [ 2 ] : if b [ 0 ] - c [ 0 ] = = b [ 1 ] - c [ 1 ] = = b [ 2 ] - c [ 2 ] : print ( " Yes " ) exit ( ) else : pass print ( " No " ) import numpy as np A = [ list ( map ( int , input ( ) . split ( ) ) ) for l in range ( 3 ) ] col _ 0 = [ A [ 0 ] [ 1 ] - A [ 0 ] [ 0 ] , A [ 0 ] [ 2 ] - A [ 0 ] [ 0 ] ] col _ 1 = [ A [ 1 ] [ 1 ] - A [ 1 ] [ 0 ] , A [ 1 ] [ 2 ] - A [ 1 ] [ 0 ] ] col _ 2 = [ A [ 2 ] [ 1 ] - A [ 2 ] [ 0 ] , A [ 2 ] [ 2 ] - A [ 2 ] [ 0 ] ] bool = ( col _ 0 = = col _ 1 ) and ( col _ 0 = = col _ 2 ) if bool = = True : print ( ' Yes ' ) else : print ( ' No ' ) C = [ ] for _ in range ( 3 ) : a = list ( map ( int , input ( ) . split ( ) ) ) b = min ( a ) for i in range ( 3 ) : a [ i ] - = b C . append ( a ) if C [ 0 ] = = C [ 1 ] = = C [ 2 ] : print ( " Yes " ) else : print ( " No " ) c = [ 0 ] * 9 for i in range ( 3 ) : tmp = list ( map ( int , input ( ) . split ( ) ) ) for j in range ( 3 ) : c [ i * 3 + j ] = tmp [ j ] if not ( c [ 0 ] - c [ 3 ] = = c [ 1 ] - c [ 4 ] and c [ 0 ] - c [ 3 ] = = c [ 2 ] - c [ 5 ] and c [ 3 ] - c [ 6 ] = = c [ 4 ] - c [ 7 ] and c [ 3 ] - c [ 6 ] = = c [ 5 ] - c [ 8 ] ) : print ( ' No ' ) exit ( ) if not ( c [ 0 ] - c [ 1 ] = = c [ 3 ] - c [ 4 ] and c [ 0 ] - c [ 1 ] = = c [ 6 ] - c [ 7 ] and c [ 1 ] - c [ 2 ] = = c [ 4 ] - c [ 5 ] and c [ 1 ] - c [ 2 ] = = c [ 7 ] - c [ 8 ] ) : print ( ' No ' ) exit ( ) print ( ' Yes ' ) import numpy as np from itertools import product import sys read = sys . stdin . buffer . read C = np . array ( read ( ) . split ( ) , np . int32 ) . reshape ( 3 , 3 ) a , b , c = np . max ( C + 1 , axis = 1 ) N = [ ] for i , j in product ( range ( a ) , range ( b ) ) : x = C [ 0 , : ] - i y = C [ 1 , : ] - j if np . all ( x = = y ) : N . append ( x ) flag = 0 z = C [ 2 , : ] for n in N : for k in range ( c ) : if np . all ( z - k = = n ) : flag = 1 break if flag : break print ( [ ' No ' , ' Yes ' ] [ flag ] ) y1 _ list = list ( map ( int , input ( ) . split ( ) ) ) y2 _ list = list ( map ( int , input ( ) . split ( ) ) ) y3 _ list = list ( map ( int , input ( ) . split ( ) ) ) L = [ y1 _ list , y2 _ list , y3 _ list ] a1 = list ( ) a2 = list ( ) b1 = list ( ) b2 = list ( ) for i in range ( 3 ) : a1 . append ( y1 _ list [ i ] - y2 _ list [ i ] ) a2 . append ( y2 _ list [ i ] - y3 _ list [ i ] ) if ( a1 [ 0 ] = = a1 [ 1 ] and a1 [ 2 ] = = a1 [ 0 ] ) : if ( a2 [ 0 ] = = a2 [ 1 ] and a2 [ 2 ] = = a2 [ 0 ] ) : print ( " Yes " ) else : print ( " No " ) else : print ( " No " ) ary = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( ary [ 0 ] [ 0 ] + 1 ) : a = [ ary [ 0 ] [ 0 ] - i , ary [ 0 ] [ 1 ] - i , ary [ 0 ] [ 2 ] - i ] a2 = ary [ 1 ] [ 0 ] - a [ 0 ] a3 = ary [ 2 ] [ 0 ] - a [ 0 ] b = [ a2 + a [ 0 ] , a2 + a [ 1 ] , a2 + a [ 2 ] ] c = [ a3 + a [ 0 ] , a3 + a [ 1 ] , a3 + a [ 2 ] ] if ary = = [ a , b , c ] : print ( " Yes " ) ; exit ( ) else : print ( " No " ) C = [ ] for i in range ( 3 ) : c = input ( ) . split ( ) C . append ( [ int ( i ) for i in c ] ) ans = " No " if C [ 0 ] [ 2 ] + C [ 2 ] [ 0 ] - C [ 0 ] [ 0 ] - C [ 2 ] [ 2 ] = = 0 : if C [ 0 ] [ 2 ] + C [ 1 ] [ 1 ] - C [ 0 ] [ 1 ] - C [ 1 ] [ 2 ] = = 0 : if C [ 2 ] [ 0 ] + C [ 1 ] [ 1 ] - C [ 1 ] [ 0 ] - C [ 2 ] [ 1 ] = = 0 : ans = " Yes " print ( ans ) def solve ( ) : import sys s = list ( map ( int , sys . stdin . read ( ) . split ( ) ) ) x , y , z = s [ 0 ] + s [ 4 ] + s [ 8 ] , s [ 1 ] + s [ 5 ] + s [ 6 ] , s [ 2 ] + s [ 3 ] + s [ 7 ] if x = = y = = z : print ( " Yes " ) else : print ( " No " ) solve ( ) import sys def getN ( ) : return int ( input ( ) ) def getNM ( ) : return map ( int , input ( ) . split ( ) ) def getlist ( ) : return list ( map ( int , input ( ) . split ( ) ) ) import math import bisect import heapq from collections import defaultdict , Counter , deque MOD = 10 * * 9 + 7 INF = 10 * * 15 def main ( ) : a , b , c = getlist ( ) s12 = b - a s13 = c - a s23 = c - b for i in range ( 2 ) : d , e , f = getlist ( ) if e - d ! = s12 : print ( " No " ) return if f - d ! = s13 : print ( " No " ) return if f - e ! = s23 : print ( " No " ) return print ( " Yes " ) return if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) import sys lis = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] d1 = lis [ 0 ] [ 0 ] - lis [ 0 ] [ 1 ] d2 = lis [ 0 ] [ 1 ] - lis [ 0 ] [ 2 ] flag = ' No ' for l in lis : if l [ 0 ] - l [ 1 ] ! = d1 or l [ 1 ] - l [ 2 ] ! = d2 : print ( ' No ' ) sys . exit ( ) else : flag = ' Yes ' print ( flag ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] x = [ 0 for i in range ( len ( c ) ) ] for i , line in enumerate ( c ) : for j in range ( len ( c ) ) : x [ j ] + = line [ ( i + j ) % len ( c ) ] print ( ' Yes ' if all ( x [ i ] = = x [ 0 ] for i in range ( len ( c ) ) ) else ' No ' ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) a1 = 0 a2 = c2 [ 0 ] - c1 [ 0 ] a3 = c3 [ 0 ] - c1 [ 0 ] b1 = c1 [ 0 ] b2 = c1 [ 1 ] b3 = c1 [ 2 ] if c1 [ 0 ] = = a1 + b1 and c1 [ 1 ] = = a1 + b2 and c1 [ 2 ] = = a1 + b3 and c2 [ 0 ] = = a2 + b1 and c2 [ 1 ] = = a2 + b2 and c2 [ 2 ] = = a2 + b3 and c3 [ 0 ] = = a3 + b1 and c3 [ 1 ] = = a3 + b2 and c3 [ 2 ] = = a3 + b3 : print ( ' Yes ' ) else : print ( ' No ' ) c = [ ] for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) ans = " Yes " for i in range ( 3 ) : for j in range ( i + 1 , 3 ) : tmp = [ ] for h in range ( 3 ) : tmp . append ( c [ h ] [ i ] - c [ h ] [ j ] ) if len ( set ( tmp ) ) ! = 1 : ans = " No " break print ( ans ) import numpy as np c = np . array ( [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] ) flag = True for a1 in range ( c . max ( ) + 1 ) : b1 , b2 , b3 = c [ 0 , : ] - a1 if ( c [ 1 , 0 ] - b1 ! = c [ 1 , 1 ] - b2 ) or ( c [ 1 , 2 ] - b3 ! = c [ 1 , 0 ] - b1 ) : flag = False break if ( c [ 2 , 0 ] - b1 ! = c [ 2 , 1 ] - b2 ) or ( c [ 2 , 2 ] - b3 ! = c [ 2 , 0 ] - b1 ) : flag = False break print ( " Yes " if flag else " No " ) l = lambda : list ( map ( int , input ( ) . split ( ) ) ) a , b , c = l ( ) d , e , f = l ( ) g , h , i = l ( ) print ( [ ' No ' , ' Yes ' ] [ d - a = = e - b = = f - c and g - d = = h - e = = i - f ] ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) for i in range ( 2 ) : c1 , c2 , c3 = map ( int , input ( ) . split ( ) ) if ( c1 - c11 ) = = ( c2 - c12 ) and ( c2 - c12 ) = = ( c3 - c13 ) : c11 , c12 , c13 = c1 , c2 , c3 else : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) for b1 in range ( 101 ) : for b2 in range ( 101 ) : for b3 in range ( 101 ) : if c1 [ 0 ] - b1 = = c1 [ 1 ] - b2 = = c1 [ 2 ] - b3 : if c2 [ 0 ] - b1 = = c2 [ 1 ] - b2 = = c2 [ 2 ] - b3 : if c3 [ 0 ] - b1 = = c3 [ 1 ] - b2 = = c3 [ 2 ] - b3 : print ( " Yes " ) exit ( ) else : print ( " No " ) import sys import numpy as np c = np . array ( sys . stdin . read ( ) . split ( ) , dtype = np . int8 ) . reshape ( 3 , 3 ) def main ( c ) : c - = c [ 0 ] c - = c [ : , 0 ] [ : , None ] return ' No ' if np . count _ nonzero ( c ) else ' Yes ' if _ _ name _ _ = = ' _ _ main _ _ ' : ans = main ( c ) print ( ans ) C = [ [ int ( x ) for x in input ( ) . split ( ) ] , [ int ( x ) for x in input ( ) . split ( ) ] , [ int ( x ) for x in input ( ) . split ( ) ] ] a1max = min ( C [ 0 ] ) for a1 in range ( a1max + 1 ) : b1 , b2 , b3 = C [ 0 ] [ 0 ] - a1 , C [ 0 ] [ 1 ] - a1 , C [ 0 ] [ 2 ] - a1 a2 = C [ 1 ] [ 0 ] - b1 a3 = C [ 2 ] [ 0 ] - b1 if C [ 1 ] [ 1 ] = = a2 + b2 and C [ 1 ] [ 2 ] = = a2 + b3 and C [ 2 ] [ 1 ] = = a3 + b2 and \ C [ 2 ] [ 2 ] = = a3 + b3 : print ( ' Yes ' ) break else : print ( ' No ' ) import sys c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] line _ max = [ ] for i in range ( len ( c ) ) : line _ max . append ( max ( c [ i ] ) ) flag = False for i in range ( line _ max [ 0 ] + 1 ) : for j in range ( line _ max [ 1 ] + 1 ) : for k in range ( line _ max [ 2 ] + 1 ) : cnt = 0 for l in range ( 3 ) : x = c [ 0 ] [ l ] - i y = c [ 1 ] [ l ] - j z = c [ 2 ] [ l ] - k if x > = 0 and y > = 0 and z > = 0 : if x = = y and y = = z and z = = x : cnt + = 1 if cnt = = 3 : flag = True print ( " Yes " ) if flag else print ( " No " ) from itertools import chain , groupby def flatten ( list _ of _ lists ) : return chain . from _ iterable ( list _ of _ lists ) def all _ equal ( iterable ) : g = groupby ( iterable ) return next ( g , True ) and not next ( g , False ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] s = sum ( flatten ( C ) ) x = all _ equal ( [ C [ 1 ] [ i ] - C [ 0 ] [ i ] for i in range ( 3 ) ] ) y = all _ equal ( [ C [ 2 ] [ i ] - C [ 0 ] [ i ] for i in range ( 3 ) ] ) z = all _ equal ( [ C [ 2 ] [ i ] - C [ 1 ] [ i ] for i in range ( 3 ) ] ) if all ( ( x , y , z ) ) and s % 3 = = 0 : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] x = c [ 0 ] [ 0 ] for i in range ( x + 1 ) : a1 = i b1 = x - i a2 = c [ 1 ] [ 0 ] - b1 a3 = c [ 2 ] [ 0 ] - b1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 if a2 + b2 = = c [ 1 ] [ 1 ] and a2 + b3 = = c [ 1 ] [ 2 ] and a3 + b2 = = c [ 2 ] [ 1 ] and a3 + b3 = = c [ 2 ] [ 2 ] : print ( " Yes " ) exit ( ) print ( " No " ) import sys c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] x = [ ] for i in range ( 3 ) : x . append ( [ c [ i ] [ 1 ] - c [ i ] [ 0 ] , c [ i ] [ 2 ] - c [ i ] [ 0 ] , c [ i ] [ 2 ] - c [ i ] [ 1 ] ] ) if x [ 0 ] ! = x [ 1 ] or x [ 1 ] ! = x [ 2 ] : print ( " No " ) sys . exit ( ) y = [ ] for j in range ( 3 ) : y . append ( [ c [ 1 ] [ i ] - c [ 0 ] [ i ] , c [ 2 ] [ i ] - c [ 0 ] [ i ] , c [ 2 ] [ i ] - c [ 1 ] [ i ] ] ) if y [ 0 ] ! = y [ 1 ] or y [ 1 ] ! = y [ 2 ] : print ( " No " ) sys . exit ( ) print ( " Yes " ) t = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a = t [ 1 ] [ 0 ] - t [ 0 ] [ 0 ] b = t [ 2 ] [ 0 ] - t [ 1 ] [ 0 ] c = t [ 0 ] [ 1 ] - t [ 0 ] [ 0 ] d = t [ 0 ] [ 2 ] - t [ 0 ] [ 1 ] flag = 0 if t [ 1 ] [ 1 ] - t [ 0 ] [ 1 ] ! = a or t [ 1 ] [ 2 ] - t [ 0 ] [ 2 ] ! = a : flag = 1 elif t [ 2 ] [ 1 ] - t [ 1 ] [ 1 ] ! = b or t [ 2 ] [ 2 ] - t [ 1 ] [ 2 ] ! = b : flag = 1 elif t [ 1 ] [ 1 ] - t [ 1 ] [ 0 ] ! = c or t [ 2 ] [ 1 ] - t [ 2 ] [ 0 ] ! = c : flag = 1 elif t [ 1 ] [ 2 ] - t [ 1 ] [ 1 ] ! = d or t [ 2 ] [ 2 ] - t [ 2 ] [ 1 ] ! = d : flag = 1 if flag = = 0 : print ( " Yes " ) else : print ( " No " ) def main ( ) : c = [ [ 0 ] * 3 ] * 3 for i in range ( 3 ) : c [ i ] = list ( map ( int , input ( ) . split ( ) ) ) if ( c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] ) = = ( c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] ) = = ( c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] ) : if ( c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] ) = = ( c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] ) = = ( c [ 1 ] [ 2 ] - c [ 2 ] [ 2 ] ) : if ( c [ 0 ] [ 0 ] - c [ 2 ] [ 0 ] ) = = ( c [ 0 ] [ 1 ] - c [ 2 ] [ 1 ] ) = = ( c [ 0 ] [ 2 ] - c [ 2 ] [ 2 ] ) : print ( ' Yes ' ) exit ( ) print ( ' No ' ) main ( ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] sa _ a = [ c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] , c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] ] sa _ b = [ c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] , c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] ] for i in range ( 2 ) : if sa _ a [ i ] ! = c [ i ] [ i + 1 ] - c [ i + 1 ] [ i + 1 ] : print ( " No " ) quit ( ) for i in range ( 2 ) : if sa _ b [ i ] ! = c [ i + 1 ] [ i ] - c [ i + 1 ] [ i + 1 ] : print ( " No " ) break else : print ( " Yes " ) C = [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( 3 ) ] flag = False for a0 in range ( 0 , min ( C [ 0 ] ) + 1 ) : b = [ 0 ] * 3 for j in range ( 3 ) : b [ j ] = C [ 0 ] [ j ] - a0 for i in range ( 1 , 3 ) : tmp1 = C [ i ] [ 0 ] - b [ 0 ] for j in range ( 1 , 3 ) : tmp2 = C [ i ] [ j ] - b [ j ] if tmp1 ! = tmp2 : flag = True else : tmp1 = tmp2 if flag : print ( " No " ) else : print ( " Yes " ) l1 = list ( map ( int , input ( ) . split ( ) ) ) l2 = list ( map ( int , input ( ) . split ( ) ) ) l3 = list ( map ( int , input ( ) . split ( ) ) ) for a1 in range ( 101 ) : b1 = [ l1 [ 0 ] - a1 , l1 [ 1 ] - a1 , l1 [ 2 ] - a1 ] for a2 in range ( 101 ) : b2 = [ l2 [ 0 ] - a2 , l2 [ 1 ] - a2 , l2 [ 2 ] - a2 ] for a3 in range ( 101 ) : b3 = [ l3 [ 0 ] - a3 , l3 [ 1 ] - a3 , l3 [ 2 ] - a3 ] if b1 = = b2 = = b3 : print ( " Yes " ) exit ( ) else : print ( " No " ) C1 = list ( map ( int , input ( ) . split ( ) ) ) C2 = list ( map ( int , input ( ) . split ( ) ) ) C3 = list ( map ( int , input ( ) . split ( ) ) ) a = 0 if C2 [ 0 ] - C1 [ 0 ] = = C2 [ 1 ] - C1 [ 1 ] = = C2 [ 2 ] - C1 [ 2 ] : a2 = C2 [ 0 ] - C1 [ 0 ] a + = 1 if C3 [ 0 ] - C2 [ 0 ] = = C3 [ 1 ] - C2 [ 1 ] = = C3 [ 2 ] - C2 [ 2 ] : a3 = C3 [ 0 ] - C2 [ 0 ] a + = 1 if a = = 2 : print ( " Yes " ) else : print ( " No " ) lst = [ ] for i in range ( 3 ) : a = map ( int , input ( ) . split ( ) ) for j in a : lst . append ( j ) for i in range ( lst [ 0 ] + 1 ) : a , d = i , lst [ 0 ] - i b = lst [ 3 ] - lst [ 0 ] + a c = lst [ 6 ] - lst [ 0 ] + a e = lst [ 1 ] - lst [ 0 ] + d f = lst [ 2 ] - lst [ 0 ] + d if lst [ 4 ] = = b + e and lst [ 5 ] = = b + f and lst [ 7 ] = = c + e and lst [ 8 ] = = c + f : print ( " Yes " ) exit ( ) print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] if c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 0 ] [ 1 ] \ and c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 2 ] - c [ 0 ] [ 2 ] \ and c [ 1 ] [ 1 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 0 ] [ 2 ] \ and c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 0 ] [ 1 ] \ and c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 2 ] [ 2 ] - c [ 0 ] [ 2 ] \ and c [ 2 ] [ 1 ] - c [ 0 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 0 ] [ 2 ] : print ( ' Yes ' ) else : print ( ' No ' ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] x = [ 0 , 0 , 0 ] y = [ 0 , 0 , 0 ] for i in range ( 3 ) : y [ i ] = C [ 0 ] [ i ] for i in range ( 3 ) : x [ i ] = C [ i ] [ 0 ] - y [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if C [ i ] [ j ] ! = x [ i ] + y [ j ] : print ( ' No ' ) exit ( ) print ( ' Yes ' ) s = [ ] for i in range ( 3 ) : array = list ( map ( int , input ( ) . split ( ) ) ) s . append ( array ) sum _ num = 0 for i in range ( 3 ) : for j in range ( 3 ) : sum _ num + = s [ i ] [ j ] magic _ num = s [ 0 ] [ 0 ] + s [ 1 ] [ 1 ] + s [ 2 ] [ 2 ] if sum _ num % 3 = = 0 and magic _ num * 3 = = sum _ num : print ( ' Yes ' ) else : print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] ans = ' Yes ' if not c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 2 ] [ 0 ] : ans = ' No ' if not c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 2 ] [ 1 ] : ans = ' No ' print ( ans ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) if c21 - c11 + c12 - c22 = = 0 and c31 - c11 + c12 - c32 = = 0 and c21 - 2 * c11 + c12 + c13 - c23 = = c31 - 2 * c11 + c12 + c13 - c33 : print ( ' Yes ' ) else : print ( ' No ' ) import sys def input ( ) : return sys . stdin . readline ( ) . strip ( ) def input _ int ( ) : return int ( input ( ) ) def input _ int _ list ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] def main ( ) : c = [ ] for _ in range ( 3 ) : c . append ( input _ int _ list ( ) ) if ( c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] ) = = ( c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] ) and ( c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] ) = = ( c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] ) and ( c [ 0 ] [ 0 ] - c [ 2 ] [ 0 ] ) = = ( c [ 0 ] [ 1 ] - c [ 2 ] [ 1 ] ) and ( c [ 0 ] [ 1 ] - c [ 2 ] [ 1 ] ) = = ( c [ 0 ] [ 2 ] - c [ 2 ] [ 2 ] ) and ( c [ 2 ] [ 0 ] - c [ 1 ] [ 0 ] ) = = ( c [ 2 ] [ 1 ] - c [ 1 ] [ 1 ] ) and ( c [ 2 ] [ 1 ] - c [ 1 ] [ 1 ] ) = = ( c [ 2 ] [ 2 ] - c [ 1 ] [ 2 ] ) : print ( " Yes " ) else : print ( " No " ) return if _ _ name _ _ = = " _ _ main _ _ " : main ( ) a11 , a12 , a13 = map ( int , input ( ) . split ( ) ) a21 , a22 , a23 = map ( int , input ( ) . split ( ) ) a31 , a32 , a33 = map ( int , input ( ) . split ( ) ) if a22 ! = a21 + a12 - a11 : print ( ' No ' ) elif a23 ! = a21 + a13 - a11 : print ( ' No ' ) elif a32 ! = a31 + a12 - a11 : print ( ' No ' ) elif a33 ! = a31 + a13 - a11 : print ( ' No ' ) else : print ( ' Yes ' ) c = [ ] for _ in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) a = [ 0 ] b = [ ] for i in range ( 3 ) : b . append ( c [ 0 ] [ i ] - a [ 0 ] ) for i in range ( 1 , 3 ) : a . append ( c [ i ] [ 0 ] - b [ 0 ] ) for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = a [ i ] + b [ j ] : print ( " No " ) exit ( ) print ( " Yes " ) l = [ ] for i in range ( 3 ) : l . append ( list ( map ( int , input ( ) . split ( ) ) ) ) if l [ 0 ] [ 1 ] - l [ 0 ] [ 0 ] = = l [ 1 ] [ 1 ] - l [ 1 ] [ 0 ] = = l [ 2 ] [ 1 ] - l [ 2 ] [ 0 ] : if l [ 0 ] [ 2 ] - l [ 0 ] [ 0 ] = = l [ 1 ] [ 2 ] - l [ 1 ] [ 0 ] = = l [ 2 ] [ 2 ] - l [ 2 ] [ 0 ] : print ( " Yes " ) exit ( ) print ( " No " ) lst _ c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] lst _ diff _ i = [ ] for i in range ( 3 ) : diff1 = lst _ c [ i ] [ 0 ] - lst _ c [ i ] [ 1 ] diff2 = lst _ c [ i ] [ 1 ] - lst _ c [ i ] [ 2 ] diff3 = lst _ c [ i ] [ 2 ] - lst _ c [ i ] [ 0 ] lst _ diff _ i . append ( [ diff1 , diff2 , diff3 ] ) if lst _ diff _ i [ 0 ] = = lst _ diff _ i [ 1 ] = = lst _ diff _ i [ 2 ] : ans = " Yes " else : print ( " No " ) exit ( ) for i in range ( 3 ) : diff1 = lst _ c [ 0 ] [ i ] - lst _ c [ 1 ] [ i ] diff2 = lst _ c [ 1 ] [ i ] - lst _ c [ 2 ] [ i ] diff3 = lst _ c [ 2 ] [ i ] - lst _ c [ 0 ] [ i ] lst _ diff _ i . append ( [ diff1 , diff2 , diff3 ] ) if lst _ diff _ i [ 0 ] = = lst _ diff _ i [ 1 ] = = lst _ diff _ i [ 2 ] : ans = " Yes " else : print ( " No " ) exit ( ) print ( ans ) c = [ ] for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) jud = True h1 = c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] h2 = c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] w1 = c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] w2 = c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] for i in range ( 3 ) : if c [ 0 ] [ i ] - c [ 1 ] [ i ] ! = h1 : jud = False if c [ 1 ] [ i ] - c [ 2 ] [ i ] ! = h2 : jud = False for i in range ( 3 ) : if c [ i ] [ 0 ] - c [ i ] [ 1 ] ! = w1 : jud = False if c [ i ] [ 1 ] - c [ i ] [ 2 ] ! = w2 : jud = False if jud : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for a1 in range ( 101 ) : b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 a2 = c [ 1 ] [ 0 ] - b1 a3 = c [ 2 ] [ 0 ] - b1 if a2 + b1 = = c [ 1 ] [ 0 ] and a2 + b2 = = c [ 1 ] [ 1 ] and a2 + b3 = = c [ 1 ] [ 2 ] and a3 + b1 = = c [ 2 ] [ 0 ] and a3 + b2 = = c [ 2 ] [ 1 ] and a3 + b3 = = c [ 2 ] [ 2 ] : print ( " Yes " ) break else : print ( " No " ) import sys c = [ [ int ( i ) for i in input ( ) . split ( ) ] for j in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 max _ val = 100 a [ 0 ] = 0 b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : left = a [ i ] + b [ j ] right = c [ i ] [ j ] if ( left ! = right ) : ans = False print ( " No " ) sys . exit ( ) print ( " Yes " ) c = [ [ ] for _ in range ( 3 ) ] for i in range ( 3 ) : c [ i ] = list ( map ( int , input ( ) . split ( ) ) ) flag = 0 a = [ 0 ] * 6 b = [ 0 ] * 6 for i in range ( 3 ) : for j in range ( 2 ) : a [ i * 2 + j ] = c [ i ] [ j + 1 ] - c [ i ] [ j ] b [ i * 2 + j ] = c [ j + 1 ] [ i ] - c [ j ] [ i ] if a [ 0 ] = = a [ 2 ] = = a [ 4 ] : flag + = 1 if a [ 1 ] = = a [ 3 ] = = a [ 5 ] : flag + = 1 if b [ 0 ] = = b [ 2 ] = = b [ 4 ] : flag + = 1 if b [ 1 ] = = b [ 3 ] = = b [ 5 ] : flag + = 1 if flag = = 4 : print ( " Yes " ) else : print ( " No " ) import sys read = sys . stdin . read readline = sys . stdin . readline readlines = sys . stdin . readlines sys . setrecursionlimit ( 10 * * 9 ) INF = 1 < < 60 MOD = 1000000007 def main ( ) : C = [ list ( map ( int , readline ( ) . split ( ) ) ) for _ in range ( 3 ) ] A = [ 0 ] * 3 B = [ 0 ] * 3 for i in range ( 3 ) : B [ i ] = C [ 0 ] [ i ] for i in range ( 1 , 3 ) : A [ i ] = C [ i ] [ 0 ] - B [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if C [ i ] [ j ] ! = A [ i ] + B [ j ] : print ( ' No ' ) return print ( ' Yes ' ) return if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] if c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 2 ] [ 0 ] and c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 2 ] [ 1 ] and c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] = = c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] and c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 2 ] [ 2 ] : print ( " Yes " ) else : print ( " No " ) import numpy as np c = np . array ( [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] ) x = [ 0 ] * 3 y = [ 0 ] * 3 for i in range ( 3 ) : y [ i ] = c [ 0 ] [ i ] - x [ 0 ] for i in range ( 3 ) : x [ i ] = c [ i ] [ 0 ] - y [ 0 ] flag = True for i in range ( 3 ) : for j in range ( 3 ) : if x [ i ] + y [ j ] ! = c [ i ] [ j ] : flag = False print ( " Yes " if flag else " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] d = [ ] for j in range ( 2 ) : d . append ( c [ 0 ] [ j ] - c [ 0 ] [ j + 1 ] ) for i in range ( 1 , 3 ) : for j in range ( 2 ) : if c [ i ] [ j ] - c [ i ] [ j + 1 ] ! = d [ j ] : print ( ' No ' ) exit ( ) print ( ' Yes ' ) cmatrix = [ ] for i in range ( 3 ) : cmatrix . append ( list ( map ( int , input ( ) . split ( ) ) ) ) if ( cmatrix [ 0 ] [ 0 ] + cmatrix [ 1 ] [ 1 ] = = cmatrix [ 0 ] [ 1 ] + cmatrix [ 1 ] [ 0 ] and \ cmatrix [ 0 ] [ 1 ] + cmatrix [ 1 ] [ 2 ] = = cmatrix [ 0 ] [ 2 ] + cmatrix [ 1 ] [ 1 ] and \ cmatrix [ 1 ] [ 0 ] + cmatrix [ 2 ] [ 1 ] = = cmatrix [ 1 ] [ 1 ] + cmatrix [ 2 ] [ 0 ] and \ cmatrix [ 1 ] [ 1 ] + cmatrix [ 2 ] [ 2 ] = = cmatrix [ 1 ] [ 2 ] + cmatrix [ 2 ] [ 1 ] ) : print ( " Yes " ) else : print ( " No " ) import numpy as np Num = np . zeros ( ( 3 , 3 ) , dtype = int ) Flag = False for T in range ( 0 , 3 ) : Num [ T , : ] = np . array ( [ int ( X ) for X in input ( ) . split ( ) ] ) for T in range ( 0 , 3 ) : Num [ : , T ] - = Num [ 0 , T ] for A2 in range ( min ( Num [ 1 , : ] ) , max ( Num [ 1 , : ] ) + 1 ) : AB2 = np . array ( [ A2 + Num [ 0 , 0 ] , A2 + Num [ 0 , 1 ] , A2 + Num [ 0 , 2 ] ] ) if np . all ( AB2 = = Num [ 1 , : ] ) : for A3 in range ( min ( Num [ 2 , : ] ) , max ( Num [ 2 , : ] ) + 1 ) : AB3 = np . array ( [ A3 + Num [ 0 , 0 ] , A3 + Num [ 0 , 1 ] , A3 + Num [ 0 , 2 ] ] ) if np . all ( AB3 = = Num [ 2 , : ] ) : Flag = True break if Flag : break if Flag : print ( ' Yes ' ) else : print ( ' No ' ) a , b , c = map ( int , input ( ) . split ( ) ) d , e , f = map ( int , input ( ) . split ( ) ) g , h , i = map ( int , input ( ) . split ( ) ) if a - b = = d - e = = g - h and b - c = = e - f = = h - i : print ( ' Yes ' ) else : print ( ' No ' ) def che ( da ) : for i in range ( 2 ) : for j in range ( 2 ) : if da [ i ] [ j ] - da [ i ] [ j + 1 ] ! = da [ 2 ] [ j ] - da [ 2 ] [ j + 1 ] : return False if da [ i ] [ j ] - da [ i + 1 ] [ j ] ! = da [ i ] [ 2 ] - da [ i + 1 ] [ 2 ] : return False return True da = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] if che ( da ) : print ( ' Yes ' ) else : print ( ' No ' ) L = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] ans = ' Yes ' if L [ 0 ] [ 0 ] + L [ 1 ] [ 1 ] ! = L [ 0 ] [ 1 ] + L [ 1 ] [ 0 ] : ans = ' No ' if L [ 0 ] [ 1 ] + L [ 1 ] [ 2 ] ! = L [ 0 ] [ 2 ] + L [ 1 ] [ 1 ] : ans = ' No ' if L [ 1 ] [ 0 ] + L [ 2 ] [ 1 ] ! = L [ 1 ] [ 1 ] + L [ 2 ] [ 0 ] : ans = ' No ' if L [ 1 ] [ 1 ] + L [ 2 ] [ 2 ] ! = L [ 1 ] [ 2 ] + L [ 2 ] [ 1 ] : ans = ' No ' print ( ans ) def main ( ) : c = [ [ int ( x ) for x in input ( ) . split ( ) ] for _ in range ( 3 ) ] all _ sum = 0 answer = True for i in range ( 3 ) : all _ sum + = sum ( c [ i ] ) if all _ sum % 3 = = 0 : all _ sum / / = 3 else : answer = False now _ sum = 0 for i in range ( 3 ) : now _ sum + = c [ i ] [ i ] if now _ sum ! = all _ sum : answer = False now _ sum = 0 for i in range ( 3 ) : now _ sum + = c [ i ] [ 2 - i ] if now _ sum ! = all _ sum : answer = False print ( " Yes " if answer else " No " ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) import sys input = sys . stdin . readline sys . setrecursionlimit ( 10 * * 7 ) from collections import Counter , deque from collections import defaultdict from itertools import combinations , permutations , accumulate , groupby , product from bisect import bisect _ left , bisect _ right from heapq import heapify , heappop , heappush from math import floor , ceil , pi from operator import itemgetter def I ( ) : return int ( input ( ) ) def MI ( ) : return map ( int , input ( ) . split ( ) ) def LI ( ) : return list ( map ( int , input ( ) . split ( ) ) ) def LI2 ( ) : return [ int ( input ( ) ) for i in range ( n ) ] def MXI ( ) : return [ [ LI ( ) ] for i in range ( n ) ] def SI ( ) : return input ( ) . rstrip ( ) def printns ( x ) : print ( ' \ n ' . join ( x ) ) def printni ( x ) : print ( ' \ n ' . join ( list ( map ( str , x ) ) ) ) inf = 10 * * 17 mod = 10 * * 9 + 7 l1 = LI ( ) l2 = LI ( ) l3 = LI ( ) c1 = l1 [ 0 ] c2 = l1 [ 1 ] c3 = l1 [ 2 ] c4 = l2 [ 0 ] c5 = l2 [ 1 ] c6 = l2 [ 2 ] c7 = l3 [ 0 ] c8 = l3 [ 1 ] c9 = l3 [ 2 ] a1 = 0 b1 = c1 a2 = c4 - c1 a3 = c7 - c1 b2 = c2 b3 = c3 count = 0 if c5 = = a2 + b2 : count + = 1 if c6 = = a2 + b3 : count + = 1 if c8 = = a3 + b2 : count + = 1 if c9 = = a3 + b3 : count + = 1 if count = = 4 : print ( " Yes " ) else : print ( " No " ) import sys , os f = lambda : list ( map ( int , input ( ) . split ( ) ) ) if ' local ' in os . environ : sys . stdin = open ( ' . / input.txt ' , ' r ' ) def solve ( ) : g = [ f ( ) for i in range ( 3 ) ] for i in range ( 2 ) : if g [ i ] [ 0 ] - g [ i + 1 ] [ 0 ] ! = g [ i ] [ 1 ] - g [ i + 1 ] [ 1 ] or g [ i ] [ 1 ] - g [ i + 1 ] [ 1 ] ! = g [ i ] [ 2 ] - g [ i + 1 ] [ 2 ] : print ( ' No ' ) return for i in range ( 2 ) : if g [ 0 ] [ i ] - g [ 0 ] [ i + 1 ] ! = g [ 1 ] [ i ] - g [ 1 ] [ i + 1 ] or g [ 2 ] [ i ] - g [ 2 ] [ i + 1 ] ! = g [ 1 ] [ i ] - g [ 1 ] [ i + 1 ] : print ( ' No ' ) return print ( ' Yes ' ) solve ( ) lc = [ [ int ( w ) for w in input ( ) . split ( ) ] for i in range ( 3 ) ] cond = True lb = lc [ 0 ] a2 = lc [ 1 ] [ 0 ] - lb [ 0 ] a3 = lc [ 2 ] [ 0 ] - lb [ 0 ] la = [ 0 , a2 , a3 ] for i in range ( 3 ) : for j in range ( 3 ) : if lc [ i ] [ j ] ! = la [ i ] + lb [ j ] : cond = False break print ( " Yes " if cond else " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] x = [ 0 , 0 , 0 ] y = [ 0 , 0 , 0 ] for i in range ( 3 ) : y [ i ] = C [ 0 ] [ i ] - x [ 0 ] for i in range ( 3 ) : x [ i ] = C [ i ] [ 0 ] - y [ 0 ] flag = True for i in range ( 3 ) : for j in range ( 3 ) : if x [ i ] + y [ j ] ! = C [ i ] [ j ] : flag = False print ( ' Yes ' if flag else ' No ' ) c = [ ] for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) a21 = [ c [ 1 ] [ i ] - c [ 0 ] [ i ] for i in range ( 3 ) ] a32 = [ c [ 2 ] [ i ] - c [ 1 ] [ i ] for i in range ( 3 ) ] b21 = [ c [ i ] [ 1 ] - c [ i ] [ 0 ] for i in range ( 3 ) ] b32 = [ c [ i ] [ 2 ] - c [ i ] [ 1 ] for i in range ( 3 ) ] if max ( a21 ) ! = min ( a21 ) or max ( a32 ) ! = min ( a32 ) or max ( b21 ) ! = min ( b21 ) or max ( b32 ) ! = min ( b32 ) : print ( " No " ) else : flag = False for a1 in range ( 101 ) : for b1 in range ( 101 ) : a = [ a1 , a1 + a21 [ 0 ] , a1 + a21 [ 0 ] + a32 [ 0 ] ] b = [ b1 , b1 + b21 [ 0 ] , b1 + b21 [ 0 ] + b32 [ 0 ] ] flagij = True for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = a [ i ] + b [ j ] : flagij = False flag | = flagij if flag : print ( " Yes " ) else : print ( " No " ) from itertools import permutations C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] A = [ 0 , 1 , 2 ] ans = [ ] for x in permutations ( A , 3 ) : temp = 0 for j in range ( 3 ) : temp + = C [ j ] [ x [ j ] ] ans . append ( temp ) if len ( set ( ans ) ) = = 1 : print ( " Yes " ) else : print ( " No " ) import sys sys . setrecursionlimit ( 5000 ) def dfs ( x ) : global ng , parity for v in adj [ x ] : if parity [ v ] = = parity [ x ] : ng = True return elif parity [ v ] < 0 : parity [ v ] = 1 ^ parity [ x ] dfs ( v ) return while True : n , m = map ( int , input ( ) . split ( ) ) if n = = 0 and m = = 0 : break adj = [ [ ] for _ in range ( n ) ] parity = [ - 1 for _ in range ( n ) ] for _ in range ( m ) : a , b = map ( int , input ( ) . split ( ) ) adj [ a - 1 ] . append ( b - 1 ) adj [ b - 1 ] . append ( a - 1 ) ng = False parity [ 0 ] = 0 dfs ( 0 ) if ng : print ( 0 ) continue ans = [ ] zero = parity . count ( 0 ) if zero % 2 = = 0 : ans . append ( zero / / 2 ) if ( n - zero ) % 2 = = 0 and zero * 2 ! = n : ans . append ( ( n - zero ) / / 2 ) ans . sort ( ) print ( len ( ans ) ) if ans : print ( * ans , sep = " \ n " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in [ 1 , 2 ] : d1 = c [ 0 ] [ 0 ] - c [ i ] [ 0 ] d2 = c [ 0 ] [ 1 ] - c [ i ] [ 1 ] d3 = c [ 0 ] [ 2 ] - c [ i ] [ 2 ] d4 = c [ 0 ] [ 0 ] - c [ 0 ] [ i ] d5 = c [ 1 ] [ 0 ] - c [ 1 ] [ i ] d6 = c [ 2 ] [ 0 ] - c [ 2 ] [ i ] if d1 ! = d2 or d1 ! = d3 or d4 ! = d5 or d4 ! = d6 : print ( " No " ) exit ( ) print ( " Yes " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] def a ( c ) : for j in range ( 2 ) : if not ( ( c [ 0 ] [ j ] - c [ 0 ] [ j + 1 ] ) = = ( c [ 1 ] [ j ] - c [ 1 ] [ j + 1 ] ) and ( c [ 1 ] [ j ] - c [ 1 ] [ j + 1 ] ) = = ( c [ 2 ] [ j ] - c [ 2 ] [ j + 1 ] ) ) : return print ( ' No ' ) if not ( ( c [ j ] [ 0 ] - c [ j + 1 ] [ 0 ] ) = = ( c [ j ] [ 1 ] - c [ j + 1 ] [ 1 ] ) and ( c [ j ] [ 1 ] - c [ j + 1 ] [ 1 ] ) = = ( c [ j ] [ 2 ] - c [ j + 1 ] [ 2 ] ) ) : return print ( ' No ' ) return print ( ' Yes ' ) a ( c ) c = [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( 3 ) ] cond = True cond & = c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] cond & = c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] = = c [ 2 ] [ 1 ] - c [ 2 ] [ 2 ] cond & = c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] = = c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] cond & = c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 2 ] [ 2 ] print ( " Yes " if cond else " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] ans = ' Yes ' for i in range ( 1 , 3 ) : for j in range ( 1 , 3 ) : if C [ i ] [ j ] + C [ 0 ] [ 0 ] ! = C [ i ] [ 0 ] + C [ 0 ] [ j ] : ans = ' No ' print ( ans ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] if c [ 0 ] [ 0 ] + c [ 1 ] [ 0 ] - 2 * c [ 2 ] [ 0 ] + c [ 0 ] [ 1 ] + c [ 1 ] [ 1 ] - 2 * c [ 2 ] [ 1 ] - 2 * c [ 0 ] [ 2 ] - 2 * c [ 1 ] [ 2 ] + 4 * c [ 2 ] [ 2 ] = = 0 : print ( " Yes " ) else : print ( " No " ) c = [ ] for i in range ( 3 ) : tmp = [ int ( x ) for x in input ( ) . split ( ) ] c . append ( tmp ) b = [ c [ 0 ] [ i ] for i in range ( 3 ) ] a = [ c [ i ] [ 0 ] - b [ 0 ] for i in range ( 3 ) ] for i in range ( 3 ) : for j in range ( 3 ) : if ( c [ i ] [ j ] ! = a [ i ] + b [ j ] ) : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] right = c [ 0 ] [ 1 ] + c [ 1 ] [ 0 ] = = c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] \ and c [ 1 ] [ 2 ] + c [ 2 ] [ 1 ] = = c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] \ and c [ 2 ] [ 0 ] + c [ 0 ] [ 2 ] = = c [ 2 ] [ 2 ] + c [ 0 ] [ 0 ] print ( ' Yes ' if right else ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 2 ) : for j in range ( 1 , 3 ) : if ( c [ i ] [ 0 ] - c [ j ] [ 0 ] ) ! = ( c [ i ] [ 1 ] - c [ j ] [ 1 ] ) or ( c [ i ] [ 2 ] - c [ j ] [ 2 ] ) ! = ( c [ i ] [ 1 ] - c [ j ] [ 1 ] ) or ( c [ i ] [ 2 ] - c [ j ] [ 2 ] ) ! = ( c [ i ] [ 0 ] - c [ j ] [ 0 ] ) : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c = [ ] for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) diff1 = [ c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] , c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] , c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] ] diff2 = [ c [ 0 ] [ 0 ] - c [ 2 ] [ 0 ] , c [ 0 ] [ 1 ] - c [ 2 ] [ 1 ] , c [ 0 ] [ 2 ] - c [ 2 ] [ 2 ] ] if diff1 [ 0 ] = = diff1 [ 1 ] and diff1 [ 2 ] = = diff1 [ 1 ] and diff2 [ 0 ] = = diff2 [ 1 ] and diff2 [ 2 ] = = diff2 [ 1 ] : print ( " Yes " ) else : print ( " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] ans = " Yes " for i in range ( 1 , - 1 , - 1 ) : C0i = C [ 0 ] [ 2 ] - C [ 0 ] [ i ] C1i = C [ 1 ] [ 2 ] - C [ 1 ] [ i ] C2i = C [ 2 ] [ 2 ] - C [ 2 ] [ i ] if C0i ! = C1i or C0i ! = C2i : ans = " No " print ( ans ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) if sum ( c1 ) + sum ( c2 ) + sum ( c3 ) = = 3 * ( c1 [ 0 ] + c2 [ 1 ] + c3 [ 2 ] ) : print ( " Yes " ) else : print ( " No " ) c = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) c . extend ( c2 ) c . extend ( c3 ) for a1 in range ( c [ 0 ] + 1 ) : b1 = c [ 0 ] - a1 b2 = c [ 1 ] - a1 b3 = c [ 2 ] - a1 a2 = c [ 3 ] - b1 a3 = c [ 6 ] - b1 ab = [ a1 , a2 , a3 , b1 , b2 , b3 ] for i in ab : if i < 0 : break if ( c [ 4 ] = = a2 + b2 ) & ( c [ 5 ] = = a2 + b3 ) & ( c [ 7 ] = = a3 + b2 ) & ( c [ 8 ] = = a3 + b3 ) : print ( " Yes " ) break else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 b [ 0 ] = c [ 0 ] [ 0 ] b [ 1 ] = c [ 0 ] [ 1 ] b [ 2 ] = c [ 0 ] [ 2 ] a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = a [ i ] + b [ j ] : print ( " No " ) exit ( ) print ( " Yes " ) a = list ( map ( int , input ( ) . split ( ) ) ) b = [ a [ i ] - a [ i + 1 ] for i in range ( 2 ) ] for i in range ( 2 ) : c = list ( map ( int , input ( ) . split ( ) ) ) d = [ c [ i ] - c [ i + 1 ] for i in range ( 2 ) ] if b ! = d : print ( ' No ' ) break else : print ( ' Yes ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] for i in range ( min ( c [ 0 ] ) + 1 ) : b1 = c [ 0 ] [ 0 ] - i b2 = c [ 0 ] [ 1 ] - i b3 = c [ 0 ] [ 2 ] - i if c [ 1 ] [ 0 ] - b1 = = c [ 1 ] [ 1 ] - b2 = = c [ 1 ] [ 2 ] - b3 : if c [ 2 ] [ 0 ] - b1 = = c [ 2 ] [ 1 ] - b2 = = c [ 2 ] [ 2 ] - b3 : print ( " Yes " ) break else : continue else : continue else : print ( " No " ) lst = [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( 3 ) ] lst1 = [ lst [ 1 ] [ i ] - lst [ 0 ] [ i ] for i in range ( 3 ) ] lst2 = [ lst [ 2 ] [ i ] - lst [ 0 ] [ i ] for i in range ( 3 ) ] if len ( set ( lst1 ) ) = = 1 and len ( set ( lst2 ) ) = = 1 : print ( ' Yes ' ) else : print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] flg = all ( c [ 0 ] [ i + 1 ] - c [ 0 ] [ i ] = = c [ 1 ] [ i + 1 ] - c [ 1 ] [ i ] = = c [ 2 ] [ i + 1 ] - c [ 2 ] [ i ] for i in range ( 2 ) ) print ( [ " No " , " Yes " ] [ flg ] ) data = [ ] for i in range ( 3 ) : data . append ( list ( map ( int , input ( ) . split ( ) ) ) ) if data [ 0 ] [ 0 ] - data [ 1 ] [ 0 ] = = data [ 0 ] [ 1 ] - data [ 1 ] [ 1 ] = = data [ 0 ] [ 2 ] - data [ 1 ] [ 2 ] : if data [ 1 ] [ 0 ] - data [ 2 ] [ 0 ] = = data [ 1 ] [ 1 ] - data [ 2 ] [ 1 ] = = data [ 1 ] [ 2 ] - data [ 2 ] [ 2 ] : if data [ 0 ] [ 0 ] - data [ 0 ] [ 1 ] = = data [ 1 ] [ 0 ] - data [ 1 ] [ 1 ] = = data [ 2 ] [ 0 ] - data [ 2 ] [ 1 ] : if data [ 0 ] [ 1 ] - data [ 0 ] [ 2 ] = = data [ 1 ] [ 1 ] - data [ 1 ] [ 2 ] = = data [ 2 ] [ 1 ] - data [ 2 ] [ 2 ] : print ( " Yes " ) else : print ( " No " ) else : print ( " No " ) else : print ( " No " ) else : print ( " No " ) import sys , math , fractions , itertools YES = " Yes " NO = " No " def solve ( c : " List [ List [ int ] ] " ) : flag = True for i in range ( 2 ) : D = [ ] for j in range ( 3 ) : d = c [ i + 1 ] [ j ] - c [ i ] [ j ] D . append ( d ) if len ( set ( D ) ) ! = 1 : flag = False for i in range ( 2 ) : D = [ ] for j in range ( 3 ) : d = c [ j ] [ i + 1 ] - c [ j ] [ i ] D . append ( d ) if len ( set ( D ) ) ! = 1 : flag = False if flag : print ( ' Yes ' ) else : print ( ' No ' ) return def main ( ) : def iterate _ tokens ( ) : for line in sys . stdin : for word in line . split ( ) : yield word tokens = iterate _ tokens ( ) c = [ [ int ( next ( tokens ) ) for _ in range ( 3 ) ] for _ in range ( 3 ) ] solve ( c ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) mycode = r import sys import os if sys . argv [ - 1 ] = = ' ONLINE _ JUDGE ' : with open ( ' mycode.pyx ' , ' w ' ) as f : f . write ( mycode ) os . system ( ' cythonize -i -3 -b mycode.pyx ' ) import mycode def main ( ) : import numpy as np c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] f = [ [ x [ 0 ] - x [ 1 ] , x [ 1 ] - x [ 2 ] , x [ 2 ] - x [ 0 ] ] for x in c ] g = f [ 0 ] = = f [ 1 ] = = f [ 2 ] print ( ' Yes ' if g else ' No ' ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) grid = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] for a1 in range ( - 10000 , 10001 ) : b1 = grid [ 0 ] [ 0 ] - a1 a2 = grid [ 1 ] [ 0 ] - b1 a3 = grid [ 2 ] [ 0 ] - b1 b2 = grid [ 0 ] [ 1 ] - a1 b3 = grid [ 0 ] [ 2 ] - a1 if a2 + b2 = = grid [ 1 ] [ 1 ] and a2 + b3 = = grid [ 1 ] [ 2 ] and a3 + b2 = = grid [ 2 ] [ 1 ] and a3 + b3 = = grid [ 2 ] [ 2 ] : print ( ' Yes ' ) break else : print ( ' No ' ) import sys def input ( ) : return sys . stdin . readline ( ) . strip ( ) def main ( ) : C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] rumor = True for i in range ( 1 , 3 ) : diff1 = C [ i ] [ 0 ] - C [ 0 ] [ 0 ] diff2 = C [ i ] [ 1 ] - C [ 0 ] [ 1 ] diff3 = C [ i ] [ 2 ] - C [ 0 ] [ 2 ] if diff1 ! = diff2 or diff2 ! = diff3 or diff1 ! = diff3 : rumor = False break if rumor : print ( " Yes " ) else : print ( " No " ) if _ _ name _ _ = = " _ _ main _ _ " : main ( ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] flg = all ( c [ 0 ] [ i + 1 ] - c [ 0 ] [ i ] = = c [ 1 ] [ i + 1 ] - c [ 1 ] [ i ] = = c [ 2 ] [ i + 1 ] - c [ 2 ] [ i ] and c [ i + 1 ] [ 0 ] - c [ i ] [ 0 ] = = c [ i + 1 ] [ 1 ] - c [ i ] [ 1 ] = = c [ i + 1 ] [ 2 ] - c [ i ] [ 2 ] for i in range ( 2 ) ) print ( [ " No " , " Yes " ] [ flg ] ) a = [ ] for i in range ( 3 ) : line = list ( map ( int , input ( ) . split ( ) ) ) a . append ( line ) r = [ ] g = [ ] for i in range ( 3 ) : x = a [ 0 ] [ i ] r . append ( x ) y = a [ i ] [ 0 ] - a [ 0 ] [ 0 ] g . append ( y ) g [ 0 ] = 0 flag = True for i in range ( 3 ) : for j in range ( 3 ) : if a [ i ] [ j ] ! = ( g [ i ] + r [ j ] ) : flag = False break if flag : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] s = sum ( [ sum ( l ) for l in c ] ) print ( ' Yes ' if s / 3 = = c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] else ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] if c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 0 ] [ 2 ] and c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 2 ] [ 2 ] : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] dif _ 1 = c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] dif _ 2 = c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] dif _ 3 = c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] dif _ 4 = c [ 2 ] [ 0 ] - c [ 1 ] [ 0 ] if c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] ! = dif _ 1 or c [ 2 ] [ 1 ] - c [ 2 ] [ 0 ] ! = dif _ 1 : print ( " No " ) exit ( ) elif c [ 1 ] [ 2 ] - c [ 1 ] [ 1 ] ! = dif _ 2 or c [ 2 ] [ 2 ] - c [ 2 ] [ 1 ] ! = dif _ 2 : print ( " No " ) exit ( ) elif c [ 1 ] [ 1 ] - c [ 0 ] [ 1 ] ! = dif _ 3 or c [ 1 ] [ 2 ] - c [ 0 ] [ 2 ] ! = dif _ 3 : print ( ' No ' ) exit ( ) elif c [ 2 ] [ 2 ] - c [ 1 ] [ 2 ] ! = dif _ 4 or c [ 2 ] [ 1 ] - c [ 1 ] [ 1 ] ! = dif _ 4 : print ( ' No ' ) exit ( ) print ( ' Yes ' ) import numpy as np C = np . zeros ( ( 3 , 3 ) ) for i in range ( 3 ) : C [ i , 0 ] , C [ i , 1 ] , C [ i , 2 ] = [ int ( _ ) for _ in input ( ) . split ( ) ] for i in range ( 3 ) : for j in range ( 2 ) : if not ( C [ i , 0 ] - C [ j , 0 ] = = C [ i , 1 ] - C [ j , 1 ] = = C [ i , 2 ] - C [ j , 2 ] ) \ or not \ ( C [ 0 , i ] - C [ 0 , j ] = = C [ 1 , i ] - C [ 1 , j ] = = C [ 2 , i ] - C [ 2 , j ] ) : print ( ' No ' ) quit ( ) print ( ' Yes ' ) B = list ( map ( int , input ( ) . strip ( ) . split ( ' ' ) ) ) for _ in range ( 2 ) : C = list ( map ( int , input ( ) . strip ( ) . split ( ' ' ) ) ) if B [ 0 ] - C [ 0 ] = = B [ 1 ] - C [ 1 ] = = B [ 2 ] - C [ 2 ] : continue else : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] b = [ c [ 0 ] [ 0 ] , c [ 0 ] [ 1 ] , c [ 0 ] [ 2 ] ] a = [ 0 , c [ 1 ] [ 0 ] - b [ 0 ] , c [ 2 ] [ 0 ] - b [ 0 ] ] for i in range ( 3 ) : for j in range ( 3 ) : if a [ i ] + b [ j ] ! = c [ i ] [ j ] : print ( ' No ' ) exit ( ) print ( ' Yes ' ) l = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] al = [ l [ i ] [ 0 ] for i in range ( 3 ) ] bl = [ l [ 0 ] [ i ] - al [ 0 ] for i in range ( 3 ) ] for i in range ( 3 ) : for j in range ( 3 ) : if al [ i ] + bl [ j ] ! = l [ i ] [ j ] : print ( " No " ) ; exit ( ) print ( " Yes " ) L1 = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 2 ) : l = list ( map ( int , input ( ) . split ( ) ) ) sabun = None for j in range ( 3 ) : if sabun = = None : sabun = L1 [ j ] - l [ j ] elif L1 [ j ] - l [ j ] ! = sabun : print ( " No " ) exit ( ) print ( " Yes " ) a = [ ] for i in range ( 3 ) : a . append ( list ( map ( int , input ( ) . split ( ) ) ) ) if ( ( a [ 1 ] [ 0 ] - a [ 0 ] [ 0 ] = = a [ 1 ] [ 1 ] - a [ 0 ] [ 1 ] = = a [ 1 ] [ 2 ] - a [ 0 ] [ 2 ] ) and ( a [ 2 ] [ 0 ] - a [ 0 ] [ 0 ] = = a [ 2 ] [ 1 ] - a [ 0 ] [ 1 ] = = a [ 2 ] [ 2 ] - a [ 0 ] [ 2 ] ) ) : print ( ' Yes ' ) else : print ( ' No ' ) a = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] for i in range ( 101 ) : b1 = a [ 0 ] [ 0 ] - i b2 = a [ 0 ] [ 1 ] - i b3 = a [ 0 ] [ 2 ] - i a1 = i a2 = a [ 1 ] [ 0 ] - b1 a3 = a [ 2 ] [ 0 ] - b1 A = [ a1 , a2 , a3 ] B = [ b1 , b2 , b3 ] flag = True for l in range ( 3 ) : for r in range ( 3 ) : if A [ l ] < 0 or B [ r ] < 0 or a [ l ] [ r ] ! = A [ l ] + B [ r ] : flag = False if flag : print ( ' Yes ' ) exit ( ) print ( ' No ' ) def main ( ) : c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] s1 = c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] s2 = c [ 1 ] [ 0 ] + c [ 2 ] [ 1 ] + c [ 0 ] [ 2 ] s3 = c [ 2 ] [ 0 ] + c [ 0 ] [ 1 ] + c [ 1 ] [ 2 ] s4 = c [ 0 ] [ 0 ] + c [ 1 ] [ 2 ] + c [ 2 ] [ 1 ] s5 = c [ 1 ] [ 0 ] + c [ 2 ] [ 2 ] + c [ 0 ] [ 1 ] s6 = c [ 2 ] [ 0 ] + c [ 0 ] [ 2 ] + c [ 1 ] [ 1 ] if s1 = = s2 = = s3 = = s4 = = s5 = = s6 : print ( ' Yes ' ) else : print ( ' No ' ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) a , b , c = map ( int , input ( ) . split ( ) ) d , e , f = map ( int , input ( ) . split ( ) ) g , h , i = map ( int , input ( ) . split ( ) ) if a - b = = d - e = = g - h and b - c = = e - f = = h - i and a - d = = b - e = = c - f and d - g = = e - h = = f - i : print ( " Yes " ) else : print ( " No " ) l = list ( list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ) first = l [ 0 ] [ 0 ] - l [ 0 ] [ 1 ] second = l [ 0 ] [ 1 ] - l [ 0 ] [ 2 ] first1 = l [ 0 ] [ 0 ] - l [ 1 ] [ 0 ] second2 = l [ 1 ] [ 0 ] - l [ 2 ] [ 0 ] for k in range ( 3 ) : if ( l [ k ] [ 0 ] - l [ k ] [ 1 ] ! = first or l [ k ] [ 1 ] - l [ k ] [ 2 ] ! = second ) : print ( " No " ) exit ( ) for j in range ( 3 ) : if ( l [ 0 ] [ k ] - l [ 1 ] [ k ] ! = first1 or l [ 1 ] [ k ] - l [ 2 ] [ k ] ! = second2 ) : print ( " No " ) exit ( ) print ( " Yes " ) c = list ( map ( int , input ( ) . split ( ) ) ) x , y , z = c [ 0 ] - c [ 1 ] , c [ 1 ] - c [ 2 ] , c [ 2 ] - c [ 0 ] flag = True for i in range ( 2 ) : c = list ( map ( int , input ( ) . split ( ) ) ) s , t , u = c [ 0 ] - c [ 1 ] , c [ 1 ] - c [ 2 ] , c [ 2 ] - c [ 0 ] if ( x ! = s ) or ( y ! = t ) or ( z ! = u ) : flag = False break if flag : print ( ' Yes ' ) else : print ( ' No ' ) from functools import reduce import math def main ( ) : INF = float ( " inf " ) MOD = 10 * * 9 + 7 c = [ ] for _ in range ( 3 ) : c . append ( list ( int ( _ ) for _ in input ( ) . split ( ) ) ) c _ row _ sum = [ ] c _ column _ sum = [ ] for i in range ( 3 ) : c _ row _ sum . append ( sum ( c [ i ] ) ) for i in range ( 3 ) : tmp _ sum = 0 for j in range ( 3 ) : tmp _ sum + = c [ j ] [ i ] c _ column _ sum . append ( tmp _ sum ) for b in range ( 301 ) : a1 = ( c _ column _ sum [ 0 ] - b ) / 3 a2 = ( c _ column _ sum [ 1 ] - b ) / 3 a3 = ( c _ column _ sum [ 2 ] - b ) / 3 if a1 . is _ integer ( ) and a2 . is _ integer ( ) and a3 . is _ integer ( ) : b1 = ( c _ row _ sum [ 0 ] - ( a1 + a2 + a3 ) ) / 3 b2 = ( c _ row _ sum [ 1 ] - ( a1 + a2 + a3 ) ) / 3 b3 = ( c _ row _ sum [ 2 ] - ( a1 + a2 + a3 ) ) / 3 if b1 . is _ integer ( ) and b2 . is _ integer ( ) and b3 . is _ integer ( ) : print ( ' Yes ' ) return print ( ' No ' ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) n = [ [ 0 for i in range ( 3 ) ] for j in range ( 3 ) ] for i in range ( 3 ) : x , y , z = input ( ) . split ( ) n [ i ] [ 0 ] = int ( x ) n [ i ] [ 1 ] = int ( y ) n [ i ] [ 2 ] = int ( z ) a = [ 0 , 0 , 0 ] b = [ 0 , 0 , 0 ] isCmp = False for j in range ( 100 + 1 ) : b [ 0 ] = j a [ 0 ] = n [ 0 ] [ 0 ] - b [ 0 ] a [ 1 ] = n [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = n [ 2 ] [ 0 ] - b [ 0 ] b [ 1 ] = n [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = n [ 0 ] [ 2 ] - a [ 0 ] isCmp = True for l in range ( 3 ) : for m in range ( 3 ) : if n [ l ] [ m ] ! = a [ l ] + b [ m ] : isCmp = False if isCmp = = False : break if isCmp = = True : print ( ' Yes ' ) isCmp = True break if isCmp = = False : print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a _ a = set ( ) a _ b = set ( ) a _ c = set ( ) for i in range ( 3 ) : a _ a . add ( c [ i ] [ 0 ] - c [ i ] [ 1 ] ) a _ b . add ( c [ i ] [ 1 ] - c [ i ] [ 2 ] ) a _ c . add ( c [ i ] [ 2 ] - c [ i ] [ 0 ] ) if len ( a _ a ) = = 1 and len ( a _ b ) = = 1 and len ( a _ c ) = = 1 : print ( ' Yes ' ) else : print ( ' No ' ) n = [ ] m = [ [ 0 for i in range ( 3 ) ] for j in range ( 2 ) ] for x in range ( 3 ) : n . append ( list ( map ( int , input ( ) . split ( ) ) ) ) k = max ( n ) kaisuu = max ( k ) + 1 def tansa ( m ) : iti = 2 for j in range ( kaisuu ) : for k in range ( kaisuu ) : if j + k = = n [ iti ] [ iti ] : m [ 0 ] [ iti ] = j m [ 1 ] [ iti ] = k for a in range ( kaisuu ) : for b in range ( kaisuu ) : if a + b = = n [ iti - 1 ] [ iti - 1 ] and a + m [ 1 ] [ iti ] = = n [ iti - 1 ] [ iti ] : m [ 0 ] [ iti - 1 ] = a m [ 1 ] [ iti - 1 ] = b for c in range ( kaisuu ) : for d in range ( kaisuu ) : if c + d = = n [ iti - 2 ] [ iti - 2 ] and c + m [ 1 ] [ iti - 1 ] = = n [ iti - 2 ] [ iti - 1 ] and c + m [ 1 ] [ iti ] = = n [ iti - 2 ] [ iti ] : m [ 0 ] [ iti - 2 ] = c m [ 1 ] [ iti - 2 ] = d if m [ 0 ] [ 1 ] + m [ 1 ] [ 0 ] = = n [ 1 ] [ 0 ] and m [ 0 ] [ 2 ] + m [ 1 ] [ 0 ] = = n [ 2 ] [ 0 ] and m [ 0 ] [ 2 ] + \ m [ 1 ] [ 1 ] = = n [ 2 ] [ 1 ] : print ( " Yes " ) exit ( ) tansa ( m ) print ( " No " ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) c = list ( map ( int , input ( ) . split ( ) ) ) mis = 0 if a [ 0 ] + b [ 1 ] ! = a [ 1 ] + b [ 0 ] : print ( " No " ) quit ( 0 ) elif a [ 1 ] + b [ 2 ] ! = a [ 2 ] + b [ 1 ] : print ( " No " ) quit ( 0 ) elif a [ 0 ] + b [ 2 ] ! = a [ 2 ] + b [ 0 ] : print ( " No " ) quit ( 0 ) elif a [ 0 ] + c [ 1 ] ! = c [ 1 ] + a [ 0 ] : print ( " No " ) quit ( 0 ) elif a [ 1 ] + c [ 2 ] ! = a [ 2 ] + c [ 1 ] : print ( " No " ) quit ( 0 ) elif a [ 0 ] + c [ 2 ] ! = a [ 2 ] + c [ 0 ] : print ( " No " ) quit ( 0 ) elif b [ 0 ] + c [ 1 ] ! = c [ 1 ] + b [ 0 ] : print ( " No " ) quit ( 0 ) elif b [ 1 ] + c [ 2 ] ! = b [ 2 ] + c [ 1 ] : print ( " No " ) quit ( 0 ) elif b [ 0 ] + c [ 2 ] ! = b [ 2 ] + c [ 0 ] : print ( " No " ) quit ( 0 ) print ( " Yes " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 ans = " Yes " a [ 0 ] = 0 b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if a [ i ] + b [ j ] ! = c [ i ] [ j ] : ans = " No " print ( ans ) L = [ ] for i in range ( 3 ) : L . append ( list ( map ( int , input ( ) . split ( ) ) ) ) flag = True for i in range ( 2 ) : if L [ 0 ] [ i ] - L [ 0 ] [ i + 1 ] ! = L [ 1 ] [ i ] - L [ 1 ] [ i + 1 ] or L [ 1 ] [ i ] - L [ 1 ] [ i + 1 ] ! = L [ 2 ] [ i ] - L [ 2 ] [ i + 1 ] or L [ i ] [ 0 ] - L [ i + 1 ] [ 0 ] ! = L [ i ] [ 1 ] - L [ i + 1 ] [ 1 ] or L [ i ] [ 1 ] - L [ i + 1 ] [ 1 ] ! = L [ i ] [ 2 ] - L [ i + 1 ] [ 2 ] : flag = False break if flag : print ( " Yes " ) else : print ( " No " ) a , b , c = map ( int , input ( ) . split ( ) ) d , e , f = map ( int , input ( ) . split ( ) ) g , h , i = map ( int , input ( ) . split ( ) ) o = p = q = r = 0 if ( a - b ) = = ( d - e ) = = ( g - h ) : o = 1 if ( b - c ) = = ( e - f ) = = ( h - i ) : p = 1 if ( a - d ) = = ( b - e ) = = ( c - f ) : q = 1 if ( d - g ) = = ( e - h ) = = ( f - i ) : r = 1 if o = = p = = q = = r = = 1 : print ( " Yes " ) else : print ( " No " ) c = [ ] for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) if c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] and c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 2 ] [ 0 ] : if c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 1 ] [ 1 ] and c [ 1 ] [ 2 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 2 ] [ 1 ] : print ( " Yes " ) exit ( ) print ( " No " ) a = [ ] for i in range ( 3 ) : a . append ( list ( map ( int , input ( ) . split ( ) ) ) ) sa1 = a [ 0 ] [ 0 ] - a [ 1 ] [ 0 ] sa2 = a [ 0 ] [ 0 ] - a [ 2 ] [ 0 ] if sum ( a [ 0 ] ) = = sum ( a [ 1 ] ) + 3 * sa1 = = sum ( a [ 2 ] ) + 3 * sa2 : print ( " Yes " ) else : print ( " No " ) c = [ [ 0 , 0 , 0 ] for _ in range ( 3 ) ] for i in range ( 3 ) : c [ i ] = list ( map ( int , input ( ) . split ( ) ) ) for a0 in range ( 101 ) : b0 = c [ 0 ] [ 0 ] - a0 b1 = c [ 0 ] [ 1 ] - a0 b2 = c [ 0 ] [ 2 ] - a0 if ( ( ( c [ 1 ] [ 0 ] - b0 ) = = ( c [ 1 ] [ 1 ] - b1 ) = = ( c [ 1 ] [ 2 ] - b2 ) ) and ( ( c [ 2 ] [ 0 ] - b0 ) = = ( c [ 2 ] [ 1 ] - b1 ) = = ( c [ 2 ] [ 2 ] - b2 ) ) ) : print ( " Yes " ) break else : print ( " No " ) ( * c , ) = map ( int , open ( 0 ) . read ( ) . split ( ) ) print ( " YNeos " [ sum ( c ) % 3 > 0 or sum ( c ) / / 3 ! = c [ 0 ] + c [ 4 ] + c [ 8 ] : : 2 ] ) import bisect , collections , copy , itertools , math , string import sys def I ( ) : return int ( sys . stdin . readline ( ) . rstrip ( ) ) def LI ( ) : return list ( map ( int , sys . stdin . readline ( ) . rstrip ( ) . split ( ) ) ) def S ( ) : return sys . stdin . readline ( ) . rstrip ( ) def LS ( ) : return list ( sys . stdin . readline ( ) . rstrip ( ) . split ( ) ) def main ( ) : grid = [ ] for _ in range ( 3 ) : grid . append ( LI ( ) ) ans = True l1 = grid [ 0 ] [ 1 ] - grid [ 0 ] [ 0 ] l2 = grid [ 0 ] [ 2 ] - grid [ 0 ] [ 1 ] ans & = grid [ 1 ] [ 1 ] - grid [ 1 ] [ 0 ] = = l1 and grid [ 1 ] [ 2 ] - grid [ 1 ] [ 1 ] = = l2 ans & = grid [ 2 ] [ 1 ] - grid [ 2 ] [ 0 ] = = l1 and grid [ 2 ] [ 2 ] - grid [ 2 ] [ 1 ] = = l2 r1 = grid [ 1 ] [ 0 ] - grid [ 0 ] [ 0 ] r2 = grid [ 1 ] [ 0 ] - grid [ 0 ] [ 0 ] ans & = grid [ 1 ] [ 1 ] - grid [ 0 ] [ 1 ] = = r1 and grid [ 1 ] [ 1 ] - grid [ 0 ] [ 1 ] = = r2 ans & = grid [ 1 ] [ 2 ] - grid [ 0 ] [ 2 ] = = r1 and grid [ 1 ] [ 2 ] - grid [ 0 ] [ 2 ] = = r2 print ( " Yes " if ans else " No " ) main ( ) M = [ ] for i in range ( 3 ) : row = list ( map ( int , input ( ) . split ( ) ) ) M . append ( row ) flg = True for i in range ( 3 ) : if M [ 0 ] [ i ] - M [ 0 ] [ i - 1 ] = = M [ 1 ] [ i ] - M [ 1 ] [ i - 1 ] = = M [ 2 ] [ i ] - M [ 2 ] [ i - 1 ] : continue else : flg = False if M [ i ] [ 0 ] - M [ i - 1 ] [ 0 ] = = M [ i ] [ 1 ] - M [ i - 1 ] [ 1 ] = = M [ i ] [ 2 ] - M [ i - 1 ] [ 2 ] : continue else : flg = False if flg : print ( " Yes " ) else : print ( " No " ) import numpy as np cs = np . zeros ( ( 3 , 3 ) ) cs [ 0 , : ] = input ( ) . split ( ) cs [ 1 , : ] = input ( ) . split ( ) cs [ 2 , : ] = input ( ) . split ( ) cs = cs . astype ( int ) flag = True x1 = cs [ 0 , 0 ] - cs [ 1 , 0 ] x2 = cs [ 0 , 1 ] - cs [ 1 , 1 ] x3 = cs [ 0 , 2 ] - cs [ 1 , 2 ] y1 = cs [ 0 , 0 ] - cs [ 2 , 0 ] y2 = cs [ 0 , 1 ] - cs [ 2 , 1 ] y3 = cs [ 0 , 2 ] - cs [ 2 , 2 ] if ( x1 ! = x2 ) | ( x2 ! = x3 ) | ( y1 ! = y2 ) | ( y2 ! = y3 ) : flag = False if flag : for a1 in range ( 0 , 100 + 1 ) : a2 = a1 - ( cs [ 0 , 0 ] - cs [ 1 , 0 ] ) a3 = a1 - ( cs [ 0 , 0 ] - cs [ 2 , 0 ] ) x1 = cs [ 0 , 0 ] - a1 x2 = cs [ 1 , 0 ] - a2 x3 = cs [ 2 , 0 ] - a3 y1 = cs [ 0 , 1 ] - a1 y2 = cs [ 1 , 1 ] - a2 y3 = cs [ 2 , 1 ] - a3 z1 = cs [ 0 , 2 ] - a1 z2 = cs [ 1 , 2 ] - a2 z3 = cs [ 2 , 2 ] - a3 if ( x1 ! = x2 ) | ( x2 ! = x3 ) | ( y1 ! = y2 ) | ( y2 ! = y3 ) | ( z1 ! = z2 ) | ( z2 ! = z3 ) : flag = False else : flag = True break if flag : print ( ' Yes ' ) else : print ( ' No ' ) C = [ ] for _ in range ( 3 ) : C . append ( [ int ( c ) for c in input ( ) . split ( ' ' ) ] ) pairs = [ ( 0 , 1 ) , ( 1 , 2 ) , ( 0 , 2 ) ] for i , j in pairs : values = [ C [ i ] [ col ] - C [ j ] [ col ] for col in range ( 3 ) ] if len ( set ( values ) ) ! = 1 : print ( ' No ' ) exit ( ) for i , j in pairs : values = [ C [ row ] [ i ] - C [ row ] [ j ] for row in range ( 3 ) ] if len ( set ( values ) ) ! = 1 : print ( ' No ' ) exit ( ) print ( ' Yes ' ) li = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] ans = li [ 0 ] for i in li : for j in range ( - 100 , 102 ) : if j = = 101 : print ( " No " ) exit ( ) if [ i + j for i in ans ] = = i : break print ( " Yes " ) c = [ 0 ] * 3 c _ max = 0 for i in range ( 3 ) : c [ i ] = list ( map ( int , input ( ) . split ( ) ) ) c _ max = max ( c _ max , max ( c [ i ] ) ) c _ max + = 1 for a1 in range ( c _ max ) : b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 a2 = c [ 1 ] [ 0 ] - b1 a3 = c [ 2 ] [ 0 ] - b1 if a1 + b1 = = c [ 0 ] [ 0 ] and a1 + b2 = = c [ 0 ] [ 1 ] and a1 + b3 = = c [ 0 ] [ 2 ] and a2 + b1 = = c [ 1 ] [ 0 ] and a2 + b2 = = c [ 1 ] [ 1 ] and a2 + b3 = = c [ 1 ] [ 2 ] and a3 + b1 = = c [ 2 ] [ 0 ] and a3 + b2 = = c [ 2 ] [ 1 ] and a3 + b3 = = c [ 2 ] [ 2 ] : print ( ' Yes ' ) exit ( ) print ( ' No ' ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] A = [ 0 ] * 3 B = [ 0 ] * 3 for i in range ( 3 ) : B [ i ] = C [ 0 ] [ i ] - A [ 0 ] for j in range ( 1 , 3 ) : A [ j ] = C [ j ] [ 0 ] - B [ 0 ] ans = ' Yes ' for k in range ( 3 ) : for l in range ( 3 ) : if C [ k ] [ l ] ! = A [ k ] + B [ l ] : ans = ' No ' print ( ans ) exit ( ) print ( ans ) field = [ ] result = " Yes " for i in range ( 3 ) : field . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in range ( 3 ) : for j in range ( 3 ) : if not ( field [ i ] [ j ] > = 0 and field [ i ] [ j ] < = 100 * 2 ) : result = " No " if j = = 0 : pos _ i0 = field [ i ] [ j ] field [ i ] [ j ] - = pos _ i0 for j in range ( 3 ) : if not ( field [ 0 ] [ j ] = = field [ 1 ] [ j ] and field [ 0 ] [ j ] = = field [ 2 ] [ j ] ) : result = " No " print ( result ) f = [ ] for i in range ( 3 ) : f . append ( list ( map ( int , input ( ) . split ( ) ) ) ) s1 = f [ 0 ] [ 0 ] + f [ 1 ] [ 1 ] + f [ 2 ] [ 2 ] s2 = f [ 0 ] [ 1 ] + f [ 1 ] [ 2 ] + f [ 2 ] [ 0 ] s3 = f [ 0 ] [ 2 ] + f [ 1 ] [ 0 ] + f [ 2 ] [ 1 ] if s1 = = s2 = = s3 : print ( " Yes " ) else : print ( " No " ) import math , string , itertools , fractions , heapq , collections , re , array , bisect , sys , random , time sys . setrecursionlimit ( 10 * * 7 ) inf = 10 * * 20 mod = 10 * * 9 + 7 def LI ( ) : return list ( map ( int , input ( ) . split ( ) ) ) def I ( ) : return int ( input ( ) ) def LS ( ) : return input ( ) . split ( ) def S ( ) : return input ( ) def main ( ) : a = LI ( ) b = LI ( ) c = LI ( ) for i in range ( 2 ) : if not ( a [ i + 1 ] - a [ i ] = = b [ i + 1 ] - b [ i ] and b [ i + 1 ] - b [ i ] = = c [ i + 1 ] - c [ i ] ) : return ' No ' return ' Yes ' print ( main ( ) ) import numpy as np c = np . array ( [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( 3 ) ] ) b123 = c [ 0 ] a123 = np . array ( [ 0 , c [ 1 ] [ 1 ] - b123 [ 1 ] , c [ 2 ] [ 2 ] - b123 [ 2 ] , ] ) isOk = True for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = a123 [ i ] + b123 [ j ] : isOk = False ans = " Yes " if isOk else " No " print ( ans ) def main ( ) : c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a = [ 0 , 0 , 0 ] b = [ 0 , 0 , 0 ] for i in range ( 1 , 101 ) : a [ 0 ] = i a [ 1 ] = - 1 a [ 2 ] = - 1 b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] for j in range ( 1 , 3 ) : if c [ j ] [ 0 ] - b [ 0 ] ! = c [ j ] [ 1 ] - b [ 1 ] or c [ j ] [ 1 ] - b [ 1 ] ! = c [ j ] [ 2 ] - b [ 2 ] : break a [ j ] = c [ j ] [ 0 ] - b [ 0 ] if j = = 2 : print ( ' Yes ' ) return print ( ' No ' ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) c = [ [ 0 ] * 3 for i in range ( 3 ) ] for i in range ( 3 ) : c [ i ] [ 0 ] , c [ i ] [ 1 ] , c [ i ] [ 2 ] = map ( int , input ( ) . split ( ' ' ) ) a _ list = [ 0 ] * 3 b _ list = [ 0 ] * 3 for a0 in range ( c [ 0 ] [ 0 ] + 1 ) : a _ list [ 0 ] = a0 b _ list [ 0 ] = c [ 0 ] [ 0 ] - a _ list [ 0 ] a _ list [ 1 ] = c [ 1 ] [ 0 ] - b _ list [ 0 ] a _ list [ 2 ] = c [ 2 ] [ 0 ] - b _ list [ 0 ] b _ list [ 1 ] = c [ 0 ] [ 1 ] - a _ list [ 0 ] b _ list [ 2 ] = c [ 0 ] [ 2 ] - a _ list [ 0 ] if not all ( [ tmp > = 0 for tmp in a _ list ] ) : continue if not all ( [ tmp > = 0 for tmp in b _ list ] ) : continue tmp = [ [ 0 ] * 3 for i in range ( 3 ) ] for i in range ( 3 ) : for j in range ( 3 ) : tmp [ i ] [ j ] = a _ list [ i ] + b _ list [ j ] for n , m in zip ( c , tmp ) : if not n = = m : break else : print ( ' Yes ' ) exit ( ) else : print ( ' No ' ) ( * c , ) = map ( int , open ( 0 ) . read ( ) . split ( ) ) print ( " YNeos " [ sum ( c ) % 3 > 0 or sum ( c ) / / 3 ! = c [ 0 ] + c [ 4 ] + c [ 8 ] : : 2 ] ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] flag = True for i in range ( 3 ) : x = [ 0 ] * 3 y = [ 0 ] * 3 for j in range ( 3 ) : x [ j ] = c [ i - 1 ] [ j ] - c [ i ] [ j ] y [ j ] = c [ j ] [ i - 1 ] - c [ j ] [ i ] if len ( set ( x ) ) ! = 1 or len ( set ( y ) ) ! = 1 : flag = False if flag : print ( " Yes " ) else : print ( " No " ) import sys sys . setrecursionlimit ( 10 * * 7 ) f _ inf = float ( ' inf ' ) mod = 10 * * 9 + 7 def resolve ( ) : C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ f _ inf ] * 3 b = [ f _ inf ] * 3 a [ 0 ] = 0 for j in range ( 3 ) : b [ j ] = C [ 0 ] [ j ] - a [ 0 ] for i in range ( 3 ) : a [ i ] = C [ i ] [ 0 ] - b [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if C [ i ] [ j ] ! = a [ i ] + b [ j ] : print ( " No " ) exit ( ) print ( " Yes " ) if _ _ name _ _ = = ' _ _ main _ _ ' : resolve ( ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) b = [ 0 ] * 3 b [ 0 ] = c1 [ 0 ] b [ 1 ] = c1 [ 1 ] b [ 2 ] = c1 [ 2 ] C = c1 + c2 + c3 a = [ 0 ] * 3 a [ 0 ] = 0 a [ 1 ] = C [ 3 ] - b [ 0 ] a [ 2 ] = C [ 6 ] - b [ 0 ] z = 0 for x in a : for y in b : if C [ z ] ! = x + y : print ( " No " ) exit ( ) z + = 1 print ( " Yes " ) C = [ ] for _ in range ( 3 ) : C . append ( list ( map ( int , input ( ) . split ( ) ) ) ) TC = [ [ 0 for i in range ( 3 ) ] for j in range ( 3 ) ] for i in range ( 3 ) : for j in range ( 3 ) : TC [ i ] [ j ] = C [ j ] [ i ] for b1 in range ( 101 ) : for b2 in range ( 101 ) : for b3 in range ( 101 ) : a1 = ( sum ( C [ 0 ] ) - ( b1 + b2 + b3 ) ) / 3 a2 = ( sum ( C [ 1 ] ) - ( b1 + b2 + b3 ) ) / 3 a3 = ( sum ( C [ 2 ] ) - ( b1 + b2 + b3 ) ) / 3 if a1 + a2 + a3 + 3 * b1 = = sum ( TC [ 0 ] ) and a1 + a2 + a3 + 3 * b2 = = sum ( TC [ 1 ] ) and a1 + a2 + a3 + 3 * b3 = = sum ( TC [ 2 ] ) : print ( " Yes " ) exit ( ) print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a0 = 0 b0 = c [ 0 ] [ 0 ] - a0 b1 = c [ 0 ] [ 1 ] - a0 b2 = c [ 0 ] [ 2 ] - a0 a1 = c [ 1 ] [ 0 ] - b0 a2 = c [ 2 ] [ 0 ] - b0 if a1 = = c [ 1 ] [ 1 ] - b1 = = c [ 1 ] [ 2 ] - b2 \ and a2 = = c [ 2 ] [ 1 ] - b1 = = c [ 2 ] [ 2 ] - b2 : print ( " Yes " ) else : print ( " No " ) l = [ [ ] for _ in range ( 3 ) ] for i in range ( 0 , 3 ) : l [ i ] = [ int ( _ ) for _ in input ( ) . split ( ) ] t = [ 0 , 0 , 0 ] for i in range ( 0 , 3 ) : for j in range ( 0 , 3 ) : t [ i ] + = l [ j ] [ i ] p = ( t [ 0 ] - t [ 1 ] ) / 3 q = ( t [ 0 ] - t [ 2 ] ) / 3 if l [ 0 ] [ 0 ] - p = = l [ 0 ] [ 1 ] and l [ 0 ] [ 0 ] - q = = l [ 0 ] [ 2 ] and l [ 1 ] [ 0 ] - p = = l [ 1 ] [ 1 ] and l [ 1 ] [ 0 ] - q = = l [ 1 ] [ 2 ] and l [ 2 ] [ 0 ] - p = = l [ 2 ] [ 1 ] and l [ 2 ] [ 0 ] - q = = l [ 2 ] [ 2 ] : print ( ' Yes ' ) else : print ( ' No ' ) import sys c = [ [ int ( x ) for x in input ( ) . split ( ) ] for _ in range ( 3 ) ] for i in range ( 2 ) : for j in range ( 2 ) : if c [ j ] [ i + 1 ] - c [ j ] [ i ] ! = c [ j + 1 ] [ i + 1 ] - c [ j + 1 ] [ i ] : print ( " No " ) sys . exit ( ) print ( " Yes " ) from itertools import combinations c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] row = [ [ 0 ] * 3 for _ in range ( 2 ) ] for i in range ( 2 ) : for j in range ( 3 ) : row [ i ] [ j ] = c [ i + 1 ] [ j ] - c [ i ] [ j ] ans = " Yes " for i in row : if any ( x ! = y for x , y in combinations ( i , 2 ) ) : ans = " No " print ( ans ) def pin ( type = int ) : return map ( type , input ( ) . split ( ) ) def worstdata ( ) : a = 0 return a def comp ( x , y ) : dp = [ 0 , max ( act [ 0 ] ) ] * ( N + 1 ) return 0 C = [ list ( pin ( ) ) for _ in range ( 3 ) ] yoko = [ [ 0 ] * 3 for _ in range ( 3 ) ] yoko [ 0 ] = [ C [ 1 ] [ i ] - C [ 0 ] [ i ] for i in range ( 3 ) ] yoko [ 1 ] = [ C [ 2 ] [ i ] - C [ 1 ] [ i ] for i in range ( 3 ) ] yoko [ 2 ] = [ C [ 0 ] [ i ] - C [ 2 ] [ i ] for i in range ( 3 ) ] cond = 1 for kakaka in range ( 3 ) : if not ( yoko [ kakaka ] [ 0 ] = = yoko [ kakaka ] [ 1 ] and yoko [ kakaka ] [ 1 ] = = yoko [ kakaka ] [ 2 ] ) : cond = 0 break print ( [ " No " , " Yes " ] [ cond ] ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] x = [ 0 ] * 3 y = [ 0 ] * 3 state = True for i in range ( 3 ) : y [ i ] = c [ 0 ] [ i ] - x [ 0 ] for i in range ( 3 ) : x [ i ] = c [ i ] [ 0 ] - y [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = x [ i ] + y [ j ] : print ( ' No ' ) state = False break if state = = False : break if state = = True : print ( ' Yes ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] ans = " No " if all ( [ all ( [ c [ i ] [ j ] - c [ i ] [ j + 1 ] = = c [ i + 1 ] [ j ] - c [ i + 1 ] [ j + 1 ] for i in range ( 2 ) ] ) for j in range ( 2 ) ] ) : if all ( [ all ( [ c [ i ] [ j ] - c [ i + 1 ] [ j ] = = c [ i ] [ j + 1 ] - c [ i + 1 ] [ j + 1 ] for i in range ( 2 ) ] ) for j in range ( 2 ) ] ) : ans = " Yes " print ( ans ) import sys sys . stdin . readline def I ( ) : return int ( input ( ) ) def MI ( ) : return map ( int , input ( ) . split ( ) ) def LI ( ) : return list ( map ( int , input ( ) . split ( ) ) ) mod = 10 * * 9 + 7 def main ( ) : c = [ [ ] for _ in range ( 3 ) ] for i in range ( 3 ) : c [ i ] = LI ( ) a = [ 0 , 0 , 0 ] b = [ 0 , 0 , 0 ] for i in range ( 3 ) : b [ i ] = c [ 0 ] [ i ] for i in range ( 1 , 3 ) : a [ i ] = c [ i ] [ 0 ] - b [ 0 ] flag = 1 for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = a [ i ] + b [ j ] : flag = 0 if flag = = 1 : print ( " Yes " ) else : print ( " No " ) main ( ) c = { } for i in range ( 3 ) : c [ i ] = list ( map ( int , input ( ) . split ( ) ) ) tfc = 0 for i in range ( 101 ) : if tfc = = 3 : break else : tfc = 0 cx = [ ] for j in c . values ( ) : for k in j : cx . append ( k ) if i > max ( cx ) : break b = [ ] for j in range ( 3 ) : b . append ( c . get ( 0 ) [ j ] - i ) for j in range ( 3 ) : p = [ ] for k in range ( 3 ) : p . append ( c . get ( j ) [ k ] - b [ k ] ) if min ( p ) = = max ( p ) : tfc + = 1 if tfc = = 3 : print ( ' Yes ' ) else : print ( ' No ' ) from itertools import permutations def main ( ) : grid = [ ] num _ sum = 0 for _ in range ( 3 ) : tmp = list ( map ( int , input ( ) . split ( " " ) ) ) num _ sum + = sum ( tmp ) grid . append ( tmp ) num _ sum / / = 3 index _ list = permutations ( [ 0 , 1 , 2 ] ) answer = " Yes " for index in index _ list : if not grid [ 0 ] [ index [ 0 ] ] + grid [ 1 ] [ index [ 1 ] ] + grid [ 2 ] [ index [ 2 ] ] = = num _ sum : answer = " No " break print ( answer ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] N = 0 for i in range ( 3 ) : N = max ( N , max ( C [ i ] ) ) + 1 for i in range ( N ) : for j in range ( N ) : for k in range ( N ) : check = 0 for l in range ( 3 ) : if C [ l ] [ 0 ] - i = = C [ l ] [ 1 ] - j = = C [ l ] [ 2 ] - k : check + = 1 if check = = 3 : print ( ' Yes ' ) exit ( ) print ( ' No ' ) c _ 0 = [ int ( _ ) for _ in input ( ) . split ( ) ] c _ 1 = [ int ( _ ) for _ in input ( ) . split ( ) ] c _ 2 = [ int ( _ ) for _ in input ( ) . split ( ) ] d = [ 0 ] * 3 e = [ 0 ] * 3 for i in range ( 3 ) : d [ i ] = c _ 0 [ i % 3 ] + c _ 1 [ ( i + 1 ) % 3 ] + c _ 2 [ ( i + 2 ) % 3 ] e [ i ] = c _ 0 [ ( i + 2 ) % 3 ] + c _ 1 [ ( i + 1 ) % 3 ] + c _ 2 [ i % 3 ] flag = True for i in range ( 2 ) : if d [ 0 ] ! = d [ i ] or d [ 0 ] ! = e [ i ] : flag = False if flag : print ( ' Yes ' ) else : print ( ' No ' ) l = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] t = True for i in range ( 3 ) : if not l [ i ] [ 0 ] - l [ i - 1 ] [ 0 ] = = l [ i ] [ 1 ] - l [ i - 1 ] [ 1 ] = = l [ i ] [ 2 ] - l [ i - 1 ] [ 2 ] or not l [ 0 ] [ i ] - l [ 0 ] [ i - 1 ] = = l [ 1 ] [ i ] - l [ 1 ] [ i - 1 ] = = l [ 2 ] [ i ] - l [ 2 ] [ i - 1 ] : t = False if t = = True : print ( " Yes " ) else : print ( " No " ) c = [ ] flag = True for i in range ( 3 ) : c1 , c2 , c3 = map ( int , input ( ) . split ( ) ) c . append ( ( c1 , c2 , c3 ) ) diff1 = abs ( c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] ) diff2 = abs ( c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] ) for i in range ( 1 , 3 ) : d1 = abs ( c [ i ] [ 0 ] - c [ i ] [ 1 ] ) d2 = abs ( c [ i ] [ 1 ] - c [ i ] [ 2 ] ) if d1 ! = diff1 or d2 ! = diff2 : flag = False break if flag : print ( " Yes " ) else : print ( " No " ) a1 = 0 c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) b1 = c11 - a1 b2 = c12 - a1 b3 = c13 - a1 c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) if c21 - b1 = = c22 - b2 = = c23 - b3 and c31 - b1 = = c32 - b2 = = c33 - b3 : print ( ' Yes ' ) else : print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a = [ 0 , 0 , 0 ] b = [ 0 , 0 , 0 ] ans = " No " for i in range ( 101 ) : if i > c [ 0 ] [ 0 ] : break a [ 0 ] = i b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] flag = 1 for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = a [ i ] + b [ j ] : flag = 0 if flag : ans = " Yes " break print ( ans ) arr = [ ] for _ in range ( 3 ) : arr + = list ( map ( int , input ( ) . split ( ) ) ) a = [ 0 ] * 3 b = [ 0 ] * 3 a [ 0 ] = 0 b [ 0 ] = arr [ 0 ] b [ 1 ] = arr [ 1 ] b [ 2 ] = arr [ 2 ] a [ 1 ] = arr [ 4 ] - b [ 1 ] a [ 2 ] = arr [ 8 ] - b [ 2 ] tmp = [ a [ i ] + b [ j ] for i in range ( 3 ) for j in range ( 3 ) ] print ( ' Yes ' if arr = = tmp else ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 2 ) : res1 = c [ i + 1 ] [ 0 ] - c [ i ] [ 0 ] res2 = c [ i + 1 ] [ 1 ] - c [ i ] [ 1 ] res3 = c [ i + 1 ] [ 2 ] - c [ i ] [ 2 ] if res1 = = res2 = = res3 : continue else : print ( ' No ' ) exit ( ) for j in range ( 2 ) : res1 = c [ 0 ] [ j + 1 ] - c [ 0 ] [ j ] res2 = c [ 1 ] [ j + 1 ] - c [ 1 ] [ j ] res3 = c [ 2 ] [ j + 1 ] - c [ 2 ] [ j ] if res1 = = res2 = = res3 : continue else : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c = [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( 3 ) ] b = [ 0 for _ in range ( 3 ) ] ans = ' Yes ' for i in range ( 3 ) : if i = = 0 : for j in range ( 3 ) : b [ j ] = c [ i ] [ j ] - c [ i ] [ ( j + 1 ) % 3 ] else : for j in range ( 3 ) : if b [ j ] ! = c [ i ] [ j ] - c [ i ] [ ( j + 1 ) % 3 ] : ans = ' No ' break if ans = = ' No ' : break print ( ans ) t = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] if t [ 0 ] [ 0 ] + t [ 1 ] [ 1 ] + t [ 2 ] [ 2 ] = = t [ 0 ] [ 1 ] + t [ 1 ] [ 2 ] + t [ 2 ] [ 0 ] = = t [ 0 ] [ 2 ] + t [ 1 ] [ 0 ] + t [ 2 ] [ 1 ] : print ( " Yes " ) else : print ( " No " ) array _ 1 = list ( map ( int , input ( ) . split ( ) ) ) array _ 2 = list ( map ( int , input ( ) . split ( ) ) ) array _ 3 = list ( map ( int , input ( ) . split ( ) ) ) for a in range ( 101 ) : for b in range ( 101 ) : for c in range ( 101 ) : if array _ 1 [ 0 ] - a = = array _ 2 [ 0 ] - b and array _ 2 [ 0 ] - b = = array _ 3 [ 0 ] - c and array _ 3 [ 0 ] - c = = array _ 1 [ 0 ] - a and array _ 1 [ 1 ] - a = = array _ 2 [ 1 ] - b and array _ 2 [ 1 ] - b = = array _ 3 [ 1 ] - c and array _ 3 [ 1 ] - c = = array _ 1 [ 1 ] - a and array _ 1 [ 2 ] - a = = array _ 2 [ 2 ] - b and array _ 2 [ 2 ] - b = = array _ 3 [ 2 ] - c and array _ 3 [ 2 ] - c = = array _ 1 [ 2 ] - a : print ( ' Yes ' ) exit ( ) print ( ' No ' ) F = [ None ] * 3 for i in range ( 3 ) : F [ i ] = list ( map ( int , input ( ) . split ( ) ) ) for a1 in range ( F [ 0 ] [ 0 ] + 1 ) : b1 = F [ 0 ] [ 0 ] - a1 b2 = F [ 0 ] [ 1 ] - a1 b3 = F [ 0 ] [ 2 ] - a1 a2 = F [ 1 ] [ 0 ] - b1 a3 = F [ 2 ] [ 0 ] - b1 for i , a in enumerate ( [ a1 , a2 , a3 ] ) : for j , b in enumerate ( [ b1 , b2 , b3 ] ) : if F [ i ] [ j ] ! = a + b : break else : continue break else : print ( ' Yes ' ) break else : print ( ' No ' ) import numpy as np c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] A = np . array ( [ [ 1 , 0 , 0 , 1 , 0 , 0 ] , [ 1 , 0 , 0 , 0 , 1 , 0 ] , [ 1 , 0 , 0 , 0 , 0 , 1 ] , [ 0 , 1 , 0 , 1 , 0 , 0 ] , [ 0 , 1 , 0 , 0 , 1 , 0 ] , [ 0 , 1 , 0 , 0 , 0 , 1 ] , [ 0 , 0 , 1 , 1 , 0 , 0 ] , [ 0 , 0 , 1 , 0 , 1 , 0 ] , [ 0 , 0 , 1 , 0 , 0 , 1 ] ] ) B = np . array ( [ [ 1 , 0 , 0 , 1 , 0 , 0 , c [ 0 ] [ 0 ] ] , [ 1 , 0 , 0 , 0 , 1 , 0 , c [ 0 ] [ 1 ] ] , [ 1 , 0 , 0 , 0 , 0 , 1 , c [ 0 ] [ 2 ] ] , [ 0 , 1 , 0 , 1 , 0 , 0 , c [ 1 ] [ 0 ] ] , [ 0 , 1 , 0 , 0 , 1 , 0 , c [ 1 ] [ 1 ] ] , [ 0 , 1 , 0 , 0 , 0 , 1 , c [ 1 ] [ 2 ] ] , [ 0 , 0 , 1 , 1 , 0 , 0 , c [ 2 ] [ 0 ] ] , [ 0 , 0 , 1 , 0 , 1 , 0 , c [ 2 ] [ 1 ] ] , [ 0 , 0 , 1 , 0 , 0 , 1 , c [ 2 ] [ 2 ] ] ] ) rankA = np . linalg . matrix _ rank ( A ) rankB = np . linalg . matrix _ rank ( B ) if rankA = = rankB : print ( " Yes " ) else : print ( " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] AB = [ 0 for i in range ( 6 ) ] AB [ 3 ] = C [ 0 ] [ 0 ] - 0 AB [ 1 ] = C [ 1 ] [ 0 ] - AB [ 3 ] AB [ 2 ] = C [ 2 ] [ 0 ] - AB [ 3 ] AB [ 4 ] = C [ 0 ] [ 1 ] - 0 AB [ 5 ] = C [ 0 ] [ 2 ] - 0 if C [ 1 ] [ 1 ] ! = AB [ 1 ] + AB [ 4 ] : print ( ' No ' ) quit ( ) if C [ 1 ] [ 2 ] ! = AB [ 1 ] + AB [ 5 ] : print ( ' No ' ) quit ( ) if C [ 2 ] [ 1 ] ! = AB [ 2 ] + AB [ 4 ] : print ( ' No ' ) quit ( ) if C [ 2 ] [ 2 ] ! = AB [ 2 ] + AB [ 5 ] : print ( ' No ' ) quit ( ) print ( ' Yes ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ 0 , 0 , 0 ] b = [ 0 , 0 , 0 ] b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] cnt = 0 for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] = = a [ i ] + b [ j ] : cnt + = 1 print ( ' Yes ' if cnt = = 9 else ' No ' ) import sys input = sys . stdin . readline L = [ None ] * 3 for i in range ( 3 ) : L [ i ] = [ int ( v ) for v in input ( ) . split ( ) ] rl = [ L [ 0 ] [ 0 ] - L [ 0 ] [ 1 ] , L [ 0 ] [ 1 ] - L [ 0 ] [ 2 ] ] hl = [ L [ 0 ] [ 0 ] - L [ 1 ] [ 0 ] , L [ 1 ] [ 0 ] - L [ 2 ] [ 0 ] ] for v in L : if [ v [ 0 ] - v [ 1 ] , v [ 1 ] - v [ 2 ] ] ! = rl : print ( " No " ) sys . exit ( ) for i in range ( 3 ) : if [ L [ 0 ] [ i ] - L [ 1 ] [ i ] , L [ 1 ] [ i ] - L [ 2 ] [ i ] ] ! = hl : print ( " No " ) sys . exit ( ) print ( " Yes " ) C = [ [ int ( i ) for i in input ( ) . split ( ) ] for j in range ( 3 ) ] a = [ sum ( C [ i ] ) - sum ( C [ i - 1 ] ) for i in range ( 3 ) ] b = [ sum ( [ C [ j ] [ i ] for j in range ( 3 ) ] ) - sum ( [ C [ j ] [ i - 1 ] for j in range ( 3 ) ] ) for i in range ( 3 ) ] for i in range ( 3 ) : if not ( a [ i ] / 3 ) . is _ integer ( ) or not ( b [ i ] / 3 ) . is _ integer ( ) : print ( " No " ) break else : print ( " Yes " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for k in range ( 3 ) ] A = [ sum ( a ) for a in c ] B = [ 0 , 0 , 0 ] AB = 0 for y in range ( 3 ) : for x in range ( 3 ) : if x = = y : AB + = c [ y ] [ x ] B [ x ] + = c [ y ] [ x ] for k in range ( 3 ) : t = ( A [ k ] + B [ k ] - AB ) if t > = 0 and t % 3 = = 0 : pass else : print ( " No " ) exit ( 0 ) print ( " Yes " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] judge = True for i in range ( 2 ) : for j in range ( 2 ) : if ( c [ j ] [ i ] - c [ j + 1 ] [ i ] ) ! = ( c [ j ] [ i + 1 ] - c [ j + 1 ] [ i + 1 ] ) : judge = False for i in range ( 2 ) : for j in range ( 2 ) : if ( c [ i ] [ j ] - c [ i ] [ j + 1 ] ) ! = ( c [ i + 1 ] [ j ] - c [ i + 1 ] [ j + 1 ] ) : judge = False if judge : print ( " Yes " ) else : print ( " No " ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) ok = False for i in range ( 101 ) : for j in range ( 101 ) : a1 = i a2 = c21 - c11 + a1 a3 = c31 - c11 + a1 b1 = j b2 = c12 - c11 + b1 b3 = c13 - c11 + b1 if ( ( c11 = = a1 + b1 ) and ( c12 = = a1 + b2 ) and ( c13 = = a1 + b3 ) and ( c21 = = a2 + b1 ) and ( c22 = = a2 + b2 ) and ( c23 = = a2 + b3 ) and ( c31 = = a3 + b1 ) and ( c32 = = a3 + b2 ) and ( c33 = = a3 + b3 ) ) : ok = True break if ( ok ) : break if ok : print ( " Yes " ) else : print ( " No " ) from itertools import product C1 = [ int ( x ) for x in input ( ) . split ( ) ] C2 = [ int ( x ) for x in input ( ) . split ( ) ] C3 = [ int ( x ) for x in input ( ) . split ( ) ] R1 = [ c [ 0 ] for c in [ C1 , C2 , C3 ] ] R2 = [ c [ 1 ] for c in [ C1 , C2 , C3 ] ] R3 = [ c [ 2 ] for c in [ C1 , C2 , C3 ] ] def check ( C1 , C2 ) : r = 1 = = len ( set ( [ C1 [ 0 ] - C2 [ 0 ] , C1 [ 1 ] - C2 [ 1 ] , C1 [ 2 ] - C2 [ 2 ] ] ) ) return r if all ( check ( c1 , c2 ) for c1 , c2 , in product ( [ C1 , C2 , C3 ] , [ C1 , C2 , C3 ] ) ) and \ all ( check ( c1 , c2 ) for c1 , c2 in product ( [ R1 , R2 , R3 ] , [ R1 , R2 , R3 ] ) ) : print ( " Yes " ) else : print ( " No " ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) diff1 = c21 - c11 diff2 = c31 - c21 if diff1 = = ( c22 - c12 ) and diff2 = = ( c32 - c22 ) and diff1 = = ( c23 - c13 ) and diff2 = = ( c33 - c23 ) : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 for i in range ( 0 , 101 ) : a [ 0 ] = i b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] for j in range ( 3 ) : for k in range ( 3 ) : if c [ j ] [ k ] ! = a [ j ] + b [ k ] : break else : continue break else : print ( ' Yes ' ) break else : print ( ' No ' ) import numpy as np a = np . array ( [ [ int ( x ) for x in input ( ) . split ( ) ] for y in range ( 3 ) ] , dtype = np . int64 ) for i in range ( 3 ) : for j in range ( 0 , 3 ) : a [ i ] [ j ] - = a [ i ] [ 2 ] for j in range ( 3 ) : for i in range ( 1 , 3 ) : if ( a [ i ] [ j ] ! = a [ 0 ] [ j ] ) : print ( " No " ) exit ( 0 ) print ( " Yes " ) import sys sys . setrecursionlimit ( 2147483647 ) INF = float ( " inf " ) MOD = 10 * * 9 + 7 input = lambda : sys . stdin . readline ( ) . rstrip ( ) def resolve ( ) : C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] if ( not ( C [ 1 ] [ 0 ] - C [ 0 ] [ 0 ] = = C [ 1 ] [ 1 ] - C [ 0 ] [ 1 ] = = C [ 1 ] [ 2 ] - C [ 0 ] [ 2 ] ) ) : print ( " No " ) return if ( not ( C [ 2 ] [ 0 ] - C [ 1 ] [ 0 ] = = C [ 2 ] [ 1 ] - C [ 1 ] [ 1 ] = = C [ 2 ] [ 2 ] - C [ 1 ] [ 2 ] ) ) : print ( " No " ) return if ( not ( C [ 0 ] [ 0 ] - C [ 2 ] [ 0 ] = = C [ 0 ] [ 1 ] - C [ 2 ] [ 1 ] = = C [ 0 ] [ 2 ] - C [ 2 ] [ 2 ] ) ) : print ( " No " ) return if ( not ( C [ 0 ] [ 1 ] - C [ 0 ] [ 0 ] = = C [ 1 ] [ 1 ] - C [ 1 ] [ 0 ] = = C [ 2 ] [ 1 ] - C [ 2 ] [ 0 ] ) ) : print ( " No " ) return if ( not ( C [ 0 ] [ 2 ] - C [ 0 ] [ 1 ] = = C [ 1 ] [ 2 ] - C [ 1 ] [ 1 ] = = C [ 2 ] [ 2 ] - C [ 2 ] [ 1 ] ) ) : print ( " No " ) return if ( not ( C [ 0 ] [ 0 ] - C [ 0 ] [ 2 ] = = C [ 1 ] [ 0 ] - C [ 1 ] [ 2 ] = = C [ 2 ] [ 0 ] - C [ 2 ] [ 2 ] ) ) : print ( " No " ) return print ( " Yes " ) resolve ( ) c = [ ] for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) a = [ 0 ] * 3 b = [ ] for i in range ( 3 ) : b . append ( c [ 0 ] [ i ] - a [ 0 ] ) for i in range ( 1 , 3 ) : a [ i ] = c [ i ] [ 0 ] - b [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if a [ i ] + b [ j ] ! = c [ i ] [ j ] : print ( " No " ) exit ( ) print ( " Yes " ) import sys input = sys . stdin . readline sys . setrecursionlimit ( 1000000 ) from collections import deque def getN ( ) : return int ( input ( ) ) def getList ( ) : return list ( map ( int , input ( ) . split ( ) ) ) import math import bisect from logging import getLogger , StreamHandler , DEBUG , WARNING logger = getLogger ( _ _ name _ _ ) handler = StreamHandler ( ) handler . setLevel ( DEBUG ) logger . setLevel ( DEBUG ) logger . addHandler ( handler ) def judge ( a1 , a2 , a3 , nums ) : b1 = nums [ 0 ] [ 0 ] - a1 b2 = nums [ 0 ] [ 1 ] - a1 b3 = nums [ 0 ] [ 2 ] - a1 if a2 + b1 = = nums [ 1 ] [ 0 ] and a2 + b2 = = nums [ 1 ] [ 1 ] and a2 + b3 = = nums [ 1 ] [ 2 ] : if a3 + b1 = = nums [ 2 ] [ 0 ] and a3 + b2 = = nums [ 2 ] [ 1 ] and a3 + b3 = = nums [ 2 ] [ 2 ] : return True return False def main ( ) : nums = [ getList ( ) for _ in range ( 3 ) ] for a1 in range ( 101 ) : for a2 in range ( 101 ) : for a3 in range ( 101 ) : if judge ( a1 , a2 , a3 , nums ) : print ( " Yes " ) return print ( " No " ) if _ _ name _ _ = = " _ _ main _ _ " : main ( ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a1 = [ ] a2 = [ ] b1 = [ ] b2 = [ ] for i in range ( 3 ) : a1 . append ( c [ 1 ] [ i ] - c [ 0 ] [ i ] ) a2 . append ( c [ 2 ] [ i ] - c [ 1 ] [ i ] ) b1 . append ( c [ i ] [ 1 ] - c [ i ] [ 0 ] ) b2 . append ( c [ i ] [ 2 ] - c [ i ] [ 1 ] ) def l ( x ) : return len ( list ( set ( x ) ) ) if ( l ( a1 ) = = 1 ) and ( l ( a2 ) = = 1 ) and ( l ( b1 ) = = 1 ) and ( l ( b2 ) = = 1 ) : print ( ' Yes ' ) else : print ( ' No ' ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) c = list ( map ( int , input ( ) . split ( ) ) ) if c [ 0 ] - b [ 0 ] = = c [ 1 ] - b [ 1 ] = = c [ 2 ] - b [ 2 ] and b [ 0 ] - a [ 0 ] = = b [ 1 ] - a [ 1 ] = = b [ 2 ] - a [ 2 ] and a [ 2 ] - a [ 1 ] = = b [ 2 ] - b [ 1 ] = = c [ 2 ] - c [ 1 ] and a [ 1 ] - a [ 0 ] = = b [ 1 ] - b [ 0 ] = = c [ 1 ] - c [ 0 ] : print ( ' Yes ' ) else : print ( ' No ' ) c = [ ] for i in range ( 3 ) : ci = list ( map ( int , input ( ) . split ( ) ) ) c . append ( ci ) for i in range ( 101 ) : a1 = i b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 a2 = c [ 1 ] [ 0 ] - b1 a3 = c [ 2 ] [ 0 ] - b1 a = [ a1 , a2 , a3 ] b = [ b1 , b2 , b3 ] T = True for j in range ( 3 ) : for k in range ( 3 ) : if c [ j ] [ k ] ! = a [ j ] + b [ k ] : T = False break if T : print ( " Yes " ) quit ( ) print ( " No " ) ls = [ ] for i in range ( 3 ) : ls . append ( list ( map ( int , input ( ) . split ( ) ) ) ) ans = ' Yes ' if ls [ 1 ] [ 1 ] - ls [ 1 ] [ 0 ] ! = ls [ 0 ] [ 1 ] - ls [ 0 ] [ 0 ] : ans = ' No ' if ls [ 2 ] [ 1 ] - ls [ 2 ] [ 0 ] ! = ls [ 0 ] [ 1 ] - ls [ 0 ] [ 0 ] : ans = ' No ' if ls [ 1 ] [ 2 ] - ls [ 1 ] [ 0 ] ! = ls [ 0 ] [ 2 ] - ls [ 0 ] [ 0 ] : ans = ' No ' if ls [ 2 ] [ 2 ] - ls [ 2 ] [ 0 ] ! = ls [ 0 ] [ 2 ] - ls [ 0 ] [ 0 ] : ans = ' No ' print ( ans ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] ans = " Yes " for i in range ( 2 ) : for j in range ( 2 ) : if c [ i + 1 ] [ j + 1 ] - c [ i ] [ j + 1 ] ! = c [ i + 1 ] [ j ] - c [ i ] [ j ] : ans = " No " break if c [ i + 1 ] [ j + 1 ] - c [ i + 1 ] [ j ] ! = c [ i ] [ j + 1 ] - c [ i ] [ j ] : ans = " No " break print ( ans ) grid = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] yokosa = [ grid [ 0 ] [ i ] - grid [ 0 ] [ i - 1 ] for i in range ( 1 , 3 ) ] for y in range ( 1 , 3 ) : tmp = [ grid [ y ] [ i ] - grid [ y ] [ i - 1 ] for i in range ( 1 , 3 ) ] if yokosa ! = tmp : print ( ' No ' ) exit ( ) tatesa = [ grid [ i ] [ 0 ] - grid [ i - 1 ] [ 0 ] for i in range ( 1 , 3 ) ] for x in range ( 1 , 3 ) : tmp = [ grid [ i ] [ x ] - grid [ i - 1 ] [ x ] for i in range ( 1 , 3 ) ] if tatesa ! = tmp : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) ans = ' No ' for i in range ( c11 + 1 ) : a1 = i b1 = c11 - a1 a2 = c21 - b1 b2 = c12 - a1 a3 = c31 - b1 b3 = c13 - a1 if ( a2 + b2 = = c22 ) and ( a2 + b3 = = c23 ) and ( a3 + b2 = = c32 ) and ( a3 + b3 = = c33 ) : ans = ' Yes ' break print ( ans ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a1 = 0 b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 a2 = c [ 1 ] [ 0 ] - b1 a3 = c [ 2 ] [ 0 ] - b1 ans = [ [ a1 + b1 , a1 + b2 , a1 + b3 ] , [ a2 + b1 , a2 + b2 , a2 + b3 ] , [ a3 + b1 , a3 + b2 , a3 + b3 ] ] for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] = = ans [ i ] [ j ] : pass else : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) count = 0 if c21 - c11 = = c22 - c12 = = c23 - c13 : count + = 1 if c31 - c21 = = c32 - c22 = = c33 - c23 : count + = 1 if c12 - c11 = = c22 - c21 = = c32 - c31 : count + = 1 if c13 - c12 = = c23 - c22 = = c33 - c32 : count + = 1 if count = = 4 : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 2 ) : for j in range ( 2 ) : if c [ i ] [ j ] - c [ i ] [ j + 1 ] = = c [ i + 1 ] [ j ] - c [ i + 1 ] [ j + 1 ] : pass else : print ( ' No ' ) exit ( ) print ( ' Yes ' ) import sys import itertools sys . setrecursionlimit ( 1000000000 ) from heapq import heapify , heappop , heappush , heappushpop import math import collections import copy import bisect if _ _ name _ _ = = " _ _ main _ _ " : c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) a1 = 0 b1 = c1 [ 0 ] b2 = c1 [ 1 ] b3 = c1 [ 2 ] b = [ b1 , b2 , b3 ] a2 = c2 [ 0 ] - b1 for i in range ( 3 ) : d = c2 [ i ] - b [ i ] if a2 ! = d : print ( " No " ) sys . exit ( ) a3 = c3 [ 0 ] - b1 for i in range ( 3 ) : d = c3 [ i ] - b [ i ] if a3 ! = d : print ( " No " ) sys . exit ( ) print ( " Yes " ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) n = ' No ' if c21 - c11 = = c22 - c12 = = c23 - c13 : if c31 - c11 = = c32 - c12 = = c33 - c13 : if c12 - c11 = = c22 - c21 = = c32 - c31 : if c13 - c11 = = c23 - c21 = = c33 - c31 : print ( ' Yes ' ) else : print ( n ) else : print ( n ) else : print ( n ) else : print ( n ) pre _ x , pre _ y , pre _ z = None , None , None for i in range ( 3 ) : x , y , z = map ( int , input ( ) . split ( ) ) if pre _ x is None : pre _ x , pre _ y , pre _ z = x , y , z else : if pre _ y - pre _ x ! = y - x or pre _ z - pre _ y ! = z - y or x - pre _ x ! = y - pre _ y or y - pre _ y ! = z - pre _ z : print ( ' No ' ) break else : print ( ' Yes ' ) l = [ ] for i in range ( 3 ) : l . append ( list ( map ( int , input ( ) . split ( ) ) ) ) ch = [ ] for i in l : ch . append ( [ i [ 0 ] - i [ 1 ] , i [ 1 ] - i [ 2 ] ] ) if ch [ 0 ] = = ch [ 1 ] and ch [ 1 ] = = ch [ 2 ] : print ( " Yes " ) else : print ( " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] x = [ list ( ) for _ in range ( 2 ) ] y = [ list ( ) for _ in range ( 2 ) ] for i in range ( 3 ) : for j in range ( 2 ) : x [ j ] . append ( C [ i ] [ j ] - C [ i ] [ j + 1 ] ) y [ j ] . append ( C [ j ] [ i ] - C [ j + 1 ] [ i ] ) out = False for j in range ( 2 ) : if min ( x [ j ] ) ! = max ( x [ j ] ) : break if min ( y [ j ] ) ! = max ( y [ j ] ) : break else : print ( " Yes " ) out = True if not out : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] r1 = sum ( c [ 0 ] [ j ] for j in range ( 3 ) ) r2 = sum ( c [ 1 ] [ j ] for j in range ( 3 ) ) r3 = sum ( c [ 2 ] [ j ] for j in range ( 3 ) ) c1 = sum ( c [ i ] [ 0 ] for i in range ( 3 ) ) c2 = sum ( c [ i ] [ 1 ] for i in range ( 3 ) ) c3 = sum ( c [ i ] [ 2 ] for i in range ( 3 ) ) if r1 % 3 = = r2 % 3 = = r3 % 3 and c1 % 3 = = c2 % 3 = = c3 % 3 : print ( " Yes " ) else : print ( " No " ) import sys read = sys . stdin . read readline = sys . stdin . readline readlines = sys . stdin . readlines sys . setrecursionlimit ( 10 * * 9 ) INF = 1 < < 60 MOD = 1000000007 def main ( ) : C = [ list ( map ( int , readline ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 3 ) : if ( not C [ ( i + 1 ) % 3 ] [ 0 ] - C [ i ] [ 0 ] = = C [ ( i + 1 ) % 3 ] [ 1 ] - C [ i ] [ 1 ] = = C [ ( i + 1 ) % 3 ] [ 2 ] - C [ i ] [ 2 ] ) : print ( ' No ' ) return if ( not C [ 0 ] [ ( i + 1 ) % 3 ] - C [ 0 ] [ i ] = = C [ 1 ] [ ( i + 1 ) % 3 ] - C [ 1 ] [ i ] = = C [ 2 ] [ ( i + 1 ) % 3 ] - C [ 2 ] [ i ] ) : print ( ' No ' ) return print ( ' Yes ' ) return if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) grid = [ ] for i in range ( 3 ) : c = list ( map ( int , input ( ) . split ( ) ) ) grid . append ( c ) a1 = 0 b1 = grid [ 0 ] [ 0 ] - a1 b2 = grid [ 0 ] [ 1 ] - a1 b3 = grid [ 0 ] [ 2 ] - a1 a21 = grid [ 1 ] [ 0 ] - b1 a22 = grid [ 1 ] [ 1 ] - b2 a23 = grid [ 1 ] [ 2 ] - b3 a31 = grid [ 2 ] [ 0 ] - b1 a32 = grid [ 2 ] [ 1 ] - b2 a33 = grid [ 2 ] [ 2 ] - b3 if a21 = = a22 = = a23 : if a31 = = a32 = = a33 : print ( ' Yes ' ) exit ( ) print ( ' No ' ) import numpy as np c = [ [ 0 ] * 3 ] * 3 for i in range ( 3 ) : c [ i ] = list ( map ( int , input ( ) . split ( ) ) ) c = np . array ( c ) if len ( set ( c [ 0 ] - c [ 1 ] ) ) = = 1 and len ( set ( c [ 1 ] - c [ 2 ] ) ) = = 1 and len ( set ( c [ : , 0 ] - c [ : , 1 ] ) ) = = 1 and len ( set ( c [ : , 1 ] - c [ : , 2 ] ) ) = = 1 : print ( " Yes " ) else : print ( " No " ) def solve ( ) : if not ( c11 - c21 = = c12 - c22 = = c13 - c23 ) : return False if not ( c11 - c31 = = c12 - c32 = = c13 - c33 ) : return False if not ( c11 - c12 = = c21 - c22 = = c31 - c32 ) : return False if not ( c11 - c13 = = c21 - c23 = = c31 - c33 ) : return False return True c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) print ( ' Yes ' if solve ( ) else ' No ' ) def ii ( ) : return int ( input ( ) ) def iim ( ) : return map ( int , input ( ) . split ( ) ) def iil ( ) : return list ( map ( int , input ( ) . split ( ) ) ) def ism ( ) : return map ( str , input ( ) . split ( ) ) def isl ( ) : return list ( map ( str , input ( ) . split ( ) ) ) l = [ ] for i in range ( 3 ) : l . append ( iil ( ) ) f = True for i in range ( 1 , 3 ) : dif0 = l [ i ] [ 0 ] - l [ i - 1 ] [ 0 ] dif1 = l [ i ] [ 1 ] - l [ i - 1 ] [ 1 ] dif2 = l [ i ] [ 2 ] - l [ i - 1 ] [ 2 ] if dif0 = = dif1 = = dif2 : continue f = False for i in range ( 1 , 3 ) : dif0 = l [ 0 ] [ i ] - l [ 0 ] [ i - 1 ] dif1 = l [ 1 ] [ i ] - l [ 1 ] [ i - 1 ] dif2 = l [ 2 ] [ i ] - l [ 2 ] [ i - 1 ] if dif0 = = dif1 = = dif2 : continue f = False print ( ' Yes ' if f else ' No ' ) import numpy as np C = [ ] for _ in range ( 3 ) : c = list ( map ( int , input ( ) . split ( ) ) ) C . append ( c ) A = np . array ( [ [ 1 , 0 , 0 , 1 , 0 , 0 ] , [ 0 , 1 , 0 , 1 , 0 , 0 ] , [ 0 , 0 , 1 , 1 , 0 , 0 ] , [ 1 , 0 , 0 , 0 , 1 , 0 ] , [ 0 , 1 , 0 , 0 , 1 , 0 ] , [ 0 , 0 , 1 , 0 , 1 , 0 ] , [ 1 , 0 , 0 , 0 , 0 , 1 ] , [ 0 , 1 , 0 , 0 , 0 , 1 ] , [ 0 , 0 , 1 , 0 , 0 , 1 ] , ] ) Aplus = np . array ( [ [ 1 , 0 , 0 , 1 , 0 , 0 , C [ 0 ] [ 0 ] ] , [ 0 , 1 , 0 , 1 , 0 , 0 , C [ 1 ] [ 0 ] ] , [ 0 , 0 , 1 , 1 , 0 , 0 , C [ 2 ] [ 0 ] ] , [ 1 , 0 , 0 , 0 , 1 , 0 , C [ 0 ] [ 1 ] ] , [ 0 , 1 , 0 , 0 , 1 , 0 , C [ 1 ] [ 1 ] ] , [ 0 , 0 , 1 , 0 , 1 , 0 , C [ 2 ] [ 1 ] ] , [ 1 , 0 , 0 , 0 , 0 , 1 , C [ 0 ] [ 2 ] ] , [ 0 , 1 , 0 , 0 , 0 , 1 , C [ 1 ] [ 2 ] ] , [ 0 , 0 , 1 , 0 , 0 , 1 , C [ 2 ] [ 2 ] ] , ] ) rankA = np . linalg . matrix _ rank ( A ) rankAp = np . linalg . matrix _ rank ( Aplus ) if rankA = = rankAp : print ( ' Yes ' ) else : print ( ' No ' ) import numpy as np IN = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] c = np . array ( IN ) column = np . sum ( c , axis = 0 ) row = np . sum ( c , axis = 1 ) S = np . sum ( c ) if S % 3 = = 0 : S _ = S / / 3 for i in range ( S _ + 1 ) : x = i y = S _ - x row _ = row - y column _ = column - x if all ( col % 3 = = 0 for col in column _ ) and all ( ro % 3 = = 0 for ro in row _ ) : print ( " Yes " ) break else : print ( " No " ) else : print ( " No " ) import sys import pprint as pp def II ( ) : return int ( sys . stdin . readline ( ) ) def MI ( ) : return map ( int , sys . stdin . readline ( ) . split ( ) ) def LI ( ) : return list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) def LLI ( rows _ number ) : return [ LI ( ) for _ in range ( rows _ number ) ] yes = " Yes " no = " No " def solver ( c _ grid ) : result = no a _ list = [ 0 , c _ grid [ 1 ] [ 0 ] - c _ grid [ 0 ] [ 0 ] , c _ grid [ 2 ] [ 0 ] - c _ grid [ 0 ] [ 0 ] ] b _ list = [ c _ grid [ 0 ] [ 0 ] , c _ grid [ 0 ] [ 1 ] , c _ grid [ 0 ] [ 2 ] ] if ( c _ grid [ 1 ] [ 1 ] = = a _ list [ 1 ] + b _ list [ 1 ] ) and \ ( c _ grid [ 1 ] [ 2 ] = = a _ list [ 1 ] + b _ list [ 2 ] ) and \ ( c _ grid [ 2 ] [ 1 ] = = a _ list [ 2 ] + b _ list [ 1 ] ) and \ ( c _ grid [ 2 ] [ 2 ] = = a _ list [ 2 ] + b _ list [ 2 ] ) : result = yes return result if _ _ name _ _ = = " _ _ main _ _ " : c _ grid = list ( ) for _ in range ( 3 ) : c _ grid . append ( LI ( ) ) print ( " { } " . format ( solver ( c _ grid ) ) ) c = [ ] for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) x = [ 0 ] * 3 y = [ 0 ] * 3 for i in range ( 3 ) : y [ i ] = c [ 0 ] [ i ] for i in range ( 3 ) : x [ i ] = c [ i ] [ 0 ] - y [ 0 ] answer = ' Yes ' for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = x [ i ] + y [ j ] : answer = ' No ' print ( answer ) import sys X = [ [ int ( x ) for x in input ( ) . split ( ) ] for _ in range ( 3 ) ] for i in range ( min ( X [ 0 ] ) + 1 ) : t1 = [ x - i for x in X [ 0 ] ] for j in range ( min ( X [ 1 ] ) + 1 ) : t2 = [ x - j for x in X [ 1 ] ] for k in range ( min ( X [ 2 ] ) + 1 ) : t3 = [ x - k for x in X [ 2 ] ] if t1 = = t2 = = t3 : print ( ' Yes ' ) sys . exit ( ) print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] flag = 0 for i in range ( 2 ) : for j in range ( 2 ) : if c [ i ] [ j ] + c [ i + 1 ] [ j + 1 ] ! = c [ i + 1 ] [ j ] + c [ i ] [ j + 1 ] : flag = 1 if flag = = 1 : print ( " No " ) else : print ( " Yes " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] c1 = [ c [ i ] [ i ] for i in range ( 3 ) ] c2 = [ sum ( i ) for i in c ] print ( ' Yes ' if sum ( c1 ) * 3 = = sum ( c2 ) else ' No ' ) c = [ ] for i in range ( 3 ) : box = list ( map ( int , input ( ) . split ( ) ) ) c . append ( box ) for i in range ( 101 ) : a1 = i b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 if c [ 1 ] [ 0 ] - b1 = = c [ 1 ] [ 1 ] - b2 = = c [ 1 ] [ 2 ] - b3 : if c [ 2 ] [ 0 ] - b1 = = c [ 2 ] [ 1 ] - b2 = = c [ 2 ] [ 2 ] - b3 : print ( ' Yes ' ) exit ( ) print ( ' No ' ) import sys c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] if not ( c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] ) : print ( " No " ) sys . exit ( ) if not ( c [ 0 ] [ 0 ] - c [ 0 ] [ 2 ] = = c [ 1 ] [ 0 ] - c [ 1 ] [ 2 ] = = c [ 2 ] [ 0 ] - c [ 2 ] [ 2 ] ) : print ( " No " ) sys . exit ( ) if not ( c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] = = c [ 2 ] [ 1 ] - c [ 2 ] [ 2 ] ) : print ( " No " ) sys . exit ( ) if not ( c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] = = c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] ) : print ( " No " ) sys . exit ( ) if not ( c [ 0 ] [ 0 ] - c [ 2 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 2 ] [ 1 ] = = c [ 0 ] [ 2 ] - c [ 2 ] [ 2 ] ) : print ( " No " ) sys . exit ( ) if not ( c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 2 ] [ 2 ] ) : print ( " No " ) sys . exit ( ) print ( " Yes " ) import sys input = sys . stdin . readline C = [ [ 0 ] * 3 for i in range ( 3 ) ] def exit _ if _ not _ eq ( i , j ) : if i ! = j : print ( " No " ) exit ( ) for i in range ( 3 ) : C [ i ] = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( C [ 0 ] [ 0 ] + 1 ) : a1 = i b1 = C [ 0 ] [ 0 ] - a1 if b1 < 0 : continue b2 = C [ 0 ] [ 1 ] - a1 if b2 < 0 : continue b3 = C [ 0 ] [ 2 ] - a1 if b3 < 0 : continue a2 = C [ 1 ] [ 0 ] - b1 if a2 < 0 : continue if C [ 1 ] [ 1 ] ! = a2 + b2 : continue if C [ 1 ] [ 2 ] ! = a2 + b3 : continue a3 = C [ 2 ] [ 0 ] - b1 if a3 < 0 : continue if C [ 2 ] [ 1 ] ! = a3 + b2 : continue if C [ 2 ] [ 2 ] ! = a3 + b3 : continue print ( " Yes " ) exit ( ) print ( " No " ) c = list ( list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ) d = [ 0 , 1 , 2 , 0 , 1 ] x = c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] ok = True for i in range ( 3 ) : a = c [ d [ i ] ] [ 0 ] + c [ d [ i + 1 ] ] [ 1 ] + c [ d [ i + 2 ] ] [ 2 ] b = c [ d [ i ] ] [ 2 ] + c [ d [ i + 1 ] ] [ 1 ] + c [ d [ i + 2 ] ] [ 0 ] if x ! = a or x ! = b : ok = False print ( ' Yes ' if ok else ' No ' ) M = [ ] for _ in range ( 3 ) : m = list ( map ( int , input ( ) . split ( ) ) ) M . append ( m ) for a1 in range ( 100 ) : b1 = M [ 0 ] [ 0 ] - a1 b2 = M [ 0 ] [ 1 ] - a1 b3 = M [ 0 ] [ 2 ] - a1 a2 = M [ 1 ] [ 0 ] - b1 a3 = M [ 2 ] [ 0 ] - b1 if ( a2 + b2 ) = = M [ 1 ] [ 1 ] and ( a2 + b3 ) = = M [ 1 ] [ 2 ] and ( a3 + b2 ) = = M [ 2 ] [ 1 ] and ( a3 + b3 ) = = M [ 2 ] [ 2 ] : print ( ' Yes ' ) exit ( ) print ( ' No ' ) C = [ [ int ( _ ) for _ in input ( ) . split ( ) ] for _ in range ( 3 ) ] B = C [ 0 ] A = ( 0 , C [ 1 ] [ 1 ] - B [ 1 ] , C [ 2 ] [ 2 ] - B [ 2 ] ) for i in range ( 3 ) : for j in range ( 3 ) : v = A [ i ] + B [ j ] if not v = = C [ i ] [ j ] : print ( " No " ) exit ( 0 ) print ( " Yes " ) import sys import numpy as np input = sys . stdin . readline def I ( ) : return int ( input ( ) ) def MI ( ) : return map ( int , input ( ) . split ( ) ) def LI ( ) : return list ( map ( int , input ( ) . split ( ) ) ) def TL ( mylist ) : return np . array ( mylist ) . T . tolist ( ) mylist1 = [ list ( map ( int , input ( ) . rstrip ( ) . split ( ) ) ) for i in range ( 3 ) ] mylist2 = TL ( mylist1 ) def chech ( mylist ) : result = True b1 = mylist [ 0 ] [ 0 ] - mylist [ 0 ] [ 1 ] c1 = mylist [ 0 ] [ 0 ] - mylist [ 0 ] [ 2 ] for i in range ( 1 , 3 ) : if ( mylist [ i ] [ 0 ] - mylist [ i ] [ 1 ] ) ! = b1 or ( mylist [ i ] [ 0 ] - mylist [ i ] [ 2 ] ) ! = c1 : result = False break return result if chech ( mylist1 ) and chech ( mylist2 ) : print ( " Yes " ) else : print ( " No " ) c _ list = [ ] for i in range ( 3 ) : c _ list . append ( [ int ( i ) for i in input ( ) . split ( ) ] ) for a1 in range ( 101 ) : b1 = c _ list [ 0 ] [ 0 ] - a1 a2 = c _ list [ 1 ] [ 0 ] - b1 a3 = c _ list [ 2 ] [ 0 ] - b1 b2 = c _ list [ 0 ] [ 1 ] - a1 b3 = c _ list [ 0 ] [ 2 ] - a1 if a2 + b2 = = c _ list [ 1 ] [ 1 ] and a2 + b3 = = c _ list [ 1 ] [ 2 ] and a3 + b2 = = c _ list [ 2 ] [ 1 ] and a3 + b3 = = c _ list [ 2 ] [ 2 ] : print ( ' Yes ' ) exit ( ) print ( ' No ' ) import sys sys . setrecursionlimit ( 10 * * 8 ) ini = lambda : int ( sys . stdin . readline ( ) ) inm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) inl = lambda : list ( inm ( ) ) ins = lambda : sys . stdin . readline ( ) . rstrip ( ) debug = lambda * a , * * kw : print ( " \ 033 " , * a , " \ 033 " , * * dict ( file = sys . stderr , * * kw ) ) C = [ inl ( ) for _ in range ( 3 ) ] def solve ( ) : a10 = C [ 1 ] [ 0 ] - C [ 0 ] [ 0 ] if C [ 1 ] [ 1 ] - C [ 0 ] [ 1 ] ! = a10 or C [ 1 ] [ 2 ] - C [ 0 ] [ 2 ] ! = a10 : return False a21 = C [ 2 ] [ 0 ] - C [ 1 ] [ 0 ] if C [ 2 ] [ 1 ] - C [ 1 ] [ 1 ] ! = a21 or C [ 2 ] [ 2 ] - C [ 1 ] [ 2 ] ! = a21 : return False b10 = C [ 0 ] [ 1 ] - C [ 0 ] [ 0 ] if C [ 1 ] [ 1 ] - C [ 1 ] [ 0 ] ! = b10 or C [ 2 ] [ 1 ] - C [ 2 ] [ 0 ] ! = b10 : return False b21 = C [ 0 ] [ 2 ] - C [ 0 ] [ 1 ] if C [ 1 ] [ 2 ] - C [ 1 ] [ 1 ] ! = b21 or C [ 2 ] [ 2 ] - C [ 2 ] [ 1 ] ! = b21 : return False return True print ( " Yes " if solve ( ) else " No " ) import sys tmp = input ( ) . split ( ) a = list ( map ( lambda a : int ( a ) , tmp ) ) tmp = input ( ) . split ( ) b = list ( map ( lambda a : int ( a ) , tmp ) ) tmp = input ( ) . split ( ) c = list ( map ( lambda a : int ( a ) , tmp ) ) if ( a [ 0 ] - b [ 0 ] = = a [ 1 ] - b [ 1 ] ) and ( a [ 1 ] - b [ 1 ] = = a [ 2 ] - b [ 2 ] ) : if ( a [ 0 ] - c [ 0 ] = = a [ 1 ] - c [ 1 ] ) and ( a [ 1 ] - c [ 1 ] = = a [ 2 ] - c [ 2 ] ) : if ( c [ 0 ] - b [ 0 ] = = c [ 1 ] - b [ 1 ] ) and ( c [ 1 ] - b [ 1 ] = = c [ 2 ] - b [ 2 ] ) : if ( a [ 0 ] - a [ 1 ] = = b [ 0 ] - b [ 1 ] ) and ( b [ 0 ] - b [ 1 ] = = c [ 0 ] - c [ 1 ] ) : if ( a [ 2 ] - a [ 1 ] = = b [ 2 ] - b [ 1 ] ) and ( b [ 2 ] - b [ 1 ] = = c [ 2 ] - c [ 1 ] ) : if ( a [ 0 ] - a [ 2 ] = = b [ 0 ] - b [ 2 ] ) and ( b [ 0 ] - b [ 2 ] = = c [ 0 ] - c [ 2 ] ) : print ( " Yes " ) sys . exit ( ) print ( " No " ) import sys import numpy as np grid = np . array ( sys . stdin . read ( ) . split ( ) , dtype = np . int8 ) . reshape ( 3 , 3 ) def main ( ) : grid [ : , : ] - = grid [ 0 ] grid [ : , : ] - = grid [ : , 0 ] [ : , None ] print ( ' No ' if np . any ( grid ) else ' Yes ' ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) cube = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a = True x = [ 0 ] * 3 y = [ 0 ] * 3 x [ 0 ] = 0 y [ 0 ] = cube [ 0 ] [ 0 ] - x [ 0 ] y [ 1 ] = cube [ 0 ] [ 1 ] - x [ 0 ] y [ 2 ] = cube [ 0 ] [ 2 ] - x [ 0 ] x [ 1 ] = cube [ 1 ] [ 0 ] - y [ 0 ] x [ 2 ] = cube [ 2 ] [ 0 ] - y [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if not ( x [ i ] + y [ j ] = = cube [ i ] [ j ] ) : a = False if a : print ( " Yes " ) else : print ( " No " ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) d = c12 - c11 e = c13 - c12 f = c21 - c11 g = c31 - c21 c12 - = c11 c13 - = c11 c21 - = c11 c22 - = c11 c23 - = c11 c31 - = c11 c32 - = c11 c33 - = c11 c11 - = c11 ok = 1 ok & = ( c11 = = 0 ) ok & = ( c12 = = d ) ok & = ( c13 = = d + e ) ok & = ( c21 = = f ) ok & = ( c22 = = f + d ) ok & = ( c23 = = f + d + e ) ok & = ( c31 = = f + g ) ok & = ( c32 = = f + g + d ) ok & = ( c33 = = f + g + d + e ) if ok : print ( " Yes " ) else : print ( " No " ) def resolve ( ) : c = [ ] c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) a01 = c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] a02 = c [ 0 ] [ 0 ] - c [ 0 ] [ 2 ] a12 = c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] b01 = c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] b02 = c [ 0 ] [ 0 ] - c [ 2 ] [ 0 ] b12 = c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] for i in range ( 3 ) : if ( ( c [ i ] [ 0 ] - c [ i ] [ 1 ] ) ! = a01 ) or ( c [ i ] [ 0 ] - c [ i ] [ 2 ] ! = a02 ) or ( c [ i ] [ 1 ] - c [ i ] [ 2 ] ! = a12 ) : return False if ( ( c [ 0 ] [ i ] - c [ 1 ] [ i ] ) ! = b01 or ( c [ 0 ] [ i ] - c [ 2 ] [ i ] ) ! = b02 or ( c [ 1 ] [ i ] - c [ 2 ] [ i ] ) ! = b12 ) : return False return True if _ _ name _ _ = = " _ _ main _ _ " : if ( resolve ( ) ) : print ( " Yes " ) else : print ( " No " ) c = [ ] for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) if ( c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] and c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] = = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] and c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 1 ] [ 1 ] and c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 2 ] [ 1 ] and c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] and c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] and c [ 0 ] [ 0 ] - c [ 2 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 2 ] [ 1 ] and c [ 0 ] [ 0 ] - c [ 2 ] [ 0 ] = = c [ 0 ] [ 2 ] - c [ 2 ] [ 2 ] ) : print ( " Yes " ) else : print ( " No " ) a = [ 0 ] * 3 b = [ 0 ] * 3 C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 3 ) : a [ i ] = C [ 0 ] [ i ] for i in range ( 3 ) : b [ i ] = C [ i ] [ 0 ] - a [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if a [ j ] + b [ i ] ! = C [ i ] [ j ] : print ( " No " ) exit ( ) print ( " Yes " ) import numpy as np array = np . zeros ( ( 3 , 3 ) , dtype = " int8 " ) for i in range ( 3 ) : inputs = [ int ( x ) for x in input ( ) . split ( ) ] for j in range ( 3 ) : array [ i , j ] = inputs [ j ] b _ 1 = array [ 0 , 0 ] b _ 2 = array [ 0 , 1 ] b _ 3 = array [ 0 , 2 ] a _ 2 = array [ 1 , 0 ] - b _ 1 a _ 3 = array [ 2 , 0 ] - b _ 1 if ( array [ 1 , 1 ] = = ( a _ 2 + b _ 2 ) ) & ( array [ 2 , 2 ] = = ( a _ 3 + b _ 3 ) ) & ( array [ 1 , 2 ] = = ( a _ 2 + b _ 3 ) ) & ( array [ 2 , 1 ] = = ( a _ 3 + b _ 2 ) ) : flag = 1 else : flag = 0 if flag : print ( " Yes " ) else : print ( " No " ) import numpy as np C = np . array ( [ [ int ( x ) for x in input ( ) . split ( ) ] for _ in range ( 3 ) ] ) ans = ' Yes ' for i in range ( 2 ) : if not ( C [ 0 , i + 1 ] - C [ 0 , i ] = = C [ 1 , i + 1 ] - C [ 1 , i ] = = C [ 2 , i + 1 ] - C [ 2 , i ] ) : ans = ' No ' if not ( C [ i + 1 , 0 ] - C [ i , 0 ] = = C [ i + 1 , 1 ] - C [ i , 1 ] = = C [ i + 1 , 2 ] - C [ i , 2 ] ) : ans = ' No ' print ( ans ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a1 = 0 a2 = 0 a3 = 0 b1 = 0 b2 = 0 b3 = 0 m = min ( c [ 0 ] ) for i in range ( m + 1 ) : a1 = i b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 0 ] [ 1 ] - a2 b3 = c [ 0 ] [ 2 ] - a3 if c [ 1 ] [ 0 ] - b1 = = c [ 1 ] [ 1 ] - b2 = = c [ 1 ] [ 2 ] - b3 : a2 = c [ 1 ] [ 0 ] - b1 else : continue if c [ 2 ] [ 0 ] - b1 = = c [ 2 ] [ 1 ] - b2 = = c [ 2 ] [ 2 ] - b3 : print ( ' Yes ' ) exit ( ) print ( ' No ' ) mat = [ ] for i in range ( 3 ) : array = list ( map ( int , input ( ) . split ( ) ) ) mat . append ( array ) diff _ tate = [ ] for i in range ( 2 ) : diff _ tate . append ( [ mat [ i ] [ 0 ] - mat [ 2 ] [ 0 ] , mat [ i ] [ 1 ] - mat [ 2 ] [ 1 ] , mat [ i ] [ 2 ] - mat [ 2 ] [ 2 ] ] ) diff _ yoko = [ ] for i in range ( 2 ) : diff _ yoko . append ( [ mat [ 0 ] [ i ] - mat [ 0 ] [ 2 ] , mat [ 1 ] [ i ] - mat [ 1 ] [ 2 ] , mat [ 2 ] [ i ] - mat [ 2 ] [ 2 ] ] ) for diff in diff _ tate + diff _ yoko : dset = set ( diff ) if len ( dset ) > 1 : print ( " No " ) break else : print ( " Yes " ) src = [ ] src . append ( list ( map ( int , input ( ) . split ( ) ) ) ) src . append ( list ( map ( int , input ( ) . split ( ) ) ) ) src . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for n1 , n2 in zip ( [ 0 , 1 , 2 ] , [ 1 , 2 , 0 ] ) : if not len ( set ( s [ n1 ] - s [ n2 ] for s in src ) ) = = 1 or \ not len ( set ( s1 - s2 for s1 , s2 in zip ( src [ n1 ] , src [ n2 ] ) ) ) = = 1 : dst = " No " break else : dst = " Yes " print ( dst ) C1 = list ( map ( int , input ( ) . split ( ) ) ) C2 = list ( map ( int , input ( ) . split ( ) ) ) C3 = list ( map ( int , input ( ) . split ( ) ) ) if C1 [ 1 ] - C1 [ 0 ] = = C2 [ 1 ] - C2 [ 0 ] = = C3 [ 1 ] - C3 [ 0 ] and C1 [ 2 ] - C1 [ 1 ] = = C2 [ 2 ] - C2 [ 1 ] = = C3 [ 2 ] - C3 [ 1 ] : if C2 [ 0 ] - C1 [ 0 ] = = C2 [ 1 ] - C1 [ 1 ] = = C2 [ 2 ] - C1 [ 2 ] and C3 [ 0 ] - C2 [ 0 ] = = C3 [ 1 ] - C2 [ 1 ] = = C3 [ 2 ] - C2 [ 2 ] : print ( " Yes " ) else : print ( " No " ) else : print ( " No " ) c _ 0 = list ( map ( int , input ( ) . split ( ) ) ) c _ 1 = list ( map ( int , input ( ) . split ( ) ) ) c _ 2 = list ( map ( int , input ( ) . split ( ) ) ) c = [ c _ 0 , c _ 1 , c _ 2 ] for a _ 0 in range ( 100 + 1 ) : for a _ 1 in range ( 100 + 1 ) : for a _ 2 in range ( 100 + 1 ) : b _ 0 = c [ 0 ] [ 0 ] - a _ 0 b _ 1 = c [ 0 ] [ 1 ] - a _ 0 b _ 2 = c [ 0 ] [ 2 ] - a _ 0 a = [ a _ 0 , a _ 1 , a _ 2 ] b = [ b _ 0 , b _ 1 , b _ 2 ] flag = True for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] = = a [ i ] + b [ j ] : continue else : flag = False if flag : print ( ' Yes ' ) exit ( ) print ( ' No ' ) C = [ ] for _ in range ( 3 ) : c = list ( map ( int , input ( ) . split ( ) ) ) C . append ( c ) a = [ 0 , C [ 1 ] [ 1 ] - C [ 0 ] [ 1 ] , C [ 2 ] [ 1 ] - C [ 0 ] [ 1 ] ] b = [ C [ 0 ] [ 0 ] , C [ 0 ] [ 1 ] , C [ 0 ] [ 2 ] ] ans = [ [ a [ 0 ] + b [ 0 ] , a [ 0 ] + b [ 1 ] , a [ 0 ] + b [ 2 ] ] , [ a [ 1 ] + b [ 0 ] , a [ 1 ] + b [ 1 ] , a [ 1 ] + b [ 2 ] ] , [ a [ 2 ] + b [ 0 ] , a [ 2 ] + b [ 1 ] , a [ 2 ] + b [ 2 ] ] ] if ans = = C : print ( " Yes " ) else : print ( " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] ans = ' Yes ' for i in range ( 1 , 3 ) : if C [ 0 ] [ i ] - C [ 1 ] [ i ] ! = C [ 0 ] [ 0 ] - C [ 1 ] [ 0 ] : ans = ' No ' break if C [ 0 ] [ i ] - C [ 2 ] [ i ] ! = C [ 0 ] [ 0 ] - C [ 2 ] [ 0 ] : ans = ' No ' break if C [ i ] [ 0 ] - C [ i ] [ 1 ] ! = C [ 0 ] [ 0 ] - C [ 0 ] [ 1 ] : ans = ' No ' break if C [ i ] [ 0 ] - C [ i ] [ 2 ] ! = C [ 0 ] [ 0 ] - C [ 0 ] [ 2 ] : ans = ' No ' break print ( ans ) a , b , c = map ( int , input ( ) . split ( ) ) s = ' Yes ' for _ in [ 0 ] * 2 : x , y , z = map ( int , input ( ) . split ( ) ) if not x - a = = y - b = = z - c : s = ' No ' print ( s ) c = [ [ int ( i ) for i in input ( ) . split ( ) ] for j in range ( 3 ) ] ans = True for i in range ( 2 ) : check = c [ i + 1 ] [ 0 ] - c [ i ] [ 0 ] for j in range ( 1 , 3 ) : if check ! = c [ i + 1 ] [ j ] - c [ i ] [ j ] : ans = False break for i in range ( 2 ) : check = c [ 0 ] [ i + 1 ] - c [ 0 ] [ i ] for j in range ( 1 , 3 ) : if check ! = c [ j ] [ i + 1 ] - c [ j ] [ i ] : ans = False break print ( ' Yes ' if ans else ' No ' ) grid = [ [ - 1 ] * 4 for i in range ( 4 ) ] for i in range ( 1 , 4 ) : grid [ i ] [ 1 ] , grid [ i ] [ 2 ] , grid [ i ] [ 3 ] = map ( int , input ( ) . split ( ) ) grid [ i ] [ 0 ] = min ( grid [ i ] [ 1 ] , grid [ i ] [ 2 ] , grid [ i ] [ 3 ] ) isOK = False for i in range ( grid [ 1 ] [ 0 ] + 1 ) : grid [ 0 ] [ 0 ] = i grid [ 0 ] [ 1 ] = grid [ 1 ] [ 1 ] - i grid [ 0 ] [ 2 ] = grid [ 1 ] [ 2 ] - i grid [ 0 ] [ 3 ] = grid [ 1 ] [ 3 ] - i if grid [ 2 ] [ 1 ] - grid [ 0 ] [ 1 ] = = grid [ 2 ] [ 2 ] - grid [ 0 ] [ 2 ] and grid [ 2 ] [ 2 ] - grid [ 0 ] [ 2 ] = = grid [ 2 ] [ 3 ] - grid [ 0 ] [ 3 ] : if grid [ 3 ] [ 1 ] - grid [ 0 ] [ 1 ] = = grid [ 3 ] [ 2 ] - grid [ 0 ] [ 2 ] and grid [ 3 ] [ 2 ] - grid [ 0 ] [ 2 ] = = grid [ 3 ] [ 3 ] - grid [ 0 ] [ 3 ] : isOK = True break if isOK : print ( ' Yes ' ) else : print ( ' No ' ) c _ li = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] res = 0 for i in range ( c _ li [ 0 ] [ 0 ] + 1 ) : a1 = i b1 = c _ li [ 0 ] [ 0 ] - a1 b2 = c _ li [ 0 ] [ 1 ] - a1 b3 = c _ li [ 0 ] [ 2 ] - a1 a2 = c _ li [ 1 ] [ 0 ] - b1 a3 = c _ li [ 2 ] [ 0 ] - b1 if c _ li [ 1 ] [ 1 ] ! = a2 + b2 : continue if c _ li [ 1 ] [ 2 ] ! = a2 + b3 : continue if c _ li [ 2 ] [ 1 ] ! = a3 + b2 : continue if c _ li [ 2 ] [ 2 ] ! = a3 + b3 : continue res = 1 if res = = 0 : print ( " No " ) else : print ( " Yes " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] ans = True row = C [ 0 ] for i in range ( 1 , 3 ) : for j in range ( 3 ) : C [ i ] [ j ] - = C [ 0 ] [ j ] if row ! = C [ i ] and len ( set ( C [ i ] ) ) ! = 1 : ans = False print ( " Yes " if ans else " No " ) lis1 = [ ] lis2 = [ ] lis3 = [ ] count = 0 for num in input ( ) . split ( ) : lis1 . append ( int ( num ) ) for num in input ( ) . split ( ) : lis2 . append ( int ( num ) ) for num in input ( ) . split ( ) : lis3 . append ( int ( num ) ) if lis1 [ 0 ] - lis2 [ 0 ] = = lis1 [ 1 ] - lis2 [ 1 ] = = lis1 [ 2 ] - lis2 [ 2 ] : count + = 1 if lis1 [ 0 ] - lis3 [ 0 ] = = lis1 [ 1 ] - lis3 [ 1 ] = = lis1 [ 2 ] - lis3 [ 2 ] : count + = 1 if lis1 [ 0 ] - lis1 [ 1 ] = = lis2 [ 0 ] - lis2 [ 1 ] = = lis3 [ 0 ] - lis3 [ 1 ] : count + = 1 if lis1 [ 0 ] - lis1 [ 2 ] = = lis2 [ 0 ] - lis2 [ 2 ] = = lis3 [ 0 ] - lis3 [ 2 ] : count + = 1 if count = = 4 : print ( " Yes " ) else : print ( " No " ) c _ matrix = [ ] for _ in range ( 3 ) : c _ list = list ( map ( int , input ( ) . split ( ) ) ) c _ matrix . append ( c _ list ) a _ matrix = [ ] a _ list = [ ] b _ list = [ ] a _ list . append ( 0 ) b _ list . append ( c _ matrix [ 0 ] [ 0 ] ) b _ list . append ( c _ matrix [ 0 ] [ 1 ] ) b _ list . append ( c _ matrix [ 0 ] [ 2 ] ) a _ list . append ( c _ matrix [ 1 ] [ 0 ] - b _ list [ 0 ] ) a _ list . append ( c _ matrix [ 2 ] [ 0 ] - b _ list [ 0 ] ) is _ ok = True for i in range ( 3 ) : for j in range ( 3 ) : if a _ list [ i ] + b _ list [ j ] ! = c _ matrix [ i ] [ j ] : is _ ok = False break if not is _ ok : break ans = ' Yes ' if is _ ok else ' No ' print ( ans ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) ma1 = max ( c11 , c12 , c13 ) + 1 ma2 = max ( c21 , c22 , c23 ) + 1 ma3 = max ( c31 , c32 , c33 ) + 1 mb1 = max ( c11 , c21 , c31 ) + 1 mb2 = max ( c12 , c22 , c32 ) + 1 mb3 = max ( c13 , c23 , c33 ) + 1 for a1 in range ( ma1 ) : for b1 in range ( mb1 ) : if a1 + b1 ! = c11 : continue for a2 in range ( ma2 ) : if a2 + b1 ! = c21 : continue for b2 in range ( mb2 ) : if a1 + b2 ! = c12 or a2 + b2 ! = c22 : continue for a3 in range ( ma3 ) : if a3 + b1 ! = c31 or a3 + b2 ! = c32 : continue for b3 in range ( mb3 ) : if a1 + b3 ! = c13 or a2 + b3 ! = c23 or a3 + b3 ! = c33 : continue print ( ' Yes ' ) exit ( ) print ( ' No ' ) c = [ ] for _ in range ( 3 ) : c . append ( tuple ( map ( int , input ( ) . split ( ) ) ) ) for a1 in range ( 0 , 1 ) : b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 a2 = c [ 1 ] [ 0 ] - b1 a3 = c [ 2 ] [ 0 ] - b1 if c [ 1 ] [ 1 ] = = a2 + b2 and c [ 1 ] [ 2 ] = = a2 + b3 and c [ 2 ] [ 1 ] = = a3 + b2 and c [ 2 ] [ 2 ] = = a3 + b3 : print ( ' Yes ' ) break else : print ( ' No ' ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] A = [ ] B = [ ] for i in range ( 3 ) : A . append ( [ C [ 0 ] [ i ] - C [ 1 ] [ i ] , C [ 1 ] [ i ] - C [ 2 ] [ i ] , C [ 2 ] [ i ] - C [ 0 ] [ i ] ] ) for i in range ( 3 ) : B . append ( [ C [ i ] [ 0 ] - C [ i ] [ 1 ] , C [ i ] [ 1 ] - C [ i ] [ 2 ] , C [ i ] [ 2 ] - C [ i ] [ 0 ] ] ) ans = ' Yes ' if A [ 0 ] ! = A [ 1 ] : ans = ' No ' elif A [ 1 ] ! = A [ 2 ] : ans = ' No ' elif B [ 0 ] ! = B [ 1 ] : ans = ' No ' elif B [ 1 ] ! = B [ 2 ] : ans = ' No ' print ( ans ) c1 , c2 , c3 = map ( int , input ( ) . split ( ) ) c4 , c5 , c6 = map ( int , input ( ) . split ( ) ) c7 , c8 , c9 = map ( int , input ( ) . split ( ) ) if c7 - c4 = = c8 - c5 = = c9 - c6 and c4 - c1 = = c5 - c2 = = c6 - c3 and c3 - c2 = = c6 - c5 = = c9 - c8 and c2 - c1 = = c5 - c4 = = c8 - c7 : print ( " Yes " ) else : print ( " No " ) li = [ ] li . append ( list ( map ( int , input ( ) . split ( ) ) ) ) li . append ( list ( map ( int , input ( ) . split ( ) ) ) ) li . append ( list ( map ( int , input ( ) . split ( ) ) ) ) ans = ' Yes ' for a0 in range ( li [ 0 ] [ 0 ] + 1 ) : b0 = li [ 0 ] [ 0 ] - a0 b1 = li [ 1 ] [ 0 ] - a0 b2 = li [ 2 ] [ 0 ] - a0 a1 = li [ 0 ] [ 1 ] - b0 a2 = li [ 0 ] [ 2 ] - b0 if li [ 0 ] [ 0 ] ! = a0 + b0 : ans = ' No ' if li [ 0 ] [ 1 ] ! = a1 + b0 : ans = ' No ' if li [ 0 ] [ 2 ] ! = a2 + b0 : ans = ' No ' if li [ 1 ] [ 0 ] ! = a0 + b1 : ans = ' No ' if li [ 1 ] [ 1 ] ! = a1 + b1 : ans = ' No ' if li [ 1 ] [ 2 ] ! = a2 + b1 : ans = ' No ' if li [ 2 ] [ 0 ] ! = a0 + b2 : ans = ' No ' if li [ 2 ] [ 1 ] ! = a1 + b2 : ans = ' No ' if li [ 2 ] [ 2 ] ! = a2 + b2 : ans = ' No ' print ( ans ) import numpy as np c = np . array ( [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] ) f = True for i in range ( 2 ) : d = c [ i , 0 ] - c [ i + 1 , 0 ] for j in range ( 2 ) : if c [ i , j + 1 ] - c [ i + 1 , j + 1 ] ! = d : f = False for i in range ( 2 ) : d = c [ 0 , i ] - c [ 0 , i + 1 ] for j in range ( 2 ) : if c [ j + 1 , i ] - c [ j + 1 , i + 1 ] ! = d : f = False print ( ' Yes ' if f else ' No ' ) c = [ ] for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) ab = [ 0 , c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] , c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] , c [ 0 ] [ 0 ] , c [ 0 ] [ 1 ] , c [ 0 ] [ 2 ] ] ans = " Yes " for i in range ( 3 ) : if ans = = " Yes " : for j in range ( 3 ) : if c [ i ] [ j ] ! = ab [ i ] + ab [ 3 + j ] : ans = " No " break print ( ans ) res = 0 a = [ ] a . append ( list ( map ( int , input ( ) . split ( ) ) ) ) a . append ( list ( map ( int , input ( ) . split ( ) ) ) ) a . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for j in range ( 2 ) : s = a [ 0 ] [ j ] - a [ 0 ] [ j + 1 ] t = a [ 1 ] [ j ] - a [ 1 ] [ j + 1 ] u = a [ 2 ] [ j ] - a [ 2 ] [ j + 1 ] if s = = t and t = = u : res = res + 1 for j in range ( 2 ) : s = a [ j ] [ 0 ] - a [ j + 1 ] [ 0 ] t = a [ j ] [ 1 ] - a [ j + 1 ] [ 1 ] u = a [ j ] [ 2 ] - a [ j + 1 ] [ 2 ] if s = = t and t = = u : res = res + 1 if res = = 4 : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in [ 0 ] * 3 ] x1 , x2 , y1 , y2 = c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] , c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] , c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] , c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] for i in range ( 1 , 3 ) : if c [ i ] [ 0 ] - c [ i ] [ 1 ] ! = x1 or c [ i ] [ 1 ] - c [ i ] [ 2 ] ! = x2 : print ( ' No ' ) exit ( ) if c [ 0 ] [ i ] - c [ 1 ] [ i ] ! = y1 or c [ 1 ] [ i ] - c [ 2 ] [ i ] ! = y2 : print ( ' No ' ) exit ( ) print ( ' Yes ' ) line1 = list ( map ( int , input ( ) . split ( ) ) ) line2 = list ( map ( int , input ( ) . split ( ) ) ) line3 = list ( map ( int , input ( ) . split ( ) ) ) b1 = [ line1 [ 1 ] - line1 [ 0 ] , line1 [ 2 ] - line1 [ 0 ] ] b2 = [ line2 [ 1 ] - line2 [ 0 ] , line2 [ 2 ] - line2 [ 0 ] ] b3 = [ line3 [ 1 ] - line3 [ 0 ] , line3 [ 2 ] - line3 [ 0 ] ] a1 = [ line2 [ 0 ] - line1 [ 0 ] , line3 [ 0 ] - line1 [ 0 ] ] a2 = [ line2 [ 1 ] - line1 [ 1 ] , line3 [ 1 ] - line1 [ 1 ] ] a3 = [ line2 [ 2 ] - line1 [ 2 ] , line3 [ 2 ] - line1 [ 2 ] ] check = False if b1 [ 0 ] = = b2 [ 0 ] and b1 [ 0 ] = = b3 [ 0 ] : if b1 [ 1 ] = = b2 [ 1 ] and b1 [ 1 ] = = b3 [ 1 ] : if a1 [ 0 ] = = a2 [ 0 ] and a1 [ 0 ] = = a3 [ 0 ] : if a1 [ 1 ] = = a2 [ 1 ] and a1 [ 1 ] = = a3 [ 1 ] : check = True if check : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] for i in range ( 101 ) : info = True a1 = i b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 a2 = c [ 1 ] [ 0 ] - b1 a3 = c [ 2 ] [ 0 ] - b1 if min ( a1 , a2 , a3 , b1 , b2 , b3 ) < 0 : info = False if c [ 1 ] [ 1 ] ! = a2 + b2 : info = False if c [ 2 ] [ 1 ] ! = a3 + b2 : info = False if c [ 1 ] [ 2 ] ! = a2 + b3 : info = False if c [ 2 ] [ 2 ] ! = a3 + b3 : info = False if info : print ( " Yes " ) break else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a = [ 0 , - 1 , - 1 ] b = [ 0 , 0 , 0 ] for i in range ( 3 ) : b [ i ] = c [ 0 ] [ i ] - a [ 0 ] a [ 1 ] = c [ 1 ] [ 1 ] - b [ 1 ] a [ 2 ] = c [ 2 ] [ 1 ] - b [ 1 ] flag = True for i in range ( 3 ) : for j in range ( 3 ) : if a [ i ] + b [ j ] = = c [ i ] [ j ] : pass else : flag = False break if flag : print ( ' Yes ' ) else : print ( ' No ' ) c = [ input ( ) . split ( ) for _ in range ( 3 ) ] for a1 in range ( 101 ) : b1 = int ( c [ 0 ] [ 0 ] ) - a1 if b1 < 0 : continue b2 = int ( c [ 0 ] [ 1 ] ) - a1 if b2 < 0 : continue b3 = int ( c [ 0 ] [ 2 ] ) - a1 if b3 < 0 : continue a2 = int ( c [ 1 ] [ 0 ] ) - b1 if a2 < 0 : continue a3 = int ( c [ 2 ] [ 0 ] ) - b1 if a3 < 0 : continue if int ( c [ 1 ] [ 1 ] ) ! = ( a2 + b2 ) : continue if int ( c [ 1 ] [ 2 ] ) ! = ( a2 + b3 ) : continue if int ( c [ 2 ] [ 1 ] ) ! = ( a3 + b2 ) : continue if int ( c [ 2 ] [ 2 ] ) ! = ( a3 + b3 ) : continue print ( " Yes " ) break else : print ( " No " ) li1 = list ( map ( int , input ( ) . split ( ) ) ) li2 = list ( map ( int , input ( ) . split ( ) ) ) li3 = list ( map ( int , input ( ) . split ( ) ) ) dyoko1 = li1 [ 1 ] - li1 [ 0 ] dyoko2 = li1 [ 2 ] - li1 [ 1 ] dtate1 = li2 [ 0 ] - li1 [ 0 ] dtate2 = li3 [ 0 ] - li2 [ 0 ] if li2 [ 1 ] - li2 [ 0 ] ! = dyoko1 or li3 [ 1 ] - li3 [ 0 ] ! = dyoko1 : print ( " No " ) exit ( ) elif li2 [ 2 ] - li2 [ 1 ] ! = dyoko2 or li3 [ 2 ] - li3 [ 1 ] ! = dyoko2 : print ( " No " ) exit ( ) elif li2 [ 1 ] - li1 [ 1 ] ! = dtate1 or li2 [ 2 ] - li1 [ 2 ] ! = dtate1 : print ( " No " ) exit ( ) elif li3 [ 1 ] - li2 [ 1 ] ! = dtate2 or li3 [ 2 ] - li2 [ 2 ] ! = dtate2 : print ( " No " ) exit ( ) print ( " Yes " ) C = [ ] for _ in range ( 3 ) : c = list ( map ( int , input ( ) . split ( ) ) ) C . append ( c ) ans = ' Yes ' for i in range ( 2 ) : d = C [ 2 ] [ i + 1 ] - C [ 2 ] [ i ] for j in range ( 2 ) : if C [ j ] [ i + 1 ] - C [ j ] [ i ] ! = d : ans = ' No ' print ( ans ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) s = c11 + c22 + c33 if s - c12 - c23 ! = c31 or s - c13 - c32 ! = c21 : print ( " No " ) else : print ( " Yes " ) inp = [ ] inp . append ( list ( map ( int , input ( ) . split ( ) ) ) ) inp . append ( list ( map ( int , input ( ) . split ( ) ) ) ) inp . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in range ( 101 ) : flag = 0 a1 = i b1 = inp [ 0 ] [ 0 ] - a1 if b1 < 0 : flag = 1 a2 = inp [ 0 ] [ 1 ] - b1 if a2 < 0 : flag = 1 a3 = inp [ 0 ] [ 2 ] - b1 if a3 < 0 : flag = 1 if inp [ 1 ] [ 0 ] - a1 ! = inp [ 1 ] [ 1 ] - a2 or inp [ 1 ] [ 0 ] - a1 ! = inp [ 1 ] [ 2 ] - a3 : flag = 1 if inp [ 2 ] [ 0 ] - a1 ! = inp [ 2 ] [ 1 ] - a2 or inp [ 2 ] [ 0 ] - a1 ! = inp [ 2 ] [ 2 ] - a3 : flag = 1 if flag = = 0 : print ( " Yes " ) exit ( ) print ( " No " ) x = list ( map ( int , input ( ) . split ( ) ) ) y = list ( map ( int , input ( ) . split ( ) ) ) z = list ( map ( int , input ( ) . split ( ) ) ) a = ( sum ( x ) + sum ( y ) + sum ( z ) ) / 3 b = x [ 0 ] + y [ 1 ] + z [ 2 ] c = x [ 1 ] + y [ 2 ] + z [ 0 ] d = x [ 2 ] + y [ 0 ] + z [ 1 ] if a = = b = = c = = d : print ( ' Yes ' ) else : print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for b1 in range ( 101 ) : a = [ c [ 0 ] [ 0 ] - b1 , c [ 1 ] [ 0 ] - b1 , c [ 2 ] [ 0 ] - b1 ] b = [ b1 , c [ 0 ] [ 1 ] - a [ 0 ] , c [ 0 ] [ 2 ] - a [ 0 ] ] if all ( a [ i ] + b [ j ] = = c [ i ] [ j ] for j in range ( 3 ) for i in range ( 3 ) ) : print ( ' Yes ' ) exit ( ) print ( ' No ' ) import sys import math import os class cin ( ) : def int ( ) : return int ( sys . stdin . readline ( ) . rstrip ( ) ) def string ( ) : return sys . stdin . readline ( ) . rstrip ( ) def mapInt ( ) : return [ int ( x ) for x in cin . string ( ) . split ( ) ] class Util ( ) : def round _ up ( a , b ) : return - ( - a / / b ) def toUpperMultiple ( a , x ) : return Util . round _ up ( a , x ) * x def toLowerMultiple ( a , x ) : return ( a / / x ) * x C = [ [ int ( x ) for x in cin . string ( ) . split ( ) ] for y in range ( 3 ) ] for a1 in range ( 0 , 100 + 1 ) : b1 = C [ 0 ] [ 0 ] - a1 b2 = C [ 0 ] [ 1 ] - a1 b3 = C [ 0 ] [ 2 ] - a1 a2 = C [ 1 ] [ 0 ] - b1 a3 = C [ 2 ] [ 0 ] - b1 m = [ [ a1 + b1 , a1 + b2 , a1 + b3 ] , [ a2 + b1 , a2 + b2 , a2 + b3 ] , [ a3 + b1 , a3 + b2 , a3 + b3 ] ] if m = = C : print ( " Yes " ) sys . exit ( ) print ( " No " ) import sys sys . setrecursionlimit ( 10 * * 7 ) input = sys . stdin . readline f _ inf = float ( ' inf ' ) mod = 10 * * 9 + 7 def resolve ( ) : C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] A = [ 0 ] * 3 B = [ 0 ] * 3 for i in range ( 3 ) : B [ i ] = C [ 0 ] [ i ] - A [ 0 ] for j in range ( 3 ) : A [ j ] = C [ j ] [ 0 ] - B [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if A [ i ] + B [ j ] ! = C [ i ] [ j ] : print ( " No " ) break else : continue break else : print ( " Yes " ) if _ _ name _ _ = = ' _ _ main _ _ ' : resolve ( ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a1 = 0 b1 = C [ 0 ] [ 0 ] - a1 b2 = C [ 0 ] [ 1 ] - a1 b3 = C [ 0 ] [ 2 ] - a1 a2 = C [ 1 ] [ 1 ] - b2 a3 = C [ 2 ] [ 2 ] - b3 As = [ a1 , a2 , a3 ] Bs = [ b1 , b2 , b3 ] for i in range ( 3 ) : for j in range ( 3 ) : if C [ i ] [ j ] ! = As [ i ] + Bs [ j ] : print ( " No " ) exit ( ) print ( " Yes " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] flag = ' Yes ' for i in range ( 2 ) : if c [ 0 ] [ i + 1 ] - c [ 0 ] [ i ] = = c [ 1 ] [ i + 1 ] - c [ 1 ] [ i ] = = c [ 2 ] [ i + 1 ] - c [ 2 ] [ i ] : pass else : flag = ' No ' for j in range ( 2 ) : if c [ j + 1 ] [ 0 ] - c [ j ] [ 0 ] = = c [ j + 1 ] [ 1 ] - c [ j ] [ 1 ] = = c [ j + 1 ] [ 2 ] - c [ j ] [ 2 ] : pass else : flag = ' No ' print ( flag ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] j = True for i in range ( 2 ) : if abs ( c [ i + 1 ] [ 0 ] - c [ i ] [ 0 ] ) = = abs ( c [ i + 1 ] [ 1 ] - c [ i ] [ 1 ] ) = = abs ( c [ i + 1 ] [ 2 ] - c [ i ] [ 2 ] ) : pass else : j = False for i in range ( 2 ) : if abs ( c [ 0 ] [ i + 1 ] - c [ 0 ] [ i ] ) = = abs ( c [ 1 ] [ i + 1 ] - c [ 1 ] [ i ] ) = = abs ( c [ 2 ] [ i + 1 ] - c [ 2 ] [ i ] ) : pass else : j = False if j : print ( " Yes " ) else : print ( " No " ) grid = [ ] for i in range ( 3 ) : grid . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in range ( 101 ) : a1 = i b = [ grid [ 0 ] [ 0 ] - a1 , grid [ 0 ] [ 1 ] - a1 , grid [ 0 ] [ 2 ] - a1 ] flag = True for j in range ( 1 , 3 ) : for k in range ( 2 ) : if grid [ j ] [ k ] - b [ k ] ! = grid [ j ] [ k + 1 ] - b [ k + 1 ] : flag = False if flag : print ( " Yes " ) exit ( ) print ( " No " ) ii = 3 s = [ ] icase = 0 if icase = = 0 : for i in range ( ii ) : s . append ( list ( map ( int , input ( ) . split ( ) ) ) ) elif icase = = 1 : s . append ( [ 1 , 0 , 1 ] ) s . append ( [ 2 , 1 , 2 ] ) s . append ( [ 1 , 0 , 1 ] ) yn = 1 for i in range ( ii - 1 ) : if ( s [ i ] [ 1 ] - s [ i ] [ 0 ] ) ! = ( s [ i + 1 ] [ 1 ] - s [ i + 1 ] [ 0 ] ) : yn = 0 for i in range ( ii - 1 ) : if ( s [ i ] [ 2 ] - s [ i ] [ 0 ] ) ! = ( s [ i + 1 ] [ 2 ] - s [ i + 1 ] [ 0 ] ) : yn = 0 for j in range ( ii - 1 ) : if ( s [ 1 ] [ j ] - s [ 0 ] [ j ] ) ! = ( s [ 1 ] [ j + 1 ] - s [ 0 ] [ j + 1 ] ) : yn = 0 for j in range ( ii - 1 ) : if ( s [ 2 ] [ j ] - s [ 0 ] [ j ] ) ! = ( s [ 2 ] [ j + 1 ] - s [ 0 ] [ j + 1 ] ) : yn = 0 if yn = = 1 : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] if ( c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] ) and ( c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 2 ] [ 0 ] ) and ( c [ 2 ] [ 1 ] - c [ 2 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] ) and ( c [ 0 ] [ 2 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 2 ] - c [ 1 ] [ 0 ] ) and ( c [ 1 ] [ 2 ] - c [ 1 ] [ 0 ] = = c [ 2 ] [ 2 ] - c [ 2 ] [ 0 ] ) and ( c [ 2 ] [ 2 ] - c [ 2 ] [ 0 ] = = c [ 0 ] [ 2 ] - c [ 0 ] [ 0 ] ) : print ( " Yes " ) else : print ( " No " ) c _ 1 = list ( map ( int , input ( ) . split ( ) ) ) c _ 2 = list ( map ( int , input ( ) . split ( ) ) ) c _ 3 = list ( map ( int , input ( ) . split ( ) ) ) diff = [ ] for i in range ( 2 ) : diff . append ( c _ 1 [ i ] - c _ 1 [ i + 1 ] ) if c _ 2 [ 0 ] - c _ 2 [ 1 ] ! = diff [ 0 ] or c _ 2 [ 1 ] - c _ 2 [ 2 ] ! = diff [ 1 ] : print ( " No " ) exit ( ) if c _ 3 [ 0 ] - c _ 3 [ 1 ] ! = diff [ 0 ] or c _ 3 [ 1 ] - c _ 3 [ 2 ] ! = diff [ 1 ] : print ( " No " ) exit ( ) print ( " Yes " ) c = [ [ int ( i ) for i in input ( ) . split ( ) ] for i in range ( 3 ) ] ans = ' Yes ' for j in range ( 2 ) : if c [ j ] [ 0 ] - c [ j + 1 ] [ 0 ] = = c [ j ] [ 1 ] - c [ j + 1 ] [ 1 ] = = c [ j ] [ 2 ] - c [ j + 1 ] [ 2 ] : ans = ' Yes ' else : ans = ' No ' print ( ans ) exit ( ) for j in range ( 2 ) : if c [ 0 ] [ j ] - c [ 0 ] [ j + 1 ] = = c [ 1 ] [ j ] - c [ 1 ] [ j + 1 ] = = c [ 2 ] [ j ] - c [ 2 ] [ j + 1 ] : ans = ' Yes ' else : ans = ' No ' print ( ans ) exit ( ) print ( ans ) def input ( ) : import sys return sys . stdin . readline ( ) . rstrip ( ) def main ( ) : import math import collections import itertools cs = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 2 ) : tmp _ diff = [ 0 ] * 3 for j in range ( 3 ) : tmp _ diff [ j ] = cs [ i ] [ j ] - cs [ i + 1 ] [ j ] if len ( set ( tmp _ diff ) ) = = 1 : pass else : print ( " No " ) exit ( ) for i in range ( 2 ) : tmp _ diff = [ 0 ] * 3 for j in range ( 3 ) : tmp _ diff [ j ] = cs [ j ] [ i ] - cs [ j ] [ i + 1 ] if len ( set ( tmp _ diff ) ) = = 1 : pass else : print ( " No " ) exit ( ) print ( " Yes " ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) C = [ [ int ( x ) for x in input ( ) . split ( ) ] for _ in range ( 3 ) ] a = [ C [ 0 ] [ 0 ] , C [ 0 ] [ 1 ] , C [ 0 ] [ 2 ] ] b = [ 0 , C [ 1 ] [ 0 ] - C [ 0 ] [ 0 ] , C [ 2 ] [ 0 ] - C [ 0 ] [ 0 ] ] hantei = True for i in range ( 3 ) : for j in range ( 3 ) : if C [ i ] [ j ] ! = a [ j ] + b [ i ] : hantei = False print ( ' Yes ' if hantei else ' No ' ) import sys a = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] x1 , x2 = a [ 0 ] [ 0 ] - a [ 0 ] [ 1 ] , a [ 0 ] [ 0 ] - a [ 0 ] [ 2 ] for i in range ( 3 ) : if a [ i ] [ 0 ] - a [ i ] [ 1 ] ! = x1 or a [ i ] [ 0 ] - a [ i ] [ 2 ] ! = x2 : print ( " No " ) , sys . exit ( ) y1 , y2 = a [ 0 ] [ 0 ] - a [ 1 ] [ 0 ] , a [ 0 ] [ 0 ] - a [ 2 ] [ 0 ] for j in range ( 3 ) : if a [ 0 ] [ j ] - a [ 1 ] [ j ] ! = y1 or a [ 0 ] [ j ] - a [ 2 ] [ j ] ! = y2 : print ( " No " ) , sys . exit ( ) print ( " Yes " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] for a1 in range ( 101 ) : for a2 in range ( 101 ) : for a3 in range ( 101 ) : if ( c [ 0 ] [ 0 ] - a1 = = c [ 1 ] [ 0 ] - a2 = = c [ 2 ] [ 0 ] - a3 ) and ( c [ 0 ] [ 1 ] - a1 = = c [ 1 ] [ 1 ] - a2 = = c [ 2 ] [ 1 ] - a3 ) and ( c [ 0 ] [ 2 ] - a1 = = c [ 1 ] [ 2 ] - a2 = = c [ 2 ] [ 2 ] - a3 ) : print ( " Yes " ) exit ( ) else : print ( " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] x = C [ 0 ] [ 0 ] a = [ c [ 0 ] - x for c in C ] b = [ C [ 0 ] [ i ] - a [ 0 ] for i in range ( 3 ) ] ans = " Yes " for i in range ( 3 ) : for j in range ( 3 ) : if C [ i ] [ j ] ! = a [ i ] + b [ j ] : ans = " No " print ( ans ) l = [ [ int ( i ) for i in input ( ) . split ( ) ] for x in range ( 3 ) ] total1 = 0 total2 = 0 for i in range ( 3 ) : total1 + = sum ( l [ i ] ) total2 + = l [ i ] [ i ] if total1 = = total2 * 3 : print ( ' Yes ' ) else : print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] mx = 0 for i in range ( 3 ) : mx = max ( mx , max ( c [ i ] ) ) flag = True for i in range ( mx + 1 ) : d1 = [ c [ 0 ] [ 0 ] - i , c [ 0 ] [ 1 ] - i , c [ 0 ] [ 2 ] - i ] for j in range ( mx + 1 ) : d2 = [ c [ 1 ] [ 0 ] - j , c [ 1 ] [ 1 ] - j , c [ 1 ] [ 2 ] - j ] for k in range ( mx + 1 ) : d3 = [ c [ 2 ] [ 0 ] - k , c [ 2 ] [ 1 ] - k , c [ 2 ] [ 2 ] - k ] if d1 = = d2 = = d3 : flag = False print ( " YNeos " [ flag : : 2 ] ) c = { } for i in range ( 3 ) : ci0 , ci1 , ci2 = list ( map ( int , input ( ) . split ( ) ) ) c [ ( i , 0 ) ] = ci0 c [ ( i , 1 ) ] = ci1 c [ ( i , 2 ) ] = ci2 for ai in range ( 101 ) : a = { 0 : ai } b = { } for i in range ( 3 ) : for j in range ( 3 ) : if ( i in a ) and ( j in b ) : if a [ i ] + b [ j ] ! = c [ ( i , j ) ] : break else : pass elif ( i in a ) and ( not j in b ) : b [ j ] = c [ ( i , j ) ] - a [ i ] elif ( not i in a ) and ( j in b ) : a [ i ] = c [ ( i , j ) ] - b [ j ] if i = = 2 and j = = 2 : print ( ' Yes ' ) exit ( ) else : continue break print ( ' No ' ) import numpy as np c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] A = np . array ( [ [ 1 , 0 , 0 , 1 , 0 , 0 ] , [ 1 , 0 , 0 , 0 , 1 , 0 ] , [ 1 , 0 , 0 , 0 , 0 , 1 ] , [ 0 , 1 , 0 , 1 , 0 , 0 ] , [ 0 , 1 , 0 , 0 , 1 , 0 ] , [ 0 , 1 , 0 , 0 , 0 , 1 ] , [ 0 , 0 , 1 , 1 , 0 , 0 ] , [ 0 , 0 , 1 , 0 , 1 , 0 ] , [ 0 , 0 , 1 , 0 , 0 , 1 ] ] ) B = np . array ( [ [ 1 , 0 , 0 , 1 , 0 , 0 , c [ 0 ] [ 0 ] ] , [ 1 , 0 , 0 , 0 , 1 , 0 , c [ 0 ] [ 1 ] ] , [ 1 , 0 , 0 , 0 , 0 , 1 , c [ 0 ] [ 2 ] ] , [ 0 , 1 , 0 , 1 , 0 , 0 , c [ 1 ] [ 0 ] ] , [ 0 , 1 , 0 , 0 , 1 , 0 , c [ 1 ] [ 1 ] ] , [ 0 , 1 , 0 , 0 , 0 , 1 , c [ 1 ] [ 2 ] ] , [ 0 , 0 , 1 , 1 , 0 , 0 , c [ 2 ] [ 0 ] ] , [ 0 , 0 , 1 , 0 , 1 , 0 , c [ 2 ] [ 1 ] ] , [ 0 , 0 , 1 , 0 , 0 , 1 , c [ 2 ] [ 2 ] ] ] ) rankA = np . linalg . matrix _ rank ( A ) rankB = np . linalg . matrix _ rank ( B ) if rankA = = rankB : print ( ' Yes ' ) else : print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for k in range ( 3 ) ] A = [ sum ( a ) for a in c ] B = [ 0 , 0 , 0 ] AB = 0 for y in range ( 3 ) : for x in range ( 3 ) : if x = = y : AB + = c [ y ] [ x ] B [ x ] + = c [ y ] [ x ] for k in range ( 3 ) : t = ( A [ k ] + B [ k ] - AB ) if t > = 0 and t % 3 = = 0 : pass else : print ( " No " ) exit ( 0 ) print ( " Yes " ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) c = list ( map ( int , input ( ) . split ( ) ) ) a = ( a [ 1 ] - a [ 0 ] , a [ 2 ] - a [ 0 ] ) b = ( b [ 1 ] - b [ 0 ] , b [ 2 ] - b [ 0 ] ) c = ( c [ 1 ] - c [ 0 ] , c [ 2 ] - c [ 0 ] ) if a = = b and b = = c : print ( " Yes " ) else : print ( " No " ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) def wrong ( ) : print ( ' No ' ) exit ( ) if c12 - c11 = = c22 - c21 = = c32 - c31 : pass else : wrong ( ) if c13 - c11 = = c23 - c21 = = c33 - c31 : pass else : wrong ( ) if c13 - c12 = = c23 - c22 = = c33 - c32 : pass else : wrong ( ) if c21 - c11 = = c22 - c12 = = c23 - c13 : pass else : wrong ( ) if c31 - c11 = = c32 - c12 = = c33 - c13 : pass else : wrong ( ) if c31 - c21 = = c32 - c22 = = c33 - c23 : pass else : wrong ( ) print ( ' Yes ' ) from sys import stdin import sys [ c11 , c12 , c13 ] = list ( map ( int , stdin . readline ( ) . rstrip ( ) . split ( ) ) ) [ c21 , c22 , c23 ] = list ( map ( int , stdin . readline ( ) . rstrip ( ) . split ( ) ) ) [ c31 , c32 , c33 ] = list ( map ( int , stdin . readline ( ) . rstrip ( ) . split ( ) ) ) if ( ( c11 + c12 + c13 ) - ( c21 + c22 + c23 ) ) % 3 ! = 0 or ( ( c21 + c22 + c23 ) - ( c31 + c32 + c33 ) ) % 3 ! = 0 or ( ( c31 + c32 + c33 ) - ( c11 + c12 + c13 ) ) % 3 ! = 0 : print ( " No " ) elif ( ( c11 + c21 + c31 ) - ( c12 + c22 + c32 ) ) % 3 ! = 0 or ( ( c12 + c22 + c32 ) - ( c13 + c23 + c33 ) ) % 3 ! = 0 or ( ( c13 + c23 + c33 ) - ( c11 + c21 + c31 ) ) % 3 ! = 0 : print ( " No " ) else : print ( " Yes " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 1 , 3 ) : if C [ i ] [ 0 ] - C [ 0 ] [ 0 ] = = C [ i ] [ 1 ] - C [ 0 ] [ 1 ] and C [ i ] [ 0 ] - C [ 0 ] [ 0 ] = = C [ i ] [ 2 ] - C [ 0 ] [ 2 ] : pass else : print ( " No " ) exit ( ) print ( " Yes " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for j in range ( 2 ) : for i in range ( 3 ) : if i = = 0 : d = c [ i ] [ j + 1 ] - c [ i ] [ j ] else : if c [ i ] [ j + 1 ] - c [ i ] [ j ] ! = d : print ( ' No ' ) exit ( ) for i in range ( 2 ) : for j in range ( 3 ) : if j = = 0 : d = c [ i + 1 ] [ j ] - c [ i ] [ j ] else : if c [ i + 1 ] [ j ] - c [ i ] [ j ] ! = d : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] A1 = c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] A2 = c [ 2 ] [ 0 ] - c [ 1 ] [ 0 ] B1 = c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] B2 = c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] if c [ 1 ] [ 1 ] = = A1 + B1 + c [ 0 ] [ 0 ] and c [ 1 ] [ 2 ] = = A1 + B1 + B2 + c [ 0 ] [ 0 ] and c [ 2 ] [ 1 ] = = A1 + A2 + B1 + c [ 0 ] [ 0 ] and c [ 2 ] [ 2 ] = = A1 + A2 + B1 + B2 + c [ 0 ] [ 0 ] : print ( " Yes " ) else : print ( " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] dx1 = C [ 0 ] [ 1 ] - C [ 0 ] [ 0 ] dx2 = C [ 0 ] [ 2 ] - C [ 0 ] [ 1 ] dy1 = C [ 1 ] [ 0 ] - C [ 0 ] [ 0 ] dy2 = C [ 2 ] [ 0 ] - C [ 1 ] [ 0 ] Ans = " Yes " for i in range ( 3 ) : if ( C [ i ] [ 1 ] - C [ i ] [ 0 ] ! = dx1 or C [ i ] [ 2 ] - C [ i ] [ 1 ] ! = dx2 or C [ 1 ] [ i ] - C [ 0 ] [ i ] ! = dy1 or C [ 2 ] [ i ] - C [ 1 ] [ i ] ! = dy2 ) : Ans = " No " break print ( Ans ) c = [ input ( ) . split ( ) for i in range ( 3 ) ] a1 = 0 a2 = 0 a3 = 0 b1 = 0 b2 = 0 b3 = 0 flag = 0 for i in range ( 0 , 101 ) : for j in range ( 0 , 101 ) : for k in range ( 0 , 101 ) : if i + j = = int ( c [ 0 ] [ 0 ] ) and i + k = = int ( c [ 0 ] [ 1 ] ) : a1 = i b1 = j b2 = k b3 = int ( c [ 0 ] [ 2 ] ) - i if int ( c [ 1 ] [ 0 ] ) - b1 = = int ( c [ 1 ] [ 1 ] ) - b2 and int ( c [ 1 ] [ 1 ] ) - b2 = = int ( c [ 1 ] [ 2 ] ) - b3 and int ( c [ 1 ] [ 0 ] ) - b1 = = int ( c [ 1 ] [ 2 ] ) - b3 : if int ( c [ 2 ] [ 0 ] ) - b1 = = int ( c [ 2 ] [ 1 ] ) - b2 and int ( c [ 2 ] [ 1 ] ) - b2 = = int ( c [ 2 ] [ 2 ] ) - b3 and int ( c [ 2 ] [ 0 ] ) - b1 = = int ( c [ 2 ] [ 2 ] ) - b3 : flag = 1 if flag = = True : print ( " Yes " ) else : print ( " No " ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) a = c1 [ 0 ] + c2 [ 1 ] + c3 [ 2 ] b = c1 [ 1 ] + c2 [ 2 ] + c3 [ 0 ] c = c1 [ 2 ] + c2 [ 0 ] + c3 [ 1 ] d = c1 [ 0 ] + c2 [ 2 ] + c3 [ 1 ] e = c1 [ 1 ] + c2 [ 0 ] + c3 [ 2 ] f = c1 [ 2 ] + c2 [ 1 ] + c3 [ 0 ] if a = = b = = c = = d = = e = = f : print ( ' Yes ' ) else : print ( ' No ' ) A = list ( map ( int , input ( ) . split ( ) ) ) B = list ( map ( int , input ( ) . split ( ) ) ) C = list ( map ( int , input ( ) . split ( ) ) ) if ( A [ 0 ] - A [ 1 ] = = B [ 0 ] - B [ 1 ] = = C [ 0 ] - C [ 1 ] ) and ( A [ 1 ] - A [ 2 ] = = B [ 1 ] - B [ 2 ] = = C [ 1 ] - C [ 2 ] ) : print ( " Yes " ) else : print ( " No " ) lst = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] ans = ' No ' if ( lst [ 1 ] [ 0 ] - lst [ 0 ] [ 0 ] + lst [ 0 ] [ 1 ] = = lst [ 1 ] [ 1 ] and lst [ 1 ] [ 2 ] - lst [ 0 ] [ 2 ] + lst [ 0 ] [ 1 ] = = lst [ 1 ] [ 1 ] and lst [ 1 ] [ 0 ] - lst [ 2 ] [ 0 ] + lst [ 2 ] [ 1 ] = = lst [ 1 ] [ 1 ] and lst [ 1 ] [ 2 ] - lst [ 2 ] [ 2 ] + lst [ 2 ] [ 1 ] = = lst [ 1 ] [ 1 ] ) : ans = ' Yes ' print ( ans ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] b = [ 0 ] * 3 N = max ( max ( c ) ) + 1 for a1 in range ( N ) : for a2 in range ( N ) : for a3 in range ( N ) : b [ 0 ] = c [ 0 ] [ 0 ] - a1 b [ 1 ] = c [ 0 ] [ 1 ] - a1 b [ 2 ] = c [ 0 ] [ 2 ] - a1 flag = True nb = [ 0 ] * 3 for i in range ( 3 ) : nb [ i ] = c [ 1 ] [ i ] - a2 if nb [ i ] ! = b [ i ] : flag = False break for i in range ( 3 ) : nb [ i ] = c [ 2 ] [ i ] - a3 if nb [ i ] ! = b [ i ] : flag = False break if flag : import sys print ( ' Yes ' ) sys . exit ( ) print ( ' No ' ) ls = [ [ int ( _ ) for _ in input ( ) . split ( ) ] for _ in range ( 3 ) ] flag = [ 0 , 0 , 0 , 0 ] if ls [ 0 ] [ 0 ] - ls [ 1 ] [ 0 ] = = ls [ 0 ] [ 1 ] - ls [ 1 ] [ 1 ] and ls [ 0 ] [ 1 ] - ls [ 1 ] [ 1 ] = = ls [ 0 ] [ 2 ] - ls [ 1 ] [ 2 ] : flag [ 0 ] = 1 if ls [ 1 ] [ 0 ] - ls [ 2 ] [ 0 ] = = ls [ 1 ] [ 1 ] - ls [ 2 ] [ 1 ] and ls [ 1 ] [ 1 ] - ls [ 2 ] [ 1 ] = = ls [ 1 ] [ 2 ] - ls [ 2 ] [ 2 ] : flag [ 1 ] = 1 if ls [ 0 ] [ 0 ] - ls [ 0 ] [ 1 ] = = ls [ 1 ] [ 0 ] - ls [ 1 ] [ 1 ] and ls [ 1 ] [ 0 ] - ls [ 1 ] [ 1 ] = = ls [ 2 ] [ 0 ] - ls [ 2 ] [ 1 ] : flag [ 2 ] = 1 if ls [ 0 ] [ 1 ] - ls [ 0 ] [ 2 ] = = ls [ 1 ] [ 1 ] - ls [ 1 ] [ 2 ] and ls [ 1 ] [ 1 ] - ls [ 1 ] [ 2 ] = = ls [ 2 ] [ 1 ] - ls [ 2 ] [ 2 ] : flag [ 3 ] = 1 if sum ( flag ) = = 4 : print ( " Yes " ) else : print ( " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 for j in range ( 3 ) : b [ j ] = C [ 0 ] [ j ] - a [ 0 ] for i in range ( 3 ) : a [ i ] = C [ i ] [ 0 ] - b [ 0 ] ans = True for i in range ( 1 , 3 ) : for j in range ( 1 , 3 ) : if C [ i ] [ j ] ! = a [ i ] + b [ j ] : ans = False print ( ' Yes ' if ans else ' No ' ) c = [ ] for i in range ( 3 ) : c _ i = [ int ( a ) for a in input ( ) . split ( ) ] c . append ( c _ i ) if ( c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] = = c [ 0 ] [ 1 ] + c [ 1 ] [ 2 ] + c [ 2 ] [ 0 ] = = c [ 0 ] [ 2 ] + c [ 1 ] [ 0 ] + c [ 2 ] [ 1 ] ) : print ( " Yes " ) else : print ( " No " ) c = [ ] c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) ans = ' Yes ' if c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] ! = c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] or c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] ! = c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] : ans = ' No ' if c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] ! = c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] or c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] ! = c [ 1 ] [ 2 ] - c [ 2 ] [ 2 ] : ans = ' No ' if c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] ! = c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] or c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] ! = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] : ans = ' No ' if c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] ! = c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] or c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] ! = c [ 2 ] [ 1 ] - c [ 2 ] [ 2 ] : ans = ' No ' print ( ans ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] ans = " Yes " for i in range ( 2 ) : if c [ 0 ] [ i ] - c [ 0 ] [ i + 1 ] ! = c [ 1 ] [ i ] - c [ 1 ] [ i + 1 ] : ans = " No " elif c [ 1 ] [ i ] - c [ 1 ] [ i + 1 ] ! = c [ 2 ] [ i ] - c [ 2 ] [ i + 1 ] : ans = " No " elif c [ i ] [ 0 ] - c [ i + 1 ] [ 0 ] ! = c [ i ] [ 1 ] - c [ i + 1 ] [ 1 ] : ans = " No " elif c [ i ] [ 1 ] - c [ i + 1 ] [ 1 ] ! = c [ i ] [ 2 ] - c [ i + 1 ] [ 2 ] : ans = " No " print ( ans ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a = [ c [ 0 ] [ i ] - 0 for i in range ( 3 ) ] b = [ c [ i ] [ 0 ] - a [ 0 ] for i in range ( 3 ) ] d = [ [ a [ i ] + b [ j ] for i in range ( 3 ) ] for j in range ( 3 ) ] print ( ' Yes ' if c = = d else ' No ' ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) c1 _ m = c1 [ 0 ] c2 _ m = c2 [ 1 ] c3 _ m = c3 [ 2 ] for a _ 1 in range ( c1 _ m + 1 ) : b _ 1 = c1 _ m - a _ 1 for a _ 2 in range ( c2 _ m + 1 ) : b _ 2 = c2 _ m - a _ 2 for a _ 3 in range ( c3 _ m + 1 ) : b _ 3 = c3 _ m - a _ 3 flg = 0 if c1 [ 0 ] ! = ( a _ 1 + b _ 1 ) : flg + = 1 if c1 [ 1 ] ! = ( a _ 1 + b _ 2 ) : flg + = 1 if c1 [ 2 ] ! = ( a _ 1 + b _ 3 ) : flg + = 1 if c2 [ 0 ] ! = ( a _ 2 + b _ 1 ) : flg + = 1 if c2 [ 1 ] ! = ( a _ 2 + b _ 2 ) : flg + = 1 if c2 [ 2 ] ! = ( a _ 2 + b _ 3 ) : flg + = 1 if c3 [ 0 ] ! = ( a _ 3 + b _ 1 ) : flg + = 1 if c3 [ 1 ] ! = ( a _ 3 + b _ 2 ) : flg + = 1 if c3 [ 2 ] ! = ( a _ 3 + b _ 3 ) : flg + = 1 if flg = = 0 : print ( ' Yes ' ) exit ( 0 ) print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 for i in range ( 3 ) : b [ i ] = c [ 0 ] [ i ] - a [ 0 ] for i in range ( 1 , 3 ) : a [ i ] = c [ i ] [ 0 ] - b [ 0 ] ans = " Yes " for i in range ( 3 ) : for j in range ( 3 ) : if a [ i ] + b [ j ] ! = c [ i ] [ j ] : ans = " No " break else : continue break print ( ans ) import sys c = list ( ) for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) a = [ 0 ] * 3 b = [ 0 ] * 3 for i in range ( 3 ) : b [ i ] = c [ 0 ] [ i ] - a [ 0 ] a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = a [ i ] + b [ j ] : print ( " No " ) sys . exit ( ) print ( " Yes " ) X = list ( map ( int , input ( ) . split ( ) ) ) Y = list ( map ( int , input ( ) . split ( ) ) ) Z = list ( map ( int , input ( ) . split ( ) ) ) if ( X [ 0 ] - X [ 1 ] = = Y [ 0 ] - Y [ 1 ] and X [ 0 ] - X [ 1 ] = = Z [ 0 ] - Z [ 1 ] and X [ 2 ] - X [ 1 ] = = Y [ 2 ] - Y [ 1 ] and X [ 2 ] - X [ 1 ] = = Z [ 2 ] - Z [ 1 ] ) : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] b = list ( c [ 0 ] ) a = [ 0 , c [ 1 ] [ 0 ] - b [ 0 ] , c [ 2 ] [ 0 ] - b [ 0 ] ] for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = a [ i ] + b [ j ] : print ( " No " ) exit ( ) print ( " Yes " ) ans = ' Yes ' c = [ ] for _ in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) adiff = [ ] bdiff = [ ] for i in range ( 2 ) : adiff . append ( c [ i + 1 ] [ 0 ] - c [ i ] [ 0 ] ) bdiff . append ( c [ 0 ] [ i + 1 ] - c [ 0 ] [ i ] ) for i in range ( 1 , 3 ) : for j in range ( 1 , 3 ) : if adiff [ i - 1 ] ! = c [ i ] [ j ] - c [ i - 1 ] [ j ] or bdiff [ j - 1 ] ! = c [ i ] [ j ] - c [ i ] [ j - 1 ] : ans = ' No ' break print ( ans ) c = [ [ 0 , 0 , 0 ] , [ 0 , 0 , 0 ] , [ 0 , 0 , 0 ] ] ; c [ 0 ] = [ int ( x ) for x in input ( ) . split ( ) ] ; c [ 1 ] = [ int ( x ) for x in input ( ) . split ( ) ] ; c [ 2 ] = [ int ( x ) for x in input ( ) . split ( ) ] ; ans = ' true ' ; for i in range ( 1 , 3 ) : hdiff = c [ 0 ] [ i ] - c [ 0 ] [ i - 1 ] ; for j in range ( 1 , 3 ) : if c [ j ] [ i ] - c [ j ] [ i - 1 ] ! = hdiff : ans = ' false ' ; break ; for i in range ( 1 , 3 ) : vdiff = c [ i ] [ 0 ] - c [ i - 1 ] [ 0 ] ; for j in range ( 1 , 3 ) : if c [ i ] [ j ] - c [ i - 1 ] [ j ] ! = vdiff : ans = ' false ' ; break ; if ( ans = = ' true ' ) : print ( ' Yes ' ) ; else : print ( ' No ' ) ; c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] ans = " Yes " for i in range ( 2 ) : if c [ i + 1 ] [ 1 ] - c [ i + 1 ] [ 0 ] ! = c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] : ans = " No " if c [ i + 1 ] [ 2 ] - c [ i + 1 ] [ 1 ] ! = c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] : ans = " No " for j in range ( 2 ) : if c [ 1 ] [ i + 1 ] - c [ 0 ] [ i + 1 ] ! = c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] : ans = " No " if c [ 2 ] [ i + 1 ] - c [ 1 ] [ i + 1 ] ! = c [ 2 ] [ 0 ] - c [ 1 ] [ 0 ] : ans = " No " print ( ans ) row1 = list ( map ( int , input ( ) . split ( ) ) ) row2 = list ( map ( int , input ( ) . split ( ) ) ) row3 = list ( map ( int , input ( ) . split ( ) ) ) if ( row1 [ 1 ] - row1 [ 0 ] ! = row2 [ 1 ] - row2 [ 0 ] or row1 [ 1 ] - row1 [ 0 ] ! = row3 [ 1 ] - row3 [ 0 ] or row1 [ 2 ] - row1 [ 1 ] ! = row2 [ 2 ] - row2 [ 1 ] or row1 [ 2 ] - row1 [ 1 ] ! = row3 [ 2 ] - row3 [ 1 ] ) : print ( ' No ' ) elif ( row1 [ 0 ] - row2 [ 0 ] ! = row1 [ 1 ] - row2 [ 1 ] or row1 [ 0 ] - row2 [ 0 ] ! = row1 [ 2 ] - row2 [ 2 ] or row1 [ 0 ] - row3 [ 0 ] ! = row1 [ 1 ] - row3 [ 1 ] or row1 [ 0 ] - row3 [ 0 ] ! = row1 [ 2 ] - row3 [ 2 ] ) : print ( ' No ' ) else : print ( ' Yes ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] b1 , b2 , b3 = c [ 0 ] [ 0 ] , c [ 0 ] [ 1 ] , c [ 0 ] [ 2 ] if c [ 1 ] [ 0 ] - b1 = = c [ 1 ] [ 1 ] - b2 = = c [ 1 ] [ 2 ] - b3 and c [ 2 ] [ 0 ] - b1 = = c [ 2 ] [ 1 ] - b2 = = c [ 2 ] [ 2 ] - b3 : print ( ' Yes ' ) else : print ( ' No ' ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) def correct ( a1 , a2 , a3 , b1 , b2 , b3 ) : if a1 + b1 ! = c11 : return False if a2 + b2 ! = c22 : return False if a3 + b3 ! = c33 : return False if a1 + b2 ! = c12 : return False if a1 + b3 ! = c13 : return False if a2 + b1 ! = c21 : return False if a2 + b3 ! = c23 : return False if a3 + b1 ! = c31 : return False if a3 + b2 ! = c32 : return False return True for i in range ( c11 + 1 ) : a1 = i b1 = c11 - i a2 = a1 - c11 + c21 a3 = a1 - c11 + c31 b2 = b1 - c11 + c12 b3 = b1 - c11 + c13 if correct ( a1 , a2 , a3 , b1 , b2 , b3 ) : print ( ' Yes ' ) exit ( 0 ) print ( ' No ' ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) a = 0 if c13 - c12 = = c23 - c22 = = c33 - c32 : if c12 - c11 = = c22 - c21 = = c32 - c31 : if c33 - c23 = = c32 - c22 = = c31 - c21 : if c23 - c13 = = c22 - c12 = = c21 - c11 : print ( " Yes " ) a = 1 if a = = 0 : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ ] b = [ ] for i in range ( 1 , 3 ) : for j in range ( 3 ) : a . append ( c [ i ] [ j ] - c [ 0 ] [ j ] ) b . append ( c [ j ] [ i ] - c [ j ] [ 0 ] ) ans = ' No ' if a [ 0 ] = = a [ 1 ] and a [ 0 ] = = a [ 2 ] and a [ 3 ] = = a [ 4 ] and a [ 3 ] = = a [ 5 ] : if b [ 0 ] = = b [ 1 ] and b [ 0 ] = = b [ 2 ] and b [ 3 ] = = b [ 4 ] and b [ 3 ] = = b [ 5 ] : ans = ' Yes ' print ( ans ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for a0 in range ( - 100 , 201 ) : for a1 in range ( - 100 , 201 ) : for a2 in range ( - 100 , 201 ) : if c [ 0 ] [ 0 ] - a0 = = c [ 1 ] [ 0 ] - a1 = = c [ 2 ] [ 0 ] - a2 : if c [ 0 ] [ 1 ] - a0 = = c [ 1 ] [ 1 ] - a1 = = c [ 2 ] [ 1 ] - a2 : if c [ 0 ] [ 2 ] - a0 = = c [ 1 ] [ 2 ] - a1 = = c [ 2 ] [ 2 ] - a2 : print ( " Yes " ) exit ( ) print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a1 = c [ 0 ] [ 0 ] for i in range ( a1 + 1 ) : b1 = a1 - i b2 = c [ 0 ] [ 1 ] - i b3 = c [ 0 ] [ 2 ] - i a2 = c [ 1 ] [ 0 ] - b1 a3 = c [ 2 ] [ 0 ] - b1 if a2 + b2 = = c [ 1 ] [ 1 ] and a2 + b3 = = c [ 1 ] [ 2 ] and a3 + b2 = = c [ 2 ] [ 1 ] and a3 + b3 = = c [ 2 ] [ 2 ] : print ( ' Yes ' ) else : print ( ' No ' ) exit ( ) def main ( ) : c = [ list ( map ( int , input ( ) . split ( ' ' ) ) ) for _ in range ( 3 ) ] for i in range ( 3 ) : next _ i = ( i + 1 ) % 3 d = [ c [ i ] [ j ] - c [ next _ i ] [ j ] for j in range ( 3 ) ] if len ( set ( d ) ) > 1 : print ( ' No ' ) return for j in range ( 3 ) : next _ j = ( j + 1 ) % 3 d = [ c [ i ] [ j ] - c [ i ] [ next _ j ] for i in range ( 3 ) ] if len ( set ( d ) ) > 1 : print ( ' No ' ) return print ( ' Yes ' ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 a = [ c [ 0 ] [ i ] for i in range ( 3 ) ] b = [ c [ i ] [ 0 ] - a [ 0 ] for i in range ( 3 ) ] for i in range ( 3 ) : for j in range ( 3 ) : if a [ j ] + b [ i ] ! = c [ i ] [ j ] : print ( " No " ) exit ( ) print ( " Yes " ) c = [ ] for _ in range ( 3 ) : c . append ( [ int ( x ) for x in input ( ) . split ( ) ] ) a = [ 0 ] b = [ c [ 0 ] [ i ] for i in range ( 3 ) ] for j in range ( 1 , 3 ) : a . append ( c [ j ] [ j ] - b [ j ] ) ans = ' Yes ' for k in range ( 3 ) : for m in range ( 3 ) : if c [ k ] [ m ] ! = a [ k ] + b [ m ] : ans = ' No ' break print ( ans ) import numpy as np N = 3 rows = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( N ) ] arr = np . array ( rows ) b1 = arr [ 0 ] - arr [ 0 ] [ 0 ] b2 = arr [ 1 ] - arr [ 1 ] [ 0 ] b3 = arr [ 2 ] - arr [ 2 ] [ 0 ] if not ( list ( b1 ) = = list ( b2 ) = = list ( b3 ) ) : print ( " No " ) exit ( ) arr = arr . T a1 = arr [ 0 ] - arr [ 0 ] [ 0 ] a2 = arr [ 1 ] - arr [ 1 ] [ 0 ] a3 = arr [ 2 ] - arr [ 2 ] [ 0 ] if not ( list ( a1 ) = = list ( a2 ) = = list ( a3 ) ) : print ( " No " ) exit ( ) print ( " Yes " ) cl = [ ] for i in range ( 3 ) : c = list ( map ( int , input ( ) . split ( ) ) ) cl . append ( c ) rcl , trcl , acl , bcl = [ ] , [ ] , [ ] , [ ] tcl = [ x for x in zip ( * cl ) ] for i in range ( 3 ) : rcb = [ ] trca = [ ] for j in range ( 3 ) : if j < 2 : rc = cl [ i ] [ j ] - cl [ i ] [ j + 1 ] trc = tcl [ i ] [ j ] - tcl [ i ] [ j + 1 ] else : rc = cl [ i ] [ j ] - cl [ i ] [ j - 2 ] trc = tcl [ i ] [ j ] - tcl [ i ] [ j - 2 ] rcb . append ( rc ) trca . append ( trc ) rcl . append ( rcb ) trcl . append ( trca ) for i in range ( 3 ) : if i < 2 : bc = [ x - y for ( x , y ) in zip ( rcl [ i ] , rcl [ i + 1 ] ) ] ac = [ x - y for ( x , y ) in zip ( trcl [ i ] , trcl [ i + 1 ] ) ] else : bc = [ x - y for ( x , y ) in zip ( rcl [ i ] , rcl [ i - 2 ] ) ] ac = [ x - y for ( x , y ) in zip ( trcl [ i ] , trcl [ i - 2 ] ) ] bcl . append ( bc ) acl . append ( ac ) f = lambda x : True if x = = 0 else False aclb = [ all ( [ f ( n ) for n in acl [ m ] ] ) for m in range ( 3 ) ] bclb = [ all ( [ f ( n ) for n in bcl [ m ] ] ) for m in range ( 3 ) ] if all ( aclb ) & all ( bclb ) : print ( ' Yes ' ) else : print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ 0 ] * 3 b = c [ 0 ] a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] flag = False for i in range ( 3 ) : if flag : break for j in range ( 3 ) : if c [ i ] [ j ] ! = a [ i ] + b [ j ] : flag = True break if flag : print ( ' No ' ) else : print ( ' Yes ' ) import numpy as np import scipy C = [ [ 0 for i in range ( 3 ) ] for j in range ( 3 ) ] for i in range ( 3 ) : C [ i ] = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) : for j in range ( 3 ) : if C [ 0 ] [ 0 ] - C [ 0 ] [ j ] ! = C [ i ] [ 0 ] - C [ i ] [ j ] : print ( " No " ) exit ( ) if C [ 0 ] [ 0 ] - C [ i ] [ 0 ] ! = C [ 0 ] [ j ] - C [ i ] [ j ] : print ( " No " ) exit ( ) print ( " Yes " ) c = [ ] for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in range ( 2 ) : if c [ 0 ] [ i ] - c [ 0 ] [ i + 1 ] = = c [ 1 ] [ i ] - c [ 1 ] [ i + 1 ] = = c [ 2 ] [ i ] - c [ 2 ] [ i + 1 ] : continue else : print ( " No " ) exit ( ) print ( " Yes " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] if c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] ! = c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] or c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] ! = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] or c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] ! = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] or c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] ! = c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] or c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] ! = c [ 2 ] [ 1 ] - c [ 2 ] [ 2 ] or c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] ! = c [ 2 ] [ 1 ] - c [ 2 ] [ 2 ] or c [ 0 ] [ 0 ] - c [ 0 ] [ 2 ] ! = c [ 1 ] [ 0 ] - c [ 1 ] [ 2 ] or c [ 1 ] [ 0 ] - c [ 1 ] [ 2 ] ! = c [ 2 ] [ 0 ] - c [ 2 ] [ 2 ] or c [ 0 ] [ 0 ] - c [ 0 ] [ 2 ] ! = c [ 2 ] [ 0 ] - c [ 2 ] [ 2 ] : print ( " No " ) exit ( ) print ( " Yes " ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) if c21 - c11 = = c22 - c12 = = c23 - c13 and c31 - c21 = = c32 - c22 = = c33 - c23 and c12 - c11 = = c22 - c21 = = c32 - c31 and c13 - c12 = = c23 - c22 = = c33 - c32 : print ( " Yes " ) else : print ( " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] base = [ C [ 0 ] [ 0 ] , C [ 1 ] [ 1 ] , C [ 2 ] [ 2 ] ] case _ AB = [ 1 for a in range ( base [ 0 ] + 1 ) for b in range ( base [ 1 ] + 1 ) for c in range ( base [ 2 ] + 1 ) if [ [ base [ 0 ] , b + ( base [ 0 ] - a ) , c + ( base [ 0 ] - a ) ] , [ a + ( base [ 1 ] - b ) , base [ 1 ] , c + ( base [ 1 ] - b ) ] , [ a + ( base [ 2 ] - c ) , b + ( base [ 2 ] - c ) , base [ 2 ] ] ] = = C ] if case _ AB : print ( " Yes " ) else : print ( " No " ) [ ( a , b , c ) , ( d , e , f ) , ( g , h , i ) ] = [ map ( int , input ( ) . split ( ) ) for i in range ( 3 ) ] if a - b = = d - e = = g - h and b - c = = e - f = = h - i : print ( ' Yes ' ) else : print ( ' No ' ) def readlines ( ) : for _ in range ( 3 ) : yield list ( map ( int , input ( ) . split ( ) ) ) c = list ( readlines ( ) ) a1 = 0 b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 a2 = c [ 1 ] [ 0 ] - b1 a3 = c [ 2 ] [ 0 ] - b1 ok = ( c [ 1 ] [ 1 ] = = a2 + b2 and c [ 1 ] [ 2 ] = = a2 + b3 and c [ 2 ] [ 1 ] = = a3 + b2 and c [ 2 ] [ 2 ] = = a3 + b3 ) print ( " Yes " if ok else " No " ) C = [ 0 ] * 3 ; A = [ 0 ] * 3 d1 = 0 ; d2 = 0 ; e1 = 0 ; e2 = 0 ; z = 0 ; p = 0 for i in range ( 3 ) : c1 , c2 , c3 = map ( int , input ( ) . split ( ) ) C [ i ] = [ c1 , c2 , c3 ] A [ i ] = [ 0 , 0 , 0 ] d1 = C [ 1 ] [ 0 ] - C [ 0 ] [ 0 ] ; d2 = C [ 2 ] [ 0 ] - C [ 0 ] [ 0 ] e1 = C [ 0 ] [ 1 ] - C [ 0 ] [ 0 ] ; e2 = C [ 0 ] [ 2 ] - C [ 0 ] [ 0 ] z = C [ 0 ] [ 0 ] A [ 0 ] [ 0 ] = z ; A [ 0 ] [ 1 ] = z + e1 ; A [ 0 ] [ 2 ] = z + e2 A [ 1 ] [ 0 ] = z + d1 ; A [ 1 ] [ 1 ] = z + e1 + d1 ; A [ 1 ] [ 2 ] = z + d1 + e2 A [ 2 ] [ 0 ] = z + d2 ; A [ 2 ] [ 1 ] = z + d2 + e1 ; A [ 2 ] [ 2 ] = z + d2 + e2 for i in range ( 3 ) : for j in range ( 3 ) : if C [ i ] [ j ] = = A [ i ] [ j ] : p = p + 1 print ( " Yes " if p = = 9 else " No " ) input _ map = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a1 = input _ map [ 0 ] [ 0 ] - input _ map [ 0 ] [ 1 ] a2 = input _ map [ 0 ] [ 0 ] - input _ map [ 0 ] [ 2 ] a3 = input _ map [ 0 ] [ 1 ] - input _ map [ 0 ] [ 2 ] b1 = input _ map [ 0 ] [ 0 ] - input _ map [ 1 ] [ 0 ] b2 = input _ map [ 0 ] [ 0 ] - input _ map [ 2 ] [ 0 ] b3 = input _ map [ 1 ] [ 0 ] - input _ map [ 2 ] [ 0 ] for i in range ( 1 , 3 ) : if a1 ! = ( input _ map [ i ] [ 0 ] - input _ map [ i ] [ 1 ] ) : print ( ' No ' ) ; exit ( ) if a2 ! = ( input _ map [ i ] [ 0 ] - input _ map [ i ] [ 2 ] ) : print ( ' No ' ) ; exit ( ) if a3 ! = ( input _ map [ i ] [ 1 ] - input _ map [ i ] [ 2 ] ) : print ( ' No ' ) ; exit ( ) for i in range ( 1 , 3 ) : if b1 ! = ( input _ map [ 0 ] [ i ] - input _ map [ 1 ] [ i ] ) : print ( ' No ' ) ; exit ( ) if b2 ! = ( input _ map [ 0 ] [ i ] - input _ map [ 2 ] [ i ] ) : print ( ' No ' ) ; exit ( ) if b3 ! = ( input _ map [ 1 ] [ i ] - input _ map [ 2 ] [ i ] ) : print ( ' No ' ) ; exit ( ) print ( ' Yes ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] for i in range ( 2 ) : dist = c [ i + 1 ] [ 0 ] - c [ i ] [ 0 ] if c [ i + 1 ] [ 1 ] - c [ i ] [ 1 ] = = dist and c [ i + 1 ] [ 2 ] - c [ i ] [ 2 ] = = dist : continue else : print ( ' No ' ) exit ( ) for i in range ( 2 ) : dist = c [ 0 ] [ i + 1 ] - c [ 0 ] [ i ] if c [ 1 ] [ i + 1 ] - c [ 1 ] [ i ] = = dist and c [ 2 ] [ i + 1 ] - c [ 2 ] [ i ] = = dist : continue else : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) for a1 in range ( 0 , 101 ) : b1 = c11 - a1 b2 = c12 - a1 b3 = c13 - a1 a2 = c21 - b1 a3 = c31 - b1 if all ( [ c22 = = a2 + b2 , c23 = = a2 + b3 , c32 = = a3 + b2 , c33 = = a3 + b3 ] ) : print ( " Yes " ) exit ( 0 ) else : print ( " No " ) c = [ ] for i in range ( 3 ) : c . append ( [ int ( x ) for x in list ( input ( ) . split ( ) ) ] ) if c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 2 ] [ 0 ] and c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 2 ] [ 1 ] and c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 0 ] [ 2 ] and c [ 2 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 1 ] [ 2 ] : print ( ' Yes ' ) else : print ( ' No ' ) c = [ [ 0 ] * 3 for _ in range ( 3 ) ] for i in range ( 3 ) : c [ i ] = list ( map ( int , input ( ) . split ( ) ) ) a = [ 0 ] * 3 b = [ 0 ] * 3 a [ 0 ] = 0 b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] flag = True for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] = = a [ i ] + b [ j ] : pass else : flag = False if flag : print ( ' Yes ' ) else : print ( ' No ' ) C = [ ] for i in range ( 3 ) : C . append ( [ int ( c ) for c in input ( ) . split ( ) ] ) ans = " Yes " tmp = C [ 0 ] [ 0 ] A = [ 0 ] * 3 B = [ 0 ] * 3 for i in range ( 3 ) : B [ i ] = C [ 0 ] [ i ] for i in range ( 3 ) : A [ i ] = C [ i ] [ 0 ] - B [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if ( C [ i ] [ j ] ! = A [ i ] + B [ j ] ) : ans = " No " print ( ans ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] A1 = [ C [ 0 ] [ 0 ] - C [ 1 ] [ 0 ] , C [ 0 ] [ 1 ] - C [ 1 ] [ 1 ] , C [ 0 ] [ 2 ] - C [ 1 ] [ 2 ] ] A1 . sort ( ) A2 = [ C [ 1 ] [ 0 ] - C [ 2 ] [ 0 ] , C [ 1 ] [ 1 ] - C [ 2 ] [ 1 ] , C [ 1 ] [ 2 ] - C [ 2 ] [ 2 ] ] A2 . sort ( ) B1 = [ C [ 0 ] [ 0 ] - C [ 0 ] [ 1 ] , C [ 1 ] [ 0 ] - C [ 1 ] [ 1 ] , C [ 2 ] [ 0 ] - C [ 2 ] [ 1 ] ] B1 . sort ( ) B2 = [ C [ 0 ] [ 1 ] - C [ 0 ] [ 2 ] , C [ 1 ] [ 1 ] - C [ 1 ] [ 2 ] , C [ 2 ] [ 1 ] - C [ 2 ] [ 2 ] ] B2 . sort ( ) if A1 [ 0 ] = = A1 [ 2 ] and A2 [ 0 ] = = A2 [ 2 ] and B1 [ 0 ] = = B1 [ 2 ] and B2 [ 0 ] = = B2 [ 2 ] : print ( ' Yes ' ) else : print ( ' No ' ) list1 = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] closs1 = 0 closs2 = 0 for i in range ( 2 ) : if list1 [ i ] [ 1 ] - list1 [ i ] [ 0 ] = = list1 [ i + 1 ] [ 1 ] - list1 [ i + 1 ] [ 0 ] and \ list1 [ i ] [ 2 ] - list1 [ i ] [ 1 ] = = list1 [ i + 1 ] [ 2 ] - list1 [ i + 1 ] [ 1 ] : continue else : print ( " No " ) exit ( ) print ( " Yes " ) c1 , c2 , c3 = map ( int , input ( ) . split ( ) ) c4 , c5 , c6 = map ( int , input ( ) . split ( ) ) c7 , c8 , c9 = map ( int , input ( ) . split ( ) ) if c1 - c2 = = c4 - c5 = = c7 - c8 and c3 - c2 = = c6 - c5 = = c9 - c8 : print ( " Yes " ) else : print ( " No " ) C = [ None for i in range ( 3 ) ] for i in range ( 3 ) : C [ i ] = list ( map ( int , input ( ) . split ( ) ) ) ok = True diff = [ 0 ] * 3 for i in range ( 3 ) : diff [ i ] = C [ i ] [ 1 ] - C [ i ] [ 0 ] if len ( set ( diff ) ) > 1 : ok = False diff = [ 0 ] * 3 for i in range ( 3 ) : diff [ i ] = C [ i ] [ 2 ] - C [ i ] [ 1 ] if len ( set ( diff ) ) > 1 : ok = False diff = [ 0 ] * 3 for i in range ( 3 ) : diff [ i ] = C [ 1 ] [ i ] - C [ 0 ] [ i ] if len ( set ( diff ) ) > 1 : ok = False diff = [ 0 ] * 3 for i in range ( 3 ) : diff [ i ] = C [ 2 ] [ i ] - C [ 1 ] [ i ] if len ( set ( diff ) ) > 1 : ok = False print ( ( " No " , " Yes " ) [ ok ] ) def checker ( ded , da ) : for i in range ( 3 ) : for j in range ( 2 ) : if da [ i ] [ j ] - ded [ j ] ! = da [ i ] [ 2 ] - ded [ 2 ] : return False return True def ma ( da ) : for i in range ( - 100 , 101 ) : for j in range ( - 100 , 101 ) : for k in range ( - 100 , 101 ) : if checker ( [ i , j , k ] , da ) : return False return True da = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] if not ma ( da ) : print ( ' Yes ' ) else : print ( ' No ' ) import numpy as np c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] C = np . array ( c ) check = np . zeros ( ( 3 , 3 ) ) for i in range ( min ( c [ 0 ] ) + 1 ) : check [ 0 ] = C [ 0 ] - i for j in range ( min ( c [ 1 ] ) + 1 ) : check [ 1 ] = C [ 1 ] - j for k in range ( min ( c [ 2 ] ) + 1 ) : check [ 2 ] = C [ 2 ] - k if list ( check [ 0 ] ) = = list ( check [ 1 ] ) and list ( check [ 0 ] ) = = list ( check [ 2 ] ) : print ( " Yes " ) exit ( ) print ( " No " ) if _ _ name _ _ = = " _ _ main _ _ " : c = list ( ) for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) tmp = list ( ) for i in range ( 3 ) : tmp . append ( [ c [ i ] [ 0 ] - c [ 0 ] [ 0 ] , c [ i ] [ 1 ] - c [ 0 ] [ 1 ] , c [ i ] [ 2 ] - c [ 0 ] [ 2 ] ] ) for i in range ( 3 ) : if tmp [ i ] [ 0 ] = = tmp [ i ] [ 1 ] = = tmp [ i ] [ 2 ] : continue else : print ( ' No ' ) exit ( ) tmp = list ( ) for i in range ( 3 ) : tmp . append ( [ c [ 0 ] [ i ] - c [ 0 ] [ 0 ] , c [ 1 ] [ i ] - c [ 1 ] [ 0 ] , c [ 2 ] [ i ] - c [ 2 ] [ 0 ] ] ) for i in range ( 3 ) : if tmp [ i ] [ 0 ] = = tmp [ i ] [ 1 ] = = tmp [ i ] [ 2 ] : continue else : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c = [ [ int ( i ) for i in input ( ) . split ( ) ] for j in range ( 3 ) ] ans = ' No ' for x in range ( 101 ) : for y in range ( 101 ) : for z in range ( 101 ) : d = [ ] d . append ( [ c [ 0 ] [ j ] - x for j in range ( 3 ) ] ) d . append ( [ c [ 1 ] [ j ] - y for j in range ( 3 ) ] ) d . append ( [ c [ 2 ] [ j ] - z for j in range ( 3 ) ] ) if sum ( len ( set ( d [ i ] [ j ] for i in range ( 3 ) ) ) for j in range ( 3 ) ) = = 3 : ans = ' Yes ' print ( ans ) c = [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( 3 ) ] h1 = c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 0 ] [ 2 ] h2 = c [ 2 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 1 ] [ 2 ] w1 = c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 2 ] [ 0 ] w2 = c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 2 ] [ 1 ] if h1 and h2 and w1 and w2 : print ( ' Yes ' ) else : print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 ok = True b = c [ 0 ] a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = a [ i ] + b [ j ] : ok = False if ok : print ( ' Yes ' ) else : print ( ' No ' ) c = [ ] for _ in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) a = [ - 1 , - 1 , - 1 ] b = [ - 1 , - 1 , - 1 ] N = min ( c [ 0 ] ) ans = ' No ' for i in range ( N + 1 ) : a [ 0 ] = i b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] flag = 1 for j in range ( 3 ) : for k in range ( 3 ) : if c [ j ] [ k ] ! = a [ j ] + b [ k ] : flag = 0 if flag = = 1 : ans = ' Yes ' break print ( ans ) c = [ [ ] for _ in range ( 3 ) ] for i in range ( 3 ) : c [ i ] = list ( map ( int , input ( ) . split ( ) ) ) diff0 = [ x - y for x , y in zip ( c [ 0 ] , c [ 1 ] ) ] diff1 = [ x - y for x , y in zip ( c [ 0 ] , c [ 2 ] ) ] if diff0 [ 0 ] = = diff0 [ 1 ] and diff0 [ 0 ] = = diff0 [ 2 ] and diff1 [ 0 ] = = diff1 [ 1 ] and diff1 [ 0 ] = = diff1 [ 2 ] : print ( ' Yes ' ) else : print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] if c [ 1 ] [ 1 ] ! = c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] + c [ 0 ] [ 1 ] : print ( ' No ' ) elif c [ 1 ] [ 2 ] ! = c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] + c [ 0 ] [ 2 ] : print ( ' No ' ) elif c [ 2 ] [ 1 ] ! = c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] + c [ 0 ] [ 1 ] : print ( ' No ' ) elif c [ 2 ] [ 2 ] ! = c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] + c [ 0 ] [ 2 ] : print ( ' No ' ) else : print ( ' Yes ' ) from fractions import gcd from itertools import combinations , permutations , accumulate , product from collections import deque , defaultdict , Counter import decimal import re import math import bisect import sys sys . setrecursionlimit ( 10000000 ) mod = 10 * * 9 + 7 from sys import stdin readline = stdin . readline def readInts ( ) : return list ( map ( int , readline ( ) . split ( ) ) ) def readTuples ( ) : return tuple ( map ( int , readline ( ) . split ( ) ) ) def I ( ) : return int ( readline ( ) ) C = [ readInts ( ) for _ in range ( 3 ) ] A = [ 0 ] * 3 B = [ 0 ] * 3 A [ 0 ] = 0 for i in range ( 3 ) : B [ i ] = C [ 0 ] [ i ] for j in range ( 3 ) : A [ j ] = C [ j ] [ 0 ] - B [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if A [ i ] + B [ j ] = = C [ i ] [ j ] : pass else : print ( ' No ' ) exit ( ) print ( ' Yes ' ) L = [ [ 0 for j in range ( 3 ) ] for i in range ( 3 ) ] for i in range ( 3 ) : c = list ( map ( int , input ( ) . split ( ) ) ) L [ i ] = c if L [ 0 ] [ 0 ] - L [ 1 ] [ 0 ] = = L [ 0 ] [ 1 ] - L [ 1 ] [ 1 ] = = L [ 0 ] [ 2 ] - L [ 1 ] [ 2 ] and L [ 0 ] [ 0 ] - L [ 2 ] [ 0 ] = = L [ 0 ] [ 1 ] - L [ 2 ] [ 1 ] = = L [ 0 ] [ 2 ] - L [ 2 ] [ 2 ] : print ( " Yes " ) else : print ( " No " ) import sys def solve ( inp ) : A = [ list ( map ( int , inp . readline ( ) . split ( ' ' ) ) ) for i in range ( 3 ) ] m = list ( map ( min , A ) ) for a1 in range ( m [ 0 ] + 1 ) : c1 = [ A [ 0 ] [ 0 ] - a1 , A [ 0 ] [ 1 ] - a1 , A [ 0 ] [ 2 ] - a1 ] for a2 in range ( m [ 1 ] + 1 ) : c2 = [ A [ 1 ] [ 0 ] - a2 , A [ 1 ] [ 1 ] - a2 , A [ 1 ] [ 2 ] - a2 ] for a3 in range ( m [ 2 ] + 1 ) : c3 = [ A [ 2 ] [ 0 ] - a3 , A [ 2 ] [ 1 ] - a3 , A [ 2 ] [ 2 ] - a3 ] if c1 = = c2 = = c3 : return " Yes " return " No " def main ( ) : result = solve ( sys . stdin ) if result : print ( result ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) import sys c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 for i in range ( 3 ) : b [ i ] = c [ 0 ] [ i ] for i in range ( 1 , 3 ) : a [ i ] = c [ i ] [ 0 ] - b [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] = = a [ i ] + b [ j ] : pass else : print ( " No " ) sys . exit ( ) print ( " Yes " ) import numpy as np import sys c = np . array ( [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] ) for i in range ( - 1 , 2 ) : if len ( set ( c [ i ] - c [ i + 1 ] ) ) = = 1 : pass else : print ( " No " ) sys . exit ( ) for i in range ( - 1 , 2 ) : if len ( set ( c [ : , i ] - c [ : , i + 1 ] ) ) = = 1 : pass else : print ( " No " ) sys . exit ( ) print ( " Yes " ) c = [ 0 ] * 3 for i in range ( 3 ) : c [ i ] = list ( map ( int , input ( ) . split ( ) ) ) a = [ 0 ] * 3 b = [ 0 ] * 3 a [ 0 ] = 0 for j in range ( 3 ) : b [ j ] = c [ 0 ] [ j ] - a [ 0 ] a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] count = 0 for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] = = a [ i ] + b [ j ] : count + = 1 if count = = 9 : print ( ' Yes ' ) else : print ( ' No ' ) import sys c = [ ] for _ in range ( 3 ) : * C , = map ( int , input ( ) . split ( ) ) c . append ( C ) for a1 in range ( 0 , 101 , 1 ) : b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 a2 = c [ 1 ] [ 0 ] - b1 if ( a2 + b2 ) ! = c [ 1 ] [ 1 ] : print ( " No " ) sys . exit ( ) if ( a2 + b3 ) ! = c [ 1 ] [ 2 ] : print ( " No " ) sys . exit ( ) a3 = c [ 2 ] [ 0 ] - b1 if ( a3 + b2 ) ! = c [ 2 ] [ 1 ] : print ( " No " ) sys . exit ( ) if ( a3 + b3 ) ! = c [ 2 ] [ 2 ] : print ( " No " ) sys . exit ( ) print ( " Yes " ) c11 , c12 , c13 = [ int ( i ) for i in input ( ) . split ( ) ] c21 , c22 , c23 = [ int ( i ) for i in input ( ) . split ( ) ] c31 , c32 , c33 = [ int ( i ) for i in input ( ) . split ( ) ] ans = 0 for a1 in range ( c11 + 1 ) : b1 = c11 - a1 b2 = c12 - a1 b3 = c13 - a1 a2 = c21 - b1 a3 = c31 - b1 if c22 = = a2 + b2 and c23 = = a2 + b3 and c32 = = a3 + b2 and c33 = = a3 + b3 : print ( " Yes " ) ans = 1 break if ans = = 0 : print ( " No " ) def i ( ) : return map ( int , input ( ) . split ( ) ) a , b , c = i ( ) d , e , f = i ( ) g , h , i = i ( ) print ( ' Yes ' if ( d - a = = e - b = = f - c ) and ( g - d = = h - e = = i - f ) and ( b - a = = e - d = = h - g ) and ( c - b = = f - e = = i - h ) else ' No ' ) def solve ( ) : c = [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( 3 ) ] if not ( c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] = = c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] ) : return ' No ' elif not ( c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 2 ] [ 2 ] ) : return ' No ' elif not ( c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] ) : return ' No ' elif not ( c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] = = c [ 2 ] [ 1 ] - c [ 2 ] [ 2 ] ) : return ' No ' else : return ' Yes ' if _ _ name _ _ = = ' _ _ main _ _ ' : print ( solve ( ) ) p = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] if p [ 0 ] [ 0 ] - p [ 0 ] [ 1 ] = = p [ 1 ] [ 0 ] - p [ 1 ] [ 1 ] = = p [ 2 ] [ 0 ] - p [ 2 ] [ 1 ] and p [ 0 ] [ 1 ] - p [ 0 ] [ 2 ] = = p [ 1 ] [ 1 ] - p [ 1 ] [ 2 ] = = p [ 2 ] [ 1 ] - p [ 2 ] [ 2 ] and p [ 0 ] [ 0 ] - p [ 1 ] [ 0 ] = = p [ 0 ] [ 1 ] - p [ 1 ] [ 1 ] = = p [ 0 ] [ 2 ] - p [ 1 ] [ 2 ] and p [ 1 ] [ 0 ] - p [ 2 ] [ 0 ] = = p [ 1 ] [ 1 ] - p [ 2 ] [ 1 ] = = p [ 1 ] [ 2 ] - p [ 2 ] [ 2 ] : print ( ' Yes ' ) else : print ( ' No ' ) c = [ ] for i in range ( 3 ) : li = list ( map ( int , input ( ) . split ( ) ) ) c . append ( li ) a = [ 0 , ( c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] ) , ( c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] ) ] b = [ c [ 0 ] [ 0 ] , c [ 0 ] [ 1 ] , c [ 0 ] [ 2 ] ] ans = " Yes " for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] = = ( a [ i ] + b [ j ] ) : pass else : ans = " No " break if ans = = " No " : break print ( ans ) ar1 = list ( map ( int , input ( ) . split ( ) ) ) ar2 = list ( map ( int , input ( ) . split ( ) ) ) ar3 = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 100 ) : a1 = i b1 = ar1 [ 0 ] - a1 b2 = ar1 [ 1 ] - a1 b3 = ar1 [ 2 ] - a1 a2 = ar2 [ 0 ] - b1 a3 = ar3 [ 0 ] - b1 if a2 + b2 = = ar2 [ 1 ] and a2 + b3 = = ar2 [ 2 ] and a3 + b2 = = ar3 [ 1 ] = = ar3 [ 1 ] and a3 + b3 = = ar3 [ 2 ] : print ( " Yes " ) exit ( ) print ( " No " ) import numpy as np L = np . array ( [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] ) a1 = 0 b1 = L [ 0 ] [ 0 ] b2 = L [ 0 ] [ 1 ] b3 = L [ 0 ] [ 2 ] a2 = L [ 1 ] [ 0 ] - b1 a3 = L [ 2 ] [ 0 ] - b1 if ( a2 + b2 ! = L [ 1 ] [ 1 ] or a2 + b3 ! = L [ 1 ] [ 2 ] or a3 + b2 ! = L [ 2 ] [ 1 ] or a3 + b3 ! = L [ 2 ] [ 2 ] ) : print ( " No " ) else : print ( " Yes " ) import sys n = 3 c = [ [ - 1 , - 1 , - 1 ] for _ in range ( n ) ] for i in range ( n ) : c [ i ] = list ( map ( int , input ( ) . split ( ) ) ) Flag = True if c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] ! = c [ 1 ] [ 1 ] - c [ 0 ] [ 1 ] or c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] ! = c [ 1 ] [ 2 ] - c [ 0 ] [ 2 ] : print ( " No " ) sys . exit ( ) if c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] ! = c [ 2 ] [ 1 ] - c [ 0 ] [ 1 ] or c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] ! = c [ 2 ] [ 2 ] - c [ 0 ] [ 2 ] : print ( " No " ) sys . exit ( ) if c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] ! = c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] or c [ 2 ] [ 1 ] - c [ 2 ] [ 0 ] ! = c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] : print ( " No " ) sys . exit ( ) if c [ 0 ] [ 2 ] - c [ 0 ] [ 0 ] ! = c [ 1 ] [ 2 ] - c [ 1 ] [ 0 ] or c [ 2 ] [ 2 ] - c [ 2 ] [ 0 ] ! = c [ 1 ] [ 2 ] - c [ 1 ] [ 0 ] : print ( " No " ) sys . exit ( ) print ( " Yes " ) c = [ [ int ( i ) for i in input ( ) . split ( ) ] for i in range ( 3 ) ] ans = False for a _ 1 in range ( 101 ) : b _ 1 = c [ 0 ] [ 0 ] - a _ 1 b _ 2 = c [ 0 ] [ 1 ] - a _ 1 b _ 3 = c [ 0 ] [ 2 ] - a _ 1 a _ 2 = c [ 1 ] [ 0 ] - b _ 1 a _ 3 = c [ 2 ] [ 0 ] - b _ 1 if a _ 2 + b _ 2 = = c [ 1 ] [ 1 ] and a _ 2 + b _ 3 = = c [ 1 ] [ 2 ] and a _ 3 + b _ 2 = = c [ 2 ] [ 1 ] and a _ 3 + b _ 3 = = c [ 2 ] [ 2 ] : ans = True break if ans : print ( " Yes " ) else : print ( " No " ) l = [ ] for i in range ( 3 ) : c1 , c2 , c3 = map ( int , input ( ) . split ( ) ) l . append ( [ c1 , c2 , c3 ] ) b1 = l [ 0 ] [ 0 ] b2 = l [ 1 ] [ 0 ] b3 = l [ 2 ] [ 0 ] flag = 0 for i in range ( 3 ) : if not ( l [ 0 ] [ 1 ] - b1 = = l [ 1 ] [ 1 ] - b2 = = l [ 2 ] [ 1 ] - b3 ) : flag = 1 if not ( l [ 0 ] [ 2 ] - b1 = = l [ 1 ] [ 2 ] - b2 = = l [ 2 ] [ 2 ] - b3 ) : flag = 1 if flag = = 1 : print ( ' No ' , flush = True ) else : print ( ' Yes ' , flush = True ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) x = min ( c1 ) y = min ( c2 ) z = min ( c3 ) for i in range ( 3 ) : c1 [ i ] - = x c2 [ i ] - = y c3 [ i ] - = z print ( ' NYoe s ' [ c1 = = c2 = = c3 : : 2 ] ) from sys import stdin from itertools import combinations from math import factorial import numpy as np li = [ list ( map ( int , stdin . readline ( ) . rstrip ( ) . split ( ) ) ) for _ in range ( 3 ) ] a1 = 0 b1 = li [ 0 ] [ 0 ] - a1 b2 = li [ 0 ] [ 1 ] - a1 b3 = li [ 0 ] [ 2 ] - a1 a2 = li [ 1 ] [ 0 ] - b1 a3 = li [ 2 ] [ 0 ] - b1 lin = [ [ a1 , a2 , a3 ] , [ b1 , b2 , b3 ] ] for i in range ( 3 ) : for j in range ( 3 ) : if li [ i ] [ j ] ! = lin [ 0 ] [ i ] + lin [ 1 ] [ j ] : print ( " No " ) exit ( ) print ( " Yes " ) c = [ [ int ( x ) for x in input ( ) . split ( ) ] for _ in range ( 3 ) ] s = True for i in range ( 2 ) : for j in range ( i + 1 , 3 ) : if c [ 0 ] [ j ] - c [ 0 ] [ i ] = = c [ 1 ] [ j ] - c [ 1 ] [ i ] = = c [ 2 ] [ j ] - c [ 2 ] [ i ] : continue else : s = False break for i in range ( 2 ) : for j in range ( i + 1 , 3 ) : if c [ j ] [ 0 ] - c [ i ] [ 0 ] = = c [ j ] [ 1 ] - c [ i ] [ 1 ] = = c [ j ] [ 2 ] - c [ i ] [ 2 ] : continue else : s = False break print ( " Yes " ) if s else print ( " No " ) c = [ ] for _ in range ( 3 ) : tmp = [ int ( x ) for x in input ( ) . split ( ) ] c . append ( tmp ) ans = True for i in range ( 2 ) : if ( c [ 0 ] [ i ] - c [ 0 ] [ i + 1 ] ) = = ( c [ 1 ] [ i ] - c [ 1 ] [ i + 1 ] ) = = ( c [ 2 ] [ i ] - c [ 2 ] [ i + 1 ] ) : pass else : ans = False break for i in range ( 2 ) : if ( c [ i ] [ 0 ] - c [ i + 1 ] [ 0 ] ) = = ( c [ i ] [ 1 ] - c [ i + 1 ] [ 1 ] ) = = ( c [ i ] [ 2 ] - c [ i + 1 ] [ 2 ] ) : pass else : ans = False break if ans : print ( " Yes " ) else : print ( " No " ) a , b , c = map ( int , input ( ) . split ( ) ) d , e , f = map ( int , input ( ) . split ( ) ) g , h , i = map ( int , input ( ) . split ( ) ) if a + e + i = = b + f + g = = c + d + h = = a + f + h = = c + e + g = = b + d + i : print ( " Yes " ) else : print ( " No " ) import numpy as np c = [ ] for i in range ( 3 ) : c . append ( list ( map ( lambda x : int ( x ) , input ( ) . split ( ) ) ) ) c = np . array ( c ) ans = ' Yes ' tmp = c [ : , 0 ] - c [ : , 1 ] if np . min ( tmp ) ! = np . max ( tmp ) : ans = ' No ' tmp = c [ : , 0 ] - c [ : , 2 ] if np . min ( tmp ) ! = np . max ( tmp ) : ans = ' No ' tmp = c [ 0 , : ] - c [ 1 , : ] if np . min ( tmp ) ! = np . max ( tmp ) : ans = ' No ' tmp = c [ 0 , : ] - c [ 2 , : ] if np . min ( tmp ) ! = np . max ( tmp ) : ans = ' No ' print ( ans ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 for i in range ( 3 ) : b [ i ] = c [ 0 ] [ i ] - a [ 0 ] for i in range ( 1 , 3 ) : a [ i ] = c [ i ] [ 0 ] - b [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if ( a [ i ] + b [ j ] ! = c [ i ] [ j ] ) : print ( " No " ) exit ( ) print ( " Yes " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] if [ c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] , c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] ] = = [ c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] , c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] ] = = [ c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] , c [ 2 ] [ 1 ] - c [ 2 ] [ 2 ] ] : if [ c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] , c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] ] = = [ c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] , c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] ] = = [ c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] , c [ 1 ] [ 2 ] - c [ 2 ] [ 2 ] ] : print ( ' Yes ' ) exit ( ) print ( ' No ' ) import sys def slove ( ) : input = sys . stdin . readline mod = 10 * * 9 + 7 a = [ list ( map ( int , input ( ) . rstrip ( ' \ n ' ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 3 ) : t = min ( a [ i ] ) if t ! = 0 : for j in range ( 3 ) : a [ i ] [ j ] - = t t = min ( [ a [ j ] [ i ] for j in range ( 3 ) ] ) if t ! = 0 : for j in range ( 3 ) : a [ j ] [ i ] - = t print ( " Yes " if max ( [ a [ i ] [ j ] for i in range ( 3 ) for j in range ( 3 ) ] ) = = 0 else " No " ) if _ _ name _ _ = = ' _ _ main _ _ ' : slove ( ) import numpy as np import copy c = [ 0 ] * 3 for i in range ( 3 ) : c [ i ] = [ int ( x ) for x in input ( ) . split ( ) ] ans = False while c [ 0 ] [ 0 ] > = 0 and c [ 0 ] [ 1 ] > = 0 and c [ 0 ] [ 2 ] > = 0 : a = copy . deepcopy ( c [ 1 ] ) b = copy . deepcopy ( c [ 2 ] ) for i in range ( 3 ) : a [ i ] - = c [ 0 ] [ i ] b [ i ] - = c [ 0 ] [ i ] if a [ 0 ] = = a [ 1 ] = = a [ 2 ] and b [ 0 ] = = b [ 1 ] = = b [ 2 ] : ans = True break for i in range ( 3 ) : c [ 0 ] [ i ] - = 1 if ans : print ( " Yes " ) else : print ( " No " ) C = [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( 3 ) ] B = C [ 0 ] A = [ 0 , C [ 1 ] [ 0 ] - B [ 0 ] , C [ 2 ] [ 0 ] - B [ 0 ] ] for i in range ( 3 ) : for j in range ( 3 ) : if C [ i ] [ j ] ! = A [ i ] + B [ j ] : print ( " No " ) quit ( ) print ( " Yes " ) a , b , c = map ( int , input ( ) . split ( ) ) d , e , f = map ( int , input ( ) . split ( ) ) g , h , i = map ( int , input ( ) . split ( ) ) if a + e + i = = b + f + g = = c + d + h : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] bl = c [ 0 ] a2 = c [ 1 ] [ 0 ] - bl [ 0 ] a3 = c [ 2 ] [ 0 ] - bl [ 0 ] al = [ 0 , a2 , a3 ] flag = ' Yes ' for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = al [ i ] + bl [ j ] : flag = ' No ' break print ( flag ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] ind = 0 for j in range ( 1 , 3 ) : if not ( C [ 0 ] [ j ] - C [ 0 ] [ j - 1 ] = = C [ 1 ] [ j ] - C [ 1 ] [ j - 1 ] = = C [ 2 ] [ j ] - C [ 2 ] [ j - 1 ] ) : ind = 1 break if ind = = 1 : print ( " No " ) else : print ( " Yes " ) import sys c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] b = [ ] a = [ 0 ] for i in range ( 3 ) : b . append ( c [ 0 ] [ i ] ) for i in range ( 3 ) : if i = = 0 : continue else : a . append ( c [ i ] [ i ] - b [ i ] ) for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = a [ i ] + b [ j ] : print ( " No " ) sys . exit ( ) print ( " Yes " ) c = [ ] for i in range ( 3 ) : a = list ( map ( int , input ( ) . split ( ) ) ) c . append ( a ) flag = True b = [ [ 0 ] * 3 ] * 3 B = dict ( ) for i in range ( 3 ) : for j in range ( 3 ) : if i = = j : continue l = [ ] for k in range ( 3 ) : x = c [ k ] [ i ] - c [ k ] [ j ] if len ( l ) < 1 : l . append ( x ) else : for m in range ( len ( l ) ) : if x ! = l [ m ] : flag = False l . append ( x ) if flag : print ( " Yes " ) else : print ( " No " ) def l ( ) : return list ( map ( int , input ( ) . split ( ) ) ) def m ( ) : return map ( int , input ( ) . split ( ) ) def main ( ) : c = [ 0 ] * 3 for i in range ( 3 ) : c [ i ] = l ( ) a = [ 0 ] * 3 b = [ 0 ] * 3 b [ 0 ] = min ( c [ 0 ] ) for i in range ( 3 ) : a [ i ] = c [ 0 ] [ i ] - b [ 0 ] for i in range ( 1 , 3 ) : b [ i ] = c [ i ] [ 0 ] - a [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = a [ j ] + b [ i ] : print ( ' No ' ) exit ( ) print ( ' Yes ' ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] import sys a1 = max ( C [ 0 ] ) a2 = max ( C [ 1 ] ) a3 = max ( C [ 2 ] ) for i in range ( a1 + 1 ) : for j in range ( a2 + 1 ) : for k in range ( a3 + 1 ) : if C [ 0 ] [ 0 ] - i = = C [ 1 ] [ 0 ] - j and C [ 1 ] [ 0 ] - j = = C [ 2 ] [ 0 ] - k : if C [ 0 ] [ 1 ] - i = = C [ 1 ] [ 1 ] - j and C [ 1 ] [ 1 ] - j = = C [ 2 ] [ 1 ] - k : if C [ 0 ] [ 2 ] - i = = C [ 1 ] [ 2 ] - j and C [ 1 ] [ 2 ] - j = = C [ 2 ] [ 2 ] - k : print ( ' Yes ' ) sys . exit ( ) print ( ' No ' ) def main ( ) : C = [ [ 0 for _ in range ( 3 ) ] for _ in range ( 3 ) ] for i in range ( 3 ) : C [ i ] = list ( map ( int , input ( ) . split ( ) ) ) possible = True for i in range ( 1 , 3 ) : tmp = C [ i ] [ 0 ] - C [ i - 1 ] [ 0 ] for j in range ( 1 , 3 ) : if C [ i ] [ j ] - C [ i - 1 ] [ j ] ! = tmp : possible = False break for j in range ( 1 , 3 ) : tmp = C [ 0 ] [ j ] - C [ 0 ] [ j - 1 ] for i in range ( 1 , 3 ) : if C [ i ] [ j ] - C [ i ] [ j - 1 ] ! = tmp : possible = False break if possible : print ( " Yes " ) else : print ( " No " ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) c = [ [ i for i in map ( int , input ( ) . split ( ) ) ] for j in range ( 3 ) ] for i in range ( 101 ) : para = [ 0 ] * 6 para [ 0 ] = i para [ 3 ] = c [ 0 ] [ 0 ] - para [ 0 ] para [ 4 ] = c [ 0 ] [ 1 ] - para [ 0 ] para [ 5 ] = c [ 0 ] [ 2 ] - para [ 0 ] para [ 1 ] = c [ 1 ] [ 0 ] - para [ 3 ] para [ 2 ] = c [ 2 ] [ 0 ] - para [ 3 ] if c [ 1 ] [ 1 ] = = para [ 1 ] + para [ 4 ] and c [ 1 ] [ 2 ] = = para [ 1 ] + para [ 5 ] : if c [ 2 ] [ 1 ] = = para [ 2 ] + para [ 4 ] and c [ 2 ] [ 2 ] = = para [ 2 ] + para [ 5 ] : print ( " Yes " ) exit ( ) print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a = [ 0 , 0 , 0 ] count = 0 for i in range ( 2 ) : for j in range ( 3 ) : a [ j ] = c [ i ] [ j ] - c [ i + 1 ] [ j ] count + = 1 if a [ 0 ] = = a [ 1 ] = = a [ 2 ] else 0 print ( " Yes " if count = = 2 else " No " ) ls1 = [ int ( s ) for s in input ( ) . split ( ) ] ls2 = [ int ( s ) for s in input ( ) . split ( ) ] ls3 = [ int ( s ) for s in input ( ) . split ( ) ] if ( ls1 [ 0 ] - ls2 [ 0 ] = = ls1 [ 1 ] - ls2 [ 1 ] and ls1 [ 0 ] - ls2 [ 0 ] = = ls1 [ 2 ] - ls2 [ 2 ] and ls1 [ 0 ] - ls3 [ 0 ] = = ls1 [ 1 ] - ls3 [ 1 ] and ls1 [ 0 ] - ls3 [ 0 ] = = ls1 [ 2 ] - ls3 [ 2 ] ) : print ( " Yes " ) else : print ( " No " ) c _ 11 , c _ 12 , c _ 13 = [ int ( c ) for c in input ( ) . split ( ) ] c _ 21 , c _ 22 , c _ 23 = [ int ( cc ) for cc in input ( ) . split ( ) ] c _ 31 , c _ 32 , c _ 33 = [ int ( ccc ) for ccc in input ( ) . split ( ) ] if c _ 11 + c _ 22 = = c _ 12 + c _ 21 and c _ 11 + c _ 33 = = c _ 13 + c _ 31 and c _ 22 + c _ 33 = = c _ 23 + c _ 32 : print ( " Yes " ) else : print ( " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] import sys min _ a1 = min ( C [ 0 ] ) min _ a2 = min ( C [ 1 ] ) min _ a3 = min ( C [ 2 ] ) for a1 in range ( min _ a1 + 1 ) : b1 _ a1 = C [ 0 ] [ 0 ] - a1 b2 _ a1 = C [ 0 ] [ 1 ] - a1 b3 _ a1 = C [ 0 ] [ 2 ] - a1 for a2 in range ( min _ a2 + 1 ) : b1 _ a2 = C [ 1 ] [ 0 ] - a2 b2 _ a2 = C [ 1 ] [ 1 ] - a2 b3 _ a2 = C [ 1 ] [ 2 ] - a2 for a3 in range ( min _ a3 + 1 ) : b1 _ a3 = C [ 2 ] [ 0 ] - a3 b2 _ a3 = C [ 2 ] [ 1 ] - a3 b3 _ a3 = C [ 2 ] [ 2 ] - a3 if b1 _ a1 = = b1 _ a2 = = b1 _ a3 and b2 _ a1 = = b2 _ a2 = = b2 _ a3 and b3 _ a1 = = b3 _ a2 = = b3 _ a3 : print ( ' Yes ' ) sys . exit ( ) print ( ' No ' ) import sys input = sys . stdin . readline c = [ [ int ( x ) for x in input ( ) . split ( ) ] for _ in range ( 3 ) ] for i in range ( 101 ) : for j in range ( 101 ) : for k in range ( 101 ) : b1 , b2 , b3 = [ x - i for x in c [ 0 ] ] if [ b1 + j , b2 + j , b3 + j ] = = c [ 1 ] and [ b1 + k , b2 + k , b3 + k ] = = c [ 2 ] : print ( " Yes " ) sys . exit ( ) print ( " No " ) from sys import stdin if _ _ name _ _ = = " _ _ main _ _ " : _ in = [ _ . rstrip ( ) for _ in stdin . readlines ( ) ] c _ arr = [ ] for i in range ( 3 ) : _ = list ( map ( int , _ in [ i ] . split ( ' ' ) ) ) c _ arr . append ( _ ) sum _ c _ arr = sum ( [ sum ( c ) for c in c _ arr ] ) if ( c _ arr [ 0 ] [ 0 ] + c _ arr [ 1 ] [ 1 ] + c _ arr [ 2 ] [ 2 ] ) = = sum _ c _ arr / 3 and \ ( c _ arr [ 1 ] [ 0 ] + c _ arr [ 2 ] [ 1 ] + c _ arr [ 0 ] [ 2 ] ) = = sum _ c _ arr / 3 and \ ( c _ arr [ 0 ] [ 1 ] + c _ arr [ 1 ] [ 2 ] + c _ arr [ 2 ] [ 0 ] ) = = sum _ c _ arr / 3 : TF = ' Yes ' else : TF = ' No ' print ( TF ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) c = c1 + c2 + c3 if sum ( c ) % 3 = = 0 and c [ 0 ] + c [ 4 ] + c [ 8 ] = = c [ 1 ] + c [ 3 ] + c [ 8 ] : print ( " Yes " ) else : print ( " No " ) a , b , c = map ( int , input ( ) . split ( ) ) d , e , f = map ( int , input ( ) . split ( ) ) g , h , i = map ( int , input ( ) . split ( ) ) if a + e = = b + d : if b + f = = c + e : if d + h = = e + g : if e + i = = f + h : print ( ' Yes ' ) exit ( ) print ( ' No ' ) c _ l = [ ] for _ in range ( 3 ) : c _ l . append ( list ( map ( int , input ( ) . split ( ) ) ) ) b2mb1 = c _ l [ 0 ] [ 1 ] - c _ l [ 0 ] [ 0 ] b3mb1 = c _ l [ 0 ] [ 2 ] - c _ l [ 0 ] [ 0 ] for i in ( 1 , 2 ) : if c _ l [ i ] [ 1 ] ! = c _ l [ i ] [ 0 ] + b2mb1 : print ( ' No ' ) exit ( ) if c _ l [ i ] [ 2 ] ! = c _ l [ i ] [ 0 ] + b3mb1 : print ( ' No ' ) exit ( ) print ( ' Yes ' ) import sys c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] ans = ' Yes ' for i in range ( c [ 0 ] [ 0 ] + 1 ) : b = [ c [ 0 ] [ 0 ] - i , c [ 0 ] [ 1 ] - i , c [ 0 ] [ 2 ] - i ] a = [ i , abs ( b [ 0 ] - c [ 1 ] [ 0 ] ) , abs ( b [ 0 ] - c [ 2 ] [ 0 ] ) ] for j in range ( 1 , 3 ) : for k in range ( 3 ) : if c [ j ] [ k ] ! = a [ j ] + b [ k ] : ans = ' No ' break if ans ! = ' Yes ' : break if ans = = ' Yes ' : break if i ! = c [ 0 ] [ 0 ] : ans = ' Yes ' print ( ans ) grid = list ( ) for i in range ( 3 ) : grid . append ( [ int ( k ) for k in input ( ) . split ( " " ) ] ) def check _ vert ( ) : for i in range ( 2 ) : diffs = [ grid [ k ] [ i ] - grid [ k ] [ i + 1 ] for k in range ( 3 ) ] if not len ( set ( diffs ) ) = = 1 : return False else : return True def check _ hor ( ) : for i in range ( 2 ) : diffs = [ grid [ i ] [ k ] - grid [ i + 1 ] [ k ] for k in range ( 3 ) ] if not len ( set ( diffs ) ) = = 1 : return False else : return True if check _ hor ( ) and check _ vert ( ) : print ( " Yes " ) else : print ( " No " ) G = [ ] for i in range ( 3 ) : g = list ( map ( int , input ( ) . split ( ) ) ) G . append ( g ) ok = True if G [ 1 ] [ 1 ] ! = G [ 1 ] [ 0 ] - G [ 0 ] [ 0 ] + G [ 0 ] [ 1 ] : ok = False if G [ 1 ] [ 2 ] ! = G [ 1 ] [ 0 ] - G [ 0 ] [ 0 ] + G [ 0 ] [ 2 ] : ok = False if G [ 2 ] [ 1 ] ! = G [ 2 ] [ 0 ] - G [ 0 ] [ 0 ] + G [ 0 ] [ 1 ] : ok = False if G [ 2 ] [ 2 ] ! = G [ 2 ] [ 0 ] - G [ 0 ] [ 0 ] + G [ 0 ] [ 2 ] : ok = False if ok : print ( " Yes " ) else : print ( " No " ) s = [ ] a = [ 0 , 0 , 0 ] b = [ 0 , 0 , 0 ] for i in range ( 3 ) : s . append ( list ( map ( int , input ( ) . split ( ) ) ) ) b [ 0 ] = s [ 0 ] [ 0 ] b [ 1 ] = s [ 0 ] [ 1 ] b [ 2 ] = s [ 0 ] [ 2 ] a [ 1 ] = s [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = s [ 2 ] [ 0 ] - b [ 0 ] for i in range ( 1 , 3 ) : for j in range ( 1 , 3 ) : if s [ i ] [ j ] ! = a [ i ] + b [ j ] : print ( " No " ) exit ( ) print ( " Yes " ) c = [ [ int ( x ) for x in input ( ) . split ( ) ] for _ in range ( 3 ) ] ans = " No " for a1 in c [ 0 ] : for a2 in c [ 1 ] : for a3 in c [ 2 ] : b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 1 ] [ 1 ] - a2 b3 = c [ 2 ] [ 2 ] - a3 if a1 + b2 = = c [ 0 ] [ 1 ] and a1 + b3 = = c [ 0 ] [ 2 ] and a2 + b1 = = c [ 1 ] [ 0 ] and a2 + b3 = = c [ 1 ] [ 2 ] and a3 + b1 = = c [ 2 ] [ 0 ] and a3 + b2 = = c [ 2 ] [ 1 ] : ans = " Yes " break if ans = = " Yes " : break if ans = = " Yes " : break print ( ans ) C = [ [ ] , [ ] , [ ] ] C [ 0 ] = list ( map ( int , input ( ) . split ( ) ) ) C [ 1 ] = list ( map ( int , input ( ) . split ( ) ) ) C [ 2 ] = list ( map ( int , input ( ) . split ( ) ) ) cond0 _ 0 = C [ 0 ] [ 0 ] - C [ 0 ] [ 1 ] = = C [ 1 ] [ 0 ] - C [ 1 ] [ 1 ] = = C [ 2 ] [ 0 ] - C [ 2 ] [ 1 ] cond0 _ 1 = C [ 0 ] [ 0 ] - C [ 0 ] [ 2 ] = = C [ 1 ] [ 0 ] - C [ 1 ] [ 2 ] = = C [ 2 ] [ 0 ] - C [ 2 ] [ 2 ] cond0 _ 2 = C [ 0 ] [ 1 ] - C [ 0 ] [ 2 ] = = C [ 1 ] [ 1 ] - C [ 1 ] [ 2 ] = = C [ 2 ] [ 1 ] - C [ 2 ] [ 2 ] cond0 = cond0 _ 0 and cond0 _ 1 and cond0 _ 2 cond1 _ 0 = C [ 0 ] [ 0 ] - C [ 1 ] [ 0 ] = = C [ 0 ] [ 1 ] - C [ 1 ] [ 1 ] = = C [ 0 ] [ 2 ] - C [ 1 ] [ 2 ] cond1 _ 1 = C [ 0 ] [ 0 ] - C [ 2 ] [ 0 ] = = C [ 0 ] [ 1 ] - C [ 2 ] [ 1 ] = = C [ 0 ] [ 2 ] - C [ 2 ] [ 2 ] cond1 _ 2 = C [ 1 ] [ 0 ] - C [ 2 ] [ 0 ] = = C [ 1 ] [ 1 ] - C [ 2 ] [ 1 ] = = C [ 1 ] [ 2 ] - C [ 2 ] [ 2 ] cond1 = cond1 _ 0 and cond1 _ 1 and cond1 _ 2 if cond0 and cond1 : print ( ' Yes ' ) else : print ( ' No ' ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] x1 = C [ 0 ] [ 1 ] - C [ 0 ] [ 0 ] ; x2 = C [ 0 ] [ 2 ] - C [ 0 ] [ 1 ] ; y1 = C [ 1 ] [ 0 ] - C [ 0 ] [ 0 ] ; y2 = C [ 2 ] [ 0 ] - C [ 1 ] [ 0 ] ; C2 = [ [ C [ 0 ] [ 0 ] , C [ 0 ] [ 0 ] + x1 , C [ 0 ] [ 0 ] + x1 + x2 ] , [ C [ 0 ] [ 0 ] + y1 , C [ 0 ] [ 0 ] + x1 + y1 , C [ 0 ] [ 0 ] + x1 + x2 + y1 ] , [ C [ 0 ] [ 0 ] + y1 + y2 , C [ 0 ] [ 0 ] + x1 + y1 + y2 , C [ 0 ] [ 0 ] + x1 + x2 + y1 + y2 ] ] print ( " Yes " if C = = C2 else " No " ) a = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] if a [ 0 ] [ 1 ] - a [ 0 ] [ 0 ] = = a [ 1 ] [ 1 ] - a [ 1 ] [ 0 ] = = a [ 2 ] [ 1 ] - a [ 2 ] [ 0 ] and a [ 0 ] [ 2 ] - a [ 0 ] [ 0 ] = = a [ 1 ] [ 2 ] - a [ 1 ] [ 0 ] = = a [ 2 ] [ 2 ] - a [ 2 ] [ 0 ] : print ( ' Yes ' ) else : print ( ' No ' ) c = [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( 3 ) ] h1 = c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 0 ] [ 2 ] h2 = c [ 2 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 1 ] [ 2 ] w1 = c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 2 ] [ 0 ] w2 = c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 2 ] [ 1 ] if h1 and h2 and w1 and w2 : print ( ' Yes ' ) else : print ( ' No ' ) c = [ ] for i in range ( 3 ) : x , y , z = map ( int , input ( ) . split ( ) ) c . append ( [ x , y , z ] ) if ( c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 0 ] [ 2 ] ) and ( c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 0 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 0 ] [ 2 ] ) : print ( ' Yes ' ) else : print ( ' No ' ) C = [ ] for i in range ( 3 ) : c = list ( map ( int , input ( ) . split ( ) ) ) C . append ( c ) a = [ None , None , None ] b = [ None , None , None ] for a1 in range ( 101 ) : a [ 0 ] = a1 b [ 0 ] = C [ 0 ] [ 0 ] - a [ 0 ] b [ 1 ] = C [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = C [ 0 ] [ 2 ] - a [ 0 ] a [ 1 ] = C [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = C [ 2 ] [ 0 ] - b [ 0 ] ans = ' Yes ' for i in range ( 3 ) : for j in range ( 3 ) : if C [ i ] [ j ] ! = a [ i ] + b [ j ] : ans = ' No ' print ( ans ) l = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] l . sort ( ) if l [ 1 ] [ 0 ] - l [ 0 ] [ 0 ] = = l [ 1 ] [ 1 ] - l [ 0 ] [ 1 ] = = l [ 1 ] [ 2 ] - l [ 0 ] [ 2 ] : if l [ 2 ] [ 0 ] - l [ 0 ] [ 0 ] = = l [ 2 ] [ 1 ] - l [ 0 ] [ 1 ] = = l [ 2 ] [ 2 ] - l [ 0 ] [ 2 ] : print ( ' Yes ' ) else : print ( ' No ' ) else : print ( ' No ' ) lst = [ ] for _ in range ( 3 ) : lst + = [ list ( map ( int , input ( ) . split ( ) ) ) ] total = 0 for i in range ( 3 ) : for j in range ( 3 ) : total + = lst [ i ] [ j ] total = total / / 3 flag = True for i in range ( 3 ) : a = lst [ 0 ] [ i % 3 ] + lst [ 1 ] [ ( i + 1 ) % 3 ] + lst [ 2 ] [ ( i + 2 ) % 3 ] if a ! = total : flag = False a = lst [ 0 ] [ 0 ] + lst [ 1 ] [ 2 ] + lst [ 2 ] [ 1 ] if a ! = total : flag = False a = lst [ 1 ] [ 1 ] + lst [ 0 ] [ 2 ] + lst [ 2 ] [ 0 ] if a ! = total : flag = False a = lst [ 2 ] [ 2 ] + lst [ 1 ] [ 0 ] + lst [ 0 ] [ 1 ] if a ! = total : flag = False if flag : print ( ' Yes ' ) else : print ( ' No ' ) def main ( ) : c = [ ] for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for a1 in range ( 101 ) : b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 if b1 < 0 or b2 < 0 or b3 < 0 : continue a2 _ 1 = c [ 1 ] [ 0 ] - b1 a2 _ 2 = c [ 1 ] [ 1 ] - b2 a2 _ 3 = c [ 1 ] [ 2 ] - b3 if a2 _ 1 < 0 or a2 _ 2 < 0 or a2 _ 3 < 0 : continue if a2 _ 1 ! = a2 _ 2 or a2 _ 2 ! = a2 _ 3 or a2 _ 1 ! = a2 _ 3 : continue a3 _ 1 = c [ 2 ] [ 0 ] - b1 a3 _ 2 = c [ 2 ] [ 1 ] - b2 a3 _ 3 = c [ 2 ] [ 2 ] - b3 if a3 _ 1 < 0 or a3 _ 2 < 0 or a3 _ 3 < 0 : continue if a3 _ 1 ! = a3 _ 2 or a3 _ 2 ! = a3 _ 3 or a3 _ 1 ! = a3 _ 3 : continue print ( " Yes " ) return print ( " No " ) if _ _ name _ _ = = " _ _ main _ _ " : main ( ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for l in range ( 3 ) ] flag = False for i in range ( c [ 0 ] [ 0 ] + 1 ) : a1 = i b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 a2 = c [ 1 ] [ 0 ] - b1 a3 = c [ 2 ] [ 0 ] - b1 if c [ 1 ] [ 1 ] = = a2 + b2 and c [ 1 ] [ 2 ] = = a2 + b3 and c [ 2 ] [ 1 ] = = a3 + b2 and c [ 2 ] [ 2 ] = = a3 + b3 : flag = True break else : continue if flag : print ( ' Yes ' ) else : print ( ' No ' ) grid = [ ] for i in range ( 3 ) : grid . append ( [ int ( i ) for i in input ( ) . split ( ) ] ) for _ in range ( 100 ) : a1 = i b1 = grid [ 0 ] [ 0 ] - a1 b2 = grid [ 0 ] [ 1 ] - a1 b3 = grid [ 0 ] [ 2 ] - a1 if grid [ 1 ] [ 0 ] - b1 = = grid [ 1 ] [ 1 ] - b2 = = grid [ 1 ] [ 2 ] - b3 and grid [ 2 ] [ 0 ] - b1 = = grid [ 2 ] [ 1 ] - b2 = = grid [ 2 ] [ 2 ] - b3 : print ( ' Yes ' ) exit ( ) print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] count = 0 x = c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] y = c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] z = c [ 0 ] [ 0 ] - c [ 0 ] [ 2 ] for i in range ( 1 , 3 ) : if ( c [ i ] [ 1 ] - c [ i ] [ 0 ] ! = x ) : count + = 1 if ( c [ i ] [ 2 ] - c [ i ] [ 1 ] ! = y ) : count + = 1 if ( c [ i ] [ 0 ] - c [ i ] [ 2 ] ! = z ) : count + = 1 X = c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] Y = c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] Z = c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] for j in range ( 1 , 3 ) : if ( c [ 0 ] [ i ] - c [ 1 ] [ i ] ! = X ) : count + = 1 if ( c [ 1 ] [ i ] - c [ 2 ] [ i ] ! = Y ) : count + = 1 if ( c [ 2 ] [ i ] - c [ 0 ] [ i ] ! = Z ) : count + = 1 if ( count = = 0 ) : print ( " Yes " ) else : print ( " No " ) import copy line = [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( 3 ) ] ansB = copy . copy ( line [ 0 ] ) ansA = [ 0 , line [ 1 ] [ 0 ] - ansB [ 0 ] , line [ 2 ] [ 0 ] - ansB [ 0 ] ] for i in range ( 1 , 3 ) : for j in range ( 1 , 3 ) : if ansA [ i ] + ansB [ j ] ! = line [ i ] [ j ] : print ( " No " ) exit ( ) print ( " Yes " ) grid = [ ] for i in range ( 3 ) : grid . append ( list ( map ( int , input ( ) . split ( ) ) ) ) b = grid [ 0 ] a = ( 0 , grid [ 1 ] [ 1 ] - b [ 1 ] , grid [ 2 ] [ 2 ] - b [ 2 ] ) for i in range ( 3 ) : for j in range ( 3 ) : if a [ i ] + b [ j ] ! = grid [ i ] [ j ] : print ( ' No ' ) exit ( 0 ) print ( ' Yes ' ) import numpy as np n1 = list ( map ( int , input ( ) . split ( ) ) ) n2 = list ( map ( int , input ( ) . split ( ) ) ) n3 = list ( map ( int , input ( ) . split ( ) ) ) A = np . array ( [ n1 , n2 , n3 ] ) def check ( b1 , b2 , b3 ) : if b1 = = b2 and b2 = = b3 : return True else : return False flg = False for i in range ( max ( A [ 0 ] ) + 1 ) : diff _ n1 = A [ 0 ] - i b1 = A [ 1 ] [ 0 ] - diff _ n1 [ 0 ] b2 = A [ 1 ] [ 1 ] - diff _ n1 [ 1 ] b3 = A [ 1 ] [ 2 ] - diff _ n1 [ 2 ] c1 = A [ 2 ] [ 0 ] - diff _ n1 [ 0 ] c2 = A [ 2 ] [ 1 ] - diff _ n1 [ 1 ] c3 = A [ 2 ] [ 2 ] - diff _ n1 [ 2 ] if check ( b1 , b2 , b3 ) and check ( c1 , c2 , c3 ) : flg = True if flg : print ( ' Yes ' ) else : print ( ' No ' ) C = [ [ 0 ] * 3 for i in range ( 3 ) ] for ii in range ( 3 ) : C [ ii ] = list ( map ( int , input ( ) . split ( ) ) ) Flag = 1 for ii in range ( 1 , 3 ) : for jj in range ( 1 , 3 ) : if C [ ii - 1 ] [ jj - 1 ] - C [ ii ] [ jj - 1 ] ! = C [ ii - 1 ] [ jj ] - C [ ii ] [ jj ] : Flag = 0 break if Flag = = 0 : break if Flag = = 1 : print ( ' Yes ' ) else : print ( ' No ' ) c = [ ] for _ in range ( 3 ) : tmp = list ( map ( int , input ( ) . split ( ) ) ) c . append ( tmp ) a _ flag = [ 0 , 0 , 0 ] b _ flag = [ 0 , 0 , 0 ] for i in range ( 3 ) : if i ! = 0 : if c [ 0 ] [ i ] - c [ 0 ] [ i - 1 ] = = c [ 1 ] [ i ] - c [ 1 ] [ i - 1 ] and c [ 1 ] [ i ] - c [ 1 ] [ i - 1 ] = = c [ 2 ] [ i ] - c [ 2 ] [ i - 1 ] : a _ flag [ i ] = 1 else : if c [ 0 ] [ 2 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 2 ] - c [ 1 ] [ 0 ] and c [ 1 ] [ 2 ] - c [ 1 ] [ 0 ] = = c [ 2 ] [ 2 ] - c [ 2 ] [ 0 ] : a _ flag [ i ] = 1 for j in range ( 3 ) : if j ! = 0 : if c [ j ] [ 0 ] - c [ j - 1 ] [ 0 ] = = c [ j ] [ 1 ] - c [ j - 1 ] [ 1 ] and c [ j ] [ 1 ] - c [ j - 1 ] [ 1 ] = = c [ j ] [ 2 ] - c [ j - 1 ] [ 2 ] : b _ flag [ j ] = 1 else : if c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 0 ] [ 1 ] and c [ 2 ] [ 1 ] - c [ 0 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 0 ] [ 2 ] : b _ flag [ j ] = 1 if sum ( a _ flag ) = = 3 and sum ( b _ flag ) = = 3 : print ( " Yes " ) else : print ( " No " ) cs = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 2 ) : yoko = abs ( cs [ 0 ] [ i ] - cs [ 0 ] [ i + 1 ] ) for j in range ( 1 , 3 ) : if yoko - abs ( cs [ j ] [ i ] - cs [ j ] [ i + 1 ] ) ! = 0 : print ( ' No ' ) exit ( ) for i in range ( 2 ) : tate = abs ( cs [ 0 + i ] [ 0 ] - cs [ 1 + i ] [ 0 ] ) for j in range ( 1 , 3 ) : if tate - abs ( cs [ i ] [ j ] - cs [ i + 1 ] [ j ] ) ! = 0 : print ( ' No ' ) exit ( ) print ( ' Yes ' ) import sys input = sys . stdin . readline def main ( ) : G = [ [ 0 for _ in range ( 3 ) ] for _ in range ( 3 ) ] for i in range ( 3 ) : G [ i ] = [ int ( e ) for e in input ( ) . split ( ) ] for a0 in range ( 0 , 100 + 1 ) : b0 = G [ 0 ] [ 0 ] - a0 b1 = G [ 0 ] [ 1 ] - a0 b2 = G [ 0 ] [ 2 ] - a0 a1 = G [ 1 ] [ 0 ] - b0 a2 = G [ 2 ] [ 0 ] - b0 if a0 + b0 = = G [ 0 ] [ 0 ] and \ a0 + b1 = = G [ 0 ] [ 1 ] and \ a0 + b2 = = G [ 0 ] [ 2 ] and \ a1 + b0 = = G [ 1 ] [ 0 ] and \ a1 + b1 = = G [ 1 ] [ 1 ] and \ a1 + b2 = = G [ 1 ] [ 2 ] and \ a2 + b0 = = G [ 2 ] [ 0 ] and \ a2 + b1 = = G [ 2 ] [ 1 ] and \ a2 + b2 = = G [ 2 ] [ 2 ] : print ( " Yes " ) return print ( " No " ) main ( ) G1 = list ( map ( int , input ( ) . split ( ) ) ) G2 = list ( map ( int , input ( ) . split ( ) ) ) G3 = list ( map ( int , input ( ) . split ( ) ) ) sub _ G1 = [ ] sub _ G2 = [ ] sub _ G3 = [ ] sub _ R12 = [ ] sub _ R23 = [ ] for i in range ( 2 ) : sub _ G1 . append ( G1 [ i + 1 ] - G1 [ i ] ) sub _ G2 . append ( G2 [ i + 1 ] - G2 [ i ] ) sub _ G3 . append ( G3 [ i + 1 ] - G3 [ i ] ) for k in range ( 3 ) : sub _ R12 . append ( G2 [ i ] - G1 [ i ] ) sub _ R23 . append ( G3 [ i ] - G2 [ i ] ) condition1 = bool ( sub _ G1 [ 0 ] = = sub _ G2 [ 0 ] = = sub _ G3 [ 0 ] ) condition2 = bool ( sub _ G1 [ 1 ] = = sub _ G2 [ 1 ] = = sub _ G3 [ 1 ] ) condition3 = bool ( len ( set ( sub _ R12 ) ) = = 1 ) condition4 = bool ( len ( set ( sub _ R23 ) ) = = 1 ) if condition1 and condition2 and condition3 and condition4 : print ( " Yes " ) else : print ( " No " ) grid = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 3 ) : c = grid [ i ] [ 0 ] for j in range ( 3 ) : grid [ i ] [ j ] - = c ans = ' Yes ' if grid [ 0 ] = = grid [ 1 ] and grid [ 1 ] = = grid [ 2 ] else ' No ' print ( ans ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for x in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 for i in range ( 3 ) : b [ i ] = c [ 0 ] [ i ] - a [ 0 ] a [ 1 ] = c [ 1 ] [ 1 ] - b [ 1 ] a [ 2 ] = c [ 2 ] [ 2 ] - b [ 2 ] for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = a [ i ] + b [ j ] : print ( ' No ' ) exit ( ) print ( ' Yes ' ) A = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] b2 _ 1 = A [ 0 ] [ 1 ] - A [ 0 ] [ 0 ] b3 _ 1 = A [ 0 ] [ 2 ] - A [ 0 ] [ 0 ] if any ( [ b2 _ 1 ! = A [ x ] [ 1 ] - A [ x ] [ 0 ] for x in [ 1 , 2 ] ] ) or any ( [ b3 _ 1 ! = A [ x ] [ 2 ] - A [ x ] [ 0 ] for x in [ 1 , 2 ] ] ) : print ( " No " ) else : print ( " Yes " ) ans = ' Yes ' C = [ ] for i in range ( 0 , 3 ) : C . append ( list ( map ( int , input ( ) . split ( ) ) ) ) a1ma2 = C [ 0 ] [ 0 ] - C [ 1 ] [ 0 ] if a1ma2 ! = C [ 0 ] [ 1 ] - C [ 1 ] [ 1 ] or a1ma2 ! = C [ 0 ] [ 2 ] - C [ 1 ] [ 2 ] : ans = ' No ' a1ma3 = C [ 0 ] [ 0 ] - C [ 2 ] [ 0 ] if a1ma3 ! = C [ 0 ] [ 1 ] - C [ 2 ] [ 1 ] or a1ma3 ! = C [ 0 ] [ 2 ] - C [ 2 ] [ 2 ] : ans = ' No ' a2ma3 = C [ 1 ] [ 0 ] - C [ 2 ] [ 0 ] if a2ma3 ! = C [ 1 ] [ 1 ] - C [ 2 ] [ 1 ] or a2ma3 ! = C [ 1 ] [ 2 ] - C [ 2 ] [ 2 ] : ans = ' No ' b1mb2 = C [ 0 ] [ 0 ] - C [ 0 ] [ 1 ] if b1mb2 ! = C [ 1 ] [ 0 ] - C [ 1 ] [ 1 ] or b1mb2 ! = C [ 2 ] [ 0 ] - C [ 2 ] [ 1 ] : ans = ' No ' b1mb3 = C [ 0 ] [ 0 ] - C [ 0 ] [ 2 ] if b1mb3 ! = C [ 1 ] [ 0 ] - C [ 1 ] [ 2 ] or b1mb3 ! = C [ 2 ] [ 0 ] - C [ 2 ] [ 2 ] : ans = ' No ' b2mb3 = C [ 0 ] [ 1 ] - C [ 0 ] [ 2 ] if b2mb3 ! = C [ 1 ] [ 1 ] - C [ 1 ] [ 2 ] or b2mb3 ! = C [ 2 ] [ 1 ] - C [ 2 ] [ 2 ] : ans = ' No ' print ( ans ) c = [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( 3 ) ] print ( ' Yes ' ) if c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] = = c [ 0 ] [ 1 ] + c [ 1 ] [ 2 ] + c [ 2 ] [ 0 ] = = c [ 0 ] [ 2 ] + c [ 1 ] [ 0 ] + c [ 2 ] [ 1 ] else print ( ' No ' ) from collections import deque C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( C [ 0 ] [ 0 ] + 1 ) : q = deque ( [ C [ 0 ] [ 0 ] - i , C [ 0 ] [ 1 ] - i , C [ 0 ] [ 2 ] - i , C [ 0 ] [ 0 ] - i , C [ 0 ] [ 1 ] - i , C [ 0 ] [ 2 ] - i ] ) flag = 0 for j in range ( 1 , 3 ) : d = set ( ) for k in range ( 3 ) : d . add ( C [ j ] [ k ] - q . popleft ( ) ) if len ( d ) = = 1 : flag + = 1 if flag = = 2 : print ( ' Yes ' ) exit ( ) print ( ' No ' ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) a1 = 0 a2 = ( c12 - c11 , c22 - c21 , c32 - c31 ) a3 = ( c13 - c11 , c23 - c21 , c33 - c31 ) if len ( set ( a2 ) ) = = 1 and len ( set ( a3 ) ) = = 1 : print ( " Yes " ) else : print ( " No " ) import numpy as np C = [ ] for i in range ( 3 ) : c _ horizontal = list ( map ( int , input ( ) . split ( ) ) ) C . append ( c _ horizontal ) A = np . array ( [ [ 1 , 0 , 0 , 1 , 0 , 0 ] , [ 1 , 0 , 0 , 0 , 1 , 0 ] , [ 1 , 0 , 0 , 0 , 0 , 1 ] , [ 0 , 1 , 0 , 1 , 0 , 0 ] , [ 0 , 1 , 0 , 0 , 1 , 0 ] , [ 0 , 1 , 0 , 0 , 0 , 1 ] , [ 0 , 0 , 1 , 1 , 0 , 0 ] , [ 0 , 0 , 1 , 0 , 1 , 0 ] , [ 0 , 0 , 1 , 0 , 0 , 1 ] ] ) Ab = np . array ( [ [ 1 , 0 , 0 , 1 , 0 , 0 , C [ 0 ] [ 0 ] ] , [ 1 , 0 , 0 , 0 , 1 , 0 , C [ 0 ] [ 1 ] ] , [ 1 , 0 , 0 , 0 , 0 , 1 , C [ 0 ] [ 2 ] ] , [ 0 , 1 , 0 , 1 , 0 , 0 , C [ 1 ] [ 0 ] ] , [ 0 , 1 , 0 , 0 , 1 , 0 , C [ 1 ] [ 1 ] ] , [ 0 , 1 , 0 , 0 , 0 , 1 , C [ 1 ] [ 2 ] ] , [ 0 , 0 , 1 , 1 , 0 , 0 , C [ 2 ] [ 0 ] ] , [ 0 , 0 , 1 , 0 , 1 , 0 , C [ 2 ] [ 1 ] ] , [ 0 , 0 , 1 , 0 , 0 , 1 , C [ 2 ] [ 2 ] ] ] ) rankA = np . linalg . matrix _ rank ( A ) rankAb = np . linalg . matrix _ rank ( Ab ) if rankA = = rankAb : print ( ' Yes ' ) else : print ( ' No ' ) a , b , c = map ( int , input ( ) . split ( ) ) d , e , f = map ( int , input ( ) . split ( ) ) g , h , i = map ( int , input ( ) . split ( ) ) if b - a = = e - d = = h - g and c - b = = f - e = = i - h and \ d - a = = e - b = = f - c and g - d = = h - e = = i - f : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] if all ( ( c [ 0 ] [ i + 1 ] - c [ 0 ] [ i ] = = c [ 1 ] [ i + 1 ] - c [ 1 ] [ i ] = = c [ 2 ] [ i + 1 ] - c [ 2 ] [ i ] for i in range ( 2 ) ) ) : print ( " Yes " ) else : print ( " No " ) matrix = [ ] for _ in range ( 3 ) : row = [ int ( i ) for i in input ( ) . split ( ) ] matrix . append ( row ) a1 = matrix [ 1 ] [ 0 ] - matrix [ 0 ] [ 0 ] a2 = matrix [ 2 ] [ 0 ] - matrix [ 0 ] [ 0 ] b1 = matrix [ 0 ] [ 1 ] - matrix [ 0 ] [ 0 ] b2 = matrix [ 0 ] [ 2 ] - matrix [ 0 ] [ 0 ] if a1 + b1 = = matrix [ 1 ] [ 1 ] - matrix [ 0 ] [ 0 ] and a2 + b2 = = matrix [ 2 ] [ 2 ] - matrix [ 0 ] [ 0 ] and a1 + b2 = = matrix [ 1 ] [ 2 ] - matrix [ 0 ] [ 0 ] and a2 + b1 = = matrix [ 2 ] [ 1 ] - matrix [ 0 ] [ 0 ] : print ( ' Yes ' ) else : print ( ' No ' ) f1 , f2 , f3 = map ( int , input ( ) . split ( ) ) d1 = f2 - f1 d2 = f3 - f2 flag = True for _ in range ( 2 ) : c1 , c2 , c3 = map ( int , input ( ) . split ( ) ) if c2 - c1 ! = d1 or c3 - c2 ! = d2 : flag = False break if flag : print ( " Yes " ) else : print ( " No " ) C = [ ] for _ in range ( 3 ) : C . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for a1 in range ( max ( C [ 0 ] ) + 1 ) : b1 = C [ 0 ] [ 0 ] - a1 for a2 in range ( max ( C [ 1 ] ) + 1 ) : b2 = C [ 1 ] [ 1 ] - a2 if a1 + b2 ! = C [ 0 ] [ 1 ] or a2 + b1 ! = C [ 1 ] [ 0 ] : continue for a3 in range ( max ( C [ 2 ] ) + 1 ) : b3 = C [ 2 ] [ 2 ] - a3 if a1 + b3 = = C [ 0 ] [ 2 ] and a2 + b3 = = C [ 1 ] [ 2 ] and a3 + b1 = = C [ 2 ] [ 0 ] and a3 + b2 = = C [ 2 ] [ 1 ] : print ( " Yes " ) exit ( ) print ( " No " ) l = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for a1 in range ( 101 ) : for a2 in range ( 101 ) : for a3 in range ( 101 ) : b1 = l [ 0 ] [ 0 ] - a1 b2 = l [ 0 ] [ 1 ] - a1 b3 = l [ 0 ] [ 2 ] - a1 a = [ a1 , a2 , a3 ] b = [ b1 , b2 , b3 ] cnt = 0 for i in range ( 3 ) : for j in range ( 3 ) : if l [ i ] [ j ] = = a [ i ] + b [ j ] : cnt + = 1 if cnt = = 9 : print ( " Yes " ) exit ( ) print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] if c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] and c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] = = c [ 2 ] [ 1 ] - c [ 2 ] [ 2 ] : print ( ' Yes ' ) else : print ( ' No ' ) * c , = map ( int , open ( 0 ) . read ( ) . split ( ) ) for i in range ( 2 ) : if ( ( c [ 1 + i ] - c [ 0 + i ] ) ! = ( c [ 4 + i ] - c [ 3 + i ] ) or ( c [ 1 + i ] - c [ 0 + i ] ) ! = ( c [ 7 + i ] - c [ 6 + i ] ) or ( c [ 3 + i * 3 ] - c [ i * 3 ] ) ! = ( c [ 4 + i * 3 ] - c [ 1 + i * 3 ] ) or ( c [ 3 + i * 3 ] - c [ i * 3 ] ) ! = ( c [ 5 + i * 3 ] - c [ 2 + i * 3 ] ) ) : print ( " No " ) break else : print ( " Yes " ) def solve ( CC ) : R = [ sum ( CC [ i ] ) for i in range ( 3 ) ] C = [ sum ( CC [ j ] [ i ] for j in range ( 3 ) ) for i in range ( 3 ) ] checked = all ( ( R [ i ] - R [ i - 1 ] ) % 3 = = 0 for i in range ( 3 ) ) checked & = all ( ( C [ i ] - C [ i - 1 ] ) % 3 = = 0 for i in range ( 3 ) ) return ' Yes ' if checked else ' No ' _ CC = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] print ( solve ( _ CC ) ) import sys read = sys . stdin . buffer . read readline = sys . stdin . buffer . readline readlines = sys . stdin . buffer . readlines sys . setrecursionlimit ( 10 * * 7 ) c _ 1 = list ( map ( int , readline ( ) . split ( ) ) ) c _ 2 = list ( map ( int , readline ( ) . split ( ) ) ) c _ 3 = list ( map ( int , readline ( ) . split ( ) ) ) c = [ c _ 1 , c _ 2 , c _ 3 ] a = [ min ( c _ 1 ) , min ( c _ 2 ) , min ( c _ 3 ) ] b = [ c _ 1 [ 0 ] - a [ 0 ] , c _ 2 [ 1 ] - a [ 1 ] , c _ 3 [ 2 ] - a [ 2 ] ] for i in range ( 3 ) : for j in range ( 3 ) : if a [ i ] + b [ j ] ! = c [ i ] [ j ] : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c = [ ] for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) cnt = [ ] ans = 0 for k in range ( 2 ) : cnt = c [ k ] for i in range ( k + 1 , 3 ) : for j in range ( - 100 , 101 , 1 ) : if k = = i : break else : d = c [ i ] d = [ a + j for a in c [ i ] ] if d = = c [ k ] : ans + = 1 break if ans = = 3 : for k in range ( 2 ) : c1 = c [ 0 ] [ k ] c2 = c [ 1 ] [ k ] c3 = c [ 2 ] [ k ] for i in range ( k + 1 , 3 ) : d1 = c [ 0 ] [ i ] d2 = c [ 1 ] [ i ] d3 = c [ 2 ] [ i ] for j in range ( - 100 , 101 , 1 ) : if k = = i : break else : d1 + = j d2 + = j d3 + = j if d1 = = c1 and d2 = = c2 and d3 = = c3 : ans + = 1 break else : d1 = c [ 0 ] [ i ] d2 = c [ 1 ] [ i ] d3 = c [ 2 ] [ i ] if ans = = 6 : print ( ' Yes ' ) else : print ( ' No ' ) else : print ( ' No ' ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = C [ 1 ] [ 0 ] - C [ 0 ] [ 0 ] = = C [ 1 ] [ 1 ] - C [ 0 ] [ 1 ] = = C [ 1 ] [ 2 ] - C [ 0 ] [ 2 ] b = C [ 2 ] [ 0 ] - C [ 0 ] [ 0 ] = = C [ 2 ] [ 1 ] - C [ 0 ] [ 1 ] = = C [ 2 ] [ 2 ] - C [ 0 ] [ 2 ] if a and b : print ( ' Yes ' ) else : print ( ' No ' ) A = [ ] for i in range ( 3 ) : temp = list ( map ( int , input ( ) . split ( ) ) ) A . append ( temp ) if A [ 0 ] [ 0 ] + A [ 1 ] [ 1 ] = = A [ 0 ] [ 1 ] + A [ 1 ] [ 0 ] and \ A [ 0 ] [ 1 ] + A [ 1 ] [ 2 ] = = A [ 0 ] [ 2 ] + A [ 1 ] [ 1 ] and \ A [ 1 ] [ 0 ] + A [ 2 ] [ 1 ] = = A [ 1 ] [ 1 ] + A [ 2 ] [ 0 ] and \ A [ 1 ] [ 1 ] + A [ 2 ] [ 2 ] = = A [ 1 ] [ 2 ] + A [ 2 ] [ 1 ] : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] d = [ list ( v [ i + 1 ] - v [ i ] for i in range ( 2 ) ) for v in c ] print ( ' Yes ' if d [ 0 ] = = d [ 1 ] = = d [ 2 ] else ' No ' ) C11 , C12 , C13 = map ( int , input ( ) . split ( ) ) ; C21 , C22 , C23 = map ( int , input ( ) . split ( ) ) ; C31 , C32 , C33 = map ( int , input ( ) . split ( ) ) ; b1 = C11 ; b2 = C12 ; b3 = C13 ; a2 = C21 - b1 ; a3 = C31 - b1 ; if ( C22 = = a2 + b2 and C23 = = a2 + b3 and C32 = = a3 + b2 and C33 = = a3 + b3 ) : print ( " Yes " ) ; else : print ( " No " ) ; Cij = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] b1 , b2 , b3 = Cij [ 0 ] [ 0 ] , Cij [ 0 ] [ 1 ] , Cij [ 0 ] [ 2 ] a2 , a3 = Cij [ 1 ] [ 0 ] - b1 , Cij [ 2 ] [ 0 ] - b1 if Cij [ 1 ] [ 1 ] ! = a2 + b2 : print ( " No " ) exit ( ) if Cij [ 1 ] [ 2 ] ! = a2 + b3 : print ( " No " ) exit ( ) if Cij [ 2 ] [ 1 ] ! = a3 + b2 : print ( " No " ) exit ( ) if Cij [ 2 ] [ 2 ] ! = a3 + b3 : print ( " No " ) exit ( ) print ( " Yes " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] for a1 in range ( 0 , 101 ) : b1 = C [ 0 ] [ 0 ] - a1 b2 = C [ 0 ] [ 1 ] - a1 b3 = C [ 0 ] [ 2 ] - a1 if b1 < 0 or b2 < 0 or b3 < 0 : continue a2 = C [ 1 ] [ 0 ] - b1 if a2 < 0 or C [ 1 ] [ 1 ] - b2 ! = C [ 1 ] [ 2 ] - b3 or C [ 1 ] [ 1 ] - b2 ! = a2 : continue a3 = C [ 2 ] [ 0 ] - b1 if a3 < 0 or a3 ! = C [ 2 ] [ 1 ] - b2 or a3 ! = C [ 2 ] [ 2 ] - b3 : continue print ( " Yes " ) exit ( ) print ( " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for a1 in range ( 101 ) : b1 = C [ 0 ] [ 0 ] - a1 b2 = C [ 0 ] [ 1 ] - a1 b3 = C [ 0 ] [ 2 ] - a1 a2 = C [ 1 ] [ 0 ] - b1 a3 = C [ 2 ] [ 0 ] - b1 if ( C [ 1 ] [ 1 ] - b2 ) = = a2 and ( C [ 1 ] [ 2 ] - b3 ) = = a2 : if ( C [ 2 ] [ 1 ] - b2 ) = = a3 and ( C [ 2 ] [ 2 ] - b3 ) = = a3 : print ( " Yes " ) exit ( ) print ( " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] result = ' No ' if C [ 1 ] [ 0 ] - C [ 0 ] [ 0 ] = = C [ 1 ] [ 1 ] - C [ 0 ] [ 1 ] and C [ 1 ] [ 2 ] - C [ 0 ] [ 2 ] = = C [ 1 ] [ 1 ] - C [ 0 ] [ 1 ] : if C [ 2 ] [ 0 ] - C [ 0 ] [ 0 ] = = C [ 2 ] [ 1 ] - C [ 0 ] [ 1 ] and C [ 2 ] [ 2 ] - C [ 0 ] [ 2 ] = = C [ 2 ] [ 1 ] - C [ 0 ] [ 1 ] : result = ' Yes ' print ( result ) N = [ [ int ( i ) for i in input ( ) . split ( ) ] for j in range ( 3 ) ] if N [ 0 ] [ 0 ] - N [ 0 ] [ 1 ] = = N [ 1 ] [ 0 ] - N [ 1 ] [ 1 ] = = N [ 2 ] [ 0 ] - N [ 2 ] [ 1 ] and N [ 0 ] [ 1 ] - N [ 0 ] [ 2 ] = = N [ 1 ] [ 1 ] - N [ 1 ] [ 2 ] = = N [ 2 ] [ 1 ] - N [ 2 ] [ 2 ] and N [ 0 ] [ 0 ] - N [ 1 ] [ 0 ] = = N [ 0 ] [ 1 ] - N [ 1 ] [ 1 ] = = N [ 0 ] [ 2 ] - N [ 1 ] [ 2 ] and N [ 1 ] [ 0 ] - N [ 2 ] [ 0 ] = = N [ 1 ] [ 1 ] - N [ 2 ] [ 1 ] = = N [ 1 ] [ 2 ] - N [ 2 ] [ 2 ] : print ( ' Yes ' ) else : print ( ' No ' ) import sys c = [ ] for _ in range ( 3 ) : c + = [ list ( map ( int , input ( ) . split ( ) ) ) ] a = [ 0 , - 1 , - 1 ] b = c [ 0 ] for l , m in enumerate ( c [ 1 : ] ) : for j , k in enumerate ( m ) : if j = = 0 : a [ l + 1 ] = k - b [ j ] else : if k ! = a [ l + 1 ] + b [ j ] : print ( ' No ' ) sys . exit ( ) print ( ' Yes ' ) def main ( ) : A = [ [ int ( i ) for i in input ( ) . split ( ) ] for j in range ( 3 ) ] for i in range ( 1 , 3 ) : for j in range ( 3 ) : A [ i ] [ j ] - = A [ 0 ] [ j ] if ( A [ 1 ] [ 0 ] = = A [ 1 ] [ 1 ] = = A [ 1 ] [ 2 ] ) and ( A [ 2 ] [ 0 ] = = A [ 2 ] [ 1 ] = = A [ 2 ] [ 2 ] ) : print ( " Yes " ) else : print ( " No " ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) c = [ tuple ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] if c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] = = c [ 0 ] [ 1 ] + c [ 1 ] [ 2 ] + c [ 2 ] [ 0 ] and c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] = = c [ 0 ] [ 2 ] + c [ 1 ] [ 0 ] + c [ 2 ] [ 1 ] : print ( " Yes " ) else : print ( " No " ) def main ( ) : c = [ ] for _ in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in range ( 101 ) : flag1 = False flag2 = False b0 = c [ 0 ] [ 0 ] - i b1 = c [ 0 ] [ 1 ] - i b2 = c [ 0 ] [ 2 ] - i a10 = c [ 1 ] [ 0 ] - b0 a11 = c [ 1 ] [ 1 ] - b1 a12 = c [ 1 ] [ 2 ] - b2 if a10 = = a11 = = a12 : flag1 = True else : continue a20 = c [ 2 ] [ 0 ] - b0 a21 = c [ 2 ] [ 1 ] - b1 a22 = c [ 2 ] [ 2 ] - b2 if a20 = = a21 = = a22 : flag2 = True break if flag1 and flag2 : print ( ' Yes ' ) else : print ( ' No ' ) if _ _ name _ _ = = " _ _ main _ _ " : main ( ) c = [ tuple ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] if ( c [ 0 ] [ 0 ] + c [ 0 ] [ 1 ] - ( c [ 0 ] [ 2 ] ) * 2 = = c [ 1 ] [ 0 ] + c [ 1 ] [ 1 ] - ( c [ 1 ] [ 2 ] ) * 2 ) and ( c [ 0 ] [ 0 ] + c [ 0 ] [ 1 ] - ( c [ 0 ] [ 2 ] ) * 2 = = c [ 2 ] [ 0 ] + c [ 2 ] [ 1 ] - ( c [ 2 ] [ 2 ] ) * 2 ) : if ( c [ 0 ] [ 0 ] + c [ 1 ] [ 0 ] - ( c [ 2 ] [ 0 ] ) * 2 = = c [ 0 ] [ 1 ] + c [ 1 ] [ 1 ] - ( c [ 2 ] [ 1 ] ) * 2 ) and ( c [ 0 ] [ 0 ] + c [ 1 ] [ 0 ] - ( c [ 2 ] [ 0 ] ) * 2 = = c [ 0 ] [ 2 ] + c [ 1 ] [ 2 ] - ( c [ 2 ] [ 2 ] ) * 2 ) : print ( " Yes " ) exit ( 0 ) print ( " No " ) x = list ( map ( int , input ( ) . split ( ) ) ) y = list ( map ( int , input ( ) . split ( ) ) ) z = list ( map ( int , input ( ) . split ( ) ) ) if x [ 1 ] - x [ 0 ] ! = y [ 1 ] - y [ 0 ] or y [ 1 ] - y [ 0 ] ! = z [ 1 ] - z [ 0 ] or x [ 2 ] - x [ 0 ] ! = y [ 2 ] - y [ 0 ] or y [ 0 ] - x [ 0 ] ! = y [ 1 ] - x [ 1 ] or z [ 1 ] - x [ 1 ] ! = z [ 2 ] - x [ 2 ] or z [ 0 ] - x [ 0 ] ! = z [ 1 ] - x [ 1 ] or z [ 1 ] - x [ 1 ] ! = z [ 2 ] - x [ 2 ] : print ( ' No ' ) else : print ( ' Yes ' ) cnt = 0 c1 , c2 , c3 = map ( int , input ( ) . split ( ) ) try : for j in range ( c1 + 1 ) : for k in range ( c2 + 1 ) : for l in range ( c3 + 1 ) : if c1 - j = = c2 - k = = c3 - l : c4 , c5 , c6 = map ( int , input ( ) . split ( ) ) if c4 - j = = c5 - k = = c6 - l : c7 , c8 , c9 = map ( int , input ( ) . split ( ) ) if c7 - j = = c8 - k = = c9 - l : cnt + = 1 break except EOFError : pass if cnt ! = 0 : print ( " Yes " ) else : print ( " No " ) import numpy as np import sys def validation ( c , a , b ) : for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = a [ i ] + b [ j ] : return False print ( ' Yes ' ) sys . exit ( ) return True c _ 1 = list ( map ( int , input ( ) . split ( ) ) ) c _ 2 = list ( map ( int , input ( ) . split ( ) ) ) c _ 3 = list ( map ( int , input ( ) . split ( ) ) ) c = np . array ( [ c _ 1 , c _ 2 , c _ 3 ] ) for i in range ( 101 ) : a = [ ] b = [ ] a . append ( i ) b . append ( c [ 0 ] [ 0 ] - a [ 0 ] ) b . append ( c [ 0 ] [ 1 ] - a [ 0 ] ) b . append ( c [ 0 ] [ 2 ] - a [ 0 ] ) a . append ( c [ 1 ] [ 0 ] - b [ 0 ] ) a . append ( c [ 2 ] [ 0 ] - b [ 0 ] ) validation ( c , a , b ) print ( ' No ' ) si = lambda : input ( ) ni = lambda : int ( input ( ) ) nm = lambda : map ( int , input ( ) . split ( ) ) nl = lambda : list ( map ( int , input ( ) . split ( ) ) ) l = [ nl ( ) for i in range ( 3 ) ] a1 = 0 b1 = l [ 0 ] [ 0 ] - a1 b2 = l [ 0 ] [ 1 ] - a1 b3 = l [ 0 ] [ 2 ] - a1 a2 = l [ 1 ] [ 0 ] - b1 a3 = l [ 2 ] [ 0 ] - b1 a = [ a1 , a2 , a3 ] b = [ b1 , b2 , b3 ] for i , aa in enumerate ( a ) : for j , bb in enumerate ( b ) : if l [ i ] [ j ] ! = aa + bb : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) for a1 in range ( 101 ) : b1 = c1 [ 0 ] - a1 b2 = c1 [ 1 ] - a1 b3 = c1 [ 2 ] - a1 a2 = c2 [ 0 ] - b1 a3 = c3 [ 0 ] - b1 if c2 [ 1 ] = = a2 + b2 and c2 [ 2 ] = = a2 + b3 and c3 [ 1 ] = = a3 + b2 and c3 [ 2 ] = = a3 + b3 : print ( ' Yes ' ) exit ( ) print ( ' No ' ) import sys def main ( ) : mod = 1000000007 inf = float ( ' inf ' ) sys . setrecursionlimit ( 10 * * 6 ) def input ( ) : return sys . stdin . readline ( ) . rstrip ( ) def ii ( ) : return int ( input ( ) ) def mi ( ) : return map ( int , input ( ) . split ( ) ) def mi _ 0 ( ) : return map ( lambda x : int ( x ) - 1 , input ( ) . split ( ) ) def lmi ( ) : return list ( map ( int , input ( ) . split ( ) ) ) def lmi _ 0 ( ) : return list ( map ( lambda x : int ( x ) - 1 , input ( ) . split ( ) ) ) def li ( ) : return list ( input ( ) ) grid = [ lmi ( ) for _ in range ( 3 ) ] vertical = [ [ grid [ i + 1 ] [ j ] - grid [ i ] [ j ] for j in range ( 3 ) ] for i in range ( 2 ) ] horizontal = [ [ grid [ i ] [ j + 1 ] - grid [ i ] [ j ] for i in range ( 3 ) ] for j in range ( 2 ) ] if len ( list ( set ( vertical [ 0 ] ) ) ) = = 1 and len ( list ( set ( vertical [ 1 ] ) ) ) = = 1 and len ( list ( set ( horizontal [ 0 ] ) ) ) = = 1 and len ( list ( set ( horizontal [ 1 ] ) ) ) = = 1 : print ( ' Yes ' ) else : print ( ' No ' ) if _ _ name _ _ = = " _ _ main _ _ " : main ( ) grid = [ [ int ( i ) for i in input ( ) . split ( ) ] for j in range ( 3 ) ] b _ patterns = [ ] for i in range ( grid [ 0 ] [ 0 ] + 1 ) : b _ pattern = [ grid [ 0 ] [ j ] - i for j in range ( 3 ) ] b _ patterns . append ( b _ pattern ) def patternCecker ( grid , b _ patterns ) : for pattern in b _ patterns : a1 = grid [ 0 ] [ 0 ] - pattern [ 0 ] a2 = grid [ 1 ] [ 0 ] - pattern [ 0 ] a3 = grid [ 2 ] [ 0 ] - pattern [ 0 ] a1 _ row = [ a1 + pattern [ l ] for l in range ( 3 ) ] a2 _ row = [ a2 + pattern [ l ] for l in range ( 3 ) ] a3 _ row = [ a3 + pattern [ l ] for l in range ( 3 ) ] if a1 _ row = = grid [ 0 ] and a2 _ row = = grid [ 1 ] and a3 _ row = = grid [ 2 ] : return True return False if patternCecker ( grid , b _ patterns ) : print ( ' Yes ' ) else : print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] def validation ( lol ) : ans = True for i in range ( len ( lis ) ) : for j in range ( len ( lis ) ) : if i = = j : break x = list ( map ( lambda x , y : x - y , c [ i ] , c [ j ] ) ) if len ( set ( x ) ) ! = 1 : ans = False return ans lis = [ ] for i in range ( 3 ) : temp = [ ] for j in range ( 3 ) : temp . append ( c [ j ] [ i ] ) lis . append ( temp ) if validation ( c ) and validation ( lis ) : print ( " Yes " ) else : print ( " No " ) c = [ ] for i in range ( 3 ) : c1 = list ( map ( int , input ( ) . split ( ) ) ) c . append ( c1 ) count = 0 ans = " Yes " for i in range ( 2 ) : for j in range ( 2 ) : if c [ i ] [ j ] - c [ i ] [ j + 1 ] ! = c [ i + 1 ] [ j ] - c [ i + 1 ] [ j + 1 ] : ans = " No " if c [ i ] [ j ] - c [ i + 1 ] [ j ] ! = c [ i ] [ j + 1 ] - c [ i + 1 ] [ j + 1 ] : ans = " No " print ( ans ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] S = 0 for i in range ( 3 ) : S + = sum ( c [ i ] ) ans = " No " if S % 3 = = 0 : tmp = S / / 3 tmp1 = c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] tmp2 = c [ 0 ] [ 1 ] + c [ 1 ] [ 2 ] + c [ 2 ] [ 0 ] tmp3 = c [ 0 ] [ 2 ] + c [ 1 ] [ 0 ] + c [ 2 ] [ 1 ] tmp4 = c [ 0 ] [ 2 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 0 ] tmp5 = c [ 0 ] [ 1 ] + c [ 1 ] [ 0 ] + c [ 2 ] [ 2 ] tmp6 = c [ 0 ] [ 0 ] + c [ 1 ] [ 2 ] + c [ 2 ] [ 1 ] if tmp = = tmp1 and tmp = = tmp2 and tmp = = tmp3 and tmp = = tmp4 and tmp = = tmp5 and tmp = = tmp6 : ans = " Yes " print ( ans ) def solve ( ) : c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 101 ) : a0 = i b0 = c [ 0 ] [ 0 ] - a0 b1 = c [ 0 ] [ 1 ] - a0 b2 = c [ 0 ] [ 2 ] - a0 a1 = c [ 1 ] [ 0 ] - b0 a2 = c [ 2 ] [ 0 ] - b0 if c [ 1 ] [ 1 ] = = a1 + b1 and c [ 1 ] [ 2 ] = = a1 + b2 and c [ 2 ] [ 1 ] = = a2 + b1 and c [ 2 ] [ 2 ] = = a2 + b2 : print ( ' Yes ' ) exit ( ) print ( ' No ' ) if _ _ name _ _ = = ' _ _ main _ _ ' : solve ( ) import sys mat = [ [ x for x in map ( int , sys . stdin . readline ( ) . rstrip ( ) . split ( ) ) ] for y in range ( 3 ) ] t = mat [ 0 ] [ 0 ] da1 = mat [ 1 ] [ 0 ] - t da2 = mat [ 2 ] [ 0 ] - t db1 = mat [ 0 ] [ 1 ] - t db2 = mat [ 0 ] [ 2 ] - t flag = True if not ( mat [ 1 ] [ 1 ] = = t + da1 + db1 and mat [ 1 ] [ 2 ] = = t + da1 + db2 ) : flag = False if not ( mat [ 2 ] [ 1 ] = = t + da2 + db1 and mat [ 2 ] [ 2 ] = = t + da2 + db2 ) : flag = False if flag : print ( ' Yes ' ) else : print ( ' No ' ) m = [ ] for i in range ( 3 ) : m . append ( list ( map ( int , input ( ) . split ( ) ) ) ) flag = True l = [ ] for i in range ( 2 ) : for j in range ( 1 , 3 ) : l = [ ] for k in range ( 3 ) : l . append ( m [ i ] [ k ] - m [ j ] [ k ] ) if len ( set ( l ) ) ! = 1 : flag = False for i in range ( 2 ) : for j in range ( 1 , 3 ) : l = [ ] for k in range ( 3 ) : l . append ( m [ k ] [ i ] - m [ k ] [ j ] ) if len ( set ( l ) ) ! = 1 : flag = False print ( " Yes " if flag else " No " ) import sys c = list ( map ( int , input ( ) . split ( ) ) ) c + = list ( map ( int , input ( ) . split ( ) ) ) c + = list ( map ( int , input ( ) . split ( ) ) ) a = [ 0 ] * 3 b = [ 0 ] * 3 a [ 0 ] = 0 b [ 0 ] = c [ 0 ] a [ 1 ] = c [ 3 ] - b [ 0 ] b [ 1 ] = c [ 4 ] - a [ 1 ] a [ 2 ] = c [ 6 ] - b [ 0 ] b [ 2 ] = c [ 8 ] - a [ 2 ] index = 0 for i in range ( 3 ) : for j in range ( 3 ) : if a [ i ] + b [ j ] ! = c [ index ] : print ( ' No ' ) sys . exit ( ) index + = 1 print ( ' Yes ' ) import numpy as np c = np . empty ( ( 3 , 3 ) , dtype = int ) for i in range ( 3 ) : c [ i ] = list ( map ( int , input ( ) . split ( ) ) ) judge = " Yes " for i in range ( 2 ) : if len ( set ( c [ i ] - c [ i + 1 ] ) ) ! = 1 : judge = " No " break if len ( set ( c [ : , i ] - c [ : , i + 1 ] ) ) ! = 1 : judge = " No " break print ( judge ) import sys input = sys . stdin . readline from collections import * c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] flag = True for i in range ( 3 ) : if c [ i ] [ 1 ] - c [ i ] [ 0 ] ! = c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] : flag = False for i in range ( 3 ) : if c [ i ] [ 2 ] - c [ i ] [ 1 ] ! = c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] : flag = False for i in range ( 3 ) : if c [ 1 ] [ i ] - c [ 0 ] [ i ] ! = c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] : flag = False for i in range ( 3 ) : if c [ 2 ] [ i ] - c [ 1 ] [ i ] ! = c [ 2 ] [ 0 ] - c [ 1 ] [ 0 ] : flag = False if flag : print ( ' Yes ' ) else : print ( ' No ' ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 2 ) : for j in range ( i + 1 , 3 ) : if C [ i ] [ 0 ] - C [ j ] [ 0 ] = = C [ i ] [ 1 ] - C [ j ] [ 1 ] and C [ i ] [ 1 ] - C [ j ] [ 1 ] = = C [ i ] [ 2 ] - C [ j ] [ 2 ] and C [ i ] [ 2 ] - C [ j ] [ 2 ] = = C [ i ] [ 0 ] - C [ j ] [ 0 ] : continue else : print ( ' No ' ) exit ( ) for i in range ( 2 ) : for j in range ( i + 1 , 3 ) : if C [ 0 ] [ i ] - C [ 0 ] [ j ] = = C [ 1 ] [ i ] - C [ 1 ] [ j ] and C [ 1 ] [ i ] - C [ 1 ] [ j ] = = C [ 2 ] [ i ] - C [ 2 ] [ j ] and C [ 2 ] [ i ] - C [ 2 ] [ j ] = = C [ 0 ] [ i ] - C [ 0 ] [ j ] : continue else : print ( ' No ' ) exit ( ) print ( ' Yes ' ) import sys def solve ( ) : input = sys . stdin . readline mod = 10 * * 9 + 7 c = [ list ( map ( int , input ( ) . rstrip ( ' \ n ' ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 3 ) : m = min ( c [ i ] ) for j in range ( 3 ) : c [ i ] [ j ] - = m for i in range ( 3 ) : m = 10 * * 10 for j in range ( 3 ) : m = min ( c [ j ] [ i ] , m ) for j in range ( 3 ) : c [ j ] [ i ] - = m mt = 0 for i in range ( 3 ) : for j in range ( 3 ) : mt = max ( mt , c [ i ] [ j ] ) print ( " Yes " if mt = = 0 else " No " ) if _ _ name _ _ = = ' _ _ main _ _ ' : solve ( ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] if c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] and c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] = = c [ 2 ] [ 1 ] - c [ 2 ] [ 2 ] : print ( " Yes " ) else : print ( " No " ) from itertools import product c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] b2 = c [ 0 ] [ 1 ] b3 = c [ 0 ] [ 2 ] a2 = c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] a3 = c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] if ( a2 + b2 = = c [ 1 ] [ 1 ] and a2 + b3 = = c [ 1 ] [ 2 ] and a3 + b2 = = c [ 2 ] [ 1 ] and a3 + b3 = = c [ 2 ] [ 2 ] ) : print ( " Yes " ) else : print ( " No " ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) s = 0 if ( c1 [ 0 ] - c2 [ 0 ] = = c1 [ 1 ] - c2 [ 1 ] and c1 [ 0 ] - c2 [ 0 ] = = c1 [ 2 ] - c2 [ 2 ] ) : s + = 1 if ( c3 [ 0 ] - c2 [ 0 ] = = c3 [ 1 ] - c2 [ 1 ] and c3 [ 0 ] - c2 [ 0 ] = = c3 [ 2 ] - c2 [ 2 ] ) : s + = 1 if ( s = = 2 ) : print ( ' Yes ' ) else : print ( ' No ' ) import itertools grid = [ ] for _ in range ( 3 ) : grid . append ( list ( map ( int , input ( ) . split ( ) ) ) ) sum = sum ( list ( itertools . chain . from _ iterable ( grid ) ) ) if sum % 3 ! = 0 : print ( ' No ' ) exit ( ) for i in range ( - 100 , 101 ) : a1 = i b1 = grid [ 0 ] [ 0 ] - a1 b2 = grid [ 0 ] [ 1 ] - a1 b3 = grid [ 0 ] [ 2 ] - a1 a2 = grid [ 1 ] [ 0 ] - b1 a3 = grid [ 2 ] [ 0 ] - b1 if a1 + a2 + a3 + b1 + b2 + b3 = = sum / / 3 : print ( ' Yes ' ) exit ( ) print ( ' No ' ) import sys c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( min ( c [ 0 ] ) + 1 ) : b = [ c [ 0 ] [ k ] - i for k in range ( 3 ) ] a = [ c [ i ] [ 0 ] - b [ 0 ] for i in range ( 3 ) ] for i in range ( 1 , 3 ) : if c [ i ] [ 1 ] ! = a [ i ] + b [ 1 ] or c [ i ] [ 2 ] ! = a [ i ] + b [ 2 ] : break else : print ( ' Yes ' ) sys . exit ( ) print ( ' No ' ) def main ( ) : c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) for a1 in range ( - 200 , 200 ) : b1 = c11 - a1 b2 = c12 - a1 b3 = c13 - a1 a2 = c21 - b1 a3 = c31 - b1 if c22 = = a2 + b2 and c23 = = a2 + b3 and c32 = = a3 + b2 and c33 = = a3 + b3 : print ( ' Yes ' ) exit ( ) print ( ' No ' ) if _ _ name _ _ = = " _ _ main _ _ " : main ( ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( max ( C [ 0 ] ) + 1 ) : flg = True a1 = i b1 = C [ 0 ] [ 0 ] - a1 b2 = C [ 0 ] [ 1 ] - a1 b3 = C [ 0 ] [ 2 ] - a1 a2 = C [ 1 ] [ 0 ] - b1 a3 = C [ 2 ] [ 0 ] - b1 if a2 + b2 ! = C [ 1 ] [ 1 ] or a2 + b3 ! = C [ 1 ] [ 2 ] or a3 + b2 ! = C [ 2 ] [ 1 ] or a3 + b3 ! = C [ 2 ] [ 2 ] : flg = False if flg = = True : print ( " Yes " ) exit ( ) print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] res = 0 ans = 0 for i in range ( 3 ) : res + = sum ( c [ i ] ) ans + = c [ i ] [ i ] * 3 if res = = ans : print ( ' Yes ' ) else : print ( ' No ' ) import sys lst = [ ] for i in range ( 3 ) : a , b , c = map ( int , input ( ) . split ( ) ) lst . append ( [ a , b , c ] ) for i in range ( 2 ) : for j in range ( 2 ) : if ( lst [ i ] [ j + 1 ] - lst [ i ] [ j ] ) ! = ( lst [ i + 1 ] [ j + 1 ] - lst [ i + 1 ] [ j ] ) or ( lst [ j + 1 ] [ i ] - lst [ j ] [ i ] ) ! = ( lst [ j + 1 ] [ i + 1 ] - lst [ j ] [ i + 1 ] ) : print ( ' No ' ) sys . exit ( ) print ( ' Yes ' ) c = [ ] for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) if c [ 0 ] [ 1 ] + c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] \ and c [ 0 ] [ 2 ] + c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 2 ] \ and c [ 0 ] [ 1 ] + c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 2 ] [ 1 ] \ and c [ 0 ] [ 2 ] + c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 2 ] [ 2 ] : print ( " Yes " ) else : print ( " No " ) b1 , b2 , b3 = map ( int , input ( ) . split ( ) ) for _ in range ( 2 ) : x , y , z = map ( int , input ( ) . split ( ) ) if x - b1 = = y - b2 = = z - b3 : continue else : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] for a1 in range ( 101 ) : flag = True b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 1 ] [ 0 ] - a1 b3 = c [ 2 ] [ 0 ] - a1 a2 = c [ 0 ] [ 1 ] - b1 if a2 ! = ( c [ 1 ] [ 1 ] - b2 ) or a2 ! = ( c [ 2 ] [ 1 ] - b3 ) : flag = False a3 = c [ 0 ] [ 2 ] - b1 if a3 ! = ( c [ 1 ] [ 2 ] - b2 ) or a3 ! = ( c [ 2 ] [ 2 ] - b3 ) : flag = False if a1 < 0 or a2 < 0 or a3 < 0 or b1 < 0 or b2 < 0 or b3 < 0 : flag = False if flag : print ( " Yes " ) exit ( ) print ( " No " ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) out = ' No ' if c13 - c11 = = c23 - c21 = = c33 - c31 : if c11 - c12 = = c21 - c22 = = c31 - c32 : if c12 - c13 = = c22 - c23 = = c32 - c33 : out = ' Yes ' print ( out ) import sys , math from itertools import permutations , combinations from collections import defaultdict , Counter , deque from math import factorial from bisect import bisect _ left , bisect _ right sys . setrecursionlimit ( 10 * * 7 ) enu = enumerate MOD = 10 * * 9 + 7 def input ( ) : return sys . stdin . readline ( ) [ : - 1 ] pl = lambda x : print ( * x , sep = ' \ n ' ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 3 ) : for j in range ( 3 ) : lu = C [ i ] [ j ] for ii in range ( 3 ) : if i = = ii : continue for jj in range ( 3 ) : if j = = jj : continue rd = C [ ii ] [ jj ] ld = C [ ii ] [ j ] ru = C [ i ] [ jj ] if lu + rd ! = ld + ru : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c = [ ] for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) a = [ 0 ] * 3 b = [ 0 ] * 3 b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] ans = " Yes " for i in range ( 3 ) : if not c [ 1 ] [ 0 ] - b [ 0 ] = = c [ 1 ] [ 1 ] - b [ 1 ] = = c [ 1 ] [ 2 ] - b [ 2 ] : ans = " No " if not c [ 2 ] [ 0 ] - b [ 0 ] = = c [ 2 ] [ 1 ] - b [ 1 ] = = c [ 2 ] [ 2 ] - b [ 2 ] : ans = " No " print ( ans ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] if ( c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] ) and ( c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] ) and ( c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] ) and ( c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] = = c [ 2 ] [ 1 ] - c [ 2 ] [ 2 ] ) : print ( ' Yes ' ) else : print ( ' No ' ) def is _ correct ( grids ) : for a1 in range ( min ( 101 , grids [ 0 ] [ 0 ] + 1 ) ) : b _ list = grids [ 0 ] [ 0 ] - a1 , grids [ 0 ] [ 1 ] - a1 , grids [ 0 ] [ 2 ] - a1 a2 , a3 = grids [ 1 ] [ 0 ] - b _ list [ 0 ] , grids [ 2 ] [ 0 ] - b _ list [ 0 ] a _ list = [ a1 , a2 , a3 ] temp _ grids = [ ] for an in a _ list : row = [ ] for bn in b _ list : row . append ( an + bn ) temp _ grids . append ( row ) if grids = = temp _ grids : return True return False grids = [ ] for _ in range ( 3 ) : grids . append ( list ( map ( int , input ( ) . split ( ) ) ) ) print ( " Yes " if is _ correct ( grids ) else " No " ) list _ c = [ ] for i in range ( 3 ) : temp _ c = list ( map ( int , input ( ) . split ( ) ) ) list _ c . append ( temp _ c ) list _ a = [ 0 for _ in range ( 3 ) ] list _ b = [ 0 for _ in range ( 3 ) ] for i in range ( 3 ) : list _ b [ i ] = list _ c [ i ] [ 0 ] for i in range ( 3 ) : if i ! = 0 : list _ a [ i ] = list _ c [ 0 ] [ i ] - list _ b [ 0 ] for j in range ( 3 ) : for i in range ( 3 ) : if list _ c [ i ] [ j ] ! = list _ a [ j ] + list _ b [ i ] : print ( " No " ) exit ( ) print ( " Yes " ) N = [ ( list ( map ( int , input ( ) . split ( ' ' ) ) ) ) for i in range ( 3 ) ] for a1 in range ( 101 ) : for a2 in range ( 101 ) : for a3 in range ( 101 ) : if ( N [ 0 ] [ 0 ] - a1 = = N [ 1 ] [ 0 ] - a2 = = N [ 2 ] [ 0 ] - a3 and N [ 0 ] [ 1 ] - a1 = = N [ 1 ] [ 1 ] - a2 = = N [ 2 ] [ 1 ] - a3 and N [ 0 ] [ 2 ] - a1 = = N [ 1 ] [ 2 ] - a2 = = N [ 2 ] [ 2 ] - a3 ) : print ( ' Yes ' ) exit ( ) print ( ' No ' ) def main ( ) : c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) r1max = max ( [ c11 , c12 , c13 ] ) r2max = max ( [ c21 , c22 , c23 ] ) r3max = max ( [ c31 , c32 , c33 ] ) c1max = max ( [ c11 , c21 , c31 ] ) c2max = max ( [ c12 , c22 , c32 ] ) c3max = max ( [ c13 , c23 , c33 ] ) for a1 in range ( 0 , r1max + 1 ) : for a2 in range ( 0 , r2max + 1 ) : for a3 in range ( 0 , r3max + 1 ) : m = max ( [ a1 , a2 , a3 ] ) for b1 in range ( 0 , c1max - m + 1 ) : if a1 + b1 = = c11 and a2 + b1 = = c21 and a3 + b1 = = c31 : for b2 in range ( 0 , c2max - m + 1 ) : if a1 + b2 = = c12 and a2 + b2 = = c22 and a3 + b2 = = c32 : for b3 in range ( 0 , c3max - m + 1 ) : if a1 + b3 = = c13 and a2 + b3 = = c23 and a3 + b3 = = c33 : print ( ' Yes ' ) return print ( ' No ' ) return if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) y1 _ list = list ( map ( int , input ( ) . split ( ) ) ) y2 _ list = list ( map ( int , input ( ) . split ( ) ) ) y3 _ list = list ( map ( int , input ( ) . split ( ) ) ) L = [ y1 _ list , y2 _ list , y3 _ list ] a1 = list ( ) a2 = list ( ) b1 = list ( ) b2 = list ( ) for i in range ( 3 ) : a1 . append ( y1 _ list [ i ] - y2 _ list [ i ] ) a2 . append ( y2 _ list [ i ] - y3 _ list [ i ] ) b1 . append ( L [ i ] [ 0 ] - L [ i ] [ 1 ] ) b2 . append ( L [ i ] [ 1 ] - L [ i ] [ 2 ] ) if ( a1 [ 0 ] = = a1 [ 1 ] and a1 [ 2 ] = = a1 [ 0 ] ) and ( b1 [ 0 ] = = b1 [ 1 ] and b1 [ 2 ] = = b1 [ 0 ] ) : if ( a2 [ 0 ] = = a2 [ 1 ] and a2 [ 2 ] = = a2 [ 0 ] ) and ( b2 [ 0 ] = = b2 [ 1 ] and b2 [ 2 ] = = b2 [ 0 ] ) : print ( " Yes " ) else : print ( " No " ) else : print ( " No " ) C1 = list ( map ( int , input ( ) . split ( ) ) ) C2 = list ( map ( int , input ( ) . split ( ) ) ) C3 = list ( map ( int , input ( ) . split ( ) ) ) k2 = C2 [ 0 ] - C1 [ 0 ] k3 = C3 [ 0 ] - C1 [ 0 ] C2 = [ i - k2 for i in C2 ] C3 = [ i - k3 for i in C3 ] print ( [ ' No ' , ' Yes ' ] [ C1 = = C2 = = C3 ] ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 ans = " Yes " for a1 in range ( 101 ) : a [ 0 ] = a1 b [ 0 ] = c [ 0 ] [ 0 ] - a1 b [ 1 ] = c [ 0 ] [ 1 ] - a1 b [ 2 ] = c [ 0 ] [ 2 ] - a1 a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if a [ i ] + b [ j ] ! = c [ i ] [ j ] : ans = " No " print ( ans ) import sys c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] for a1 in range ( 0 , c [ 0 ] [ 0 ] + 1 ) : b1 = c [ 0 ] [ 0 ] - a1 a2 = c [ 1 ] [ 0 ] - b1 a3 = c [ 2 ] [ 0 ] - b1 b2 = c [ 0 ] [ 1 ] - a1 if a2 + b2 ! = c [ 1 ] [ 1 ] : continue if a3 + b2 ! = c [ 2 ] [ 1 ] : continue b3 = c [ 0 ] [ 2 ] - a1 if a2 + b3 ! = c [ 1 ] [ 2 ] : continue if a3 + b3 ! = c [ 2 ] [ 2 ] : continue print ( ' Yes ' ) sys . exit ( ) print ( ' No ' ) c = [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( 3 ) ] x = 0 for i in range ( 2 ) : if c [ 0 ] [ i ] - c [ 0 ] [ i + 1 ] = = c [ 1 ] [ i ] - c [ 1 ] [ i + 1 ] = = c [ 2 ] [ i ] - c [ 2 ] [ i + 1 ] : x + = 1 for i in range ( 2 ) : if c [ i ] [ 0 ] - c [ i + 1 ] [ 0 ] = = c [ i ] [ 1 ] - c [ i + 1 ] [ 1 ] = = c [ i ] [ 2 ] - c [ i + 1 ] [ 2 ] : x + = 1 if x = = 4 : print ( " Yes " ) else : print ( " No " ) grid = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] B = [ x for x in grid [ 0 ] ] b = B [ 0 ] A = [ grid [ i ] [ 0 ] - b for i in range ( 3 ) ] res = True for i , a in enumerate ( A ) : for j , b in enumerate ( B ) : if grid [ i ] [ j ] ! = a + b : res = False break else : continue break print ( ' Yes ' if res else ' No ' ) import os import sys def main ( ) : c = [ ] for _ in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) a _ 12 = c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] a _ 13 = c [ 0 ] [ 0 ] - c [ 2 ] [ 0 ] a _ 23 = c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] b _ 12 = c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] b _ 13 = c [ 0 ] [ 0 ] - c [ 0 ] [ 2 ] b _ 23 = c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] for i in range ( 1 , 3 ) : if b _ 12 ! = c [ i ] [ 0 ] - c [ i ] [ 1 ] or b _ 13 ! = c [ i ] [ 0 ] - c [ i ] [ 2 ] or b _ 23 ! = c [ i ] [ 1 ] - c [ i ] [ 2 ] : print ( " No " ) return if a _ 12 ! = c [ 0 ] [ i ] - c [ 1 ] [ i ] or a _ 13 ! = c [ 0 ] [ i ] - c [ 2 ] [ i ] or a _ 23 ! = c [ 1 ] [ i ] - c [ 2 ] [ i ] : print ( " No " ) return print ( " Yes " ) if _ _ name _ _ = = " _ _ main _ _ " : main ( ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) if c1 [ 0 ] - c1 [ 1 ] ! = c2 [ 0 ] - c2 [ 1 ] or c1 [ 0 ] - c1 [ 1 ] ! = c3 [ 0 ] - c3 [ 1 ] : print ( ' No ' ) exit ( ) if c1 [ 0 ] - c1 [ 2 ] ! = c2 [ 0 ] - c2 [ 2 ] or c1 [ 0 ] - c1 [ 2 ] ! = c3 [ 0 ] - c3 [ 2 ] : print ( ' No ' ) exit ( ) if c1 [ 0 ] - c2 [ 0 ] ! = c1 [ 1 ] - c2 [ 1 ] or c1 [ 0 ] - c2 [ 0 ] ! = c1 [ 2 ] - c2 [ 2 ] : print ( ' No ' ) exit ( ) if c1 [ 0 ] - c3 [ 0 ] ! = c1 [ 1 ] - c3 [ 1 ] or c1 [ 0 ] - c3 [ 0 ] ! = c1 [ 2 ] - c3 [ 2 ] : print ( ' No ' ) exit ( ) print ( ' Yes ' ) o = 0 t1 = list ( map ( int , input ( ) . split ( ) ) ) t2 = list ( map ( int , input ( ) . split ( ) ) ) t3 = list ( map ( int , input ( ) . split ( ) ) ) o = sum ( t1 ) + sum ( t2 ) + sum ( t3 ) if o % 3 > 0 : print ( ' No ' ) elif ( t1 [ 0 ] - t1 [ 1 ] = = t2 [ 0 ] - t2 [ 1 ] = = t3 [ 0 ] - t3 [ 1 ] and t1 [ 2 ] - t1 [ 1 ] = = t2 [ 2 ] - t2 [ 1 ] = = t3 [ 2 ] - t3 [ 1 ] and t1 [ 0 ] - t2 [ 0 ] = = t1 [ 1 ] - t2 [ 1 ] = = t1 [ 2 ] - t2 [ 2 ] and t1 [ 0 ] - t3 [ 0 ] = = t1 [ 1 ] - t3 [ 1 ] = = t1 [ 2 ] - t3 [ 2 ] ) : print ( ' Yes ' ) else : print ( ' No ' ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) for a in range ( 0 , 101 ) : for b in range ( 0 , 101 ) : for c in range ( 0 , 101 ) : a1 = a a2 = b a3 = c b1 = c1 [ 0 ] - a1 b2 = c1 [ 1 ] - a1 b3 = c1 [ 2 ] - a1 if a1 + b1 = = c1 [ 0 ] and a1 + b2 = = c1 [ 1 ] and a1 + b3 = = c1 [ 2 ] \ and a2 + b1 = = c2 [ 0 ] and a2 + b2 = = c2 [ 1 ] and a2 + b3 = = c2 [ 2 ] \ and a3 + b1 = = c3 [ 0 ] and a3 + b2 = = c3 [ 1 ] and a3 + b3 = = c3 [ 2 ] : print ( " Yes " ) exit ( ) print ( " No " ) c = [ ] for _ in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) j1 = c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] j2 = c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] for i in range ( 1 , 3 ) : _ j1 = c [ i ] [ 0 ] - c [ i ] [ 1 ] _ j2 = c [ i ] [ 1 ] - c [ i ] [ 2 ] if j1 = = _ j1 and j2 = = _ j2 : continue print ( " No " ) break else : print ( " Yes " ) tab = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 a [ 0 ] = 0 b [ 0 ] = tab [ 0 ] [ 0 ] - a [ 0 ] a [ 1 ] = tab [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = tab [ 2 ] [ 0 ] - b [ 0 ] b [ 1 ] = tab [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = tab [ 0 ] [ 2 ] - a [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if tab [ i ] [ j ] ! = a [ i ] + b [ j ] : print ( ' No ' ) break else : continue break else : print ( ' Yes ' ) from sys import exit C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] if not ( C [ 0 ] [ 0 ] - C [ 0 ] [ 1 ] = = C [ 1 ] [ 0 ] - C [ 1 ] [ 1 ] = = C [ 2 ] [ 0 ] - C [ 2 ] [ 1 ] ) : print ( " No " ) exit ( ) if not ( C [ 0 ] [ 0 ] - C [ 0 ] [ 2 ] = = C [ 1 ] [ 0 ] - C [ 1 ] [ 2 ] = = C [ 2 ] [ 0 ] - C [ 2 ] [ 2 ] ) : print ( " No " ) exit ( ) if not ( C [ 0 ] [ 2 ] - C [ 0 ] [ 1 ] = = C [ 1 ] [ 2 ] - C [ 1 ] [ 1 ] = = C [ 2 ] [ 2 ] - C [ 2 ] [ 1 ] ) : print ( " No " ) exit ( ) print ( " Yes " ) C1 = list ( map ( int , input ( ) . split ( ) ) ) C2 = list ( map ( int , input ( ) . split ( ) ) ) C3 = list ( map ( int , input ( ) . split ( ) ) ) if ( ( C1 [ 1 ] - C1 [ 0 ] ) = = ( C2 [ 1 ] - C2 [ 0 ] ) = = ( C3 [ 1 ] - C3 [ 0 ] ) and ( C1 [ 2 ] - C1 [ 1 ] ) = = ( C2 [ 2 ] - C2 [ 1 ] ) = = ( C3 [ 2 ] - C3 [ 1 ] ) ) : ans = ' Yes ' else : ans = ' No ' print ( ans ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] ans = " Yes " for i in range ( 1 , - 1 , - 1 ) : C0j = C [ 0 ] [ 2 ] - C [ 0 ] [ i ] C1j = C [ 1 ] [ 2 ] - C [ 1 ] [ i ] C2j = C [ 2 ] [ 2 ] - C [ 2 ] [ i ] if C0j ! = C1j or C0j ! = C2j : ans = " No " print ( ans ) import sys input = sys . stdin . readline C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] dx1 = C [ 1 ] [ 0 ] - C [ 0 ] [ 0 ] dx2 = C [ 2 ] [ 0 ] - C [ 1 ] [ 0 ] dy1 = C [ 0 ] [ 1 ] - C [ 0 ] [ 0 ] dy2 = C [ 0 ] [ 2 ] - C [ 0 ] [ 1 ] ans = " Yes " for i in range ( 3 ) : if C [ 1 ] [ i ] - C [ 0 ] [ i ] ! = dx1 or C [ 2 ] [ i ] - C [ 1 ] [ i ] ! = dx2 : ans = " No " break if C [ i ] [ 1 ] - C [ i ] [ 0 ] ! = dy1 or C [ i ] [ 2 ] - C [ i ] [ 1 ] ! = dy2 : ans = " No " break print ( ans ) from itertools import product flag = True c _ list = [ ] for _ in range ( 3 ) : c _ list . append ( list ( map ( int , input ( ) . split ( ) ) ) ) min _ n = min ( sum ( c _ list , [ ] ) ) new _ list = [ ] for i in c _ list : new _ list . append ( [ j - min _ n for j in i ] ) a = [ None , None , None ] b = [ None , None , None ] for i in range ( 3 ) : for j in range ( 3 ) : if new _ list [ i ] [ j ] = = 0 : a [ i ] = 0 a _ other = [ num for num in [ 0 , 1 , 2 ] if i ! = num ] b [ j ] = 0 b _ other = [ num for num in [ 0 , 1 , 2 ] if j ! = num ] for k in a _ other : a [ k ] = new _ list [ k ] [ j ] for k in b _ other : b [ k ] = new _ list [ i ] [ k ] break for i , j in product ( [ 0 , 1 , 2 ] , repeat = 2 ) : if new _ list [ i ] [ j ] ! = a [ i ] + b [ j ] : print ( ' No ' ) flag = False break if flag : print ( ' Yes ' ) a = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] b = list ( zip ( * a ) ) c = a [ 0 ] d = b [ 0 ] f = True dx1 = c [ 1 ] - c [ 0 ] dx2 = c [ 2 ] - c [ 1 ] dy1 = d [ 1 ] - d [ 0 ] dy2 = d [ 2 ] - d [ 1 ] for i in range ( 3 ) : c = a [ i ] d = b [ i ] if dx1 = = c [ 1 ] - c [ 0 ] and dx2 = = c [ 2 ] - c [ 1 ] and dy1 = = d [ 1 ] - d [ 0 ] and dy2 = = d [ 2 ] - d [ 1 ] : f = True else : f = False break if f : print ( ' Yes ' ) else : print ( ' No ' ) c = [ ] for _ in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) a = [ ] for i in range ( 3 ) : tmp = [ ] for j in range ( 3 ) : tmp . append ( c [ i ] [ j % 3 ] - c [ i ] [ ( j + 1 ) % 3 ] ) a . append ( tmp ) for i in range ( 2 ) : for j in range ( 3 ) : if a [ i ] [ j ] ! = a [ i + 1 ] [ j ] : print ( ' No ' ) break else : continue break else : print ( ' Yes ' ) c _ grid = [ 0 ] * 3 for i in range ( 3 ) : c _ grid [ i ] = list ( map ( int , input ( ) . split ( ) ) ) res = ' No ' for a1 in range ( 101 ) : b1 = c _ grid [ 0 ] [ 0 ] - a1 b2 = c _ grid [ 0 ] [ 1 ] - a1 b3 = c _ grid [ 0 ] [ 2 ] - a1 if b1 < 0 or b2 < 0 or b3 < 0 : continue if b1 > 100 or b2 > 100 or b3 > 100 : continue a2 = c _ grid [ 1 ] [ 0 ] - b1 if a2 < 0 or a2 > 100 or a2 ! = c _ grid [ 1 ] [ 1 ] - b2 or a2 ! = c _ grid [ 1 ] [ 2 ] - b3 : continue a3 = c _ grid [ 2 ] [ 0 ] - b1 if a3 < 0 or a3 > 100 or a3 ! = c _ grid [ 2 ] [ 1 ] - b2 or a3 ! = c _ grid [ 2 ] [ 2 ] - b3 : continue res = ' Yes ' print ( res ) def main ( ) : grid = [ [ int ( c ) for c in input ( ) . split ( ) ] for i in range ( 3 ) ] a1 = 0 a2 = 0 a3 = 0 b1 = 0 b2 = 0 b3 = 0 find _ a1 = False find _ a2 = False find _ a3 = False find _ b1 = False find _ b2 = False find _ b3 = False find _ all = False for a in range ( 101 ) : find _ a1 = False find _ a2 = False find _ a3 = False find _ b1 = False find _ b2 = False find _ b3 = False for b in range ( 101 ) : if a + b = = grid [ 0 ] [ 0 ] : b1 = b find _ b1 = True if a + b = = grid [ 0 ] [ 1 ] : b2 = b find _ b2 = True if a + b = = grid [ 0 ] [ 2 ] : b3 = b find _ b3 = True if find _ b1 and find _ b2 and find _ b3 : a1 = a find _ a1 = True break for a _ in range ( 101 ) : if ( a _ = = grid [ 1 ] [ 0 ] - b1 ) and ( a _ = = grid [ 1 ] [ 1 ] - b2 ) and ( a _ = = grid [ 1 ] [ 2 ] - b3 ) : a2 = a _ find _ a2 = True break for a _ in range ( 101 ) : if ( a _ = = grid [ 2 ] [ 0 ] - b1 ) and ( a _ = = grid [ 2 ] [ 1 ] - b2 ) and ( a _ = = grid [ 2 ] [ 2 ] - b3 ) : a3 = a _ find _ a3 = True break if find _ a1 and find _ a2 and find _ a3 and find _ b1 and find _ b2 and find _ b3 : find _ all = True break if find _ all : print ( " Yes " ) else : print ( " No " ) if _ _ name _ _ = = " _ _ main _ _ " : main ( ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] x = c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] y = c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] ans = ' Yes ' for i in range ( 1 , 3 ) : if c [ i ] [ 2 ] - c [ i ] [ 1 ] ! = x or c [ i ] [ 1 ] - c [ i ] [ 0 ] ! = y : ans = " No " break print ( ans ) ans = [ ] flag = True for i in range ( 3 ) : ans . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in range ( 2 ) : diff1 = ans [ i ] [ 0 ] - ans [ i + 1 ] [ 0 ] diff2 = ans [ i ] [ 1 ] - ans [ i + 1 ] [ 1 ] diff3 = ans [ i ] [ 2 ] - ans [ i + 1 ] [ 2 ] if diff1 ! = diff2 or diff2 ! = diff2 or diff3 ! = diff1 : flag = False break if flag : print ( ' Yes ' ) else : print ( ' No ' ) C = [ [ int ( hoge ) for hoge in input ( ) . split ( ) ] for i in range ( 3 ) ] B = C [ 0 ] A = [ 0 , C [ 1 ] [ 0 ] - C [ 0 ] [ 0 ] , C [ 2 ] [ 0 ] - C [ 0 ] [ 0 ] ] if C [ 1 ] = = [ A [ 1 ] + B [ 0 ] , A [ 1 ] + B [ 1 ] , A [ 1 ] + B [ 2 ] ] and C [ 2 ] = = [ A [ 2 ] + B [ 0 ] , A [ 2 ] + B [ 1 ] , A [ 2 ] + B [ 2 ] ] : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] if c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] and c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] = = c [ 2 ] [ 1 ] - c [ 2 ] [ 2 ] : print ( " Yes " ) else : print ( " No " ) S = [ ] for _ in range ( 3 ) : s = list ( map ( int , input ( ) . split ( ) ) ) S . append ( s ) a = [ None , None , None ] b = [ None , None , None ] a [ 0 ] = 0 b [ 0 ] = S [ 0 ] [ 0 ] - a [ 0 ] b [ 1 ] = S [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = S [ 0 ] [ 2 ] - a [ 0 ] a [ 1 ] = S [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = S [ 2 ] [ 0 ] - b [ 0 ] yes = 1 for i in range ( 3 ) : for j in range ( 3 ) : if not S [ i ] [ j ] = = a [ i ] + b [ j ] : yes = 0 break if yes : print ( " Yes " ) else : print ( " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a = [ 1 , 0 , 0 ] b = [ 0 , 0 , 0 ] b [ 0 ] = C [ 0 ] [ 0 ] - 1 b [ 1 ] = C [ 0 ] [ 1 ] - 1 b [ 2 ] = C [ 0 ] [ 2 ] - 1 a [ 1 ] = C [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = C [ 2 ] [ 0 ] - b [ 0 ] D = [ [ 0 , 0 , 0 ] for i in range ( 3 ) ] for i in range ( 3 ) : for j in range ( 3 ) : D [ i ] [ j ] = a [ i ] + b [ j ] if C = = D : print ( " Yes " ) else : print ( " No " ) import sys input = lambda : sys . stdin . readline ( ) . rstrip ( " \ r \ n " ) c = [ [ int ( x ) for x in input ( ) . split ( ) ] for _ in range ( 3 ) ] flag = 1 for a1 in range ( 101 ) : for a2 in range ( 101 ) : for a3 in range ( 101 ) : if c [ 0 ] [ 0 ] - a1 = = c [ 1 ] [ 0 ] - a2 and c [ 1 ] [ 0 ] - a2 = = c [ 2 ] [ 0 ] - a3 : if c [ 0 ] [ 1 ] - a1 = = c [ 1 ] [ 1 ] - a2 and c [ 1 ] [ 1 ] - a2 = = c [ 2 ] [ 1 ] - a3 : if c [ 0 ] [ 2 ] - a1 = = c [ 1 ] [ 2 ] - a2 and c [ 1 ] [ 2 ] - a2 = = c [ 2 ] [ 2 ] - a3 : flag = 0 if flag : print ( ' No ' ) else : print ( ' Yes ' ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] D = [ [ 0 , 0 , 0 ] , [ 0 , 0 , 0 ] , [ 0 , 0 , 0 ] ] for i in range ( 3 ) : for j in range ( 3 ) : D [ i ] [ j ] = C [ i ] [ j ] - C [ i ] [ j - 1 ] if D [ 0 ] = = D [ 1 ] = = D [ 2 ] : print ( " Yes " ) else : print ( " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 3 ) : minint = min ( C [ i ] ) for j in range ( 3 ) : C [ i ] [ j ] - = minint ans = True for j in range ( 3 ) : t = C [ 0 ] [ j ] for i in range ( 3 ) : if t ! = C [ i ] [ j ] : ans = False break if ans : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] q1 = c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] q2 = c [ 0 ] [ 0 ] - c [ 0 ] [ 2 ] = = c [ 1 ] [ 0 ] - c [ 1 ] [ 2 ] = = c [ 2 ] [ 0 ] - c [ 2 ] [ 2 ] q3 = c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] = = c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] q4 = c [ 0 ] [ 0 ] - c [ 2 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 2 ] [ 1 ] = = c [ 0 ] [ 2 ] - c [ 2 ] [ 2 ] print ( " Yes " if q1 and q2 and q3 and q4 else " No " ) c11 , c12 , c13 = map ( int , input ( ) . split ( ) ) c21 , c22 , c23 = map ( int , input ( ) . split ( ) ) c31 , c32 , c33 = map ( int , input ( ) . split ( ) ) if c11 - c12 = = c21 - c22 and c11 - c12 = = c31 - c32 and c12 - c13 = = c22 - c23 and c12 - c13 = = c32 - c33 : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] ans = " Yes " for i in range ( len ( c ) ) : mi = min ( c [ i ] ) * c [ i ] , = map ( lambda x : x - mi , c [ i ] ) print ( " Yes " if c [ 0 ] = = c [ 1 ] and c [ 1 ] = = c [ 2 ] else " No " ) C = [ ] for _ in range ( 3 ) : C . append ( list ( map ( int , input ( ) . split ( ) ) ) ) ans = False for a1 in range ( 0 , 101 ) : for a2 in range ( 0 , 101 ) : for a3 in range ( 0 , 101 ) : b1 , b2 , b3 = C [ 0 ] [ 0 ] - a1 , C [ 0 ] [ 1 ] - a1 , C [ 0 ] [ 2 ] - a1 flag1 = ( b1 = = C [ 1 ] [ 0 ] - a2 ) and ( b1 = = C [ 2 ] [ 0 ] - a3 ) flag2 = ( b2 = = C [ 1 ] [ 1 ] - a2 ) and ( b2 = = C [ 2 ] [ 1 ] - a3 ) flag3 = ( b3 = = C [ 1 ] [ 2 ] - a2 ) and ( b3 = = C [ 2 ] [ 2 ] - a3 ) if flag1 and flag2 and flag3 : ans = True if ans : print ( " Yes " ) else : print ( " No " ) from sys import stdin def main ( ) : readline = stdin . readline c = [ ] s = 0 for i in range ( 3 ) : li = list ( map ( int , readline ( ) . split ( ) ) ) s + = sum ( li ) c . append ( li ) if s % 3 ! = 0 : print ( " No " ) else : if c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] = = s / / 3 : print ( " Yes " ) else : print ( " No " ) if _ _ name _ _ = = " _ _ main _ _ " : main ( ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] if ( c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] = = c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] ) and \ ( c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 2 ] [ 2 ] ) : print ( ' Yes ' ) else : print ( ' No ' ) c1 = tuple ( map ( int , input ( ) . split ( ) ) ) c2 = tuple ( map ( int , input ( ) . split ( ) ) ) c3 = tuple ( map ( int , input ( ) . split ( ) ) ) q = 0 adif = [ c1 [ 1 ] - c1 [ 0 ] , c1 [ 2 ] - c1 [ 1 ] ] bdif1 = int ( c2 [ 0 ] - c1 [ 0 ] ) bdif2 = int ( c3 [ 0 ] - c2 [ 0 ] ) acnt = 0 bdif = 0 if c2 [ 1 ] - c2 [ 0 ] ! = adif [ 0 ] : q = 1 if c2 [ 2 ] - c2 [ 1 ] ! = adif [ 1 ] : q = 1 if c3 [ 1 ] - c3 [ 0 ] ! = adif [ 0 ] : q = 1 if c3 [ 2 ] - c3 [ 1 ] ! = adif [ 1 ] : q = 1 if int ( c2 [ 1 ] - c1 [ 1 ] ) ! = bdif1 : q = 1 if c2 [ 2 ] - c1 [ 2 ] ! = bdif1 : q = 1 if c3 [ 1 ] - c2 [ 1 ] ! = bdif2 : q = 1 if c3 [ 2 ] - c2 [ 2 ] ! = bdif2 : q = 1 if q = = 1 : print ( " No " ) else : print ( " Yes " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a = [ ] b = [ ] for i in range ( 3 ) : a . append ( C [ 1 ] [ i ] - C [ 0 ] [ i ] ) for j in range ( 3 ) : b . append ( C [ 2 ] [ j ] - C [ 0 ] [ j ] ) if ( a [ 0 ] = = a [ 1 ] and a [ 1 ] = = a [ 2 ] ) and ( b [ 0 ] = = b [ 1 ] and b [ 1 ] = = b [ 2 ] ) : print ( ' Yes ' ) else : print ( ' No ' ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] b2 _ 1 = c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] b3 _ 1 = c [ 0 ] [ 2 ] - c [ 0 ] [ 0 ] if any ( [ b2 _ 1 ! = c [ x ] [ 1 ] - c [ x ] [ 0 ] for x in [ 1 , 2 ] ] ) or any ( [ b3 _ 1 ! = c [ x ] [ 2 ] - c [ x ] [ 0 ] for x in [ 1 , 2 ] ] ) : print ( " No " ) else : print ( " Yes " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] cnt = 0 if ( c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] ) = = ( c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] ) = = ( c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] ) : cnt + = 1 if ( c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] ) = = ( c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] ) = = ( c [ 1 ] [ 2 ] - c [ 2 ] [ 2 ] ) : cnt + = 1 if ( c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] ) = = ( c [ 2 ] [ 1 ] - c [ 0 ] [ 1 ] ) = = ( c [ 2 ] [ 2 ] - c [ 0 ] [ 2 ] ) : cnt + = 1 if cnt = = 3 : print ( ' Yes ' ) else : print ( ' No ' ) a = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] flag = False for a1 in range ( 101 ) : for a2 in range ( 101 ) : for a3 in range ( 101 ) : if ( a [ 0 ] [ 0 ] - a1 = = a [ 1 ] [ 0 ] - a2 = = a [ 2 ] [ 0 ] - a3 ) and ( a [ 0 ] [ 1 ] - a1 = = a [ 1 ] [ 1 ] - a2 = = a [ 2 ] [ 1 ] - a3 ) and ( a [ 0 ] [ 2 ] - a1 = = a [ 1 ] [ 2 ] - a2 = = a [ 2 ] [ 2 ] - a3 ) : flag = True break if flag : print ( ' Yes ' ) else : print ( ' No ' ) Z = [ ] for i in range ( 3 ) : A = list ( map ( int , input ( ) . split ( ) ) ) Z . append ( A ) Q = [ ] a1 = 0 b1 = Z [ 0 ] [ 0 ] - a1 b2 = Z [ 0 ] [ 1 ] - a1 b3 = Z [ 0 ] [ 2 ] - a1 a2 = Z [ 1 ] [ 0 ] - b1 a3 = Z [ 2 ] [ 0 ] - b1 c1 = [ a1 + b1 , a1 + b2 , a1 + b3 ] c2 = [ a2 + b1 , a2 + b2 , a2 + b3 ] c3 = [ a3 + b1 , a3 + b2 , a3 + b3 ] Q . append ( c1 ) Q . append ( c2 ) Q . append ( c3 ) if Z = = Q : print ( " Yes " ) else : print ( " No " ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] ans = ' Yes ' for i in range ( 2 ) : if C [ i ] [ 0 ] - C [ i + 1 ] [ 0 ] ! = C [ i ] [ 1 ] - C [ i + 1 ] [ 1 ] or \ C [ i ] [ 0 ] - C [ i + 1 ] [ 0 ] ! = C [ i ] [ 2 ] - C [ i + 1 ] [ 2 ] : ans = ' No ' for j in range ( 2 ) : if C [ 0 ] [ j ] - C [ 0 ] [ j + 1 ] ! = C [ 1 ] [ j ] - C [ 1 ] [ j + 1 ] or \ C [ 0 ] [ j ] - C [ 0 ] [ j + 1 ] ! = C [ 2 ] [ j ] - C [ 2 ] [ j + 1 ] : ans = ' No ' print ( ans ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] c1 , c2 , c3 = C [ 0 ] c1 , c2 , c3 = c1 - c2 , c2 - c3 , c3 - c2 ans = ' Yes ' for c in C [ 1 : ] : cc1 , cc2 , cc3 = c cc1 , cc2 , cc3 = cc1 - cc2 , cc2 - cc3 , cc3 - cc2 if c1 = = cc1 and c2 = = cc2 and c3 = = cc3 : pass else : ans = ' No ' break c1 , c2 , c3 = C [ 0 ] [ 0 ] , C [ 1 ] [ 0 ] , C [ 2 ] [ 0 ] c1 , c2 , c3 = c1 - c2 , c2 - c3 , c3 - c2 for i in range ( 1 , 3 ) : cc1 , cc2 , cc3 = C [ 0 ] [ i ] , C [ 1 ] [ i ] , C [ 2 ] [ i ] cc1 , cc2 , cc3 = cc1 - cc2 , cc2 - cc3 , cc3 - cc2 if c1 = = cc1 and c2 = = cc2 and c3 = = cc3 : pass else : ans = ' No ' break print ( ans ) import sys def input ( ) : return sys . stdin . readline ( ) . strip ( ) def resolve ( ) : c0 = list ( map ( int , input ( ) . split ( ) ) ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) a = [ 0 ] * 3 b = [ 0 ] * 3 b [ 0 ] = c0 [ 0 ] b [ 1 ] = c1 [ 0 ] b [ 2 ] = c2 [ 0 ] a [ 1 ] = c0 [ 1 ] - b [ 0 ] a [ 2 ] = c0 [ 2 ] - b [ 0 ] if a [ 1 ] + b [ 1 ] = = c1 [ 1 ] and a [ 1 ] + b [ 2 ] = = c2 [ 1 ] and \ a [ 2 ] + b [ 1 ] = = c1 [ 2 ] and a [ 2 ] + b [ 2 ] = = c2 [ 2 ] : print ( ' Yes ' ) else : print ( ' No ' ) resolve ( ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] a = max ( c [ 0 ] ) for i in range ( a + 1 ) : a1 = i b = [ 0 , 0 , 0 ] a = [ 0 , 0 , 0 ] cnt = 0 for j in range ( 3 ) : for k in range ( 3 ) : if j = = 0 : b [ k ] = c [ j ] [ k ] - a1 elif j = = 2 or j = = 1 : a [ k ] = c [ j ] [ k ] - b [ k ] if ( j = = 1 or j = = 2 ) and k = = 2 : if len ( set ( a ) ) = = 1 and a [ 0 ] > = 0 : cnt + = 1 print ( ' Yes ' if cnt = = 2 else ' No ' ) C = [ None for i in range ( 3 ) ] for i in range ( 3 ) : C [ i ] = list ( map ( int , input ( ) . split ( ) ) ) ok = True for p in range ( 2 ) : diff = [ 0 ] * 3 for i in range ( 3 ) : diff [ i ] = C [ i ] [ p + 1 ] - C [ i ] [ p ] if len ( set ( diff ) ) > 1 : ok = False for p in range ( 2 ) : diff = [ 0 ] * 3 for i in range ( 3 ) : diff [ i ] = C [ p + 1 ] [ i ] - C [ p ] [ i ] if len ( set ( diff ) ) > 1 : ok = False print ( ( " No " , " Yes " ) [ ok ] ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) a1 _ a2 = c1 [ 0 ] - c2 [ 0 ] a2 _ a3 = c2 [ 0 ] - c3 [ 0 ] b1 _ b2 = c1 [ 0 ] - c1 [ 1 ] b2 _ b3 = c1 [ 1 ] - c1 [ 2 ] cnt = 0 if a1 _ a2 = = c1 [ 1 ] - c2 [ 1 ] = = c1 [ 2 ] - c2 [ 2 ] : cnt + = 1 if a2 _ a3 = = c2 [ 1 ] - c3 [ 1 ] = = c2 [ 2 ] - c3 [ 2 ] : cnt + = 1 if b1 _ b2 = = c2 [ 0 ] - c2 [ 1 ] = = c3 [ 0 ] - c3 [ 1 ] : cnt + = 1 if b2 _ b3 = = c2 [ 1 ] - c2 [ 2 ] = = c3 [ 1 ] - c3 [ 2 ] : cnt + = 1 if cnt = = 4 : print ( " Yes " ) else : print ( " No " ) F = [ None ] * 3 a = list ( map ( int , input ( ) . split ( ) ) ) b = [ a [ i ] - a [ i + 1 ] for i in range ( 2 ) ] for i in range ( 2 ) : c = list ( map ( int , input ( ) . split ( ) ) ) d = [ c [ i ] - c [ i + 1 ] for i in range ( 2 ) ] if b ! = d : print ( ' No ' ) break else : print ( ' Yes ' ) C = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] def thr _ check ( a , b , c ) : if a = = b and b = = c and c = = a : return True else : return False s1 = thr _ check ( C [ 0 ] [ 0 ] - C [ 0 ] [ 1 ] , C [ 1 ] [ 0 ] - C [ 1 ] [ 1 ] , C [ 2 ] [ 0 ] - C [ 2 ] [ 1 ] ) s2 = thr _ check ( C [ 0 ] [ 1 ] - C [ 0 ] [ 2 ] , C [ 1 ] [ 1 ] - C [ 1 ] [ 2 ] , C [ 2 ] [ 1 ] - C [ 2 ] [ 2 ] ) s3 = thr _ check ( C [ 0 ] [ 2 ] - C [ 0 ] [ 0 ] , C [ 1 ] [ 2 ] - C [ 1 ] [ 0 ] , C [ 2 ] [ 2 ] - C [ 2 ] [ 0 ] ) s4 = thr _ check ( C [ 0 ] [ 0 ] - C [ 1 ] [ 0 ] , C [ 0 ] [ 1 ] - C [ 1 ] [ 1 ] , C [ 0 ] [ 2 ] - C [ 1 ] [ 2 ] ) s5 = thr _ check ( C [ 1 ] [ 0 ] - C [ 2 ] [ 0 ] , C [ 1 ] [ 1 ] - C [ 2 ] [ 1 ] , C [ 1 ] [ 2 ] - C [ 2 ] [ 2 ] ) s6 = thr _ check ( C [ 2 ] [ 0 ] - C [ 0 ] [ 0 ] , C [ 2 ] [ 1 ] - C [ 0 ] [ 1 ] , C [ 2 ] [ 2 ] - C [ 0 ] [ 2 ] ) if s1 and s2 and s3 and s4 and s5 and s6 : print ( " Yes " ) else : print ( " No " ) c = [ 0 ] * 3 for i in range ( 3 ) : c [ i ] = list ( map ( int , input ( ) . split ( ) ) ) if ( c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] ) = = ( c [ 0 ] [ 1 ] + c [ 1 ] [ 2 ] + c [ 2 ] [ 0 ] ) and ( c [ 0 ] [ 2 ] + c [ 2 ] [ 1 ] + c [ 1 ] [ 0 ] ) = = ( c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] ) : print ( " Yes " ) else : print ( " No " ) lis1 = [ ] lis2 = [ ] lis3 = [ ] count = 0 for num in input ( ) . split ( ) : lis1 . append ( int ( num ) ) for num in input ( ) . split ( ) : lis2 . append ( int ( num ) ) for num in input ( ) . split ( ) : lis3 . append ( int ( num ) ) for a1 in range ( 101 ) : for a2 in range ( 101 ) : for a3 in range ( 101 ) : count = 0 if lis1 [ 0 ] - a1 = = lis2 [ 0 ] - a2 = = lis3 [ 0 ] - a3 : count + = 1 if lis1 [ 1 ] - a1 = = lis2 [ 1 ] - a2 = = lis3 [ 1 ] - a3 : count + = 1 if lis1 [ 2 ] - a1 = = lis2 [ 2 ] - a2 = = lis3 [ 2 ] - a3 : count + = 1 if count = = 3 : print ( " Yes " ) break if count = = 3 : break if count = = 3 : break if a1 = = 100 and count ! = 3 : print ( " No " ) def readInts ( ) : return list ( map ( int , input ( ) . split ( ) ) ) def main ( ) : C = [ readInts ( ) for _ in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 for i in range ( 3 ) : b [ i ] = C [ 0 ] [ i ] - a [ 0 ] for i in range ( 1 , 3 ) : a [ i ] = C [ i ] [ 0 ] - b [ 0 ] for i in range ( 3 ) : for j in range ( 3 ) : if C [ j ] [ i ] = = a [ j ] + b [ i ] : pass else : print ( ' No ' ) exit ( ) print ( ' Yes ' ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) c = [ [ ] ] * 3 for i in range ( 3 ) : c [ i ] = list ( map ( int , input ( ) . split ( ) ) ) arr = [ 0 ] * 3 sum = 0 for i in range ( 3 ) : arr [ 0 ] + = c [ i ] [ i ] for i in range ( 3 ) : if i + 1 < 3 : arr [ 1 ] + = c [ i ] [ i + 1 ] else : arr [ 1 ] + = c [ i ] [ 0 ] for i in range ( 3 ) : if i + 2 < 3 : arr [ 2 ] + = c [ i ] [ i + 2 ] else : arr [ 2 ] + = c [ i ] [ i - 1 ] if arr [ 0 ] ! = arr [ 1 ] or arr [ 0 ] ! = arr [ 2 ] : print ( " No " ) exit ( 0 ) print ( " Yes " ) exit ( 0 ) def readlines ( ) : for _ in range ( 3 ) : yield list ( map ( int , input ( ) . split ( ) ) ) c = list ( readlines ( ) ) def it ( ) : for a1 in range ( 100 ) : b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 a2 = c [ 1 ] [ 0 ] - b1 a3 = c [ 2 ] [ 0 ] - b1 yield ( c [ 1 ] [ 1 ] = = a2 + b2 and c [ 1 ] [ 2 ] = = a2 + b3 and c [ 2 ] [ 1 ] = = a3 + b2 and c [ 2 ] [ 2 ] = = a3 + b3 ) print ( " Yes " if any ( it ( ) ) else " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] for i in range ( 1 , 3 ) : d = c [ i ] [ 0 ] - c [ 0 ] [ 0 ] e = c [ 0 ] [ i ] - c [ 0 ] [ 0 ] for j in range ( 1 , 3 ) : if d ! = c [ i ] [ j ] - c [ 0 ] [ j ] : print ( " No " ) exit ( ) if e ! = c [ j ] [ i ] - c [ j ] [ 0 ] : print ( " No " ) exit ( ) print ( " Yes " ) def main ( ) : a = list ( map ( int , input ( ) . split ( ) ) ) a1 , a2 = a [ 1 ] - a [ 0 ] , a [ 2 ] - a [ 1 ] b = list ( map ( int , input ( ) . split ( ) ) ) b1 , b2 = b [ 1 ] - b [ 0 ] , b [ 2 ] - b [ 1 ] c = list ( map ( int , input ( ) . split ( ) ) ) c1 , c2 = c [ 1 ] - c [ 0 ] , c [ 2 ] - c [ 1 ] if a1 = = b1 = = c1 and a2 = = b2 = = c2 : print ( ' Yes ' ) else : print ( ' No ' ) if _ _ name _ _ = = ' _ _ main _ _ ' : main ( ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] for a1 in range ( 101 ) : for a2 in range ( 101 ) : for a3 in range ( 101 ) : b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 if a2 + b1 = = c [ 1 ] [ 0 ] and a2 + b2 = = c [ 1 ] [ 1 ] and a2 + b3 = = c [ 1 ] [ 2 ] : if a3 + b1 = = c [ 2 ] [ 0 ] and a3 + b2 = = c [ 2 ] [ 1 ] and a3 + b3 = = c [ 2 ] [ 2 ] : print ( ' Yes ' ) quit ( ) print ( ' No ' ) numbers = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] answer = " No " for a1 in range ( 101 ) : b1 = numbers [ 0 ] [ 0 ] - a1 b2 = numbers [ 1 ] [ 0 ] - a1 b3 = numbers [ 2 ] [ 0 ] - a1 a2 = numbers [ 0 ] [ 1 ] - b1 a3 = numbers [ 0 ] [ 2 ] - b1 if a2 + b2 = = numbers [ 1 ] [ 1 ] and a3 + b2 = = numbers [ 1 ] [ 2 ] and a2 + b3 = = numbers [ 2 ] [ 1 ] and a3 + b3 = = numbers [ 2 ] [ 2 ] and a1 > = 0 and a2 > = 0 and a3 > = 0 and b1 > = 0 and b2 > = 0 and b3 > = 0 : answer = " Yes " print ( answer ) a = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] for i in range ( 1 ) : for j in range ( len ( a ) - 1 ) : b = a [ j + 1 ] [ i ] - a [ j ] [ i ] if a [ j + 1 ] [ i + 1 ] - a [ j ] [ i + 1 ] ! = b or a [ j + 1 ] [ i + 2 ] - a [ j ] [ i + 2 ] ! = b : print ( " No " ) exit ( ) print ( " Yes " ) c = [ [ int ( i ) for i in input ( ) . split ( ) ] for i in range ( 3 ) ] for a1 in range ( 101 ) : b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 a2 _ 1 = c [ 1 ] [ 0 ] - b1 a2 _ 2 = c [ 1 ] [ 1 ] - b2 a2 _ 3 = c [ 1 ] [ 2 ] - b3 a3 _ 1 = c [ 2 ] [ 0 ] - b1 a3 _ 2 = c [ 2 ] [ 1 ] - b2 a3 _ 3 = c [ 2 ] [ 2 ] - b3 if ( a2 _ 1 = = a2 _ 2 = = a2 _ 3 ) and ( a3 _ 1 = = a3 _ 2 = = a3 _ 3 ) : print ( ' Yes ' ) exit ( ) print ( ' No ' ) c1 = list ( map ( int , input ( ) . split ( ) ) ) c2 = list ( map ( int , input ( ) . split ( ) ) ) c3 = list ( map ( int , input ( ) . split ( ) ) ) c = [ c1 , c2 , c3 ] d = [ [ - 1 , - 1 , - 1 ] for _ in range ( 3 ) ] for a1 in range ( c [ 0 ] [ 0 ] + 1 ) : b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 a2 = c [ 1 ] [ 0 ] - b1 a3 = c [ 2 ] [ 0 ] - b1 d [ 0 ] [ 0 ] = a1 + b1 d [ 0 ] [ 1 ] = a1 + b2 d [ 0 ] [ 2 ] = a1 + b3 d [ 1 ] [ 0 ] = a2 + b1 d [ 1 ] [ 1 ] = a2 + b2 d [ 1 ] [ 2 ] = a2 + b3 d [ 2 ] [ 0 ] = a3 + b1 d [ 2 ] [ 1 ] = a3 + b2 d [ 2 ] [ 2 ] = a3 + b3 if c = = d : print ( ' Yes ' ) exit ( 0 ) else : continue print ( ' No ' ) li = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] def chk ( al , bl , li ) : for i in range ( 3 ) : for j in range ( 3 ) : if li [ i ] [ j ] ! = al [ i ] + bl [ j ] : return False return True flag = True for a1 in range ( max ( li [ 0 ] ) + 1 ) : al = [ ] bl = [ ] bl = [ li [ 0 ] [ 0 ] - a1 , li [ 0 ] [ 1 ] - a1 , li [ 0 ] [ 2 ] - a1 ] al . append ( a1 ) al . append ( li [ 1 ] [ 0 ] - bl [ 0 ] ) al . append ( li [ 2 ] [ 0 ] - bl [ 0 ] ) if chk ( al , bl , li ) : print ( " Yes " ) exit ( ) print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] flg = False for i in range ( max ( c [ 0 ] [ 0 ] , c [ 1 ] [ 0 ] , c [ 2 ] [ 0 ] ) + 1 ) : a1 , a2 , a3 = c [ 0 ] [ 0 ] - i , c [ 1 ] [ 0 ] - i , c [ 2 ] [ 0 ] - i if c [ 0 ] [ 1 ] - a1 = = c [ 1 ] [ 1 ] - a2 and c [ 0 ] [ 1 ] - a1 = = c [ 2 ] [ 1 ] - a3 and \ c [ 0 ] [ 2 ] - a1 = = c [ 1 ] [ 2 ] - a2 and c [ 0 ] [ 2 ] - a1 = = c [ 2 ] [ 2 ] - a3 : flg = True print ( " Yes " if flg else " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] b = c [ 0 ] a = [ 0 ] for i in range ( 1 , 3 ) : a . append ( c [ i ] [ i ] - b [ i ] ) for i in range ( 3 ) : for j in range ( 3 ) : if c [ i ] [ j ] ! = a [ i ] + b [ j ] : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c _ 0 = list ( map ( int , input ( ) . split ( ) ) ) c _ 1 = list ( map ( int , input ( ) . split ( ) ) ) c _ 2 = list ( map ( int , input ( ) . split ( ) ) ) d = c _ 0 [ 0 ] + c _ 1 [ 1 ] + c _ 2 [ 2 ] e = c _ 1 [ 0 ] + c _ 0 [ 2 ] + c _ 2 [ 1 ] f = c _ 0 [ 1 ] + c _ 1 [ 2 ] + c _ 2 [ 0 ] if d = = e = = f : print ( " Yes " ) else : print ( " No " ) c = [ [ int ( x ) for x in input ( ) . split ( ) ] for _ in range ( 3 ) ] ans = False for a1 in range ( 101 ) : for a2 in range ( 101 ) : for a3 in range ( 101 ) : ok = True b1 = c [ 0 ] [ 0 ] - a1 b2 = c [ 0 ] [ 1 ] - a1 b3 = c [ 0 ] [ 2 ] - a1 if c [ 1 ] [ 0 ] ! = a2 + b1 or \ c [ 1 ] [ 1 ] ! = a2 + b2 or \ c [ 1 ] [ 2 ] ! = a2 + b3 or \ c [ 2 ] [ 0 ] ! = a3 + b1 or \ c [ 2 ] [ 1 ] ! = a3 + b2 or \ c [ 2 ] [ 2 ] ! = a3 + b3 : ok = False if ok : ans = True if ans : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] ans = " Yes " for i in range ( 1 , 3 ) : if c [ i ] [ 0 ] - c [ 0 ] [ 0 ] ! = c [ i ] [ 1 ] - c [ 0 ] [ 1 ] or c [ i ] [ 1 ] - c [ 0 ] [ 1 ] ! = c [ i ] [ 2 ] - c [ 0 ] [ 2 ] : ans = " No " print ( ans ) c = [ ] for i in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( " " ) ) ) ) f = " No " for a1 in range ( 101 ) : for a2 in range ( 101 ) : for a3 in range ( 101 ) : if ( c [ 0 ] [ 0 ] - a1 = = c [ 0 ] [ 1 ] - a2 = = c [ 0 ] [ 2 ] - a3 and c [ 1 ] [ 0 ] - a1 = = c [ 1 ] [ 1 ] - a2 = = c [ 1 ] [ 2 ] - a3 and c [ 2 ] [ 0 ] - a1 = = c [ 2 ] [ 1 ] - a2 = = c [ 2 ] [ 2 ] - a3 ) : f = " Yes " print ( f ) n = 3 x = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( n ) ] a = [ 0 ] * n b = [ 0 ] * n a [ 0 ] = 0 b [ 0 ] = x [ 0 ] [ 0 ] b [ 1 ] = x [ 0 ] [ 1 ] b [ 2 ] = x [ 0 ] [ 2 ] a [ 1 ] = x [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = x [ 2 ] [ 0 ] - b [ 0 ] for i in range ( n ) : for j in range ( n ) : if x [ i ] [ j ] ! = ( a [ i ] + b [ j ] ) : print ( ' No ' ) exit ( ) print ( ' Yes ' ) c = [ ] for _ in range ( 3 ) : c . append ( list ( map ( int , input ( ) . split ( ) ) ) ) if c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] and c [ 2 ] [ 1 ] - c [ 2 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] and c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 1 ] [ 1 ] and c [ 2 ] [ 2 ] - c [ 2 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 1 ] [ 1 ] : print ( " Yes " ) else : print ( " No " ) C = [ ] for i in range ( 3 ) : C . append ( list ( map ( int , input ( ) . split ( ) ) ) ) flg = True for i in range ( 2 ) : for j in range ( 2 ) : if C [ i ] [ j + 1 ] - C [ i ] [ j ] ! = C [ i + 1 ] [ j + 1 ] - C [ i + 1 ] [ j ] : flg = False break elif C [ i + 1 ] [ j ] - C [ i ] [ j ] ! = C [ i + 1 ] [ j + 1 ] - C [ i ] [ j + 1 ] : flg = False break if flg : print ( " Yes " ) else : print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a2 = c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] a3 = c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] if any ( c [ 1 ] [ x ] ! = a2 + c [ 0 ] [ x ] for x in [ 1 , 2 ] ) or any ( c [ 2 ] [ x ] ! = a3 + c [ 0 ] [ x ] for x in [ 1 , 2 ] ) : print ( ' No ' ) else : print ( ' Yes ' ) c = [ ] c . append ( [ int ( i ) for i in input ( ) . split ( ) ] ) c . append ( [ int ( i ) for i in input ( ) . split ( ) ] ) c . append ( [ int ( i ) for i in input ( ) . split ( ) ] ) for i in range ( 2 ) : c0 = c [ 0 ] [ i ] - c [ 0 ] [ i + 1 ] c1 = c [ 1 ] [ i ] - c [ 1 ] [ i + 1 ] c2 = c [ 2 ] [ i ] - c [ 2 ] [ i + 1 ] if not ( c0 = = c1 = = c2 ) : print ( " No " ) exit ( 0 ) for i in range ( 2 ) : r0 = c [ i ] [ 0 ] - c [ i + 1 ] [ 0 ] r1 = c [ i ] [ 1 ] - c [ i + 1 ] [ 1 ] r2 = c [ i ] [ 2 ] - c [ i + 1 ] [ 2 ] if not ( c0 = = c1 = = c2 ) : print ( " No " ) exit ( 0 ) print ( " Yes " ) L = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] T = sum ( [ sum ( i ) for i in L ] ) print ( ' Yes ' if L [ 0 ] [ 0 ] + L [ 1 ] [ 1 ] + L [ 2 ] [ 2 ] = = ( T / 3 ) else ' No ' ) " " " a , b , c = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 3 ) ] for i in range ( a [ 0 ] + 1 ) : b1 = a [ 0 ] - i b2 = a [ 1 ] - i b3 = a [ 2 ] - i a2 = [ ] a3 = [ ] a2 . append ( b [ 0 ] - b1 ) a2 . append ( b [ 1 ] - b2 ) a2 . append ( b [ 2 ] - b3 ) a3 . append ( c [ 0 ] - b1 ) a3 . append ( c [ 1 ] - b2 ) a3 . append ( c [ 2 ] - b3 ) if len ( set ( a2 ) ) = = 1 and len ( set ( a3 ) ) = = 1 : print ( " Yes " ) exit ( ) print ( " No " ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( 3 ) ] a = [ 0 ] * 3 b = [ 0 ] * 3 for j in range ( 3 ) : b [ j ] = c [ 0 ] [ j ] for i in range ( 1 , 3 ) : a [ i ] = c [ i ] [ 0 ] - b [ 0 ] import sys for i in range ( 3 ) : for j in range ( 3 ) : if a [ i ] + b [ j ] ! = c [ i ] [ j ] : print ( ' No ' ) sys . exit ( ) print ( ' Yes ' ) import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int k = scanner . nextInt ( ) ; int s = scanner . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { if ( s - ( i + j ) < = k & & s - ( i + j ) > = 0 ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] P = new int [ N + 1 ] ; for ( int i = 1 ; i < = N ; i + + ) { P [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int ans = 1 ; int min = P [ 1 ] ; for ( int i = 2 ; i < = N ; i + + ) { min = Math . min ( min , P [ i ] ) ; if ( P [ i ] < = min ) { ans + + ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int count = 0 ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { if ( i + j < = s & & s - ( i + j ) < = k ) { count + + ; } } } System . out . println ( count ) ; } } import java . io . * ; class Main { static StreamTokenizer st = new StreamTokenizer ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; static int nextInt ( ) throws IOException { st . nextToken ( ) ; return ( int ) st . nval ; } public static void main ( String [ ] args ) throws IOException { PrintWriter pw = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; int k = nextInt ( ) , s = nextInt ( ) , ans = 0 ; for ( int x = 0 ; x < = k & & x < = s ; + + x ) { for ( int y = 0 ; y < = k & & y + x < = s ; + + y ) { if ( s - x - y < = k ) + + ans ; } } pw . print ( ans ) ; pw . print ( ' \ n ' ) ; pw . flush ( ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] ks = scanner . nextLine ( ) . split ( " " , 2 ) ; int k = Integer . parseInt ( ks [ 0 ] ) ; int s = Integer . parseInt ( ks [ 1 ] ) ; int count = 0 ; for ( int x = 0 ; x < = Math . min ( k , s ) ; x + + ) { for ( int y = 0 ; y < = Math . min ( k , s - x ) ; y + + ) { int z = s - x - y ; if ( 0 < = z & & z < = k ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String S [ ] = new String [ N ] ; String count = " Three " ; for ( int i = 0 ; i < N ; i + + ) { S [ i ] = sc . next ( ) ; if ( S [ i ] . equals ( " Y " ) ) count = " Four " ; } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; int ans = 0 ; for ( int i = 0 ; i < n ; i + + ) { a [ i ] = sc . nextInt ( ) ; } int min = a [ 0 ] ; for ( int i = 1 ; i < n ; i + + ) { if ( min > a [ i ] ) { ans + + ; min = a [ i ] ; } } System . out . println ( ans + 1 ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { if ( 0 < = S - i - j & & S - i - j < = K ) { ans + + ; } } } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int k = stdIn . nextInt ( ) ; int s = stdIn . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { if ( 0 < = s - ( i + j ) & & s - ( i + j ) < = k ) { cnt + + ; } } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . nextLine ( ) ) ; int [ ] PList = new int [ N ] ; PList [ 0 ] = sc . nextInt ( ) ; int minNumber = PList [ 0 ] ; int cnt = 1 ; for ( int i = 1 ; i < N ; i + + ) { PList [ i ] = sc . nextInt ( ) ; if ( minNumber > = PList [ i ] ) { minNumber = PList [ i ] ; cnt + + ; } else { } } System . out . println ( cnt ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { int count = 0 ; boolean sw = false ; String answer = " " ; int e = 0 ; int f = 0 ; int g = 0 ; int h = 0 ; Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; if ( a = = 1 | | b = = 1 | | c = = 1 | | d = = 1 ) { e = 1 ; } if ( a = = 9 | | b = = 9 | | c = = 9 | | d = = 9 ) { f = 1 ; } if ( a = = 7 | | b = = 7 | | c = = 7 | | d = = 7 ) { g = 1 ; } if ( a = = 4 | | b = = 4 | | c = = 4 | | d = = 4 ) { h = 1 ; } if ( e = = 1 & & f = = 1 & & g = = 1 & & h = = 1 ) { answer = " YES " ; } else { answer = " NO " ; } System . out . println ( answer ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int count = 0 ; int min = Integer . MAX _ VALUE ; for ( int i = 0 ; i < n ; i + + ) { int p = in . nextInt ( ) ; if ( p < = min ) { min = p ; count + + ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int a [ ] = new int [ N ] ; int nowp = 1 ; for ( int i = 0 ; i < a . length ; i + + ) { a [ i ] = scanner . nextInt ( ) ; } long ans = 0 ; for ( int i = 0 ; i < a . length ; i + + ) { if ( a [ i ] = = nowp ) { nowp + + ; continue ; } if ( a [ i ] < nowp ) { continue ; } if ( a [ i ] % nowp = = 0 | | nowp = = 1 ) { ans = ans + a [ i ] / nowp - 1 ; if ( nowp = = 1 ) { nowp + + ; } } else { ans = ans + a [ i ] / nowp ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner scan = new Scanner ( System . in ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i ! = a + 1 ; i + + ) { for ( int j = 0 ; j ! = a + 1 ; j + + ) { if ( b - i - j > = 0 & & b - i - j < = a ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] atgs ) { Scanner scan = new Scanner ( System . in ) ; int ans = 0 ; int K = scan . nextInt ( ) ; int S = scan . nextInt ( ) ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { int z = S - x - y ; if ( 0 < = z & & z < = K ) { ans = ans + 1 ; } } } System . out . println ( ans ) ; scan . close ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { if ( S - i - j > = 0 & & S - i - j < = K ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] a = new int [ 3 ] ; int [ ] b = new int [ 3 ] ; for ( int i = 0 ; i < = 100 ; i + + ) { a [ 0 ] = i ; for ( int j = 0 ; j < 2 ; j + + ) { b [ j ] = c [ 0 ] [ j ] - a [ 0 ] ; } a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] ; a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] ; if ( infomation ( a , b , c ) ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } public static boolean infomation ( int [ ] a , int [ ] b , int [ ] [ ] c ) { for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( a [ i ] + b [ j ] ! = c [ i ] [ j ] ) { return false ; } } } return true ; } } import java . io . * ; class Main { public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int output = 0 ; try { String [ ] keyboardInput = br . readLine ( ) . split ( " " ) ; int K = Integer . parseInt ( keyboardInput [ 0 ] ) ; int S = Integer . parseInt ( keyboardInput [ 1 ] ) ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { if ( S - x - y > = 0 & & S - x - y < = K ) { output + + ; } } } System . out . println ( output ) ; } catch ( IOException e ) { System . out . println ( e . getMessage ( ) ) ; } } } import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { if ( 0 < = s - i - j & & k > = s - i - j ) cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cnt = 0 ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { if ( s - x - y > = 0 & & s - x - y < = k ) cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int w _ diffs [ ] = new int [ 2 ] ; int h _ diffs [ ] = new int [ 2 ] ; int m [ ] [ ] = new int [ 3 ] [ 3 ] ; boolean con = true ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { m [ i ] [ j ] = sc . nextInt ( ) ; } } w _ diffs [ 0 ] = m [ 0 ] [ 1 ] - m [ 0 ] [ 0 ] ; w _ diffs [ 1 ] = m [ 0 ] [ 2 ] - m [ 0 ] [ 1 ] ; h _ diffs [ 0 ] = m [ 1 ] [ 0 ] - m [ 0 ] [ 0 ] ; h _ diffs [ 1 ] = m [ 2 ] [ 0 ] - m [ 1 ] [ 0 ] ; for ( int i = 1 ; i < 3 & & con ; i + + ) { for ( int j = 0 ; j < 2 ; j + + ) { if ( m [ i ] [ j + 1 ] - m [ i ] [ j ] ! = w _ diffs [ j ] ) con = false ; if ( m [ j + 1 ] [ i ] - m [ j ] [ i ] ! = h _ diffs [ j ] ) con = false ; } } if ( con ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . Arrays ; import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Main { InputStream in = System . in ; PrintStream out = System . out ; public void _ main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int N = sc . nextInt ( ) ; Set < String > s = new HashSet < > ( ) ; for ( int i = 0 ; i < N ; i + + ) { s . add ( sc . next ( ) ) ; } sc . close ( ) ; if ( s . size ( ) = = 3 ) { out . println ( " Three " ) ; } else { out . println ( " Four " ) ; } } public static void main ( String [ ] args ) { new Main ( ) . _ main ( args ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int min = 200000 ; int cnt = 0 ; for ( int i = 0 ; i < N ; i + + ) { int P = sc . nextInt ( ) ; min = Math . min ( min , P ) ; if ( min = = P ) cnt + + ; } System . out . println ( cnt ) ; } } import java . io . FileNotFoundException ; import java . io . FileReader ; import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner cin = new Scanner ( System . in ) ; int [ ] res = new int [ 4 ] ; res [ 0 ] = cin . nextInt ( ) ; res [ 1 ] = cin . nextInt ( ) ; res [ 2 ] = cin . nextInt ( ) ; res [ 3 ] = cin . nextInt ( ) ; Arrays . sort ( res ) ; if ( res [ 0 ] ! = 1 ) { System . out . println ( " NO " ) ; return ; } if ( res [ 1 ] ! = 4 ) { System . out . println ( " NO " ) ; return ; } if ( res [ 2 ] ! = 7 ) { System . out . println ( " NO " ) ; return ; } if ( res [ 3 ] ! = 9 ) { System . out . println ( " NO " ) ; return ; } System . out . println ( " YES " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; int count = 0 ; int x = Integer . MAX _ VALUE ; for ( int i = 0 ; i < n ; i + + ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i + + ) { x = Math . min ( x , a [ i ] ) ; if ( x = = a [ i ] ) { count + + ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { private static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int K = Integer . parseInt ( scan . next ( ) ) ; int S = Integer . parseInt ( scan . next ( ) ) ; int count = 0 ; for ( int i = 0 ; i < = K ; i + + ) { int XY = S - i ; if ( XY < 0 ) break ; if ( XY < = 2 * K ) { for ( int j = 0 ; j < = K ; j + + ) { int X = XY - j ; if ( X < 0 ) break ; if ( X < = K ) count + + ; } } } System . out . println ( count ) ; scan . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int X = sc . nextInt ( ) ; long ok = Long . MAX _ VALUE / 3 ; long ng = 0 ; while ( ok - ng > 1 ) { long m = ( ok + ng ) / 2 ; if ( f ( m ) > X ) { ok = m ; } else { ng = m ; } } System . out . println ( ok - 1 ) ; } static int f ( long n ) { if ( n < = 2 ) return 0 ; return 1 + f ( ( n - 1 ) / 2 ) ; } static void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int cnt = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( 0 < = z & & z < = k ) { cnt + + ; } } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int count = 0 ; int P [ ] = new int [ N ] ; int Pj = 0 ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = sc . nextInt ( ) ; Pj = P [ 0 ] ; } for ( int i = 0 ; i < N ; i + + ) { if ( P [ i ] < = Pj ) { count + + ; Pj = P [ i ] ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] P = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) P [ i ] = sc . nextInt ( ) ; int min = P [ 0 ] ; int cnt = 0 ; for ( int i = 0 ; i < N ; i + + ) { if ( min > = P [ i ] ) { cnt + + ; min = P [ i ] ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n1 = sc . nextInt ( ) ; int n2 = sc . nextInt ( ) ; int n3 = sc . nextInt ( ) ; int n4 = sc . nextInt ( ) ; sc . close ( ) ; int [ ] r = new int [ 10 ] ; r [ n1 ] + + ; r [ n2 ] + + ; r [ n3 ] + + ; r [ n4 ] + + ; System . out . println ( r [ 1 ] = = 1 & & r [ 4 ] = = 1 & & r [ 7 ] = = 1 & & r [ 9 ] = = 1 ? " YES " : " NO " ) ; } } import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int [ ] n = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; + + i ) n [ i ] = sc . nextInt ( ) ; Arrays . sort ( n ) ; int [ ] m = { 1 , 4 , 7 , 9 } ; String ans = ( Arrays . equals ( n , m ) ) ? " YES " : " NO " ; System . out . println ( ans ) ; } } import java . util . Arrays ; import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String ans = " Three " ; for ( int i = 0 ; i < n ; i + + ) { if ( sc . next ( ) . equals ( " Y " ) ) { ans = " Four " ; break ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int pm = 1000000 ; int ans = 0 ; for ( int i = 0 ; i < n ; i + + ) { int p = sc . nextInt ( ) ; if ( p < = pm ) { ans + + ; pm = p ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { if ( i + j < = S & & S - ( i + j ) < = K ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int S = scanner . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < = N ; i + + ) { for ( int j = 0 ; j < = N ; j + + ) { if ( 0 < = S - i - j & & S - i - j < = N ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int C11 = scan . nextInt ( ) ; int C12 = scan . nextInt ( ) ; int C13 = scan . nextInt ( ) ; scan . nextLine ( ) ; int C21 = scan . nextInt ( ) ; int C22 = scan . nextInt ( ) ; int C23 = scan . nextInt ( ) ; scan . nextLine ( ) ; int C31 = scan . nextInt ( ) ; int C32 = scan . nextInt ( ) ; int C33 = scan . nextInt ( ) ; scan . nextLine ( ) ; if ( ( ( C12 - C11 ) = = ( C22 - C21 ) & & ( C22 - C21 ) = = ( C32 - C31 ) ) & & ( ( C13 - C12 ) = = ( C23 - C22 ) & & ( C23 - C22 ) = = ( C33 - C32 ) ) & & ( ( C31 - C21 ) = = ( C32 - C22 ) & & ( C32 - C22 ) = = ( C33 - C23 ) ) & & ( ( C21 - C11 ) = = ( C22 - C12 ) & & ( C22 - C12 ) = = ( C23 - C13 ) ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; import java . io . File ; import java . io . FileNotFoundException ; public class Main { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { arr [ i ] = scanner . nextInt ( ) ; } int min = ( 1 < < 30 ) , ans = 0 ; for ( int i = 0 ; i < n ; i + + ) { if ( arr [ i ] < min ) { min = arr [ i ] ; ans + = 1 ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; long toori = 0 ; if ( K < = 200 ) { for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { for ( int k = 0 ; k < = K ; k + + ) { if ( i + j + k = = S ) { toori + + ; } } } } System . out . println ( toori ) ; } else { if ( S < = K ) { System . out . println ( ( S + 2 ) * ( S + 1 ) / 2 ) ; } else if ( S > K & & S < = 2 * K ) { System . out . println ( ( S + 2 ) * ( S + 1 ) / 2 - 3 * ( S - K + 1 ) * ( S - K ) / 2 ) ; } else if ( S > 2 * K ) { int tmp = 3 * K - S ; System . out . println ( ( tmp + 2 ) * ( tmp + 1 ) / 2 ) ; } } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int p [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = scan . nextInt ( ) ; } int min = p [ 0 ] ; int ans = 1 ; for ( int i = 1 ; i < n ; i + + ) { if ( min > p [ i ] ) { min = p [ i ] ; } if ( min > = p [ i ] ) { ans + = 1 ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] data = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { data [ i ] [ j ] = sc . nextInt ( ) ; } } int a1 = 0 ; int b1 = data [ 0 ] [ 0 ] ; int b2 = data [ 1 ] [ 0 ] ; int b3 = data [ 2 ] [ 0 ] ; int a2 = data [ 0 ] [ 1 ] - b1 ; int a3 = data [ 0 ] [ 2 ] - b1 ; if ( data [ 0 ] [ 0 ] = = a1 + b1 & & data [ 0 ] [ 1 ] = = a2 + b1 & & data [ 0 ] [ 2 ] = = a3 + b1 & & data [ 1 ] [ 0 ] = = a1 + b2 & & data [ 1 ] [ 1 ] = = a2 + b2 & & data [ 1 ] [ 2 ] = = a3 + b2 & & data [ 2 ] [ 0 ] = = a1 + b3 & & data [ 2 ] [ 1 ] = = a2 + b3 & & data [ 2 ] [ 2 ] = = a3 + b3 ) { System . out . println ( " Yes " ) ; } else System . out . println ( " No " ) ; sc . close ( ) ; } } import java . util . * ; import java . util . function . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] P = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) P [ i ] = sc . nextInt ( ) ; sc . close ( ) ; int min = P [ 0 ] ; int ans = 0 ; for ( int i = 0 ; i < N ; i + + ) { if ( min < P [ i ] ) continue ; min = P [ i ] ; ans + + ; } System . out . println ( ans ) ; } } import java . util . Scanner ; import java . util . Stack ; public class Main { final int [ ] [ ] dir = { { - 1 , - 1 } , { - 1 , 1 } , { 1 , - 1 } , { 1 , 1 } } ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = readInt ( sc ) ; int s = readInt ( sc ) ; int cnt = 0 ; for ( int a = 0 ; a < = k ; a + + ) { for ( int b = 0 ; b < = k ; b + + ) { int c = s - a - b ; if ( c > = 0 & & c < = k ) { cnt + + ; } } } System . out . println ( cnt ) ; } static int readInt ( Scanner sc ) { return Integer . parseInt ( sc . next ( ) ) ; } static double calcDistance ( Pair p1 , Pair p2 ) { return Math . pow ( Math . pow ( p1 . getX ( ) - p2 . getX ( ) , 2 ) + Math . pow ( p1 . getY ( ) - p2 . getY ( ) , 2 ) , 0.5 ) ; } } class Pair { private int x ; private int y ; public int getX ( ) { return x ; } public void setX ( int x ) { this . x = x ; } public int getY ( ) { return y ; } public void setY ( int y ) { this . y = y ; } public Pair ( ) { } public Pair ( int x , int y ) { this . x = x ; this . y = y ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int num = sc . nextInt ( ) ; int numArrasy [ ] = new int [ num ] ; for ( int i = 0 ; i < num ; i + + ) { numArrasy [ i ] = sc . nextInt ( ) ; } int count = 1 ; int tmp = numArrasy [ 0 ] ; for ( int i = 0 ; i < num ; i + + ) { if ( tmp > numArrasy [ i ] ) { count + + ; } tmp = Math . min ( tmp , numArrasy [ i ] ) ; } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } sc . close ( ) ; int b0b1 _ 1 = c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] ; int b1b2 _ 1 = c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] ; int b0b1 _ 2 = c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] ; int b1b2 _ 2 = c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] ; int b0b1 _ 3 = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] ; int b1b2 _ 3 = c [ 2 ] [ 1 ] - c [ 2 ] [ 2 ] ; int a0a1 _ 1 = c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] ; int a1a2 _ 1 = c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] ; int a0a1 _ 2 = c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] ; int a1a2 _ 2 = c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] ; int a0a1 _ 3 = c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] ; int a1a2 _ 3 = c [ 1 ] [ 2 ] - c [ 2 ] [ 2 ] ; String result = " No " ; if ( b0b1 _ 1 = = b0b1 _ 2 & & b0b1 _ 2 = = b0b1 _ 3 ) { if ( b1b2 _ 1 = = b1b2 _ 2 & & b1b2 _ 2 = = b1b2 _ 3 ) { if ( a0a1 _ 1 = = a0a1 _ 2 & & a0a1 _ 2 = = a0a1 _ 3 ) { if ( a1a2 _ 1 = = a1a2 _ 2 & & a1a2 _ 2 = = a1a2 _ 3 ) { result = " Yes " ; } } } } System . out . println ( result ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] P = new int [ N ] ; int ans = 0 ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = sc . nextInt ( ) ; } int max = P [ 0 ] ; int min = P [ 0 ] ; for ( int i = 0 ; i < N ; i + + ) { if ( max > = P [ i ] & & min > = P [ i ] ) { ans + = 1 ; } max = Math . max ( max , P [ i ] ) ; min = Math . min ( min , P [ i ] ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner cin = new Scanner ( System . in ) ; int K = cin . nextInt ( ) ; int S = cin . nextInt ( ) ; cin . close ( ) ; int count = 0 ; for ( int X = 0 ; X < = K ; X + + ) { for ( int Y = 0 ; Y < = K ; Y + + ) { int Z = S - X - Y ; if ( Z > = 0 & & Z < = K ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . * ; final class Solver { static final Solver INSTANCE = new Solver ( ) ; void solve ( Iterator < String > sc ) { int K = Integer . parseInt ( sc . next ( ) ) ; int S = Integer . parseInt ( sc . next ( ) ) ; int sum = 0 ; for ( int x = 0 ; x < = K & & x < = S ; x + + ) { int remaining = S - x ; sum + = Math . max ( Math . min ( remaining , K ) - Math . max ( remaining - K , 0 ) + 1 , 0 ) ; } System . out . println ( sum ) ; } } class Main { public static void main ( String ... args ) { Solver . INSTANCE . solve ( new Scanner ( System . in ) ) ; } } import java . util . * ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( z < = k & & z > = 0 ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { if ( ( S - i - j > = 0 ) & & ( S - i - j < = K ) ) cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { int z = S - x - y ; if ( z > = 0 & & z < = K ) count + + ; } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 4 ] [ 4 ] ; for ( int i = 1 ; i < = 3 ; i + + ) { for ( int j = 1 ; j < = 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } int a1 = 0 ; int b1 = c [ 1 ] [ 1 ] - a1 ; int b2 = c [ 1 ] [ 2 ] - a1 ; int b3 = c [ 1 ] [ 3 ] - a1 ; boolean ans = c [ 2 ] [ 1 ] - b1 = = c [ 2 ] [ 2 ] - b2 & & c [ 2 ] [ 2 ] - b2 = = c [ 2 ] [ 3 ] - b3 & & c [ 3 ] [ 1 ] - b1 = = c [ 3 ] [ 2 ] - b2 & & c [ 3 ] [ 2 ] - b2 = = c [ 3 ] [ 3 ] - b3 ; System . out . println ( ans ? " Yes " : " No " ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } boolean flag = false ; if ( c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] & & c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] = = c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] & & c [ 0 ] [ 0 ] - c [ 2 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 2 ] [ 1 ] & & c [ 0 ] [ 1 ] - c [ 2 ] [ 1 ] = = c [ 0 ] [ 2 ] - c [ 2 ] [ 2 ] ) flag = true ; if ( flag ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . io . IOException ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i + + ) { if ( sc . next ( ) . equals ( " Y " ) ) { System . out . println ( " Four " ) ; return ; } } System . out . println ( " Three " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { int tmp = s - i - j ; if ( tmp < = k & & tmp > = 0 ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int [ ] [ ] arr = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) for ( int j = 0 ; j < 3 ; j + + ) arr [ i ] [ j ] = in . nextInt ( ) ; for ( int i = 0 ; i < = 100 ; i + + ) { int [ ] a = new int [ 3 ] ; int [ ] b = new int [ 3 ] ; boolean ok = true ; for ( int j = 0 ; j < 3 ; j + + ) a [ j ] = arr [ j ] [ 0 ] - i ; for ( int j = 0 ; j < 3 ; j + + ) b [ j ] = arr [ 0 ] [ j ] - a [ 0 ] ; for ( int k = 0 ; k < 3 ; k + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( arr [ k ] [ j ] ! = a [ k ] + b [ j ] ) ok = false ; } } if ( ok ) { System . out . println ( " Yes " ) ; return ; } a = null ; b = null ; } System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int c = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { int z = S - x - y ; if ( 0 < = z & & z < = K ) { c + = 1 ; } } } System . out . println ( c ) ; } } import java . util . * ; public class Main { void solve ( ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; ArrayList < Character > s = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i + + ) { char c = scan . next ( ) . charAt ( 0 ) ; if ( ! s . contains ( c ) ) s . add ( c ) ; } System . out . println ( s . size ( ) = = 3 ? " Three " : " Four " ) ; scan . close ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int min = Integer . MAX _ VALUE ; int count = 0 ; for ( int i = 0 ; i < n ; i + + ) { int x = sc . nextInt ( ) ; if ( min > = x ) { count + + ; min = x ; } } System . out . println ( count ) ; } } import java . io . BufferedInputStream ; import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( new BufferedInputStream ( System . in ) ) ; int a = sc . nextInt ( ) ; int m [ ] = new int [ a ] ; int min = a ; int count = 0 ; for ( int i = 0 ; i < a ; i + + ) { m [ i ] = sc . nextInt ( ) ; if ( m [ i ] < min ) min = m [ i ] ; if ( m [ i ] < = min ) count + + ; } System . out . println ( count ) ; } } import java . util . Arrays ; import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Set < Integer > remaining = new HashSet < > ( Arrays . asList ( 1 , 9 , 7 , 4 ) ) ; for ( int i = 0 ; i < 4 ; i + + ) { int a = sc . nextInt ( ) ; if ( remaining . contains ( a ) ) { remaining . remove ( a ) ; } } System . out . println ( remaining . isEmpty ( ) ? " YES " : " NO " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; long ans = 0 ; for ( int i = 0 ; i < = K ; i + + ) for ( int j = 0 ; j < = K ; j + + ) if ( 0 < = S - i - j & & S - i - j < = K ) ans + + ; System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < 4 ; i + + ) { list . add ( sc . next ( ) ) ; } System . out . println ( list . contains ( " 1 " ) & & list . contains ( " 9 " ) & & list . contains ( " 7 " ) & & list . contains ( " 4 " ) ? " YES " : " NO " ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { new Solver ( ) . run ( ) ; } } class Solver { public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] P = new int [ N ] ; int sum = 0 ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = sc . nextInt ( ) ; } int min = Integer . MAX _ VALUE ; int cnt = 0 ; for ( int i = 0 ; i < N ; i + + ) { if ( min > = P [ i ] ) { min = P [ i ] ; cnt + + ; } } System . out . println ( cnt ) ; return ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { int z = s - i - j ; if ( z < = k & & z > = 0 ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { if ( 0 < = s - i - j & & s - i - j < = k ) { cnt + + ; } } } System . out . println ( cnt ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; int sub = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { sub = s - ( x + y ) ; if ( 0 < = sub & & sub < = k ) { count + + ; } } } System . out . print ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] N = new int [ 4 ] ; N [ 0 ] = sc . nextInt ( ) ; N [ 1 ] = sc . nextInt ( ) ; N [ 2 ] = sc . nextInt ( ) ; N [ 3 ] = sc . nextInt ( ) ; Arrays . sort ( N ) ; int [ ] array = { 1 , 4 , 7 , 9 } ; if ( Arrays . equals ( N , array ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; String s ; String sl [ ] ; int c [ ] [ ] = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { sl = r . readLine ( ) . split ( " " ) ; for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = Integer . parseInt ( sl [ j ] ) ; } } int a [ ] = new int [ 3 ] ; int b [ ] = new int [ 3 ] ; boolean f = true ; for ( int i = 0 ; i < 2 ; i + + ) { int z = c [ i ] [ 0 ] - c [ i + 1 ] [ 0 ] ; for ( int j = 0 ; j < 3 ; j + + ) { if ( c [ i ] [ j ] - c [ i + 1 ] [ j ] ! = z ) { f = false ; } } } for ( int i = 0 ; i < 2 ; i + + ) { int z = c [ 0 ] [ i ] - c [ 0 ] [ i + 1 ] ; for ( int j = 0 ; j < 3 ; j + + ) { if ( c [ j ] [ i ] - c [ j ] [ i + 1 ] ! = z ) { f = false ; } } } System . out . println ( f ? " Yes " : " No " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int ans = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { int Z = S - x - y ; if ( Z > = 0 & & Z < = K ) ans + + ; } } System . out . println ( ans ) ; } } import java . util . * ; public final class Main { private static int solution ( int [ ] array ) { int current = 1 ; int score = 1 ; int minimum = array [ 0 ] ; while ( current < array . length ) { if ( array [ current ] < minimum ) { minimum = array [ current ] ; score + + ; } current + + ; } return score ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] array = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { array [ i ] = sc . nextInt ( ) ; } System . out . println ( solution ( array ) ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = Integer . parseInt ( sc . next ( ) ) ; int s = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { if ( ( s - i - j ) < = k & & ( s - i - j ) > = 0 ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] p = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = sc . nextInt ( ) ; } int min = n + 1 ; int ans = 0 ; for ( int i = 0 ; i < n ; i + + ) { if ( p [ i ] < min ) { min = p [ i ] ; ans + + ; } } System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = " " ; int strN = 1 ; for ( int i = 0 ; i < strN ; i + + ) { line + = br . readLine ( ) + " " ; } String [ ] param = line . split ( " " ) ; AtoZString ( param ) ; } static void AtoZString ( String [ ] param ) { int K = Integer . parseInt ( param [ 0 ] ) ; int S = Integer . parseInt ( param [ 1 ] ) ; int count = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { int k = S - ( i + j ) ; if ( k > = 0 & & k < = K ) count + + ; } } System . out . println ( count ) ; } } import java . util . * ; import static java . lang . Integer . * ; import static java . lang . Long . * ; import static java . lang . Math . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = parseInt ( sc . next ( ) ) ; int s = parseInt ( sc . next ( ) ) ; sc . close ( ) ; int ans = 0 ; for ( int a = 0 ; a < = k ; a + + ) { for ( int b = 0 ; b < = k ; b + + ) { if ( s - a - b < = k & & s - a - b > = 0 ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . * ; import java . util . Collections ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = Integer . parseInt ( sc . next ( ) ) ; int S = Integer . parseInt ( sc . next ( ) ) ; long count = 0 ; for ( int x = 0 ; x < = K ; x + + ) { if ( x = = S ) { count + + ; break ; } if ( x > S ) { break ; } if ( x + K + K < S ) { continue ; } for ( int y = 0 ; y < = K ; y + + ) { if ( x + y = = S ) { count + + ; break ; } if ( x + y > S ) { break ; } if ( x + y + K < S ) { continue ; } count + + ; } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { int z = S - x - y ; if ( z > = 0 & & z < = K ) { count + = 1 ; } } } System . out . println ( count ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BSumOfThreeIntegers solver = new BSumOfThreeIntegers ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BSumOfThreeIntegers { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int k = in . nextInt ( ) , s = in . nextInt ( ) ; long ans = 0 ; for ( int x = Math . max ( 0 , s - 2 * k ) ; x < = Math . min ( k , s ) ; x + + ) { for ( int y = Math . max ( 0 , s - x - k ) ; y < = Math . min ( k , s - x ) ; y + + ) { ans + + ; } } out . println ( ans ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int K = scan . nextInt ( ) , S = scan . nextInt ( ) ; int x , y , cnt = 0 ; for ( x = 0 ; x < = K ; x + + ) { int ylim = K ; if ( S - x < ylim ) ylim = S - x ; for ( y = 0 ; y < = ylim ; y + + ) { if ( S - x - y < = K ) cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 4 ] ; for ( int i = 0 ; i < a . length ; i + + ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; if ( a [ 0 ] = = 1 & & a [ 1 ] = = 4 & & a [ 2 ] = = 7 & & a [ 3 ] = = 9 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int [ ] math = new int [ 9 ] ; for ( int i = 0 ; i < 9 ; + + i ) { math [ i ] = sc . nextInt ( ) ; } int a = math [ 1 ] - math [ 0 ] ; int b = math [ 4 ] - math [ 3 ] ; int c = math [ 7 ] - math [ 6 ] ; int d = math [ 2 ] - math [ 0 ] ; int e = math [ 5 ] - math [ 3 ] ; int f = math [ 8 ] - math [ 6 ] ; int g = math [ 3 ] - math [ 0 ] ; int h = math [ 4 ] - math [ 1 ] ; int i = math [ 5 ] - math [ 2 ] ; int j = math [ 6 ] - math [ 0 ] ; int k = math [ 7 ] - math [ 1 ] ; int l = math [ 8 ] - math [ 2 ] ; if ( ( a = = b & & b = = c & & c = = a ) & & ( d = = e & & e = = f & & f = = d ) & & ( g = = h & & h = = i & & i = = g ) & & ( j = = k & & k = = l & & l = = j ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int counter = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { if ( S - i - j > = 0 & & S - i - j < = K ) counter + + ; } } System . out . println ( counter ) ; } } import java . util . * ; import java . io . * ; import static java . lang . System . in ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int X = sc . nextInt ( ) ; long ans = 2 ; for ( int i = 0 ; i < X ; i + + ) { ans = 2 * ans + 2 ; } System . out . println ( ans ) ; } } import java . math . BigDecimal ; import java . util . * ; import java . util . stream . Collectors ; class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int cnt = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int a = s - y - x ; if ( a > = 0 & & a < = k ) { cnt + + ; } } } System . out . println ( cnt ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; HashSet < String > hs = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i + + ) { hs . add ( sc . next ( ) ) ; } if ( hs . size ( ) = = 3 ) { System . out . println ( " Three " ) ; } else { System . out . println ( " Four " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String ... args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int n = sc . nextInt ( ) ; int [ ] p = new int [ n ] ; int tmp = Integer . MAX _ VALUE ; int count = 0 ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = sc . nextInt ( ) ; if ( tmp > p [ i ] ) { tmp = p [ i ] ; count + + ; } } System . out . println ( count ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = scanner . nextInt ( ) ; } } int c012 = c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] ; int c021 = c [ 0 ] [ 0 ] + c [ 1 ] [ 2 ] + c [ 2 ] [ 1 ] ; int c102 = c [ 0 ] [ 1 ] + c [ 1 ] [ 0 ] + c [ 2 ] [ 2 ] ; int c120 = c [ 0 ] [ 1 ] + c [ 1 ] [ 2 ] + c [ 2 ] [ 0 ] ; int c210 = c [ 0 ] [ 2 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 0 ] ; int c201 = c [ 0 ] [ 2 ] + c [ 1 ] [ 0 ] + c [ 2 ] [ 1 ] ; if ( c012 = = c021 & & c021 = = c102 & & c102 = = c120 & & c120 = = c210 & & c210 = = c201 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { if ( S - i - j > = 0 & & S - i - j < = K ) { cnt + + ; } } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int min = Integer . parseInt ( sc . next ( ) ) ; int count = 1 ; for ( int i = 1 ; i < n ; i + + ) { int p = Integer . parseInt ( sc . next ( ) ) ; if ( p < = min ) { count + + ; min = p ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int [ ] level = new int [ n ] ; int count = 1 ; int min = 0 ; for ( int i = 0 ; i < n ; i + + ) { level [ i ] = input . nextInt ( ) ; if ( i = = 0 ) { min = level [ 0 ] ; } else { if ( level [ i ] < = min ) { count + + ; min = level [ i ] ; } } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; int ans = 1 ; a [ 0 ] = sc . nextInt ( ) ; int min = a [ 0 ] ; for ( int i = 1 ; i < N ; i + + ) { a [ i ] = sc . nextInt ( ) ; if ( a [ i ] < = min ) { min = a [ i ] ; ans + + ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; import java . util . List ; import java . util . ArrayList ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i + + ) { list . add ( scanner . nextInt ( ) ) ; } scanner . close ( ) ; int count = 0 ; int min = list . get ( 0 ) ; for ( int i = 0 ; i < list . size ( ) ; i + + ) { if ( list . get ( i ) . compareTo ( min ) = = 1 ) { continue ; } count + = 1 ; min = list . get ( i ) ; } System . out . println ( count ) ; } } import java . io . FileNotFoundException ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int min = sc . nextInt ( ) ; int ans = 1 ; for ( int i = 1 ; i < N ; i + + ) { int x = sc . nextInt ( ) ; if ( x < min ) { min = x ; ans + + ; } } System . out . println ( ans ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = k ; i + + ) for ( int j = 0 ; j < = k ; j + + ) { if ( i + j < = s & & s - i - j < = k ) count + + ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] n = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) { int N = sc . nextInt ( ) ; if ( N = = 1 ) n [ 0 ] + + ; else if ( N = = 9 ) n [ 1 ] + + ; else if ( N = = 7 ) n [ 2 ] + + ; else if ( N = = 4 ) n [ 3 ] + + ; } if ( n [ 0 ] = = 1 & & n [ 1 ] = = 1 & & n [ 2 ] = = 1 & & n [ 3 ] = = 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Main implements Runnable { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Thread ( null , new Main ( ) , " " , 128 * 1024 * 1024 ) . start ( ) ; } public void run ( ) { int c [ ] [ ] = new int [ 3 ] [ 3 ] ; int a1 , a2 , a3 , b1 , b2 , b3 ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } a1 = Math . min ( c [ 0 ] [ 0 ] , Math . min ( c [ 0 ] [ 1 ] , c [ 0 ] [ 2 ] ) ) ; a2 = Math . min ( c [ 1 ] [ 0 ] , Math . min ( c [ 1 ] [ 1 ] , c [ 1 ] [ 2 ] ) ) ; a3 = Math . min ( c [ 2 ] [ 0 ] , Math . min ( c [ 2 ] [ 1 ] , c [ 2 ] [ 2 ] ) ) ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { int min = i = = 0 ? a1 : i = = 1 ? a2 : a3 ; c [ i ] [ j ] - = min ; } } for ( int j = 0 ; j < 3 ; j + + ) { int tmp = c [ 0 ] [ j ] ; for ( int i = 1 ; i < 3 ; i + + ) { if ( c [ i ] [ j ] ! = tmp ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; HashMap < String , Integer > hashmap = new HashMap < > ( ) ; int n = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i + + ) { hashmap . put ( sc . next ( ) , 1 ) ; } if ( hashmap . size ( ) = = 4 ) { System . out . println ( " Four " ) ; } else { System . out . println ( " Three " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; sc . close ( ) ; int count = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { int k = S - i - j ; if ( k < = K & & 0 < = k ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = K & & x < = S ; x + + ) { for ( int y = 0 ; y < = K & & y < = S ; y + + ) { if ( S - x - y > = 0 & & S - x - y < = K ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int c [ ] [ ] = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } boolean ans = true ; for ( int i = 0 ; i < 2 ; i + + ) { if ( c [ 0 ] [ i ] - c [ 0 ] [ i + 1 ] ! = c [ 1 ] [ i ] - c [ 1 ] [ i + 1 ] ) { ans = false ; break ; } if ( c [ 1 ] [ i ] - c [ 1 ] [ i + 1 ] ! = c [ 2 ] [ i ] - c [ 2 ] [ i + 1 ] ) { ans = false ; break ; } } if ( ans = = true ) { for ( int i = 0 ; i < 2 ; i + + ) { if ( c [ i ] [ 0 ] - c [ i + 1 ] [ 0 ] ! = c [ i ] [ 1 ] - c [ i + 1 ] [ 1 ] ) { ans = false ; break ; } if ( c [ i ] [ 1 ] - c [ i + 1 ] [ 1 ] ! = c [ i ] [ 2 ] - c [ i + 1 ] [ 2 ] ) { ans = false ; break ; } } } if ( ans = = true ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int ans = 0 ; for ( int x = 0 ; x < = K ; x + + ) for ( int y = 0 ; y < = K ; y + + ) { int z = S - x - y ; if ( z > = 0 & & z < = K ) ans + + ; } System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { String line = " " ; try { line = readLine ( ) ; StringTokenizer st = new StringTokenizer ( line , " " ) ; String tempK = st . nextToken ( ) ; String tempS = st . nextToken ( ) ; int k = Integer . parseInt ( tempK ) ; int s = Integer . parseInt ( tempS ) ; int cnt = 0 ; for ( int i = 0 ; i < s + 1 ; i + + ) { if ( i > k ) { continue ; } for ( int j = 0 ; j < s + 1 ; j + + ) { if ( j > k ) { continue ; } else if ( s - i - j > k ) { continue ; } if ( i + j < = s ) { cnt + + ; } } } System . out . println ( cnt ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } private static String readLine ( ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; return br . readLine ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int K = scan . nextInt ( ) ; int S = scan . nextInt ( ) ; int a ; int b ; int cnt = 0 ; for ( a = 0 ; a < = K ; a + + ) { int qw = K ; if ( S - a < qw ) { qw = S - a ; } for ( b = 0 ; b < = qw ; b + + ) { if ( S - a - b < = K ) cnt + + ; } } System . out . println ( cnt ) ; } } import java . math . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int p [ ] = new int [ n ] ; int sum = 0 ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = sc . nextInt ( ) ; } int min = p [ 0 ] ; for ( int i = 0 ; i < n ; i + + ) { if ( min > = p [ i ] ) { min = p [ i ] ; sum + + ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int a = 0 ; int b = 0 ; int c = 0 ; int d = 0 ; for ( int i = 0 ; i < 4 ; + + i ) { int temp = sc . nextInt ( ) ; if ( temp = = 1 ) { a = 1 ; } else if ( temp = = 9 ) { b = 1 ; } else if ( temp = = 7 ) { c = 1 ; } else if ( temp = = 4 ) { d = 1 ; } } if ( ( a + b + c + d ) = = 4 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; MyScanner sc = new MyScanner ( ) ; int n = sc . nextInt ( ) ; String [ ] input = new String [ n ] ; input = sc . nextLine ( ) . split ( " " ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { arr [ i ] = Integer . parseInt ( input [ i ] ) ; } int sum = 1 , low = arr [ 0 ] ; for ( int i = 1 ; i < n ; i + + ) { if ( arr [ i ] < low ) { sum + + ; low = arr [ i ] ; } } out . println ( sum ) ; out . close ( ) ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st = = null | | ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = Integer . parseInt ( sc . next ( ) ) ; int s = Integer . parseInt ( sc . next ( ) ) ; int ans = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { if ( s - x - y < = k & & 0 < = s - x - y ) { ans + = 1 ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; + + i ) { for ( int k = 0 ; k < 3 ; + + k ) { c [ i ] [ k ] = Integer . parseInt ( scan . next ( ) ) ; } } int [ ] x = new int [ 3 ] ; int [ ] y = new int [ 3 ] ; x [ 0 ] = 0 ; for ( int i = 0 ; i < 3 ; + + i ) { y [ i ] = c [ 0 ] [ i ] - x [ 0 ] ; } for ( int i = 0 ; i < 3 ; + + i ) { x [ i ] = c [ i ] [ 0 ] - y [ 0 ] ; } boolean ok = true ; for ( int i = 0 ; i < 3 ; + + i ) { for ( int k = 0 ; k < 3 ; + + k ) { if ( c [ i ] [ k ] ! = x [ i ] + y [ k ] ) { ok = false ; } } } System . out . print ( ok ? " Yes " : " No " ) ; } } import java . util . Scanner ; import java . lang . Math ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int m = n ; int a = 0 ; for ( int i = 0 ; i < n ; i + + ) { int c = Integer . parseInt ( sc . next ( ) ) ; m = Math . min ( m , c ) ; if ( m > = c ) { a + = 1 ; } } System . out . println ( a ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; c [ 0 ] [ 0 ] = Integer . parseInt ( sc . next ( ) ) ; c [ 0 ] [ 1 ] = Integer . parseInt ( sc . next ( ) ) ; c [ 0 ] [ 2 ] = Integer . parseInt ( sc . next ( ) ) ; c [ 1 ] [ 0 ] = Integer . parseInt ( sc . next ( ) ) ; c [ 1 ] [ 1 ] = Integer . parseInt ( sc . next ( ) ) ; c [ 1 ] [ 2 ] = Integer . parseInt ( sc . next ( ) ) ; c [ 2 ] [ 0 ] = Integer . parseInt ( sc . next ( ) ) ; c [ 2 ] [ 1 ] = Integer . parseInt ( sc . next ( ) ) ; c [ 2 ] [ 2 ] = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ 3 ] ; int [ ] b = new int [ 3 ] ; a [ 0 ] = 0 ; b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] ; b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] ; b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] ; a [ 1 ] = c [ 1 ] [ 1 ] - b [ 1 ] ; a [ 2 ] = c [ 2 ] [ 1 ] - b [ 1 ] ; String ans = " Yes " ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( c [ i ] [ j ] ! = a [ i ] + b [ j ] ) { ans = " No " ; break ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long ans = 0 ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { a [ i ] = sc . nextInt ( ) ; } ans + = a [ 0 ] - 1 ; int k = 2 ; for ( int i = 1 ; i < n ; i + + ) { if ( a [ i ] = = k ) { k + + ; continue ; } ans + = ( a [ i ] - 1 ) / k ; } System . out . println ( ans ) ; } } import java . util . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int [ ] a = new int [ 10 ] ; for ( int i = 0 ; i < 4 ; i + + ) { a [ sc . nextInt ( ) ] = 1 ; } if ( a [ 1 ] + a [ 9 ] + a [ 7 ] + a [ 4 ] = = 4 ) out . println ( " YES " ) ; else out . println ( " NO " ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String [ ] strs = sc . nextLine ( ) . split ( " " ) ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < 4 ; i + + ) { list . add ( Integer . parseInt ( strs [ i ] ) ) ; } Collections . sort ( list ) ; if ( list . get ( 0 ) = = 1 & & list . get ( 1 ) = = 4 & & list . get ( 2 ) = = 7 & & list . get ( 3 ) = = 9 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int min = Integer . MAX _ VALUE ; int count = 0 ; for ( int i = 1 ; i < = N ; i + + ) { int P = scanner . nextInt ( ) ; if ( P < = min ) { count + + ; min = P ; } } System . out . println ( count ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; long sum = 0 ; long cnt = 2 ; long a = scan . nextLong ( ) ; if ( a > = 2 ) { sum + = a - 1 ; } for ( int i = 1 ; i < n ; i + + ) { a = scan . nextLong ( ) ; long b = a / cnt ; if ( cnt = = a ) { cnt + + ; b = 0 ; } else if ( a % cnt = = 0 ) { b -- ; } sum + = b ; } System . out . println ( sum ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] argv ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int k = Integer . parseInt ( str [ 0 ] ) ; int n = Integer . parseInt ( str [ 1 ] ) ; int x , y , cnt = 0 ; for ( x = 0 ; x < = k ; x + + ) { for ( y = 0 ; y < = k ; y + + ) { if ( ( 0 < = n - x - y ) & & ( n - x - y < = k ) ) cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String [ ] c1 = sc . nextLine ( ) . split ( " " ) ; String [ ] c2 = sc . nextLine ( ) . split ( " " ) ; String [ ] c3 = sc . nextLine ( ) . split ( " " ) ; int [ ] [ ] grid = new int [ ] [ ] { { Integer . valueOf ( c1 [ 0 ] ) , Integer . valueOf ( c2 [ 0 ] ) , Integer . valueOf ( c3 [ 0 ] ) } , { Integer . valueOf ( c1 [ 1 ] ) , Integer . valueOf ( c2 [ 1 ] ) , Integer . valueOf ( c3 [ 1 ] ) } , { Integer . valueOf ( c1 [ 2 ] ) , Integer . valueOf ( c2 [ 2 ] ) , Integer . valueOf ( c3 [ 2 ] ) } } ; int [ ] x = new int [ 3 ] ; int [ ] y = new int [ 3 ] ; x [ 0 ] = 0 ; for ( int i = 0 ; i < 3 ; i + + ) y [ i ] = grid [ 0 ] [ i ] - x [ 0 ] ; for ( int i = 0 ; i < 3 ; i + + ) x [ i ] = grid [ i ] [ 0 ] - y [ 0 ] ; String ans = " Yes " ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( x [ i ] + y [ j ] ! = grid [ i ] [ j ] ) ans = " No " ; } } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int num [ ] = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) { num [ i ] = sc . nextInt ( ) ; } boolean f1 = false , f2 = false , f3 = false , f4 = false ; for ( int i = 0 ; i < 4 ; i + + ) { if ( num [ i ] = = 1 ) f1 = true ; else if ( num [ i ] = = 9 ) f2 = true ; else if ( num [ i ] = = 7 ) f3 = true ; else if ( num [ i ] = = 4 ) f4 = true ; } if ( f1 & & f2 & & f3 & & f4 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long A [ ] = new long [ N ] ; for ( int i = 0 ; i < N ; i + + ) { A [ i ] = sc . nextLong ( ) ; } long min = A [ 0 ] ; int count = 0 ; for ( int i = 0 ; i < N ; i + + ) { if ( A [ i ] < = min ) { count + + ; min = A [ i ] ; } } System . out . println ( count ) ; return ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = 3 ; int [ ] [ ] t = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i + + ) { for ( int j = 0 ; j < n ; j + + ) { t [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 0 ; i < n - 1 ; i + + ) { int dif0 = t [ i ] [ 0 ] - t [ i + 1 ] [ 0 ] ; for ( int j = 1 ; j < n ; j + + ) { int difj = t [ i ] [ j ] - t [ i + 1 ] [ j ] ; if ( dif0 ! = difj ) { System . out . println ( " No " ) ; return ; } } } for ( int j = 0 ; j < n - 1 ; j + + ) { int dif0 = t [ 0 ] [ j ] - t [ 0 ] [ j + 1 ] ; for ( int i = 1 ; i < n ; i + + ) { int difi = t [ i ] [ j ] - t [ i ] [ j + 1 ] ; if ( dif0 ! = difi ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] P = new int [ N ] ; int min = Integer . MAX _ VALUE ; int count = 0 ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = sc . nextInt ( ) ; if ( min > = P [ i ] ) { min = P [ i ] ; count + + ; } } System . out . println ( count ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] p = new int [ n ] ; for ( int c = 0 ; c < n ; c + + ) { p [ c ] = sc . nextInt ( ) ; } int ans = 0 ; int c = p [ 0 ] ; for ( int d = 0 ; d < n - 1 ; d + + ) { if ( c < p [ d + 1 ] ) { ans + + ; } c = Math . min ( c , p [ d + 1 ] ) ; } System . out . println ( n - ans ) ; } } import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; final int N = Integer . parseInt ( sc . next ( ) ) ; int ans = 0 ; int pre = N + 1 ; int [ ] ar = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { ar [ i ] = N - i ; } for ( int i = 0 ; i < N ; i + + ) { int p = Integer . parseInt ( sc . next ( ) ) ; if ( p = = 1 ) { + + ans ; break ; } else if ( p < = ar [ i ] & & p < pre ) { + + ans ; pre = p ; } } out . println ( ans ) ; out . flush ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; Set < String > set1 = new HashSet < > ( ) ; for ( int i = 0 ; i < N ; i + + ) { set1 . add ( sc . next ( ) ) ; } int ans = set1 . size ( ) ; if ( ans = = 3 ) { System . out . println ( " Three " ) ; } else { System . out . println ( " Four " ) ; } } } import java . util . * ; import java . io . PrintWriter ; import static java . lang . Integer . * ; import static java . lang . Long . * ; import static java . lang . Math . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { int i , j ; Scanner sc = new Scanner ( in ) ; int k = parseInt ( sc . next ( ) ) ; int s = parseInt ( sc . next ( ) ) ; sc . close ( ) ; int cnt = 0 ; for ( i = 0 ; i < = k ; i + + ) { for ( j = 0 ; j < = k ; j + + ) { if ( 0 < = s - ( i + j ) & & s - ( i + j ) < = k ) cnt + + ; } } out . println ( cnt ) ; } } import java . util . Arrays ; import java . util . Scanner ; class A { public static void main ( String ... args ) { final Scanner sc = new Scanner ( System . in ) ; final int [ ] N = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) N [ i ] = sc . nextInt ( ) ; Arrays . sort ( N ) ; System . out . println ( Arrays . equals ( N , new int [ ] { 1 , 4 , 7 , 9 } ) ? " YES " : " NO " ) ; } } public class Main { public static void main ( String ... args ) { A . main ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int [ ] num = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) { num [ i ] = input . nextInt ( ) ; } Arrays . sort ( num ) ; if ( num [ 0 ] = = 1 & & num [ 1 ] = = 4 & & num [ 2 ] = = 7 & & num [ 3 ] = = 9 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { static final int SIZE = 3 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ SIZE ] [ SIZE ] ; for ( int i = 0 ; i < SIZE ; + + i ) { for ( int j = 0 ; j < SIZE ; + + j ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } System . out . println ( solve ( c ) ? " Yes " : " No " ) ; sc . close ( ) ; } static boolean solve ( int [ ] [ ] c ) { return IntStream . range ( 0 , SIZE ) . map ( i - > c [ i ] [ 1 ] - c [ i ] [ 0 ] ) . distinct ( ) . count ( ) = = 1 & & IntStream . range ( 0 , SIZE ) . map ( i - > c [ i ] [ 2 ] - c [ i ] [ 1 ] ) . distinct ( ) . count ( ) = = 1 & & IntStream . range ( 0 , SIZE ) . map ( j - > c [ 1 ] [ j ] - c [ 0 ] [ j ] ) . distinct ( ) . count ( ) = = 1 & & IntStream . range ( 0 , SIZE ) . map ( j - > c [ 2 ] [ j ] - c [ 1 ] [ j ] ) . distinct ( ) . count ( ) = = 1 ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] p = new int [ n ] ; int smallest = 200001 ; int counter = 0 ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = sc . nextInt ( ) ; if ( p [ i ] < = smallest ) { counter + + ; smallest = p [ i ] ; } } System . out . println ( counter ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a1 , a2 , a3 , b1 , b2 , b3 ; int [ ] [ ] grid = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { grid [ i ] [ j ] = sc . nextInt ( ) ; } } String res = " No " ; for ( a1 = 0 ; a1 < = grid [ 0 ] [ 0 ] ; a1 + + ) { b1 = grid [ 0 ] [ 0 ] - a1 ; b2 = grid [ 0 ] [ 1 ] - a1 ; b3 = grid [ 0 ] [ 2 ] - a1 ; a2 = grid [ 1 ] [ 0 ] - b1 ; a3 = grid [ 2 ] [ 0 ] - b1 ; if ( a2 + b2 = = grid [ 1 ] [ 1 ] & & a2 + b3 = = grid [ 1 ] [ 2 ] & & a3 + b2 = = grid [ 2 ] [ 1 ] & & a3 + b3 = = grid [ 2 ] [ 2 ] ) res = " Yes " ; } System . out . println ( res ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] p = new int [ n ] ; int [ ] min _ p = new int [ n ] ; int counter = 0 ; for ( int i = 0 ; i < p . length ; i + + ) { p [ i ] = sc . nextInt ( ) ; } min _ p [ 0 ] = p [ 0 ] ; for ( int i = 0 ; i < n ; i + + ) { if ( i > = 1 ) { if ( min _ p [ i - 1 ] > p [ i ] ) { min _ p [ i ] = p [ i ] ; } else { min _ p [ i ] = min _ p [ i - 1 ] ; } } if ( p [ i ] = = min _ p [ i ] ) { counter + + ; } } System . out . println ( counter ) ; sc . close ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < = Math . min ( s , k ) ; i + + ) { ans + = Math . max ( 0 , Math . min ( s - i + 1 , k + 1 ) - Math . max ( 0 , s - i - k ) ) ; } System . out . println ( ans ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; boolean flag = true ; if ( a [ 0 ] ! = 1 ) flag = false ; if ( a [ 1 ] ! = 4 ) flag = false ; if ( a [ 2 ] ! = 7 ) flag = false ; if ( a [ 3 ] ! = 9 ) flag = false ; if ( flag ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int ans = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { if ( x + y > S ) break ; if ( S - ( x + y ) < = K ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; for ( int i = 1 ; i < = N ; i + + ) { String s = sc . next ( ) ; if ( s . equals ( " Y " ) ) { System . out . println ( " Four " ) ; System . exit ( 0 ) ; } } System . out . println ( " Three " ) ; } } import java . io . * ; import java . math . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int N = input . nextInt ( ) ; int lo = Integer . MAX _ VALUE ; int cnt = 0 ; for ( int i = 0 ; i < N ; i + + ) { int x = input . nextInt ( ) ; if ( x < lo ) { cnt + + ; lo = x ; } } System . out . println ( cnt ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int P ; int min = 0 ; int counter = 0 ; for ( int i = 0 ; i < N ; i + + ) { P = sc . nextInt ( ) ; if ( min < 1 | | P < min ) { min = P ; counter + + ; } } System . out . println ( counter ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { int N , D , ans = 0 ; Scanner sc = new Scanner ( System . in ) ; D = sc . nextInt ( ) ; N = sc . nextInt ( ) ; int temperature [ ] = new int [ D ] ; int min [ ] = new int [ N ] ; int max [ ] = new int [ N ] ; int show [ ] = new int [ N ] ; int showreminder [ ] [ ] = new int [ D ] [ N ] ; for ( int i = 0 ; i < D ; i + + ) { temperature [ i ] = sc . nextInt ( ) ; } for ( int j = 0 ; j < N ; j + + ) { min [ j ] = sc . nextInt ( ) ; max [ j ] = sc . nextInt ( ) ; show [ j ] = sc . nextInt ( ) ; } for ( int i = 1 ; i < D ; i + + ) { for ( int j = 0 ; j < N ; j + + ) { if ( min [ j ] < = temperature [ i ] & & max [ j ] > = temperature [ i ] ) { for ( int k = 0 ; k < N ; k + + ) { if ( min [ k ] < = temperature [ i - 1 ] & & max [ k ] > = temperature [ i - 1 ] ) { if ( showreminder [ i ] [ j ] < showreminder [ i - 1 ] [ k ] + Math . abs ( show [ k ] - show [ j ] ) ) { showreminder [ i ] [ j ] = showreminder [ i - 1 ] [ k ] + Math . abs ( show [ k ] - show [ j ] ) ; } } } } } } for ( int i = 0 ; i < N ; i + + ) { if ( ans < showreminder [ D - 1 ] [ i ] ) { ans = showreminder [ D - 1 ] [ i ] ; } } System . out . println ( ans ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc1 = new Scanner ( System . in ) ; int [ ] n = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) { n [ i ] = sc1 . nextInt ( ) ; } Arrays . sort ( n ) ; if ( n [ 0 ] = = 1 & & n [ 1 ] = = 4 & & n [ 2 ] = = 7 & & n [ 3 ] = = 9 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } sc1 . close ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { a [ i ] = sc . nextInt ( ) ; } int min = a [ 0 ] ; int count = 0 ; for ( int i = 0 ; i < n ; i + + ) { if ( a [ i ] < = min ) { count + + ; min = a [ i ] ; } } System . out . println ( count ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] n = new int [ 4 ] ; int [ ] Ans = { 1 , 4 , 7 , 9 } ; for ( int i = 0 ; i < 4 ; i + + ) { n [ i ] = sc . nextInt ( ) ; } Arrays . sort ( n ) ; boolean isAns = true ; for ( int i = 0 ; i < 4 ; i + + ) { if ( n [ i ] ! = Ans [ i ] ) isAns = false ; } System . out . println ( isAns ? " YES " : " NO " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { int N ; int [ ] Pi = null ; try ( Scanner sc = new Scanner ( System . in ) ) { N = sc . nextInt ( ) ; Pi = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { Pi [ i ] = sc . nextInt ( ) ; } } int result = 0 ; int min = Integer . MAX _ VALUE ; for ( int i = 0 ; i < Pi . length ; i + + ) { if ( Pi [ i ] < min ) { result + + ; min = Pi [ i ] ; } } System . out . println ( result ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { if ( S - i - j > = 0 & & S - i - j < = K ) { cnt + + ; } } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; for ( int i = 0 ; i < n ; i + + ) { String s = sc . next ( ) ; if ( s . equals ( " Y " ) ) { System . out . println ( " Four " ) ; return ; } } System . out . println ( " Three " ) ; sc . close ( ) ; } } import java . util . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = sc . nextInt ( ) , ans = 0 ; int [ ] p = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) p [ i ] = sc . nextInt ( ) ; int m = p [ 0 ] ; for ( int i = 0 ; i < N ; i + + ) { m = Math . min ( m , p [ i ] ) ; if ( m = = p [ i ] ) ans + + ; } System . out . println ( ans ) ; } } import java . lang . reflect . Array ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) , s = sc . nextInt ( ) , ret = 0 ; for ( int i = 0 ; i < = k ; i + + ) for ( int j = 0 ; j < = k ; j + + ) { if ( 0 < = s - i - j & & s - i - j < = k ) ret + = 1 ; } System . out . println ( ret ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int k = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int s = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int count = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { if ( s > = i + j & & s - ( i + j ) < = k ) { count + + ; } if ( s < i + j ) break ; } if ( s < i ) break ; } System . out . println ( count ) ; } } import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] n = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) { n [ i ] = sc . nextInt ( ) ; } Arrays . sort ( n ) ; if ( n [ 0 ] = = 1 ) { if ( n [ 1 ] = = 4 ) { if ( n [ 2 ] = = 7 ) { if ( n [ 3 ] = = 9 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } else { System . out . println ( " NO " ) ; } } else { System . out . println ( " NO " ) ; } } else { System . out . println ( " NO " ) ; } } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; String c [ ] = new String [ n ] ; Set < String > colors = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i + + ) { c [ i ] = scanner . next ( ) ; colors . add ( c [ i ] ) ; } if ( colors . size ( ) = = 3 ) { System . out . println ( " Three " ) ; } else { System . out . println ( " Four " ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > c1 = new ArrayList < > ( ) ; List < Integer > c2 = new ArrayList < > ( ) ; List < Integer > c3 = new ArrayList < > ( ) ; IntStream . range ( 0 , 3 ) . forEach ( i - > c1 . add ( sc . nextInt ( ) ) ) ; IntStream . range ( 0 , 3 ) . forEach ( i - > c2 . add ( sc . nextInt ( ) ) ) ; IntStream . range ( 0 , 3 ) . forEach ( i - > c3 . add ( sc . nextInt ( ) ) ) ; int a1 = 0 ; int b1 = c1 . get ( 0 ) - a1 ; int a2 = c2 . get ( 0 ) - b1 ; int b2 = c2 . get ( 1 ) - a2 ; int a3 = c3 . get ( 0 ) - b1 ; int b3 = c3 . get ( 2 ) - a3 ; if ( c1 . get ( 0 ) = = a1 + b1 & & c1 . get ( 1 ) = = a1 + b2 & & c1 . get ( 2 ) = = a1 + b3 & & c2 . get ( 0 ) = = a2 + b1 & & c2 . get ( 1 ) = = a2 + b2 & & c2 . get ( 2 ) = = a2 + b3 & & c3 . get ( 0 ) = = a3 + b1 & & c3 . get ( 1 ) = = a3 + b2 & & c3 . get ( 2 ) = = a3 + b3 ) { System . out . println ( " Yes " ) ; return ; } System . out . println ( " No " ) ; } } import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int max = 999999999 ; long sum = 0 ; for ( int i = 0 ; i < N ; i + + ) { int now = sc . nextInt ( ) ; if ( now < max ) { max = now ; sum + + ; } } System . out . println ( sum ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( z > = 0 & & z < = k ) { count + + ; } } } System . out . println ( count ) ; } } import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] t = sc . nextLine ( ) . split ( " " ) ; int K = Integer . parseInt ( t [ 0 ] ) ; int S = Integer . parseInt ( t [ 1 ] ) ; int count = 0 ; br : for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { int k = S - i - j ; if ( 0 < = k & & k < = K ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int size = in . nextInt ( ) ; ArrayList < Long > list = new ArrayList < Long > ( ) ; for ( int x = 0 ; x < size ; x + + ) { list . add ( in . nextLong ( ) ) ; } long minimum = 2 ; long counter = list . get ( 0 ) - 1 ; for ( int x = 1 ; x < size ; x + + ) { long num = list . get ( x ) ; if ( num % minimum = = 0 ) { counter + = ( num / minimum ) - 1 ; list . set ( x , minimum ) ; } else { counter + = ( num / minimum ) ; list . set ( x , list . get ( x ) % minimum ) ; } if ( list . get ( x ) - minimum = = 0 & & num = = minimum ) { minimum + + ; } } System . out . println ( counter ) ; in . close ( ) ; } } import java . util . Scanner ; public class Main { final int size = 3 ; final int [ ] [ ] grid = new int [ size ] [ size ] ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; for ( int i = 0 ; i < size ; i + + ) for ( int j = 0 ; j < size ; j + + ) grid [ i ] [ j ] = sc . nextInt ( ) ; sc . close ( ) ; int aAry [ ] = new int [ size ] ; int bAry [ ] = new int [ size ] ; for ( int i = 0 ; i < = grid [ 0 ] [ 0 ] ; i + + ) { aAry [ 0 ] = i ; bAry [ 0 ] = grid [ 0 ] [ 0 ] - aAry [ 0 ] ; bAry [ 1 ] = grid [ 0 ] [ 1 ] - aAry [ 0 ] ; bAry [ 2 ] = grid [ 0 ] [ 2 ] - aAry [ 0 ] ; aAry [ 1 ] = grid [ 1 ] [ 0 ] - bAry [ 0 ] ; aAry [ 2 ] = grid [ 2 ] [ 0 ] - bAry [ 0 ] ; if ( judge ( aAry , bAry ) ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } boolean judge ( int aAry [ ] , int bAry [ ] ) { boolean res = true ; for ( int i = 0 ; i < size ; i + + ) { for ( int j = 0 ; j < size ; j + + ) { if ( grid [ i ] [ j ] ! = aAry [ i ] + bAry [ j ] ) return false ; } } return res ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] num = new int [ 9 ] ; for ( int i = 0 ; i < 9 ; i + + ) { num [ i ] = sc . nextInt ( ) ; } if ( num [ 0 ] - num [ 3 ] = = num [ 1 ] - num [ 4 ] & & num [ 2 ] - num [ 5 ] = = num [ 1 ] - num [ 4 ] & & num [ 0 ] - num [ 3 ] = = num [ 2 ] - num [ 5 ] ) { if ( num [ 0 ] - num [ 6 ] = = num [ 1 ] - num [ 7 ] & & num [ 2 ] - num [ 8 ] = = num [ 1 ] - num [ 7 ] & & num [ 0 ] - num [ 6 ] = = num [ 2 ] - num [ 8 ] ) { if ( num [ 3 ] - num [ 6 ] = = num [ 4 ] - num [ 7 ] & & num [ 5 ] - num [ 8 ] = = num [ 4 ] - num [ 7 ] & & num [ 3 ] - num [ 6 ] = = num [ 5 ] - num [ 8 ] ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } else { System . out . println ( " No " ) ; } } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M [ ] = new int [ N ] ; int s = 0 ; for ( int i = 0 ; i < N ; i + + ) { M [ i ] = sc . nextInt ( ) ; s = s + 1 ; if ( M [ i ] = = 1 ) { break ; } } int x = 0 ; int L = M [ 0 ] ; for ( int j = 0 ; j < s ; j + + ) { L = Math . min ( M [ j ] , L ) ; if ( L = = M [ j ] ) { x = x + 1 ; } else { x = x ; } } System . out . println ( x ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int c = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { int z = S - x - y ; if ( 0 < = z & & z < = K ) { c + = 1 ; } } } System . out . println ( c ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] atgs ) { Scanner scan = new Scanner ( System . in ) ; int ans = 0 ; int K = scan . nextInt ( ) ; int S = scan . nextInt ( ) ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { int z = S - x - y ; if ( 0 < = z & & z < = K ) { ans = ans + 1 ; } } } System . out . println ( ans ) ; scan . close ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int max = Integer . parseInt ( sc . next ( ) ) ; int target = Integer . parseInt ( sc . next ( ) ) ; int cnt = 0 ; for ( int i = 0 ; i < = max ; i + + ) { for ( int j = 0 ; j < = max ; j + + ) { int total = i + j ; if ( target - total < = max & & target - total > = 0 ) { cnt + + ; } } } System . out . println ( cnt ) ; } } import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int length = sc . nextInt ( ) ; int [ ] data = new int [ length ] ; for ( int a = 0 ; a < length ; a + + ) { data [ a ] = sc . nextInt ( ) ; } int count = 0 ; int i = 0 ; int min = data [ 0 ] ; for ( int b = 0 ; b < length ; b + + ) { i = data [ b ] ; if ( min > = i ) { count + + ; min = i ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int c [ ] = new int [ 9 ] ; for ( int i = 0 ; i < 9 ; i + + ) { c [ i ] = sc . nextInt ( ) ; } String ans ; if ( c [ 0 ] - c [ 1 ] = = c [ 3 ] - c [ 4 ] & & c [ 0 ] - c [ 1 ] = = c [ 6 ] - c [ 7 ] & & c [ 2 ] - c [ 1 ] = = c [ 5 ] - c [ 4 ] & & c [ 2 ] - c [ 1 ] = = c [ 8 ] - c [ 7 ] & & c [ 0 ] - c [ 3 ] = = c [ 1 ] - c [ 4 ] & & c [ 0 ] - c [ 3 ] = = c [ 2 ] - c [ 5 ] & & c [ 4 ] - c [ 7 ] = = c [ 3 ] - c [ 6 ] & & c [ 5 ] - c [ 8 ] = = c [ 3 ] - c [ 6 ] ) { ans = " Yes " ; } else { ans = " No " ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] P = new int [ N ] ; int i = 0 ; while ( i < N ) { P [ i ] = sc . nextInt ( ) ; i + + ; } int counter = 1 ; int min = P [ 0 ] ; for ( i = 1 ; i < N ; i + + ) { if ( P [ i ] < min ) { min = P [ i ] ; counter + + ; } } System . out . println ( counter ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; sc . close ( ) ; int ans = 0 ; for ( int i = 0 ; i < = K ; + + i ) { for ( int j = 0 ; j < = K ; + + j ) { int res = S - i - j ; if ( 0 < = res & & res < = K ) + + ans ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; boolean isA = false , isB = false , isC = false , isD = false ; int [ ] index = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) { index [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < 4 ; i + + ) { int idx = index [ i ] ; if ( idx = = 1 ) { isA = true ; } else if ( idx = = 9 ) { isB = true ; } else if ( idx = = 7 ) { isC = true ; } else if ( idx = = 4 ) { isD = true ; } } System . out . println ( isA & & isB & & isC & & isD ? " YES " : " NO " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; int [ ] a = new int [ 3 ] ; int [ ] b = new int [ 3 ] ; boolean flag = false ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 0 ; i < = 100 ; i + + ) { a [ 0 ] = i ; b [ 0 ] = c [ 0 ] [ 0 ] - i ; b [ 1 ] = c [ 0 ] [ 1 ] - i ; b [ 2 ] = c [ 0 ] [ 2 ] - i ; a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] ; a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] ; flag = true ; for ( int m = 0 ; m < 3 ; m + + ) { for ( int k = 0 ; k < 3 ; k + + ) { if ( c [ m ] [ k ] ! = ( a [ m ] + b [ k ] ) ) flag = false ; } } if ( flag ) break ; } System . out . println ( flag ? " Yes " : " No " ) ; sc . close ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) , s = sc . nextInt ( ) ; int cnt = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { if ( s - x - y > = 0 & & s - x - y < = k ) cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { int cnt = 0 ; Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { int k = S - i - j ; if ( 0 < = k & & k < = K ) cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Main { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; int [ ] a = new int [ 3 ] ; int [ ] b = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } int count = 0 ; for ( int i = 0 ; i < = 100 ; i + + ) { for ( int j = 0 ; j < = 100 ; j + + ) { a [ 0 ] = i ; b [ 0 ] = j ; if ( a [ 0 ] + b [ 0 ] ! = c [ 0 ] [ 0 ] ) continue ; else { a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] ; a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] ; b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] ; b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] ; for ( int k = 1 ; k < 3 ; k + + ) { for ( int l = 1 ; l < 3 ; l + + ) { if ( c [ k ] [ l ] = = a [ k ] + b [ l ] ) { count + + ; } else { count = 0 ; } } } if ( count = = 4 ) { System . out . println ( " Yes " ) ; return ; } count = 0 ; } } } System . out . println ( " No " ) ; sc . close ( ) ; } void debug ( Object ... o ) { System . out . println ( Arrays . deepToString ( o ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner cro = new Scanner ( System . in ) ; int a [ ] [ ] = new int [ 3 ] [ 3 ] ; int i , j ; for ( i = 0 ; i < 3 ; i + + ) for ( j = 0 ; j < 3 ; j + + ) a [ i ] [ j ] = cro . nextInt ( ) ; if ( a [ 0 ] [ 0 ] - a [ 0 ] [ 1 ] = = a [ 1 ] [ 0 ] - a [ 1 ] [ 1 ] & & a [ 0 ] [ 0 ] - a [ 0 ] [ 1 ] = = a [ 2 ] [ 0 ] - a [ 2 ] [ 1 ] & & a [ 0 ] [ 2 ] - a [ 0 ] [ 1 ] = = a [ 1 ] [ 2 ] - a [ 1 ] [ 1 ] & & a [ 0 ] [ 2 ] - a [ 0 ] [ 1 ] = = a [ 2 ] [ 2 ] - a [ 2 ] [ 1 ] & & a [ 0 ] [ 0 ] - a [ 1 ] [ 0 ] = = a [ 0 ] [ 1 ] - a [ 1 ] [ 1 ] & & a [ 0 ] [ 0 ] - a [ 1 ] [ 0 ] = = a [ 0 ] [ 2 ] - a [ 1 ] [ 2 ] & & a [ 2 ] [ 0 ] - a [ 1 ] [ 0 ] = = a [ 2 ] [ 1 ] - a [ 1 ] [ 1 ] & & a [ 2 ] [ 0 ] - a [ 1 ] [ 0 ] = = a [ 2 ] [ 2 ] - a [ 1 ] [ 2 ] ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; char [ ] S = new char [ N ] ; for ( int i = 0 ; i < S . length ; + + i ) { S [ i ] = sc . next ( ) . charAt ( 0 ) ; } System . out . println ( solve ( S ) ) ; sc . close ( ) ; } static String solve ( char [ ] S ) { return IntStream . range ( 0 , S . length ) . anyMatch ( i - > S [ i ] = = ' Y ' ) ? " Four " : " Three " ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; long A [ ] = new long [ N ] ; for ( int i = 0 ; i < N ; i + + ) { A [ i ] = scan . nextLong ( ) ; } long res = 0 ; long min = 0 ; for ( int i = 0 ; i < N ; i + + ) { if ( i = = 0 ) { res + = A [ i ] - 1 ; min = 1 ; continue ; } if ( min + 1 = = A [ i ] ) { min = A [ i ] ; } else if ( min + 1 < A [ i ] ) { res + = ( A [ i ] - 1 ) / ( min + 1 ) ; } } System . out . println ( res ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] s = br . readLine ( ) . split ( " " , 0 ) ; int K = Integer . parseInt ( s [ 0 ] ) ; int S = Integer . parseInt ( s [ 1 ] ) ; int X , Y , Z ; int count = 0 ; for ( X = 0 ; X < = K ; X + + ) { for ( Y = 0 ; Y < = K ; Y + + ) { Z = S - X - Y ; if ( 0 < = Z & & Z < = K ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { private static final int N = 3 ; public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int [ ] [ ] c = new int [ N ] [ N ] ; IntStream . range ( 0 , N ) . forEach ( i - > IntStream . range ( 0 , N ) . forEach ( j - > c [ i ] [ j ] = scanner . nextInt ( ) ) ) ; boolean result = true ; for ( int i = 0 ; i < N - 1 ; i + + ) { int diff1 = c [ i + 1 ] [ 0 ] - c [ i ] [ 0 ] ; int diff2 = c [ 0 ] [ i + 1 ] - c [ 0 ] [ i ] ; for ( int j = 1 ; j < N ; j + + ) { if ( ( c [ i + 1 ] [ j ] - c [ i ] [ j ] ) ! = diff1 ) { result = false ; break ; } if ( ( c [ j ] [ i + 1 ] - c [ j ] [ i ] ) ! = diff2 ) { result = false ; break ; } } } System . out . println ( result ? " Yes " : " No " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; sc . close ( ) ; int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( z < = k & & z > = 0 ) count + + ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { int k , s , ans = 0 ; Scanner sc = new Scanner ( System . in ) ; k = sc . nextInt ( ) ; s = sc . nextInt ( ) ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( 0 < = z & & z < = k ) { ans + = 1 ; } } } System . out . println ( ans ) ; } } import java . util . PriorityQueue ; import java . util . Scanner ; class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int ans = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { if ( 0 < = S - x - y & & S - x - y < = K ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < = K ; i + + ) { int X = i ; for ( int j = 0 ; j < = K ; j + + ) { int Y = j ; if ( S - X - Y > = 0 & & S - X - Y < = K ) { ans + = 1 ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int D = sc . nextInt ( ) , N = sc . nextInt ( ) ; int [ ] T = new int [ D ] ; int [ ] A = new int [ N ] ; int [ ] B = new int [ N ] ; int [ ] C = new int [ N ] ; int [ ] curr = new int [ N ] ; int [ ] next = new int [ N ] ; for ( int i = 0 ; i < D ; i + + ) T [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < N ; i + + ) { A [ i ] = sc . nextInt ( ) ; B [ i ] = sc . nextInt ( ) ; C [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < D - 1 ; i + + ) { for ( int j = 0 ; j < N ; j + + ) for ( int k = 0 ; k < N ; k + + ) { if ( A [ j ] < = T [ i ] & & T [ i ] < = B [ j ] & & A [ k ] < = T [ i + 1 ] & & T [ i + 1 ] < = B [ k ] ) { int currNext = 0 ; currNext + = curr [ j ] ; currNext + = Math . abs ( C [ j ] - C [ k ] ) ; if ( currNext > next [ k ] ) next [ k ] = currNext ; } } for ( int j = 0 ; j < N ; j + + ) { curr [ j ] = next [ j ] ; next [ j ] = 0 ; } } int max = curr [ 0 ] ; for ( int i = 1 ; i < N ; i + + ) max = Math . max ( max , curr [ i ] ) ; System . out . println ( max ) ; } } import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int ans = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = Math . min ( k , s - x ) ; y + + ) { int z = s - x - y ; if ( z > = 0 & & z < = k ) ans + + ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] tmpString = sc . nextLine ( ) . split ( " " ) ; int K = Integer . parseInt ( tmpString [ 0 ] ) ; int S = Integer . parseInt ( tmpString [ 1 ] ) ; int count = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { int total = S - i - j ; if ( total > = 0 & & total < = K ) count + + ; } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] list = new int [ n ] ; for ( int i = 0 ; i < list . length ; i + + ) { list [ i ] = sc . nextInt ( ) ; } int cnt = 0 ; int min = Integer . MAX _ VALUE ; for ( int i = 0 ; i < list . length ; i + + ) { if ( min > = list [ i ] ) { min = list [ i ] ; cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; if ( str . indexOf ( " 1 " ) ! = - 1 & & str . indexOf ( " 4 " ) ! = - 1 & & str . indexOf ( " 7 " ) ! = - 1 & & str . indexOf ( " 9 " ) ! = - 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int total = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { int last = S - i - j ; if ( last > = 0 & & last < = K ) total + + ; } } System . out . println ( total ) ; } } import java . util . * ; import java . io . * ; class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; Integer K = Integer . parseInt ( st . nextToken ( ) ) ; Integer S = Integer . parseInt ( st . nextToken ( ) ) ; long ans = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { if ( i + j > S ) continue ; if ( S - i - j < = K ) ans + + ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { int count = 0 ; boolean sw = false ; String answer = " " ; int e = 0 ; int f = 0 ; int g = 0 ; int h = 0 ; Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; if ( a = = 1 | | b = = 1 | | c = = 1 | | d = = 1 ) { e = 1 ; } if ( a = = 9 | | b = = 9 | | c = = 9 | | d = = 9 ) { f = 1 ; } if ( a = = 7 | | b = = 7 | | c = = 7 | | d = = 7 ) { g = 1 ; } if ( a = = 4 | | b = = 4 | | c = = 4 | | d = = 4 ) { h = 1 ; } if ( e = = 1 & & f = = 1 & & g = = 1 & & h = = 1 ) { answer = " YES " ; } else { answer = " NO " ; } System . out . println ( answer ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; System . out . println ( s . contains ( " 1 " ) & & s . contains ( " 9 " ) & & s . contains ( " 7 " ) & & s . contains ( " 4 " ) ? " YES " : " NO " ) ; sc . close ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int c [ ] [ ] = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } int b [ ] = { c [ 0 ] [ 0 ] - 0 , c [ 0 ] [ 1 ] - 0 , c [ 0 ] [ 2 ] - 0 } ; int a [ ] = { 0 , c [ 1 ] [ 0 ] - b [ 0 ] , c [ 2 ] [ 0 ] - b [ 0 ] } ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( c [ i ] [ j ] ! = a [ i ] + b [ j ] ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int cnt = 0 ; sc . close ( ) ; for ( int i = Math . max ( 0 , s - 2 * k ) ; i < = Math . min ( k , s ) ; i + + ) { for ( int j = Math . max ( 0 , s - i - k ) ; j < = Math . min ( k , s - i ) ; j + + ) { int tmp = s - i - j ; if ( tmp > = 0 & & tmp < = k ) { cnt + + ; } } } System . out . println ( cnt ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BHinaArare solver = new BHinaArare ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BHinaArare { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int n = in . nextInt ( ) ; boolean four = false ; for ( int i = 0 ; i < n ; i + + ) { char c = in . next ( ) . charAt ( 0 ) ; if ( c = = ' Y ' ) four = true ; } out . println ( four ? " Four " : " Three " ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer = = null | | ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int n = stdIn . nextInt ( ) ; int [ ] p = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = stdIn . nextInt ( ) ; } int cnt = 1 ; int min = p [ 0 ] ; for ( int i = 0 ; i < n - 1 ; i + + ) { if ( min > = p [ i + 1 ] ) { cnt + + ; min = p [ i + 1 ] ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) throws InterruptedException { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int wa = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < = x ; i + + ) { for ( int j = 0 ; j < = x ; j + + ) { if ( 0 < = wa - i - j & & wa - i - j < = x ) { ans + + ; } } } System . out . println ( ans ) ; sc . close ( ) ; } public static void saiki ( int a , String b ) { if ( a = = 0 ) { System . out . println ( b ) ; } else { for ( char ch = ' a ' ; ch < = ' c ' ; ch + + ) { saiki ( a - 1 , b + ch ) ; } } } public static int gcd ( int a , int b ) { if ( a < b ) { int tmp = a ; a = b ; b = tmp ; } int r = - 1 ; while ( r ! = 0 ) { r = a % b ; a = b ; b = r ; } return a ; } } import java . util . * ; public class Main implements Runnable { private static int MOD = 1 _ 000 _ 000 _ 007 ; public static void main ( String [ ] args ) { Thread thread = new Thread ( null , new Main ( ) , " " , 32 * 1024 * 1024 ) ; thread . start ( ) ; } @ Override public void run ( ) { final Scanner scanner = new Scanner ( System . in ) ; solve ( scanner ) ; } static void solve ( Scanner scanner ) { int N = Integer . parseInt ( scanner . next ( ) ) ; int min = Integer . MAX _ VALUE , ans = 0 ; for ( int i = 0 ; i < N ; i + + ) { int n = Integer . parseInt ( scanner . next ( ) ) ; if ( n < min ) { ans + + ; min = n ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] youso = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { youso [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] tmp = new int [ 3 ] ; tmp [ 0 ] = youso [ 1 ] [ 0 ] - youso [ 0 ] [ 0 ] ; tmp [ 1 ] = youso [ 2 ] [ 0 ] - youso [ 1 ] [ 0 ] ; tmp [ 2 ] = youso [ 2 ] [ 0 ] - youso [ 0 ] [ 0 ] ; int aa [ ] [ ] = { { 1 , 0 } , { 2 , 1 } , { 2 , 0 } } ; boolean [ ] vali = new boolean [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { vali [ i ] = true ; } for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( youso [ aa [ i ] [ 0 ] ] [ j ] - youso [ aa [ i ] [ 1 ] ] [ j ] ! = tmp [ i ] ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } } System . out . println ( " Yes " ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] N = new int [ 4 ] ; N [ 0 ] = sc . nextInt ( ) ; N [ 1 ] = sc . nextInt ( ) ; N [ 2 ] = sc . nextInt ( ) ; N [ 3 ] = sc . nextInt ( ) ; boolean ans = solve ( N ) ; System . out . println ( ans ? " YES " : " NO " ) ; } private static boolean solve ( int [ ] N ) { Arrays . sort ( N ) ; if ( N [ 0 ] = = 1 & & N [ 1 ] = = 4 & & N [ 2 ] = = 7 & & N [ 3 ] = = 9 ) { return true ; } return false ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; boolean isY = false ; for ( int i = 0 ; i < N ; i + + ) { String S = sc . next ( ) ; if ( S . equals ( " Y " ) ) isY = true ; } System . out . println ( isY ? " Four " : " Three " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { int count = 0 ; boolean sw = false ; int max = Integer . MIN _ VALUE ; int min = Integer . MAX _ VALUE ; double dMax = Double . MIN _ VALUE ; double dMin = Double . MAX _ VALUE ; Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; for ( int i = 0 ; i < = k ; + + i ) { for ( int j = 0 ; j < = k ; + + j ) { int a = s - i - j ; if ( a < = k & & a > = 0 ) { + + count ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; int P [ ] = new int [ N ] ; int countI = 1 ; for ( int i = 0 ; i < N ; i + + ) { int b = scan . nextInt ( ) ; P [ i ] = b ; } int j = 1 ; int Min = P [ 0 ] ; while ( j < N ) { if ( P [ j ] < Min ) { Min = P [ j ] ; countI + + ; } j + + ; } System . out . println ( countI ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int ans = 1 ; int max = sc . nextInt ( ) ; int min = 0 ; for ( int i = 0 ; i < n - 1 ; i + + ) { int p = sc . nextInt ( ) ; if ( i = = 0 ) { min = p ; if ( max < min ) { int tmp = min ; min = max ; max = tmp ; } } if ( max > = p & & min > = p ) { ans + + ; } if ( p > max ) max = p ; if ( p < min ) min = p ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int [ ] [ ] c1 = new int [ 3 ] [ 3 ] ; int [ ] [ ] c2 = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c1 [ i ] [ j ] = in . nextInt ( ) ; c2 [ i ] [ j ] = c1 [ i ] [ j ] ; } } for ( int i = 0 ; i < 3 ; i + + ) { c1 [ i ] [ 2 ] - = c1 [ i ] [ 0 ] ; c1 [ i ] [ 1 ] - = c1 [ i ] [ 0 ] ; c1 [ i ] [ 0 ] - = c1 [ i ] [ 0 ] ; } for ( int j = 0 ; j < 3 ; j + + ) { if ( ! ( c1 [ 0 ] [ j ] = = c1 [ 1 ] [ j ] & & c1 [ 1 ] [ j ] = = c1 [ 2 ] [ j ] ) ) { System . out . println ( " No " ) ; return ; } } for ( int i = 0 ; i < 3 ; i + + ) { c2 [ 2 ] [ i ] - = c2 [ 0 ] [ i ] ; c2 [ 1 ] [ i ] - = c2 [ 0 ] [ i ] ; c2 [ 0 ] [ i ] - = c2 [ 0 ] [ i ] ; } for ( int j = 0 ; j < 3 ; j + + ) { if ( ! ( c2 [ j ] [ 0 ] = = c2 [ j ] [ 1 ] & & c2 [ j ] [ 1 ] = = c2 [ j ] [ 2 ] ) ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } String ans = " Yes " ; for ( int i = 0 ; i < 2 ; i + + ) { if ( ! ( c [ 0 ] [ i ] - c [ 0 ] [ i + 1 ] = = c [ 1 ] [ i ] - c [ 1 ] [ i + 1 ] & & c [ 0 ] [ i ] - c [ 0 ] [ i + 1 ] = = c [ 2 ] [ i ] - c [ 2 ] [ i + 1 ] ) ) { ans = " No " ; } } System . out . println ( ans ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; import java . io . IOException ; import java . util . InputMismatchException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int [ ] a = in . nextIntArray ( 4 ) ; Arrays . sort ( a ) ; int [ ] b = { 1 , 4 , 7 , 9 } ; for ( int i = 0 ; i < 4 ; i + + ) { if ( a [ i ] ! = b [ i ] ) { out . println ( " NO " ) ; return ; } } out . println ( " YES " ) ; } } static class InputReader { private BufferedReader br ; private StringTokenizer st ; public InputReader ( InputStream inputStream ) { br = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; st = new StringTokenizer ( " " ) ; } public String nextString ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) , " " ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( nextString ( ) ) ; } public int [ ] nextIntArray ( int n ) { int [ ] res = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { res [ i ] = nextInt ( ) ; } return res ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int [ ] num = new int [ 10 ] ; for ( int i = 0 ; i < 4 ; + + i ) { int n = scanner . nextInt ( ) ; num [ n ] + + ; } if ( num [ 1 ] = = 1 & & num [ 9 ] = = 1 & & num [ 7 ] = = 1 & & num [ 4 ] = = 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] list = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { int a = Integer . parseInt ( sc . next ( ) ) ; list [ i ] [ j ] = a ; } } if ( list [ 0 ] [ 0 ] - list [ 1 ] [ 0 ] = = list [ 0 ] [ 1 ] - list [ 1 ] [ 1 ] & & list [ 0 ] [ 1 ] - list [ 1 ] [ 1 ] = = list [ 0 ] [ 2 ] - list [ 1 ] [ 2 ] & & list [ 1 ] [ 0 ] - list [ 2 ] [ 0 ] = = list [ 1 ] [ 1 ] - list [ 2 ] [ 1 ] & & list [ 1 ] [ 1 ] - list [ 2 ] [ 1 ] = = list [ 1 ] [ 2 ] - list [ 2 ] [ 2 ] & & list [ 0 ] [ 0 ] - list [ 0 ] [ 1 ] = = list [ 1 ] [ 0 ] - list [ 1 ] [ 1 ] & & list [ 0 ] [ 0 ] - list [ 0 ] [ 1 ] = = list [ 2 ] [ 0 ] - list [ 2 ] [ 1 ] & & list [ 0 ] [ 1 ] - list [ 0 ] [ 2 ] = = list [ 1 ] [ 1 ] - list [ 1 ] [ 2 ] & & list [ 0 ] [ 1 ] - list [ 0 ] [ 2 ] = = list [ 2 ] [ 1 ] - list [ 2 ] [ 2 ] ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int b = scan . nextInt ( ) ; int a = scan . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < = b ; i + + ) { for ( int n = 0 ; n < = b ; n + + ) { int f = a - i - n ; if ( f < = b & & f > = 0 ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; Integer N [ ] = new Integer [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) { N [ i ] = sc . nextInt ( ) ; } if ( Arrays . asList ( N ) . contains ( 1 ) & & Arrays . asList ( N ) . contains ( 7 ) & & Arrays . asList ( N ) . contains ( 9 ) & & Arrays . asList ( N ) . contains ( 4 ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = Integer . parseInt ( sc . next ( ) ) ; int S = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; int z = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { z = S - x - y ; if ( z > = 0 & & z < = K ) count + + ; } } System . out . println ( count ) ; } } import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int P [ ] = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) P [ i ] = sc . nextInt ( ) ; int count = 1 ; int min = P [ 0 ] ; for ( int i = 1 ; i < N ; i + + ) { if ( P [ i ] < min ) { min = P [ i ] ; count + + ; } } System . out . println ( count ) ; } } import java . io . * ; import java . util . * ; public class Main { private static FastReader in = new FastReader ( System . in ) ; private static PrintWriter out = new PrintWriter ( System . out ) ; private static final long MOD = ( long ) 1e9 + 7 ; public static void main ( String [ ] args ) { solve ( ) ; out . flush ( ) ; } private static void solve ( ) { int n = in . nextInt ( ) ; int [ ] p = in . nextIntArray ( n ) ; int ans = 0 ; int min = p [ 0 ] ; for ( int i = 0 ; i < n ; i + + ) { min = Math . min ( min , p [ i ] ) ; if ( p [ i ] < = min ) { ans + + ; } } out . println ( ans ) ; } static class FastReader { BufferedReader br ; StringTokenizer st ; FastReader ( InputStream inputStream ) { br = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; } String next ( ) { while ( st = = null | | ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } public int [ ] nextIntArray ( int n ) { int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) a [ i ] = nextInt ( ) ; return a ; } public long [ ] nextLongArray ( int n ) { long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i + + ) a [ i ] = nextLong ( ) ; return a ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { if ( 0 < = S - x - y & & S - x - y < = K ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Set < String > set = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i + + ) { String s = sc . next ( ) ; set . add ( s ) ; } if ( set . size ( ) = = 3 ) { System . out . println ( " Three " ) ; } else { System . out . println ( " Four " ) ; } sc . close ( ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int [ ] [ ] map = new int [ 3 ] [ 3 ] ; boolean ans = false ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { map [ i ] [ j ] = scanner . nextInt ( ) ; } } for ( int i = 0 ; i < = 100 ; i + + ) { for ( int j = 0 ; j < = 100 ; j + + ) { for ( int k = 0 ; k < = 100 ; k + + ) { int ok = 0 ; int [ ] b = { map [ 0 ] [ 0 ] - i , map [ 1 ] [ 1 ] - j , map [ 2 ] [ 2 ] - k } ; if ( i + b [ 1 ] = = map [ 0 ] [ 1 ] ) ok + + ; if ( i + b [ 2 ] = = map [ 0 ] [ 2 ] ) ok + + ; if ( j + b [ 0 ] = = map [ 1 ] [ 0 ] ) ok + + ; if ( j + b [ 2 ] = = map [ 1 ] [ 2 ] ) ok + + ; if ( k + b [ 0 ] = = map [ 2 ] [ 0 ] ) ok + + ; if ( k + b [ 1 ] = = map [ 2 ] [ 1 ] ) ok + + ; if ( ok = = 6 ) ans = true ; } } } if ( ans ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Main { static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; int N = gi ( ) ; int [ ] P = new int [ N ] ; int min = Integer . MAX _ VALUE ; int c = 0 ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = gi ( ) ; if ( min > P [ i ] ) { min = P [ i ] ; c + + ; } } System . out . println ( c ) ; } public static String gs ( ) { return scanner . next ( ) ; } public static int gi ( ) { return Integer . parseInt ( scanner . next ( ) ) ; } public static long gl ( ) { return Long . parseLong ( scanner . next ( ) ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int cnt = 0 ; sc . close ( ) ; for ( int i = Math . max ( 0 , s - 2 * k ) ; i < = Math . min ( k , s ) ; i + + ) { for ( int j = Math . max ( 0 , s - i - k ) ; j < = Math . min ( k , s - i ) ; j + + ) { if ( ( s - i - j ) > = 0 & & ( s - i - j ) < = k ) { cnt + + ; } } } System . out . println ( cnt ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] P = new int [ N ] ; int max = 0 ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = sc . nextInt ( ) ; max = Math . max ( max , P [ i ] ) ; } int min = max ; int count = 0 ; for ( int i = 0 ; i < N ; i + + ) { if ( P [ i ] < = min ) { count + + ; min = P [ i ] ; } } System . out . println ( count ) ; } } import java . util . * ; import java . lang . Math . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] p = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = sc . nextInt ( ) ; } int cnt = 1 ; int min = p [ 0 ] ; for ( int i = 1 ; i < n ; i + + ) { if ( min > p [ i ] ) { min = p [ i ] ; cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { if ( 0 < = ( s - x - y ) & & ( s - x - y ) < = k ) { count + = 1 ; } } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int res = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - ( x + y ) ; if ( z < 0 | | z > k ) continue ; res + + ; } } System . out . println ( res ) ; } } import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . nextLine ( ) ; sc . close ( ) ; boolean judge = n . contains ( " 1 " ) & & n . contains ( " 9 " ) & & n . contains ( " 7 " ) & & n . contains ( " 4 " ) ; String result = judge ? " YES " : " NO " ; System . out . println ( result ) ; } } import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; String [ ] s = new String [ n ] ; Arrays . setAll ( s , i - > sc . next ( ) ) ; sc . close ( ) ; Set < String > set = new HashSet < > ( Arrays . asList ( s ) ) ; boolean judge = set . size ( ) = = 3 ; String result = judge ? " Three " : " Four " ; System . out . println ( result ) ; } } import java . util . PriorityQueue ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int n = sc . nextInt ( ) ; PriorityQueue < Integer > q = new PriorityQueue < > ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i + + ) { int now = sc . nextInt ( ) ; q . add ( now ) ; if ( now = = q . peek ( ) ) { ans + + ; } } System . out . println ( ans ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int cnt = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { int z = S - x - y ; if ( 0 < = z & & z < = K ) cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int min = Integer . MAX _ VALUE ; int cnt = 0 ; for ( int i = 0 ; i < a . length ; i + + ) { int t = sc . nextInt ( ) ; a [ i ] = t ; if ( t < = min ) { min = t ; cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int num = sc . nextInt ( ) ; int sum = sc . nextInt ( ) ; int cnt = 0 ; for ( int x = 0 ; x < = num ; x + + ) { for ( int y = 0 ; y < = num ; y + + ) { if ( ( sum - ( x + y ) < = num ) & & ( sum - ( x + y ) > = 0 ) ) { cnt + + ; } } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { if ( S - i - j > = 0 & & S - i - j < = K ) { sum + + ; } } } System . out . println ( sum ) ; sc . close ( ) ; } } import java . io . * ; import java . util . * ; public class Main { private static boolean debug = false ; private static boolean elapsed = false ; private static PrintWriter _ out = new PrintWriter ( System . out ) ; private static PrintWriter _ err = new PrintWriter ( System . err ) ; private void solve ( Scanner sc ) { int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int cnt = 0 ; for ( int x = 0 ; x < = K ; + + x ) { for ( int y = 0 ; y < = K ; + + y ) { int z = S - x - y ; if ( 0 < = z & & z < = K ) { + + cnt ; } } } _ out . println ( cnt ) ; } private long C ( long n , long r ) { long res = 1 ; for ( long i = n ; i > n - r ; -- i ) { res * = i ; } for ( long i = r ; i > 1 ; -- i ) { res / = i ; } return res ; } private long P ( long n , long r ) { long res = 1 ; for ( long i = n ; i > n - r ; -- i ) { res * = i ; } return res ; } public static void main ( String [ ] args ) { long S = System . currentTimeMillis ( ) ; Scanner sc = new Scanner ( System . in ) ; new Main ( ) . solve ( sc ) ; _ out . flush ( ) ; long G = System . currentTimeMillis ( ) ; if ( elapsed ) { _ err . println ( ( G - S ) + " ms " ) ; } _ err . flush ( ) ; } } import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { final String s = reader . readLine ( ) ; final String [ ] sl = s . split ( " " ) ; int K = Integer . parseInt ( sl [ 0 ] ) ; int S = Integer . parseInt ( sl [ 1 ] ) ; int cnt = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { if ( x + y < = S ) { int z = S - x - y ; if ( z < = K ) cnt + + ; } } } System . out . println ( cnt ) ; } } } import java . util . * ; class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . nextLine ( ) ) ; String line = sc . nextLine ( ) ; Set < String > sList = new HashSet < > ( Arrays . asList ( line . split ( " " ) ) ) ; if ( sList . size ( ) = = 4 ) { System . out . println ( " Four " ) ; } else { System . out . println ( " Three " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; String str = s . nextLine ( ) ; String [ ] sp = str . split ( " " ) ; int [ ] year = { 1 , 9 , 4 , 7 } ; boolean check1947 = true ; for ( int j = 0 ; j < year . length ; j + + ) { boolean checkNo = false ; for ( int i = 0 ; i < sp . length ; i + + ) { if ( Integer . parseInt ( sp [ i ] ) = = year [ j ] ) checkNo = true ; } check1947 = check1947 & & checkNo ; } if ( check1947 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } import java . util . * ; public class Main { private void doit ( ) { Scanner sc = new Scanner ( System . in ) ; long mod = 1000000007 ; while ( sc . hasNext ( ) ) { int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { int z = s - i - j ; if ( z < 0 | | z > k ) continue ; count + + ; } } System . out . println ( count ) ; } } private void debug ( Object ... o ) { System . out . println ( " debug = " + Arrays . deepToString ( o ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . doit ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner as = new Scanner ( System . in ) ; int a = as . nextInt ( ) ; int b = as . nextInt ( ) ; int c ; int l = 0 ; if ( a < b ) { for ( int i = 0 ; i < = a ; i + + ) { c = b ; c - = i ; for ( int s = 0 ; s < = a ; s + + ) { c - = s ; if ( c < 0 ) { break ; } else { if ( c > a ) { c + = s ; } else { l + + ; c + = s ; } } } } } else { l + = ( b + 2 ) * ( b + 1 ) / 2 ; } System . out . println ( l ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Main { static String [ ] ANS = { " Three " , " Four " } ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . nextLine ( ) ) ; Set < String > set = new HashSet < > ( ) ; for ( int i = 0 ; i < N ; i + + ) { set . add ( sc . next ( ) ) ; } System . out . println ( ANS [ set . size ( ) - 3 ] ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; Set < String > set = new HashSet < String > ( ) ; int i = 0 ; for ( i = 0 ; i < n ; i + + ) { set . add ( scan . next ( ) ) ; } if ( set . size ( ) = = 3 ) { System . out . println ( " Three " ) ; } else { System . out . println ( " Four " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = Integer . parseInt ( sc . next ( ) ) ; int [ ] n = new int [ a ] ; for ( int i = 0 ; i < a ; i + + ) { n [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int cnt = 1 , min = n [ 0 ] ; for ( int i = 1 ; i < a ; i + + ) { if ( min > n [ i ] ) { cnt + + ; min = n [ i ] ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; sc . close ( ) ; int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { if ( s - ( x + y ) > = 0 & & s - ( x + y ) < = k ) { if ( x + y + ( s - ( x + y ) ) = = s ) { count + + ; } } } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = Integer . parseInt ( sc . next ( ) ) ; int s = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { if ( s - i - j > = 0 & & s - i - j < = k ) count + + ; } } System . out . println ( count ) ; } } import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; long n = 0 ; for ( int i = 0 ; i < = x ; i + + ) { n + + ; n * = 2 ; } System . out . println ( n ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } String ans = solve ( c ) ; System . out . println ( ans ) ; } private static String solve ( int [ ] [ ] c ) { for ( int d = 0 ; d < 2 ; d + + ) { if ( ! equals ( c [ 0 ] [ d + 1 ] - c [ 0 ] [ d ] , c [ 1 ] [ d + 1 ] - c [ 1 ] [ d ] , c [ 2 ] [ d + 1 ] - c [ 2 ] [ d ] ) ) { return " No " ; } } for ( int d = 0 ; d < 2 ; d + + ) { if ( ! equals ( c [ d + 1 ] [ 0 ] - c [ d ] [ 0 ] , c [ d + 1 ] [ 1 ] - c [ d ] [ 1 ] , c [ d + 1 ] [ 2 ] - c [ d ] [ 2 ] ) ) { return " No " ; } } return " Yes " ; } private static boolean equals ( int d1 , int d2 , int d3 ) { if ( d1 = = d2 & & d2 = = d3 ) return true ; return false ; } } import java . util . * ; class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n [ ] = { sc . nextInt ( ) , sc . nextInt ( ) , sc . nextInt ( ) , sc . nextInt ( ) } ; Arrays . sort ( n ) ; boolean b = false ; if ( n [ 0 ] = = 1 ) { if ( n [ 1 ] = = 4 ) { if ( n [ 2 ] = = 7 ) { if ( n [ 3 ] = = 9 ) System . out . println ( " YES " ) ; b = true ; } } } if ( b = = false ) System . out . println ( " NO " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; Integer output = 0 ; Integer kInteger = new Integer ( scanner . next ( ) ) ; Integer sInteger = new Integer ( scanner . next ( ) ) ; for ( int x = 0 ; x < = kInteger ; x + + ) { for ( int y = 0 ; y < = kInteger ; y + + ) { if ( kInteger > = ( sInteger - x - y ) & & 0 < = ( sInteger - x - y ) ) output + + ; } } System . out . println ( output ) ; scanner . close ( ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int count = 1 ; int min = sc . nextInt ( ) ; for ( int i = 1 ; i < n ; i + + ) { int tmp = sc . nextInt ( ) ; if ( tmp < = min ) { count + + ; min = tmp ; } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] values = new int [ 3 ] [ 3 ] ; for ( int y = 0 ; y < 3 ; y + + ) { for ( int x = 0 ; x < 3 ; x + + ) { values [ y ] [ x ] = sc . nextInt ( ) ; } } int [ ] a _ values = new int [ 3 ] ; int [ ] b _ values = new int [ 3 ] ; a _ values [ 0 ] = 0 ; for ( int x = 0 ; x < 3 ; x + + ) { b _ values [ x ] = values [ 0 ] [ x ] ; } for ( int y = 1 ; y < 3 ; y + + ) { a _ values [ y ] = values [ y ] [ 0 ] - b _ values [ 0 ] ; } for ( int y = 0 ; y < 3 ; y + + ) { for ( int x = 0 ; x < 3 ; x + + ) { if ( values [ y ] [ x ] ! = a _ values [ y ] + b _ values [ x ] ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int [ ] p = new int [ n ] ; int count = 0 ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int arrayMin = Integer . MAX _ VALUE ; for ( int i = 0 ; i < n ; i + + ) { arrayMin = Math . min ( p [ i ] , arrayMin ) ; if ( arrayMin = = p [ i ] ) { count + + ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int k = scanner . nextInt ( ) ; int s = scanner . nextInt ( ) ; int ans = 0 ; int [ ] n = new int [ k + 1 ] ; for ( int i = 0 ; i < = k ; i + + ) { n [ i ] = i ; } for ( int i = 0 ; i < n . length ; i + + ) { int x = i ; for ( int j = 0 ; j < n . length ; j + + ) { int y = j ; int z = s - x - y ; if ( z > = 0 & & z < = k ) { ans + + ; } } } System . out . println ( ans ) ; scanner . close ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int K = scanner . nextInt ( ) ; int S = scanner . nextInt ( ) ; int Z = K ; int counter = 0 ; while ( Z > = 0 ) { int Y = S - Z ; if ( Y > K ) { Y = K ; } while ( Y > = 0 ) { int X = S - Z - Y ; if ( K > = X & & X > = 0 ) { counter + + ; } Y -- ; } Z -- ; } System . out . println ( counter ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int X = 0 ; X < = K ; X + + ) { for ( int Y = 0 ; Y < = K ; Y + + ) { int Z = S - X - Y ; if ( 0 < = Z & & Z < = K ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int result = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { if ( x + y < = s & & x + y + k > = s ) { result + + ; } } } System . out . println ( result ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int c [ ] [ ] = new int [ 4 ] [ 4 ] ; for ( int i = 1 ; i < = 3 ; i + + ) { for ( int k = 1 ; k < = 3 ; k + + ) { c [ i ] [ k ] = sc . nextInt ( ) ; } } boolean ans = true ; if ( c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] ! = c [ 2 ] [ 1 ] - c [ 2 ] [ 2 ] | | c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] ! = c [ 3 ] [ 1 ] - c [ 3 ] [ 2 ] | | c [ 1 ] [ 2 ] - c [ 1 ] [ 3 ] ! = c [ 2 ] [ 2 ] - c [ 2 ] [ 3 ] | | c [ 1 ] [ 2 ] - c [ 1 ] [ 3 ] ! = c [ 3 ] [ 2 ] - c [ 3 ] [ 3 ] ) { ans = false ; } if ( c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] ! = c [ 1 ] [ 2 ] - c [ 2 ] [ 2 ] | | c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] ! = c [ 1 ] [ 3 ] - c [ 2 ] [ 3 ] | | c [ 2 ] [ 1 ] - c [ 3 ] [ 1 ] ! = c [ 2 ] [ 2 ] - c [ 3 ] [ 2 ] | | c [ 2 ] [ 1 ] - c [ 3 ] [ 1 ] ! = c [ 2 ] [ 3 ] - c [ 3 ] [ 3 ] ) { ans = false ; } if ( ans ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int D = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int [ ] T = new int [ D ] ; for ( int i = 0 ; i < D ; + + i ) { T [ i ] = sc . nextInt ( ) ; } int [ ] A = new int [ N ] ; int [ ] B = new int [ N ] ; int [ ] C = new int [ N ] ; for ( int i = 0 ; i < N ; + + i ) { A [ i ] = sc . nextInt ( ) ; B [ i ] = sc . nextInt ( ) ; C [ i ] = sc . nextInt ( ) ; } int [ ] [ ] dp = new int [ D ] [ N ] ; for ( int [ ] a : dp ) { Arrays . fill ( a , - 1 ) ; } for ( int i = 0 ; i < N ; + + i ) { if ( A [ i ] < = T [ 0 ] & & T [ 0 ] < = B [ i ] ) dp [ 0 ] [ i ] = 0 ; } for ( int i = 1 ; i < D ; + + i ) { for ( int j = 0 ; j < N ; + + j ) { if ( A [ j ] < = T [ i ] & & T [ i ] < = B [ j ] ) { for ( int k = 0 ; k < N ; + + k ) { if ( dp [ i - 1 ] [ k ] < 0 ) continue ; dp [ i ] [ j ] = Math . max ( dp [ i ] [ j ] , dp [ i - 1 ] [ k ] + Math . abs ( C [ j ] - C [ k ] ) ) ; } } } } int ans = 0 ; for ( int i = 0 ; i < N ; + + i ) { ans = Math . max ( ans , dp [ D - 1 ] [ i ] ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int z ; int ans = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { z = S - x - y ; if ( z < = K & & z > = 0 ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; int [ ] [ ] C = new int [ 3 ] [ 3 ] ; int [ ] A = new int [ 3 ] ; int [ ] B = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { C [ i ] [ j ] = gi ( ) ; } } for ( A [ 0 ] = 0 ; A [ 0 ] < = C [ 0 ] [ 0 ] ; A [ 0 ] + + ) { B [ 0 ] = C [ 0 ] [ 0 ] - A [ 0 ] ; for ( A [ 1 ] = 0 ; A [ 1 ] < = C [ 1 ] [ 1 ] ; A [ 1 ] + + ) { B [ 1 ] = C [ 1 ] [ 1 ] - A [ 1 ] ; for ( A [ 2 ] = 0 ; A [ 2 ] < = C [ 2 ] [ 2 ] ; A [ 2 ] + + ) { B [ 2 ] = C [ 2 ] [ 2 ] - A [ 2 ] ; boolean f = true ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( A [ i ] + B [ j ] ! = C [ i ] [ j ] ) { f = false ; break ; } } } if ( f ) { System . out . println ( " Yes " ) ; return ; } } } } System . out . println ( " No " ) ; } public static String gs ( ) { return scanner . next ( ) ; } public static int gi ( ) { return Integer . parseInt ( scanner . next ( ) ) ; } public static long gl ( ) { return Long . parseLong ( scanner . next ( ) ) ; } public static double gd ( ) { return Double . parseDouble ( scanner . next ( ) ) ; } } import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int grid [ ] [ ] = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { grid [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 0 ; i < 2 ; i + + ) { int a = ( grid [ i ] [ 0 ] - grid [ i + 1 ] [ 0 ] ) ; int b = ( grid [ i ] [ 1 ] - grid [ i + 1 ] [ 1 ] ) ; int c = ( grid [ i ] [ 2 ] - grid [ i + 1 ] [ 2 ] ) ; if ( a ! = b | | b ! = c ) { System . out . println ( " No " ) ; return ; } } for ( int i = 0 ; i < 2 ; i + + ) { int a = ( grid [ 0 ] [ i ] - grid [ 0 ] [ i + 1 ] ) ; int b = ( grid [ 1 ] [ i ] - grid [ 1 ] [ i + 1 ] ) ; int c = ( grid [ 2 ] [ i ] - grid [ 2 ] [ i + 1 ] ) ; if ( a ! = b | | b ! = c ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int length = sc . nextInt ( ) ; int [ ] data = new int [ length ] ; for ( int a = 0 ; a < length ; a + + ) { data [ a ] = sc . nextInt ( ) ; } int count = 0 ; int i = 0 ; int min = data [ 0 ] ; for ( int b = 0 ; b < length ; b + + ) { i = data [ b ] ; if ( min > = i ) { count + + ; min = i ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String s2 = sc . next ( ) ; String s3 = sc . next ( ) ; String s4 = sc . next ( ) ; String t = s + s2 + s3 + s4 ; if ( t . contains ( " 1 " ) & & t . contains ( " 9 " ) & & t . contains ( " 7 " ) & & t . contains ( " 4 " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } System . out . println ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int ret = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { int z = S - x - y ; if ( 0 < = z & & z < = K ) { ret + + ; } } } System . out . println ( ret ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] a = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { a [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] x = new int [ 3 ] ; int [ ] y = new int [ 3 ] ; x [ 0 ] = 0 ; for ( int i = 0 ; i < 3 ; i + + ) y [ i ] = a [ 0 ] [ i ] ; x [ 1 ] = a [ 1 ] [ 0 ] - y [ 0 ] ; x [ 2 ] = a [ 2 ] [ 0 ] - y [ 0 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( a [ i ] [ j ] ! = x [ i ] + y [ j ] ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } import java . io . PrintStream ; import java . util . Scanner ; public class Main { static void exec ( Scanner in , PrintStream out ) { int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + = 1 ) { for ( int j = 0 ; j < 3 ; j + = 1 ) { c [ i ] [ j ] = in . nextInt ( ) ; } } for ( int i = 0 ; i < = 100 ; i + = 1 ) { int a1 = i ; int b1 = c [ 0 ] [ 0 ] - a1 ; int b2 = c [ 0 ] [ 1 ] - a1 ; int b3 = c [ 0 ] [ 2 ] - a1 ; int a2 = c [ 1 ] [ 0 ] - b1 ; if ( a2 + b2 ! = c [ 1 ] [ 1 ] | | a2 + b3 ! = c [ 1 ] [ 2 ] ) { continue ; } int a3 = c [ 2 ] [ 0 ] - b1 ; if ( a3 + b2 ! = c [ 2 ] [ 1 ] | | a3 + b3 ! = c [ 2 ] [ 2 ] ) { continue ; } out . println ( " Yes " ) ; return ; } out . println ( " No " ) ; } public static void main ( String [ ] args ) { exec ( new Scanner ( System . in ) , System . out ) ; } } import java . io . BufferedInputStream ; import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( new BufferedInputStream ( System . in ) ) ; int a = sc . nextInt ( ) ; int m [ ] = new int [ a ] ; int min = a ; int count = 0 ; for ( int i = 0 ; i < a ; i + + ) { m [ i ] = sc . nextInt ( ) ; if ( m [ i ] < min ) min = m [ i ] ; if ( m [ i ] < = min ) count + + ; } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int mi = 200001 , ans = 0 ; for ( int i = 0 ; i < N ; i + + ) { int P = sc . nextInt ( ) ; if ( P < mi ) { ans + + ; mi = P ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { int z = s - i - j ; if ( 0 < = z & & z < = k ) ans + + ; } } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 1 ; j < 3 ; j + + ) { c [ i ] [ j ] - = c [ i ] [ 0 ] ; } } System . out . println ( c [ 0 ] [ 1 ] = = c [ 1 ] [ 1 ] & & c [ 1 ] [ 1 ] = = c [ 2 ] [ 1 ] & & c [ 0 ] [ 2 ] = = c [ 1 ] [ 2 ] & & c [ 1 ] [ 2 ] = = c [ 2 ] [ 2 ] ? " Yes " : " No " ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int c1 = sc . nextInt ( ) ; int c2 = sc . nextInt ( ) ; int c3 = sc . nextInt ( ) ; int c4 = sc . nextInt ( ) ; int c5 = sc . nextInt ( ) ; int c6 = sc . nextInt ( ) ; int c7 = sc . nextInt ( ) ; int c8 = sc . nextInt ( ) ; int c9 = sc . nextInt ( ) ; int flag = 0 ; ArrayList < Integer > Aarray = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < 3 ; i + + ) { Aarray . add ( 0 ) ; } ArrayList < Integer > Barray = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < 3 ; i + + ) { Barray . add ( 0 ) ; } loop : for ( int i = 0 ; i < 100 ; i + + ) { Aarray . set ( 0 , i ) ; Barray . set ( 0 , c1 - Aarray . get ( 0 ) ) ; Barray . set ( 1 , c2 - Aarray . get ( 0 ) ) ; Barray . set ( 2 , c3 - Aarray . get ( 0 ) ) ; for ( int j = 0 ; j < 2 ; j + + ) { Aarray . set ( 1 , c4 - Barray . get ( j ) ) ; for ( int k = 0 ; k < 2 ; k + + ) { Aarray . set ( 2 , c7 - Barray . get ( k ) ) ; if ( Aarray . get ( 1 ) + Barray . get ( 1 ) = = c5 & & Aarray . get ( 1 ) + Barray . get ( 2 ) = = c6 & & Aarray . get ( 2 ) + Barray . get ( 1 ) = = c8 & & Aarray . get ( 2 ) + Barray . get ( 2 ) = = c9 ) { flag + + ; break loop ; } } } } if ( flag = = 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) , s = sc . nextInt ( ) ; int cnt = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { if ( x + y < = s & & x + y + k > = s ) cnt + + ; } } System . out . println ( cnt ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; A solver = new A ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class A { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int n1 = Integer . parseInt ( in . next ( ) ) ; int n2 = Integer . parseInt ( in . next ( ) ) ; int n3 = Integer . parseInt ( in . next ( ) ) ; int n4 = Integer . parseInt ( in . next ( ) ) ; boolean ok = false ; String tmp = new String ( Integer . toString ( n1 ) + Integer . toString ( n2 ) + Integer . toString ( n3 ) + Integer . toString ( n4 ) ) ; if ( tmp . contains ( " 1 " ) & & tmp . contains ( " 9 " ) & & tmp . contains ( " 7 " ) & & tmp . contains ( " 4 " ) ) ok = true ; out . println ( ok ? " YES " : " NO " ) ; } } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; Set < String > set = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i + + ) { set . add ( sc . next ( ) ) ; } String result = set . size ( ) = = 3 ? " Three " : " Four " ; System . out . println ( result ) ; sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st ; PrintWriter pw = new PrintWriter ( System . out ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { a [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; } int min = Integer . MAX _ VALUE ; int count = 0 ; for ( int i = 0 ; i < n ; i + + ) { if ( a [ i ] < = min ) { min = a [ i ] ; count + + ; } } pw . print ( count ) ; pw . flush ( ) ; pw . close ( ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ans = 0 ; int [ ] [ ] nums = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 9 ; i + + ) { nums [ i / 3 ] [ i % 3 ] = sc . nextInt ( ) ; } System . out . println ( nums [ 1 ] [ 0 ] - nums [ 0 ] [ 0 ] = = nums [ 1 ] [ 1 ] - nums [ 0 ] [ 1 ] & & nums [ 1 ] [ 1 ] - nums [ 0 ] [ 1 ] = = nums [ 1 ] [ 2 ] - nums [ 0 ] [ 2 ] & & nums [ 2 ] [ 0 ] - nums [ 1 ] [ 0 ] = = nums [ 2 ] [ 1 ] - nums [ 1 ] [ 1 ] & & nums [ 2 ] [ 1 ] - nums [ 1 ] [ 1 ] = = nums [ 2 ] [ 2 ] - nums [ 1 ] [ 2 ] ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int count = 1 ; int min = sc . nextInt ( ) ; int P = 0 ; for ( int i = 2 ; i < = N ; i + + ) { P = sc . nextInt ( ) ; if ( P < = min ) { count + + ; min = P ; } } System . out . print ( count ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = Integer . parseInt ( sc . next ( ) ) ; int S = Integer . parseInt ( sc . next ( ) ) ; int ans = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { int z = S - i - j ; if ( 0 < = z & & z < = K ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int x = Math . max ( 0 , s - 2 * k ) ; x < = k ; x + + ) { for ( int y = Math . max ( 0 , s - k - x ) ; y < = Math . min ( k , s - x ) ; y + + ) { count + + ; } } System . out . println ( count ) ; } } import java . util . * ; import java . util . stream . Stream ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; String [ ] nums = new String [ n ] ; for ( int i = 0 ; i < n ; i + + ) { nums [ i ] = sc . next ( ) ; } long result = Stream . of ( nums ) . distinct ( ) . count ( ) ; if ( result = = 3 ) { System . out . println ( " Three " ) ; } else { System . out . println ( " Four " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int ans = 0 ; int min = 210000 ; for ( int i = 0 ; i < n ; i + + ) { int p = sc . nextInt ( ) ; if ( p < = min ) { ans + + ; min = p ; } } System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] input = br . readLine ( ) . split ( " " ) ; int k = Integer . parseInt ( input [ 0 ] ) ; int s = Integer . parseInt ( input [ 1 ] ) ; int x = 0 ; int y = 0 ; int z = 0 ; int count = 0 ; for ( int i = 0 ; i < = k ; i + + ) { x = i ; for ( int j = 0 ; j < = k ; j + + ) { y = j ; int rest = s - x - y ; if ( rest > = 0 & & rest < = k ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = Integer . parseInt ( in . nextLine ( ) ) ; String [ ] params = in . nextLine ( ) . split ( " " ) ; int [ ] ps = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { ps [ i ] = Integer . parseInt ( params [ i ] ) ; } int ans = 0 ; int min = ps [ 0 ] ; for ( int i = 0 ; i < n ; i + + ) { if ( ps [ i ] < = min ) { ans + + ; min = ps [ i ] ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new java . util . Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int [ ] p = new int [ n ] ; int a = 1 ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = scan . nextInt ( ) ; } int min = p [ 0 ] ; for ( int i = 0 ; i < n - 1 ; i + + ) { if ( p [ i + 1 ] < = min & & p [ i ] > p [ i + 1 ] ) { min = p [ i + 1 ] ; a + + ; } } System . out . println ( a ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 9 ; i + + ) c [ i / 3 ] [ i % 3 ] = sc . nextInt ( ) ; System . out . println ( c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] = = c [ 0 ] [ 1 ] + c [ 1 ] [ 0 ] & & c [ 0 ] [ 2 ] + c [ 2 ] [ 0 ] = = c [ 0 ] [ 0 ] + c [ 2 ] [ 2 ] & & c [ 1 ] [ 2 ] + c [ 2 ] [ 1 ] = = c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; boolean ans = false ; for ( int i = 0 ; i < n ; i + + ) { String s = sc . next ( ) ; if ( s . equals ( " Y " ) ) { ans = true ; break ; } } if ( ans ) { System . out . println ( " Four " ) ; } else { System . out . println ( " Three " ) ; } } } import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int sum = 0 ; for ( int h = 0 ; h < = k ; h + + ) { for ( int i = 0 ; i < = k ; i + + ) { if ( h + i + k > = s & & h + i < = s ) { sum = sum + 1 ; } } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String output = " Three " ; int num = sc . nextInt ( ) ; String [ ] colors = new String [ num ] ; for ( int i = 0 ; i < num ; i + + ) { colors [ i ] = sc . next ( ) ; } sc . close ( ) ; for ( int i = 0 ; i < colors . length ; i + + ) { if ( colors [ i ] . equals ( " Y " ) ) { output = " Four " ; break ; } } System . out . println ( output ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int count = 0 ; int [ ] p = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = sc . nextInt ( ) ; } int min = 0 ; for ( int i = 0 ; i < n ; i + + ) { if ( i = = 0 ) { min = p [ i ] ; count + + ; } else if ( p [ i ] < min ) { count + + ; min = p [ i ] ; } } System . out . println ( count ) ; } } import java . util . Scanner ; import java . util . Arrays ; import java . util . ArrayList ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a [ ] [ ] = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) for ( int j = 0 ; j < 3 ; j + + ) a [ i ] [ j ] = sc . nextInt ( ) ; boolean flag = true ; for ( int i = 0 ; i < 2 ; i + + ) { if ( ( a [ 0 ] [ i ] - a [ 0 ] [ i + 1 ] ! = a [ 1 ] [ i ] - a [ 1 ] [ i + 1 ] | | a [ 1 ] [ i ] - a [ 1 ] [ i + 1 ] ! = a [ 2 ] [ i ] - a [ 2 ] [ i + 1 ] ) ) flag = false ; } for ( int i = 0 ; i < 2 ; i + + ) { if ( ( a [ i ] [ 0 ] - a [ i + 1 ] [ 0 ] ! = a [ i ] [ 1 ] - a [ i + 1 ] [ 1 ] | | a [ i ] [ 1 ] - a [ i + 1 ] [ 1 ] ! = a [ i ] [ 2 ] - a [ i + 1 ] [ 2 ] ) ) flag = false ; } if ( flag ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int sum = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - ( x + y ) ; if ( ( 0 < = z ) & & ( z < = k ) ) { sum + + ; } } } System . out . println ( sum ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . HashSet ; import java . util . Set ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; int n = sc . nextInt ( ) ; Set < Character > set = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i + + ) { char c = sc . next ( ) . charAt ( 0 ) ; set . add ( c ) ; } if ( set . size ( ) = = 3 ) { System . out . println ( " Three " ) ; } else if ( set . size ( ) = = 4 ) { System . out . println ( " Four " ) ; } } static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st = = null | | ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = 3 ; int [ ] [ ] c = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i + + ) { for ( int j = 0 ; j < n ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } int a1 , a2 , a3 , b1 , b2 , b3 ; String ans = " No " ; for ( int i = 0 ; i < n ; i + + ) { a1 = i ; b1 = c [ 0 ] [ 0 ] - a1 ; b2 = c [ 0 ] [ 1 ] - a1 ; b3 = c [ 0 ] [ 2 ] - a1 ; a2 = c [ 1 ] [ 0 ] - b1 ; a3 = c [ 2 ] [ 0 ] - b1 ; if ( a2 + b2 = = c [ 1 ] [ 1 ] & & a2 + b3 = = c [ 1 ] [ 2 ] & & a3 + b2 = = c [ 2 ] [ 1 ] & & a3 + b3 = = c [ 2 ] [ 2 ] ) { ans = " Yes " ; break ; } } System . out . println ( ans ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; HashSet < String > set = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i + + ) { set . add ( sc . next ( ) ) ; } if ( set . size ( ) = = 4 ) { System . out . println ( " Four " ) ; } else { System . out . println ( " Three " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int c [ ] [ ] = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } boolean b1 = c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] & & c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] = = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] ; boolean b2 = c [ 0 ] [ 0 ] - c [ 0 ] [ 2 ] = = c [ 1 ] [ 0 ] - c [ 1 ] [ 2 ] & & c [ 0 ] [ 0 ] - c [ 0 ] [ 2 ] = = c [ 2 ] [ 0 ] - c [ 2 ] [ 2 ] ; boolean b3 = c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] & & c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] ; boolean b4 = c [ 0 ] [ 0 ] - c [ 2 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 2 ] [ 1 ] & & c [ 0 ] [ 0 ] - c [ 2 ] [ 0 ] = = c [ 0 ] [ 2 ] - c [ 2 ] [ 2 ] ; if ( b1 & & b2 & & b3 & & b4 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int min = Integer . parseInt ( sc . next ( ) ) ; int cnt = 1 ; for ( int i = 1 ; i < n ; i + + ) { int pi = Integer . parseInt ( sc . next ( ) ) ; if ( pi < = min ) { min = pi ; cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . * ; class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int sum = 0 ; for ( int x = 0 ; x < = K ; x + + ) { if ( x > S ) break ; for ( int y = 0 ; y < = K ; y + + ) { if ( x + y > S ) break ; int z = S - x - y ; if ( z > = 0 & & z < = K ) sum + + ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int ans = 0 ; for ( int X = 0 ; X < = K ; X + + ) { for ( int Y = 0 ; Y < = K ; Y + + ) { int Z = S - X - Y ; if ( Z < = K & & Z > = 0 ) ans + + ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int k = scan . nextInt ( ) ; int s = scan . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( z > = 0 & & z < = k ) { count + + ; } } } System . out . println ( count ) ; } } import java . io . * ; import java . util . * ; public class Main { void run ( ) { int [ ] need = new int [ ] { 1 , 4 , 7 , 9 } ; int [ ] a = new int [ need . length ] ; for ( int i = 0 ; i < a . length ; i + + ) { a [ i ] = in . nextInt ( ) ; } Arrays . sort ( a ) ; System . out . println ( Arrays . equals ( a , need ) ? " YES " : " NO " ) ; } static MyScanner in ; static PrintWriter out ; public static void main ( String [ ] args ) throws IOException { boolean stdStreams = true ; String fileName = Main . class . getSimpleName ( ) . replaceFirst ( " _ . * " , " " ) . toLowerCase ( ) ; String inputFileName = fileName + " .in " ; String outputFileName = fileName + " .out " ; Locale . setDefault ( Locale . US ) ; BufferedReader br ; if ( stdStreams ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; out = new PrintWriter ( System . out ) ; } else { br = new BufferedReader ( new FileReader ( inputFileName ) ) ; out = new PrintWriter ( outputFileName ) ; } in = new MyScanner ( br ) ; int tests = 1 ; for ( int test = 0 ; test < tests ; test + + ) { new Main ( ) . run ( ) ; } br . close ( ) ; out . close ( ) ; } static class MyScanner { BufferedReader br ; StringTokenizer st ; MyScanner ( BufferedReader br ) { this . br = br ; } void findToken ( ) { while ( st = = null | | ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } } String next ( ) { findToken ( ) ; return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] P = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int min = 1 _ 000 _ 000 _ 000 ; int ans = 0 ; for ( int i = 0 ; i < N ; i + + ) { min = Math . min ( P [ i ] , min ) ; if ( min > = P [ i ] ) { ans + + ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String [ ] s = new String [ n ] ; for ( int i = 0 ; i < n ; i + + ) { s [ i ] = sc . next ( ) ; } if ( Arrays . asList ( s ) . contains ( " Y " ) ) { System . out . println ( " Four " ) ; } else { System . out . println ( " Three " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } int a1 = 0 ; int b1 = c [ 0 ] [ 0 ] - a1 ; int b2 = c [ 0 ] [ 1 ] - a1 ; int b3 = c [ 0 ] [ 2 ] - a1 ; int a2 = c [ 1 ] [ 0 ] - b1 ; int a3 = c [ 2 ] [ 0 ] - b1 ; if ( a2 + b2 = = c [ 1 ] [ 1 ] & & a2 + b3 = = c [ 1 ] [ 2 ] & & a3 + b2 = = c [ 2 ] [ 1 ] & & a3 + b3 = = c [ 2 ] [ 2 ] ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) ; int N , A , B , C ; int a = 0 , b = 0 , c = 0 , d = 0 ; for ( int i = 0 ; i < 4 ; i + + ) { N = stdin . nextInt ( ) ; if ( N = = 1 & & a = = 0 ) a + + ; if ( N = = 9 & & b = = 0 ) b + + ; if ( N = = 7 & & c = = 0 ) c + + ; if ( N = = 4 & & d = = 0 ) d + + ; } if ( a + b + c + d > = 4 ) { System . out . print ( " YES " ) ; } else { System . out . print ( " NO " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; int [ ] b = new int [ 3 ] ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = scanner . nextInt ( ) ; } } for ( int i = 0 ; i < 3 ; i + + ) { b [ i ] = c [ 0 ] [ i ] ; } a [ 0 ] = 0 ; a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] ; a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] ; boolean wronganswer = false ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( c [ i ] [ j ] ! = a [ i ] + b [ j ] ) { wronganswer = true ; } ; } } if ( wronganswer ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } scanner . close ( ) ; } } import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; ArrayList < Integer > P = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i + + ) P . add ( sc . nextInt ( ) ) ; int sum = 1 ; int now = P . get ( 0 ) ; for ( int i = 1 ; i < N ; i + + ) { if ( now > = P . get ( i ) ) { sum + + ; now = P . get ( i ) ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { if ( s - i - j > = 0 & & s - i - j < = k ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int k = scan . nextInt ( ) ; int s = scan . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = s ; x + + ) { if ( x < = k ) { for ( int y = 0 ; y < = s - x ; y + + ) { if ( y < = k & & s - x - y < = k ) { count + = 1 ; } } } } System . out . println ( String . valueOf ( count ) ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] p = new int [ n ] ; int max = 0 ; int min = 0 ; int cnt = 0 ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = sc . nextInt ( ) ; if ( i = = 0 ) { max = min = p [ i ] ; } if ( min > = p [ i ] ) { + + cnt ; min = p [ i ] ; } else { max = p [ i ] ; } } System . out . println ( cnt ) ; } } import java . io . * ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws IOException { init ( ) ; int min = Integer . MAX _ VALUE ; int n = nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i + + ) { int b = nextInt ( ) ; if ( b < min ) ans + + ; min = Math . min ( b , min ) ; } System . out . println ( ans ) ; } private static BufferedReader reader ; private static StringTokenizer tokenizer ; private static void init ( ) { reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; tokenizer = new StringTokenizer ( " " ) ; } private static String next ( ) throws IOException { String read ; while ( ! tokenizer . hasMoreTokens ( ) ) { read = reader . readLine ( ) ; if ( read = = null | | read . equals ( " " ) ) return " -1 " ; tokenizer = new StringTokenizer ( read ) ; } return tokenizer . nextToken ( ) ; } private static int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } private static long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } } import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; public class Main { static int X = 0 ; static int Y = 0 ; static int Z = 0 ; static int answer = 0 ; public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( new InputStreamReader ( System . in ) ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; sc . close ( ) ; setNumber ( K , S ) ; execute ( K , S ) ; System . out . println ( answer ) ; } static void setNumber ( int k , int s ) { if ( k > = s ) { X = s ; return ; } else { X = k ; s = s - k ; if ( k > = s ) { Y = s ; return ; } else { Y = k ; Z = s - k ; return ; } } } static void execute ( int K , int S ) { int check = 0 ; int x = X ; int y = Y ; int z = Z ; for ( ; x > = Math . ceil ( ( double ) S / 3 ) ; x -- ) { for ( ; y > = z ; y -- ) { if ( x > = y ) { check = checkCombi ( x , y , z ) ; if ( check = = 0 ) { answer + = 6 ; } else if ( check = = 2 ) { answer + = 3 ; } else if ( check = = 3 ) { answer + = 1 ; } } z + + ; } Y + + ; y = Y ; z = Z ; } } static int checkCombi ( int x , int y , int z ) { if ( ( x = = y ) & & ( x = = z ) ) { return 3 ; } else if ( ( x = = y ) | | ( x = = z ) | | ( y = = z ) ) { return 2 ; } else { return 0 ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; for ( int i = 0 ; i < N ; i + + ) { if ( sc . next ( ) . equals ( " Y " ) ) { System . out . println ( " Four " ) ; break ; } if ( i = = N - 1 ) { System . out . println ( " Three " ) ; } } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { SumOfThreeIntegers solver = new SumOfThreeIntegers ( ) ; solver . readInput ( ) ; solver . solve ( ) ; solver . writeOutput ( ) ; } static class SumOfThreeIntegers { private int k ; private int s ; private Scanner scanner ; private int output ; public SumOfThreeIntegers ( ) { scanner = new Scanner ( System . in ) ; output = 0 ; } public void readInput ( ) { k = scanner . nextInt ( ) ; s = scanner . nextInt ( ) ; } public void solve ( ) { for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { if ( s - x - y < = k & & s - x - y > = 0 ) { output + + ; } } } } public void writeOutput ( ) { System . out . print ( output ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; String ans = " No " ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } if ( c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 1 ] [ 1 ] & & c [ 1 ] [ 2 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 2 ] [ 1 ] ) { if ( c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] & & c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 2 ] [ 0 ] ) { if ( c [ 2 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 1 ] [ 1 ] & & c [ 2 ] [ 1 ] - c [ 1 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 1 ] [ 2 ] ) { if ( c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 0 ] [ 1 ] & & c [ 1 ] [ 1 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 0 ] [ 2 ] ) { ans = " Yes " ; } } } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { static int MOD = 1000000007 ; public static void main ( String [ ] args ) { int ans = 1 ; Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int [ ] p = new int [ n ] ; int [ ] min = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = sc . nextInt ( ) ; } min [ 0 ] = p [ 0 ] ; for ( int i = 1 ; i < n ; i + + ) { min [ i ] = Math . min ( min [ i - 1 ] , p [ i ] ) ; } for ( int i = 1 ; i < n ; i + + ) { if ( p [ i ] < min [ i - 1 ] ) ans + + ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) , s = sc . nextInt ( ) , ret = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { if ( s - x - y < = k & & s - x - y > = 0 ) ret + + ; } } System . out . println ( ret ) ; sc . close ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { if ( ( S - i - j ) < = K & & 0 < = ( S - i - j ) ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = Integer . parseInt ( sc . next ( ) ) ; int s = Integer . parseInt ( sc . next ( ) ) ; int ans = 0 ; for ( int x = 0 ; x < = k ; x + + ) for ( int y = 0 ; y < = k ; y + + ) if ( s - x - y > = 0 & & s - x - y < = k ) ans + + ; System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n1 = sc . nextInt ( ) ; int n2 = sc . nextInt ( ) ; int n3 = sc . nextInt ( ) ; int n4 = sc . nextInt ( ) ; List < Integer > list = new ArrayList < Integer > ( ) ; list . add ( n1 ) ; list . add ( n2 ) ; list . add ( n3 ) ; list . add ( n4 ) ; if ( list . contains ( 1 ) & & list . contains ( 9 ) & & list . contains ( 7 ) & & list . contains ( 4 ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a1 ; int a2 ; int a3 ; int HUNDRED = 100 ; boolean flag = false ; int c [ ] [ ] = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } for ( a1 = 0 ; a1 < = HUNDRED & & ! flag ; a1 + + ) { int b1 = c [ 0 ] [ 0 ] - a1 ; int b2 = c [ 0 ] [ 1 ] - a1 ; int b3 = c [ 0 ] [ 2 ] - a1 ; for ( a2 = 0 ; a2 < = HUNDRED & & ! flag ; a2 + + ) { if ( c [ 1 ] [ 0 ] = = a2 + b1 & & c [ 1 ] [ 1 ] = = a2 + b2 & & c [ 1 ] [ 2 ] = = a2 + b3 ) { for ( a3 = 0 ; a3 < = HUNDRED & & ! flag ; a3 + + ) { if ( c [ 2 ] [ 0 ] = = a3 + b1 & & c [ 2 ] [ 1 ] = = a3 + b2 & & c [ 2 ] [ 2 ] = = a3 + b3 ) { flag = true ; } } } } } if ( flag ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String str = " " ; for ( int i = 0 ; i < n ; i + + ) { str + = sc . next ( ) ; } String ans = " Three " ; if ( str . contains ( " G " ) & & str . contains ( " W " ) & & str . contains ( " Y " ) & & str . contains ( " P " ) ) { ans = " Four " ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int count = 1 ; int min = sc . nextInt ( ) ; for ( int i = 1 ; i < n ; i + + ) { int x = sc . nextInt ( ) ; if ( min > = x ) { count + + ; min = x ; } } sc . close ( ) ; System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int max = sc . nextInt ( ) ; int sum = sc . nextInt ( ) ; int ct = 0 ; for ( int i = 0 ; i < = max ; i + + ) { for ( int j = 0 ; j < = max ; j + + ) { int tmp = sum - i - j ; if ( tmp < = max & & tmp > = 0 ) ct + + ; } } System . out . println ( ct ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskC solver = new TaskC ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskC { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) for ( int j = 0 ; j < 3 ; j + + ) c [ i ] [ j ] = in . nextInt ( ) ; int [ ] a = new int [ 3 ] ; int [ ] b = new int [ 3 ] ; a [ 0 ] = 0 ; b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] ; b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] ; b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] ; a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] ; a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] ; String ans = " Yes " ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( c [ i ] [ j ] ! = a [ i ] + b [ j ] ) { ans = " No " ; break ; } } } out . println ( ans ) ; } } } import java . io . IOException ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner scanner = new Scanner ( System . in ) ; int k = scanner . nextInt ( ) + 1 ; int s = scanner . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < k ; i + + ) { for ( int j = 0 ; j < k ; j + + ) { int a = s - ( i + j ) ; if ( a < = k - 1 & & a > = 0 ) { count + + ; } } } System . out . println ( count ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; A _ Beginning solver = new A _ Beginning ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class A _ Beginning { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { int [ ] a = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) { a [ i ] = in . nextInt ( ) ; } int [ ] b = { 1 , 4 , 7 , 9 } ; Arrays . sort ( a ) ; out . println ( Arrays . equals ( a , b ) ? " YES " : " NO " ) ; } } static class FastScanner { private BufferedReader in ; private StringTokenizer st ; public FastScanner ( InputStream stream ) { in = new BufferedReader ( new InputStreamReader ( stream ) ) ; } public String next ( ) { while ( st = = null | | ! st . hasMoreTokens ( ) ) { try { String rl = in . readLine ( ) ; if ( rl = = null ) { return null ; } st = new StringTokenizer ( rl ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } } import java . util . * ; public class Main { public static int p [ ] ; public static int min = 2 * 10 * 10 * 10 * 10 * 10 + 1 ; private static boolean judge ( int i ) { if ( min > p [ i - 1 ] ) { min = p [ i - 1 ] ; return true ; } else { return false ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; p = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = sc . nextInt ( ) ; } int count = 0 ; for ( int i = 1 ; i < = n ; i + + ) { if ( judge ( i ) ) { count + + ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { try ( Scanner in = new Scanner ( System . in ) ) { int K = in . nextInt ( ) ; int S = in . nextInt ( ) ; int count = 0 ; for ( int X = 0 ; X < = K ; X + + ) { for ( int Y = 0 ; Y < = K ; Y + + ) { int Z = S - ( X + Y ) ; if ( ! ( Z > = 0 & & Z < = K ) ) { continue ; } count + + ; } } System . out . println ( count ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int answer = 0 ; for ( int x = 0 ; x < = k ; x + + ) { if ( x > s ) { break ; } for ( int y = 0 ; y < = k ; y + + ) { if ( x + y > s ) { break ; } else { if ( x + y + k > = s ) { answer + + ; } } } } System . out . println ( answer ) ; } } import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; boolean [ ] k = new boolean [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) { int n = sc . nextInt ( ) ; if ( n = = 1 ) k [ 0 ] = true ; if ( n = = 9 ) k [ 1 ] = true ; if ( n = = 7 ) k [ 2 ] = true ; if ( n = = 4 ) k [ 3 ] = true ; } boolean ans = true ; for ( int i = 0 ; i < 4 ; i + + ) { ans & = k [ i ] ; } System . out . println ( ans ? " YES " : " NO " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) arr [ i ] = sc . nextInt ( ) ; int cnt = 1 ; int min = arr [ 0 ] ; for ( int i = 1 ; i < n ; i + + ) { if ( min > arr [ i ] ) cnt + + ; min = Math . min ( min , arr [ i ] ) ; } System . out . println ( cnt ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int ans = 0 ; int sum = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { sum = S - ( i + j ) ; if ( 0 < = sum & & sum < = K ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int cnt = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { if ( s - x - y > = 0 & & s - x - y < = k ) cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = k & & i < = t ; i + + ) { for ( int j = 0 ; j < = k & & i + j < = t ; j + + ) { if ( t - ( i + j ) < = k ) count + + ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] a = new int [ 3 ] ; int [ ] b = new int [ 3 ] ; a [ 0 ] = 0 ; for ( int i = 0 ; i < 3 ; i + + ) b [ i ] = c [ 0 ] [ i ] - a [ 0 ] ; for ( int i = 0 ; i < 3 ; i + + ) a [ i ] = c [ i ] [ 0 ] - b [ 0 ] ; boolean good = true ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( a [ i ] + b [ j ] ! = c [ i ] [ j ] ) good = false ; } } System . out . println ( good ? " Yes " : " No " ) ; } } import java . util . Scanner ; import java . lang . Math ; import java . util . ArrayList ; import java . util . List ; class Main { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; List < Integer > n = new ArrayList < > ( ) ; int [ ] n1 = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) n1 [ i ] = stdIn . nextInt ( ) ; for ( int i = 0 ; i < 4 ; i + + ) n . add ( n1 [ i ] ) ; if ( n . contains ( 1 ) ) { int b = n . indexOf ( 1 ) ; n . remove ( b ) ; } if ( n . contains ( 9 ) ) { int c = n . indexOf ( 9 ) ; n . remove ( c ) ; } if ( n . contains ( 7 ) ) { int d = n . indexOf ( 7 ) ; n . remove ( d ) ; } if ( n . contains ( 4 ) ) { int e = n . indexOf ( 4 ) ; n . remove ( e ) ; } if ( n . isEmpty ( ) = = true ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } import java . util . * ; class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int map [ ] [ ] = new int [ 3 ] [ 3 ] ; for ( int h = 0 ; h < 3 ; h + + ) { for ( int w = 0 ; w < 3 ; w + + ) { map [ h ] [ w ] = sc . nextInt ( ) ; } } int dw1 = map [ 0 ] [ 1 ] - map [ 0 ] [ 0 ] ; if ( dw1 ! = map [ 1 ] [ 1 ] - map [ 1 ] [ 0 ] | | dw1 ! = map [ 2 ] [ 1 ] - map [ 2 ] [ 0 ] ) { answer ( false ) ; return ; } int dw2 = map [ 0 ] [ 2 ] - map [ 0 ] [ 1 ] ; if ( dw2 ! = map [ 1 ] [ 2 ] - map [ 1 ] [ 1 ] | | dw2 ! = map [ 2 ] [ 2 ] - map [ 2 ] [ 1 ] ) { answer ( false ) ; return ; } int dh1 = map [ 1 ] [ 0 ] - map [ 0 ] [ 0 ] ; if ( dh1 ! = map [ 1 ] [ 1 ] - map [ 0 ] [ 1 ] | | dh1 ! = map [ 1 ] [ 2 ] - map [ 0 ] [ 2 ] ) { answer ( false ) ; return ; } int dh2 = map [ 2 ] [ 0 ] - map [ 1 ] [ 0 ] ; if ( dh2 ! = map [ 2 ] [ 1 ] - map [ 1 ] [ 1 ] | | dh2 ! = map [ 2 ] [ 2 ] - map [ 1 ] [ 2 ] ) { answer ( false ) ; return ; } answer ( true ) ; } private static void answer ( boolean ans ) { if ( ans ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] num = new int [ 10 ] ; for ( int i = 0 ; i < 4 ; i + + ) { int n = sc . nextInt ( ) ; num [ n ] + + ; } if ( num [ 1 ] = = 1 & & num [ 9 ] = = 1 & & num [ 7 ] = = 1 & & num [ 4 ] = = 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] g = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { g [ i ] [ 0 ] = sc . nextInt ( ) ; g [ i ] [ 1 ] = sc . nextInt ( ) ; g [ i ] [ 2 ] = sc . nextInt ( ) ; } boolean ans = true ; for ( int i = 0 ; i < 2 ; i + + ) { for ( int j = 0 ; j < 2 ; j + + ) { if ( g [ i ] [ j ] - g [ i + 1 ] [ j ] ! = g [ i ] [ j + 1 ] - g [ i + 1 ] [ j + 1 ] ) { ans = false ; break ; } if ( g [ i ] [ j ] - g [ i ] [ j + 1 ] ! = g [ i + 1 ] [ j ] - g [ i + 1 ] [ j + 1 ] ) { ans = false ; break ; } } } if ( ans ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; sc . close ( ) ; } } import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; long K = sc . nextInt ( ) ; long S = sc . nextInt ( ) ; long res = 0 ; for ( long i = Math . min ( K , S ) ; i > = 0 ; i -- ) { long v = S - i ; if ( v < K ) res + = ( v + 1 ) ; else if ( v = = K ) res + = ( K + 1 ) ; else if ( v < = 2 * K ) { long a = v - K ; res + = K - a + 1 ; } } System . out . println ( res ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; C solver = new C ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class C { static long inf = ( long ) 1e17 ; public void solve ( int testNumber , Scanner in , PrintWriter out ) { int n = Integer . parseInt ( in . next ( ) ) ; int [ ] p = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = Integer . parseInt ( in . next ( ) ) ; } long min = inf ; int ans = 0 ; for ( int i = 0 ; i < n ; i + + ) { if ( p [ i ] < min ) { min = p [ i ] ; ans + + ; } } out . println ( ans ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . HashMap ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } public void solve ( ) { Scanner scan = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int a1 = scan . nextInt ( ) ; int a2 = scan . nextInt ( ) ; int a3 = scan . nextInt ( ) ; int a4 = scan . nextInt ( ) ; boolean [ ] digits = new boolean [ 10 ] ; digits [ a1 ] = true ; digits [ a2 ] = true ; digits [ a3 ] = true ; digits [ a4 ] = true ; if ( digits [ 1 ] & & digits [ 4 ] & & digits [ 7 ] & & digits [ 9 ] ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < 4 ; i + + ) { list . add ( in . nextInt ( ) ) ; } boolean one = list . contains ( 1 ) , seven = list . contains ( 7 ) , nine = list . contains ( 9 ) , four = list . contains ( 4 ) ; if ( one & & seven & & nine & & four ) { System . out . println ( " YES " ) ; return ; } System . out . println ( " NO " ) ; } } import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; sc . close ( ) ; long count = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { int z = S - i - j ; if ( z > = 0 & & z < = K ) count + + ; } } System . out . println ( count ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; import java . math . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int k = Integer . parseInt ( str [ 0 ] ) ; int s = Integer . parseInt ( str [ 1 ] ) ; int cnt = 0 ; int x = 0 ; int y = 0 ; int z = 0 ; for ( x = k ; x > - 1 ; -- x ) { int rest = s - x ; if ( rest > 2 * k | | rest < 0 ) continue ; if ( rest > k ) { cnt + = - ( rest - 2 * k ) + 1 ; } else { cnt + = rest + 1 ; } } sb . append ( cnt ) ; System . out . println ( sb ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Set < String > colors = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i + + ) { colors . add ( sc . next ( ) ) ; } if ( colors . size ( ) = = 4 ) { System . out . println ( " Four " ) ; } else { System . out . println ( " Three " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; int check = 0 ; int [ ] a = new int [ 9 ] ; for ( int i = 0 ; i < a . length ; + + i ) { a [ i ] = scn . nextInt ( ) ; } int x1 = 0 ; int x2 = 0 ; int y1 = 0 ; int y2 = 0 ; x1 = a [ 3 ] - a [ 0 ] ; x2 = a [ 6 ] - a [ 3 ] ; if ( a [ 4 ] ! = a [ 1 ] + x1 ) { check = 1 ; } if ( a [ 5 ] ! = a [ 2 ] + x1 ) { check = 1 ; } if ( a [ 7 ] ! = a [ 4 ] + x2 ) { check = 1 ; } if ( a [ 8 ] ! = a [ 5 ] + x2 ) { check = 1 ; } if ( check = = 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; ArrayList < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i + + ) { String s = scan . next ( ) ; if ( ! list . contains ( s ) ) list . add ( s ) ; } if ( list . size ( ) = = 4 ) System . out . println ( " Four " ) ; else System . out . println ( " Three " ) ; scan . close ( ) ; } } import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int number [ ] = new int [ n ] ; int mini = Integer . MAX _ VALUE ; int count = 0 ; for ( int i = 0 ; i < n ; i + + ) number [ i ] = scan . nextInt ( ) ; scan . close ( ) ; for ( int j = 0 ; j < n ; j + + ) { mini = Math . min ( mini , number [ j ] ) ; if ( mini > = number [ j ] ) count + + ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int p [ ] = new int [ n ] ; int max = 999999 ; int tmp ; int c = 0 ; for ( int i = 0 ; i < n ; i + + ) { tmp = sc . nextInt ( ) ; if ( tmp < max ) { max = tmp ; c + + ; } } System . out . println ( c ) ; return ; } } import java . util . * ; import java . math . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > plist = new ArrayList < > ( ) ; plist . add ( sc . nextInt ( ) ) ; plist . add ( sc . nextInt ( ) ) ; plist . add ( sc . nextInt ( ) ) ; plist . add ( sc . nextInt ( ) ) ; Collections . sort ( plist ) ; if ( plist . get ( 0 ) = = 1 & & plist . get ( 1 ) = = 4 & & plist . get ( 2 ) = = 7 & & plist . get ( 3 ) = = 9 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int k = scanner . nextInt ( ) ; int s = scanner . nextInt ( ) ; int ans = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = x ; y + + ) { for ( int z = 0 ; z < = y ; z + + ) { if ( x + y + z = = s ) { if ( x = = y & & y = = z ) ans + + ; else if ( x = = y | | y = = z | | x = = z ) ans + = 3 ; else ans + = 6 ; } } } } System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = k ; + + x ) { for ( int y = 0 ; y < = k ; + + y ) { int z = s - x - y ; if ( 0 < = z & & z < = k ) { count + + ; } } } System . out . println ( count ) ; bw . flush ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int a [ ] [ ] = new int [ 3 ] [ 3 ] ; boolean flag = true ; for ( int j = 0 ; j < 3 ; j + + ) { for ( int i = 0 ; i < 3 ; i + + ) { a [ i ] [ j ] = in . nextInt ( ) ; } } int sa1 = a [ 0 ] [ 1 ] - a [ 0 ] [ 0 ] ; int sa2 = a [ 1 ] [ 1 ] - a [ 1 ] [ 0 ] ; int sa3 = a [ 2 ] [ 1 ] - a [ 2 ] [ 0 ] ; int sa21 = a [ 0 ] [ 2 ] - a [ 0 ] [ 0 ] ; int sa22 = a [ 1 ] [ 2 ] - a [ 1 ] [ 0 ] ; int sa23 = a [ 2 ] [ 2 ] - a [ 2 ] [ 0 ] ; int sa31 = a [ 0 ] [ 2 ] - a [ 0 ] [ 1 ] ; int sa32 = a [ 1 ] [ 2 ] - a [ 1 ] [ 1 ] ; int sa33 = a [ 2 ] [ 2 ] - a [ 2 ] [ 1 ] ; if ( sa1 = = sa2 & & sa1 = = sa3 ) { if ( sa21 = = sa22 & & sa21 = = sa23 ) { if ( sa31 = = sa32 & & sa31 = = sa33 ) { flag = true ; } else { flag = false ; } } else { flag = false ; } } else { flag = false ; } if ( flag ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] P = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) P [ i ] = sc . nextInt ( ) ; int min = 999999999 ; int cnt = 0 ; for ( int i = 0 ; i < N ; i + + ) { if ( min > = P [ i ] ) { cnt + + ; min = P [ i ] ; } } System . out . println ( cnt ) ; } } import java . io . File ; import java . io . IOException ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int ans = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { int z = S - x - y ; if ( z > = 0 & & z < = K ) ans + + ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] p = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = sc . nextInt ( ) ; } int min = 1000000 ; int c = 0 ; for ( int i = 0 ; i < n ; i + + ) { if ( p [ i ] < min ) { c + + ; min = p [ i ] ; } } System . out . println ( c ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; class Main { public static void main ( final String [ ] args ) throws Exception { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; ) { List < String > inputString = Arrays . asList ( br . readLine ( ) . split ( " " ) ) ; List < Integer > numbers = new ArrayList < > ( ) ; for ( String str : inputString ) { numbers . add ( Integer . parseInt ( str ) ) ; } int ans = 0 ; for ( int i = 0 ; i < = numbers . get ( 0 ) ; i + + ) { for ( int j = 0 ; j < = numbers . get ( 0 ) ; j + + ) { int k = numbers . get ( 1 ) - i - j ; if ( 0 < = k & & k < = numbers . get ( 0 ) ) { ans + + ; } } } System . out . println ( ans ) ; } catch ( IOException | NumberFormatException e ) { e . printStackTrace ( ) ; System . exit ( 0 ) ; } catch ( final Exception e ) { e . printStackTrace ( ) ; System . exit ( 0 ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; boolean gg = true ; Integer [ ] array = new Integer [ n ] ; int a = 1 ; int b = 0 ; for ( int i = 0 ; i < n ; i + + ) { array [ i ] = s . nextInt ( ) ; if ( i ! = 0 ) { if ( array [ i ] < b ) { b = array [ i ] ; a + + ; } else { } } else { b = array [ i ] ; } } System . out . print ( a ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String W = in . readLine ( ) ; int N = Integer . parseInt ( W ) ; W = in . readLine ( ) ; String [ ] Ws = W . split ( " " ) ; int [ ] P = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = Integer . parseInt ( Ws [ i ] ) ; } int ans = 0 ; int Pj = Integer . MAX _ VALUE ; for ( int i = 0 ; i < N ; i + + ) { if ( P [ i ] < = Pj ) { ans + + ; Pj = P [ i ] ; } } System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; class Main { Scanner sc ; int N ; int [ ] P ; private void calc ( ) { sc = new Scanner ( new BufferedInputStream ( System . in ) ) ; int N = sc . nextInt ( ) ; P = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) P [ i ] = Integer . parseInt ( sc . next ( ) ) ; int c = 0 ; int min = Integer . MAX _ VALUE ; for ( int i = 0 ; i < N ; i + + ) { if ( min > P [ i ] ) c + + ; min = Math . min ( min , P [ i ] ) ; } System . out . println ( c ) ; } public static void main ( String [ ] args ) { new Main ( ) . calc ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int min = Integer . MAX _ VALUE ; int i ; int temp ; long ans = 0 ; for ( i = 0 ; i < n ; i + + ) { temp = scan . nextInt ( ) ; if ( temp < min ) { min = temp ; ans + + ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int count = 0 ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( 0 < = z & & z < = k ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] permutations = new int [ n + 1 ] ; int min = n ; int [ ] mins = new int [ n + 1 ] ; for ( int i = 1 ; i < = n ; i + + ) { permutations [ i ] = sc . nextInt ( ) ; if ( i = = 1 ) { min = permutations [ 1 ] ; } min = Math . min ( min , permutations [ i ] ) ; mins [ i ] = min ; } int ans = 0 ; for ( int i = 1 ; i < = n ; i + + ) { if ( permutations [ i ] = = mins [ i ] ) { ans + + ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int ans = 0 ; int m = 1000000 ; for ( int i = 0 ; i < n ; i + + ) { int p = sc . nextInt ( ) ; m = Math . min ( m , p ) ; if ( p = = m ) ans + + ; } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; ArrayList < Integer > numList = new ArrayList < > ( ) ; int ans = 0 ; for ( int i = 0 ; i < N ; i + + ) { numList . add ( sc . nextInt ( ) ) ; } int min = numList . get ( 0 ) ; for ( int i = 0 ; i < N ; i + + ) { if ( numList . get ( i ) < min ) { min = numList . get ( i ) ; } if ( numList . get ( i ) < = min ) { ans + + ; } } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int count = sc . nextInt ( ) ; int answer = 1 ; int before = sc . nextInt ( ) ; for ( int i = 1 ; i < count ; i + + ) { int after = sc . nextInt ( ) ; if ( before > = after ) { answer + + ; before = after ; } } System . out . println ( answer ) ; } } import java . util . * ; import static java . lang . Math . * ; import java . math . BigInteger ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String result = " Three " ; for ( int i = 0 ; i < n ; i + + ) { String s = sc . next ( ) ; if ( s . equals ( " Y " ) ) result = " Four " ; } System . out . println ( result ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = 4 ; int obj [ ] = { 1 , 7 , 9 , 4 } ; int arr [ ] = new int [ 4 ] ; boolean judge [ ] = new boolean [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) { arr [ i ] = scan . nextInt ( ) ; for ( int j = 0 ; j < 4 ; j + + ) { if ( arr [ i ] = = obj [ j ] ) { judge [ j ] = true ; break ; } } } boolean flag = true ; for ( int j = 0 ; j < 4 ; j + + ) { if ( ! judge [ j ] ) { System . out . println ( " NO " ) ; flag = false ; break ; } } if ( flag ) { System . out . println ( " YES " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int [ ] p = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int result = 1 ; int min = p [ 0 ] ; for ( int i = 1 ; i < p . length ; i + + ) { if ( p [ i ] < = min ) { result + + ; } min = Math . min ( min , p [ i ] ) ; } System . out . println ( result ) ; sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; public class Main { static int n ; static ArrayList < ArrayList < Integer > > edge ; static boolean used [ ] ; static boolean flag = false ; static int ans ; public static void main ( String args [ ] ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; n = Integer . parseInt ( br . readLine ( ) ) ; String str [ ] = br . readLine ( ) . split ( " " ) ; int a [ ] = new int [ n ] ; int min = Integer . MAX _ VALUE ; for ( int i = 0 ; i < n ; i + + ) { a [ i ] = Integer . parseInt ( str [ i ] ) ; } int ans = 0 ; for ( int i = 0 ; i < n ; i + + ) { min = Math . min ( a [ i ] , min ) ; if ( min < a [ i ] ) { } else { ans + + ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = Integer . parseInt ( sc . next ( ) ) ; int S = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; for ( int x = 0 ; x < = K & & x < = S ; x + + ) { for ( int y = 0 ; y < = K & & y < = S ; y + + ) { if ( ( x + y ) < = S & & S - ( x + y ) < = K ) { count + + ; } } } System . out . print ( count ) ; } } import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] P = new int [ N ] ; for ( int i = 0 ; i < N ; + + i ) { P [ i ] = sc . nextInt ( ) ; } int count = 0 ; int Pj = P [ 0 ] ; for ( int i = 0 ; i < N ; + + i ) { if ( P [ i ] < = Pj ) { + + count ; Pj = P [ i ] ; } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int k = in . nextInt ( ) ; int s = in . nextInt ( ) ; int answer = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = x ; y < = k ; y + + ) { int z = s - y - x ; if ( y < = z & & z < = k ) { if ( x = = y & & y = = z & & x = = z ) { answer + = 1 ; } else if ( x = = y | | y = = z | | x = = z ) { answer + = 3 ; } else { answer + = 6 ; } } } } System . out . println ( answer ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] [ ] dx = new int [ 3 ] [ 2 ] ; int [ ] [ ] dy = new int [ 2 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { dx [ i ] [ 0 ] = ( c [ i ] [ 0 ] - c [ i ] [ 1 ] ) ; dx [ i ] [ 1 ] = ( c [ i ] [ 1 ] - c [ i ] [ 2 ] ) ; } for ( int j = 0 ; j < 3 ; j + + ) { dy [ 0 ] [ j ] = Math . abs ( c [ 0 ] [ j ] - c [ 1 ] [ j ] ) ; dy [ 1 ] [ j ] = Math . abs ( c [ 1 ] [ j ] - c [ 2 ] [ j ] ) ; } for ( int i = 0 ; i < 2 ; i + + ) { if ( dy [ i ] [ 0 ] ! = dy [ i ] [ 1 ] | | dy [ i ] [ 0 ] ! = dy [ i ] [ 2 ] ) { System . out . println ( " No " ) ; return ; } } for ( int j = 0 ; j < 2 ; j + + ) { if ( dx [ 0 ] [ j ] ! = dx [ 1 ] [ j ] | | dx [ 0 ] [ j ] ! = dx [ 2 ] [ j ] ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { int [ ] [ ] grid = new int [ 3 ] [ 3 ] ; Scanner sc = new Scanner ( System . in ) ; for ( int row = 0 ; row < 3 ; row + + ) { for ( int col = 0 ; col < 3 ; col + + ) { grid [ row ] [ col ] = sc . nextInt ( ) ; } } int aDiff1 = grid [ 0 ] [ 0 ] - grid [ 0 ] [ 1 ] ; int aDiff2 = grid [ 0 ] [ 1 ] - grid [ 0 ] [ 2 ] ; int bDiff1 = grid [ 0 ] [ 0 ] - grid [ 1 ] [ 0 ] ; int bDiff2 = grid [ 1 ] [ 0 ] - grid [ 2 ] [ 0 ] ; if ( ( grid [ 1 ] [ 0 ] - aDiff1 ! = grid [ 1 ] [ 1 ] ) | | ( grid [ 1 ] [ 1 ] - aDiff2 ! = grid [ 1 ] [ 2 ] ) | | ( grid [ 2 ] [ 0 ] - aDiff1 ! = grid [ 2 ] [ 1 ] ) | | ( grid [ 2 ] [ 1 ] - aDiff2 ! = grid [ 2 ] [ 2 ] ) | | ( grid [ 0 ] [ 1 ] - bDiff1 ! = grid [ 1 ] [ 1 ] ) | | ( grid [ 1 ] [ 1 ] - bDiff2 ! = grid [ 2 ] [ 1 ] ) | | ( grid [ 0 ] [ 2 ] - bDiff1 ! = grid [ 1 ] [ 2 ] ) | | ( grid [ 1 ] [ 2 ] - bDiff2 ! = grid [ 2 ] [ 2 ] ) ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int Z = 0 ; int count = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { Z = S - i - j ; if ( Z > = 0 & & Z < = K ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; for ( int i = 1 ; i < n ; i + + ) { s + = sc . next ( ) ; } int bf = s . length ( ) ; s = s . replace ( " Y " , " " ) ; if ( s . length ( ) = = bf ) { System . out . println ( " Three " ) ; } else { System . out . println ( " Four " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } if ( c [ 1 ] [ 1 ] = = c [ 0 ] [ 1 ] + c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] & & c [ 1 ] [ 2 ] = = c [ 1 ] [ 0 ] + c [ 0 ] [ 2 ] - c [ 0 ] [ 0 ] & & c [ 2 ] [ 1 ] = = c [ 2 ] [ 0 ] + c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] & & c [ 2 ] [ 2 ] = = c [ 2 ] [ 0 ] + c [ 0 ] [ 2 ] - c [ 0 ] [ 0 ] ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } public static int lcm ( int x , int y ) { return x * y / gcd ( x , y ) ; } public static int gcd ( int x , int y ) { if ( x < y ) return gcd ( y , x ) ; if ( y = = 0 ) return x ; return gcd ( y , x % y ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int X , Y , Z ; int count = 0 ; for ( X = 0 ; X < = K ; X + + ) { for ( Y = 0 ; Y < = K ; Y + + ) { if ( X + Y < = S & & S - ( X + Y ) < = K ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int cnt = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( 0 < = z & & z < = k ) { cnt + + ; } } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner stdIn = new Scanner ( System . in ) ; int N = stdIn . nextInt ( ) ; int P [ ] = new int [ N ] ; int min = N * 2 , ans = 0 ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = stdIn . nextInt ( ) ; if ( P [ i ] < = min ) { min = P [ i ] ; ans + + ; } } System . out . println ( ans ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Main { static Scanner sc = new Scanner ( System . in ) ; static int [ ] N = new int [ 4 ] ; static { Arrays . setAll ( N , i - > sc . nextInt ( ) ) ; } public static void main ( String [ ] args ) { Arrays . sort ( N ) ; if ( Arrays . toString ( N ) . equals ( " [ 1 , 4 , 7 , 9 ] " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Integer n = sc . nextInt ( ) ; int [ ] array = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { array [ i ] = sc . nextInt ( ) ; } int min = Integer . MAX _ VALUE ; int ans = 0 ; for ( int i = 0 ; i < n ; i + + ) { if ( array [ i ] < = min ) { ans + + ; min = array [ i ] ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { if ( S - i - j > = 0 & & S - i - j < = 3 * K & & S - i - j < = K ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int k = scan . nextInt ( ) ; int s = scan . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { int temp = s - i - j ; if ( k > = temp & & temp > = 0 ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; HashSet < Character > hashSet = new HashSet < > ( ) ; for ( int i = 0 ; i < N ; i + + ) { String S = scanner . next ( ) ; hashSet . add ( S . charAt ( 0 ) ) ; } if ( hashSet . size ( ) = = 3 ) { System . out . println ( " Three " ) ; } else { System . out . println ( " Four " ) ; } } } import java . util . Scanner ; class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { int last = s - i - j ; if ( last > = 0 & & last < = k ) cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int k = scan . nextInt ( ) ; int s = scan . nextInt ( ) ; if ( k > = s ) { System . out . println ( ( s + 2 ) * ( s + 1 ) / 2 ) ; } else { int ans = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( z > = 0 & & z < = k ) { ans + + ; } } } System . out . println ( ans ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int N = scn . nextInt ( ) ; int min = N + 1 ; int ans = 0 ; for ( int i = 0 ; i < N ; i + + ) { int a = scn . nextInt ( ) ; if ( min > = a ) { min = a ; ans + + ; } } System . out . println ( ans ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; long ans = 2 ; for ( int i = 0 ; i < x ; i + + ) { ans = ans * 2 + 2 ; } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int P [ ] = new int [ N ] ; int min = 0 ; int answer = 0 ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = sc . nextInt ( ) ; } min = P [ 0 ] ; answer = answer + 1 ; for ( int i = 1 ; i < N ; i + + ) { if ( P [ i ] < min ) { answer = answer + 1 ; min = P [ i ] ; } } System . out . println ( answer ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] grid = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { grid [ i ] [ j ] = sc . nextInt ( ) ; } } boolean b = true ; for ( int i = 0 ; i < 3 ; i + + ) { int x = 0 ; int y = 0 ; for ( int j = 0 ; j < 3 ; j + + ) { int bX = grid [ j ] [ i ] - grid [ j ] [ ( ( i + 1 ) % 3 ) ] ; int bY = grid [ i ] [ j ] - grid [ ( ( i + 1 ) % 3 ) ] [ j ] ; if ( j = = 0 ) { x = bX ; y = bY ; } else { b & = x = = bX ; b & = y = = bY ; } if ( ! b ) break ; } if ( ! b ) break ; } System . out . println ( b ? " Yes " : " No " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; if ( S . contains ( " 1 " ) & & S . contains ( " 9 " ) & & S . contains ( " 7 " ) & & S . contains ( " 4 " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) throws IOException { StringTokenizer st ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String temp = br . readLine ( ) ; int n = Integer . parseInt ( temp ) ; temp = br . readLine ( ) ; st = new StringTokenizer ( temp , " " ) ; int [ ] a = new int [ n ] ; int j = 0 ; int min = n + 1 ; int ans = 0 ; while ( st . hasMoreTokens ( ) ) { a [ j ] = Integer . parseInt ( st . nextToken ( ) ) ; if ( a [ j ] < min ) { min = a [ j ] ; ans + + ; } j + + ; } br . close ( ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { static public void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long k = sc . nextInt ( ) ; long s = sc . nextInt ( ) ; long count = 0 ; for ( long x = 0 ; x < = k ; x + + ) { long s1 = s - x ; if ( s1 < 0 ) break ; else if ( s1 > = 0 & & s1 < = k ) { count + = s1 + 1 ; } else if ( k < s1 & & s1 < = 2 * k ) { count + = 2 * k - s1 + 1 ; } } System . out . println ( count ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] [ ] d = new int [ 3 ] [ 2 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 2 ; j + + ) { d [ i ] [ j ] = c [ i ] [ j + 1 ] - c [ i ] [ j ] ; } } if ( d [ 0 ] [ 0 ] = = d [ 1 ] [ 0 ] & & d [ 1 ] [ 0 ] = = d [ 2 ] [ 0 ] & & d [ 0 ] [ 1 ] = = d [ 1 ] [ 1 ] & & d [ 1 ] [ 1 ] = = d [ 2 ] [ 1 ] ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int ret = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { int t = s - i - j ; if ( 0 < = t & & t < = k ) ret + + ; } } System . out . println ( ret ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int ans = 0 ; for ( int X = 0 ; X < = K ; X + + ) { for ( int Y = 0 ; Y < = K ; Y + + ) { int Z = S - X - Y ; if ( Z > = 0 & & Z < = K ) ans + + ; } } System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( in . readLine ( ) ) ; String [ ] s = in . readLine ( ) . split ( " " ) ; boolean yellow _ flg = false ; for ( int i = 0 ; i < n ; i + + ) { if ( s [ i ] . charAt ( 0 ) = = ' Y ' ) yellow _ flg = true ; } System . out . println ( yellow _ flg = = true ? " Four " : " Three " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int k = in . nextInt ( ) ; int s = in . nextInt ( ) ; int res = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { int z = s - i - j ; if ( z > = 0 & & z < = k ) { res + + ; } } } System . out . println ( res ) ; } static class FastScanner { BufferedReader br ; StringTokenizer st ; public FastScanner ( InputStream in ) { br = new BufferedReader ( new InputStreamReader ( in ) ) ; st = new StringTokenizer ( " " ) ; } public String next ( ) throws IOException { if ( ! st . hasMoreTokens ( ) ) { st = new StringTokenizer ( br . readLine ( ) ) ; return next ( ) ; } return st . nextToken ( ) ; } public int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { int z = S - x - y ; if ( 0 < = z & & z < = K ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] input = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { input [ i ] = sc . nextInt ( ) ; } int min = Integer . MAX _ VALUE ; int res = 0 ; for ( int i = 0 ; i < input . length ; i + + ) { if ( input [ i ] < min ) { min = input [ i ] ; res + + ; } } System . out . print ( res ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int N1 = stdIn . nextInt ( ) ; int N2 = stdIn . nextInt ( ) ; int N3 = stdIn . nextInt ( ) ; int N4 = stdIn . nextInt ( ) ; int h1 = 0 , h2 = 0 , h3 = 0 , h4 = 0 ; if ( N1 = = 1 ) h1 + + ; if ( N2 = = 1 ) h1 + + ; if ( N3 = = 1 ) h1 + + ; if ( N4 = = 1 ) h1 + + ; if ( h1 = = 0 | | h1 > 1 ) System . out . println ( " NO " ) ; else { if ( N1 = = 9 ) h2 + + ; if ( N2 = = 9 ) h2 + + ; if ( N3 = = 9 ) h2 + + ; if ( N4 = = 9 ) h2 + + ; if ( h2 = = 0 | | h2 > 1 ) System . out . println ( " NO " ) ; else { if ( N1 = = 7 ) h3 + + ; if ( N2 = = 7 ) h3 + + ; if ( N3 = = 7 ) h3 + + ; if ( N4 = = 7 ) h3 + + ; if ( h3 = = 0 | | h3 > 1 ) System . out . println ( " NO " ) ; else { if ( N1 = = 4 ) h4 + + ; if ( N2 = = 4 ) h4 + + ; if ( N3 = = 4 ) h4 + + ; if ( N4 = = 4 ) h4 + + ; if ( h4 = = 0 | | h4 > 1 ) System . out . println ( " NO " ) ; else { System . out . println ( " YES " ) ; } } } } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int b = sc . nextInt ( ) ; int [ ] hairetu = new int [ b ] ; for ( int i = 0 ; i < hairetu . length ; i + + ) { int c = sc . nextInt ( ) ; hairetu [ i ] = c ; } int count = 0 ; int champ = hairetu [ 0 ] ; for ( int k = 0 ; k < hairetu . length ; k + + ) { if ( champ > = hairetu [ k ] ) { champ = hairetu [ k ] ; count + + ; } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] P = new int [ N ] ; int ans = 1 ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i < N ; i + + ) { if ( P [ i - 1 ] > = P [ i ] ) { ans + + ; } else { P [ i ] = P [ i - 1 ] ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner kb = new Scanner ( System . in ) ; int n = kb . nextInt ( ) ; int min = kb . nextInt ( ) ; int count = 1 ; for ( int i = 0 ; i < n - 1 ; i + + ) { int j = kb . nextInt ( ) ; int b = j ; if ( b > min ) { } else { count + = 1 ; min = b ; } } System . out . println ( count ) ; kb . close ( ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int [ ] sMinusZ = new int [ K + 1 ] ; for ( int i = 0 ; i < = K ; i + + ) { sMinusZ [ i ] = S - i ; } Arrays . sort ( sMinusZ ) ; int sum = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { if ( Arrays . binarySearch ( sMinusZ , i + j ) > = 0 ) { sum + + ; } } } System . out . println ( sum ) ; } } import java . util . * ; import java . io . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int result = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { if ( 0 < = s - ( i + j ) & & s - ( i + j ) < = k ) result + + ; } } System . out . println ( result ) ; } public static class Scanner { private BufferedReader br ; private StringTokenizer tok ; public Scanner ( InputStream is ) throws IOException { br = new BufferedReader ( new InputStreamReader ( is ) ) ; } private void getLine ( ) throws IOException { while ( ! hasNext ( ) ) tok = new StringTokenizer ( br . readLine ( ) ) ; } private boolean hasNext ( ) { return tok ! = null & & tok . hasMoreTokens ( ) ; } public String next ( ) throws IOException { getLine ( ) ; return tok . nextToken ( ) ; } public int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; char a [ ] = new char [ n ] ; for ( int i = 0 ; i < n ; i + + ) { a [ i ] = scan . next ( ) . charAt ( 0 ) ; } scan . close ( ) ; int check = 0 ; for ( int i = 0 ; i < n ; i + + ) { if ( a [ i ] = = ' Y ' ) { check = 1 ; break ; } } System . out . println ( ( check = = 1 ) ? " Four " : " Three " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] a = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { a [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] x = new int [ 3 ] ; int [ ] y = new int [ 3 ] ; x [ 0 ] = 0 ; for ( int i = 0 ; i < 3 ; i + + ) y [ i ] = a [ 0 ] [ i ] ; x [ 1 ] = a [ 1 ] [ 0 ] - y [ 0 ] ; x [ 2 ] = a [ 2 ] [ 0 ] - y [ 0 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( a [ i ] [ j ] ! = x [ i ] + y [ j ] ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] list = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) list [ i ] = sc . nextInt ( ) ; int min = Integer . MAX _ VALUE ; int count = 0 ; for ( int i = 0 ; i < n ; i + + ) { if ( min > = list [ i ] ) { count + + ; min = list [ i ] ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; int [ ] a = new int [ 3 ] ; int [ ] b = new int [ 3 ] ; for ( int y = 0 ; y < 3 ; y + + ) { for ( int x = 0 ; x < 3 ; x + + ) { c [ y ] [ x ] = sc . nextInt ( ) ; if ( y = = 0 ) b [ x ] = c [ y ] [ x ] ; else a [ y ] = c [ y ] [ x ] - b [ x ] ; } } boolean isAns = true ; for ( int y = 0 ; y < 3 ; y + + ) { for ( int x = 0 ; x < 3 ; x + + ) { if ( c [ y ] [ x ] ! = a [ y ] + b [ x ] ) { isAns = false ; break ; } } } System . out . println ( isAns ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; long cnt = 0 ; int K = input . nextInt ( ) ; int S = input . nextInt ( ) ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { int k = S - i - j ; if ( k > = 0 & & k < = K ) cnt + + ; } } System . out . println ( cnt ) ; } public static boolean Three ( int a , int b , int c ) { if ( a ! = b & & b ! = c & & c ! = a ) return true ; return false ; } public static boolean One ( int a , int b , int c ) { if ( a = = b & & b = = c & & c = = a ) return true ; return false ; } } import java . util . Scanner ; public class Main { private static int N ; private static int [ ] P ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; N = sc . nextInt ( ) ; P = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = sc . nextInt ( ) ; } int ans = 0 ; int tempMin = Integer . MAX _ VALUE ; for ( int i = 0 ; i < N ; i + + ) { if ( P [ i ] < = tempMin ) { ans + + ; } tempMin = Math . min ( P [ i ] , tempMin ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i + + ) { if ( sc . next ( ) . charAt ( 0 ) = = ' Y ' ) { System . out . println ( " Four " ) ; return ; } } System . out . println ( " Three " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int t = scan . nextInt ( ) , temp = t , counter = 0 ; for ( int count = 0 ; count < t ; count + + ) { int x = scan . nextInt ( ) ; if ( x < = temp ) { temp = x ; counter + + ; } } System . out . println ( counter ) ; scan . close ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) a [ i ] = sc . nextInt ( ) ; Arrays . sort ( a ) ; if ( a [ 0 ] = = 1 & & a [ 1 ] = = 4 & & a [ 2 ] = = 7 & & a [ 3 ] = = 9 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] a = new int [ 3 ] ; a [ 0 ] = 0 ; int [ ] b = { c [ 0 ] [ 0 ] , c [ 0 ] [ 1 ] , c [ 0 ] [ 2 ] } ; a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] ; a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( ( a [ i ] + b [ j ] ) ! = c [ i ] [ j ] ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] x = new int [ 3 ] ; int [ ] y = new int [ 3 ] ; x [ 0 ] = 0 ; for ( int i = 0 ; i < 3 ; i + + ) { y [ i ] = c [ 0 ] [ i ] - x [ 0 ] ; } for ( int i = 0 ; i < 3 ; i + + ) { x [ i ] = c [ i ] [ 0 ] - y [ 0 ] ; } for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( c [ i ] [ j ] ! = x [ i ] + y [ j ] ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . Collections ; import java . util . ArrayList ; import java . util . List ; import java . util . HashSet ; import java . io . PrintWriter ; import java . io . OutputStream ; import java . util . Comparator ; public class Main { static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static int [ ] inputval ( ) throws Exception { String [ ] strarray = br . readLine ( ) . trim ( ) . split ( " " ) ; int [ ] intarray = new int [ strarray . length ] ; for ( int i = 0 ; i < intarray . length ; i + + ) { intarray [ i ] = Integer . parseInt ( strarray [ i ] ) ; } return intarray ; } static List < Integer > inputIntList ( ) throws Exception { List < String > strList = Arrays . asList ( br . readLine ( ) . trim ( ) . split ( " " ) ) ; List < Integer > intList = new ArrayList < Integer > ( ) ; for ( String elem : strList ) { intList . add ( Integer . parseInt ( elem ) ) ; } return intList ; } static Integer [ ] inputvalInteger ( ) throws Exception { String [ ] strarray = br . readLine ( ) . trim ( ) . split ( " " ) ; Integer [ ] intarray = new Integer [ strarray . length ] ; for ( int i = 0 ; i < intarray . length ; i + + ) { intarray [ i ] = Integer . parseInt ( strarray [ i ] ) ; } return intarray ; } public static void main ( String [ ] args ) throws Exception { int [ ] inputval = inputval ( ) ; int k = inputval [ 0 ] ; int s = inputval [ 1 ] ; int cnt = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { if ( s - ( i + j ) > = 0 & & s - ( i + j ) < = k ) { cnt + + ; } } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int c11 = sc . nextInt ( ) ; int c12 = sc . nextInt ( ) ; int c13 = sc . nextInt ( ) ; int c21 = sc . nextInt ( ) ; int c22 = sc . nextInt ( ) ; int c23 = sc . nextInt ( ) ; int c31 = sc . nextInt ( ) ; int c32 = sc . nextInt ( ) ; int c33 = sc . nextInt ( ) ; int diff21 = c21 - c11 ; int diff31 = c31 - c11 ; if ( c22 - c12 = = diff21 & & c23 - c13 = = diff21 & & c32 - c12 = = diff31 & & c33 - c13 = = diff31 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int min = Integer . MAX _ VALUE ; int cnt = 0 ; for ( int i = 0 ; i < N ; i + + ) { int tmp = sc . nextInt ( ) ; if ( tmp < min ) { min = Math . min ( min , tmp ) ; cnt + + ; } } System . out . print ( cnt ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int c = 0 ; int o = n + 1 ; for ( int i = 0 ; i < n ; i + + ) { int p = sc . nextInt ( ) ; if ( o > p ) { c + + ; o = p ; } } System . out . println ( c ) ; } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . Scanner ; public class Main { InputStream in = System . in ; PrintStream out = System . out ; public void _ main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } sc . close ( ) ; int [ ] a = new int [ 3 ] ; int [ ] b = new int [ 3 ] ; String ans = " No " ; LOOP : for ( a [ 0 ] = 0 ; a [ 0 ] < = 100 ; a [ 0 ] + + ) { b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] ; b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] ; b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] ; if ( b [ 0 ] < 0 | | b [ 1 ] < 0 | | b [ 2 ] < 0 ) { break ; } a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] ; a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( a [ i ] + b [ j ] ! = c [ i ] [ j ] ) { continue LOOP ; } } } ans = " Yes " ; break ; } out . println ( ans ) ; } public static void main ( String [ ] args ) { new Main ( ) . _ main ( args ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i + + ) { list . add ( scan . nextInt ( ) ) ; } int count = 0 ; int min = Collections . max ( list ) ; for ( int i = 0 ; i < n ; i + + ) { if ( list . get ( i ) < = min ) { min = list . get ( i ) ; count + + ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; int P [ ] = new int [ N ] ; int result = 1 ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = scan . nextInt ( ) ; } int min = P [ 0 ] ; for ( int i = 1 ; i < N ; i + + ) { if ( min > P [ i ] ) { min = P [ i ] ; result + + ; } } System . out . println ( result ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] p = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = sc . nextInt ( ) ; } int m = n + 1 ; int count = 0 ; for ( int i = 0 ; i < n ; i + + ) { if ( m > = p [ i ] ) { count + + ; m = p [ i ] ; } } System . out . println ( count ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { int l = s - ( i + j ) ; if ( l > = 0 & & l < = k ) { count + + ; } } } System . out . println ( count ) ; } } import java . io . * ; import java . util . * ; class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; int n = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; + + i ) a [ i ] = sc . nextLong ( ) ; long ans = 0 ; long c = 1 ; for ( int i = 0 ; i < n ; + + i ) { long q = ( a [ i ] - 1 ) / c ; ans + = q ; if ( q > 0 ) a [ i ] = 1 ; c = Math . max ( c , a [ i ] + 1 ) ; } out . println ( ans ) ; out . close ( ) ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st = = null | | ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = Integer . parseInt ( sc . next ( ) ) ; } } int [ ] t = new int [ 6 ] ; t [ 0 ] = c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] ; t [ 1 ] = c [ 0 ] [ 1 ] + c [ 1 ] [ 2 ] + c [ 2 ] [ 0 ] ; t [ 2 ] = c [ 0 ] [ 2 ] + c [ 1 ] [ 0 ] + c [ 2 ] [ 1 ] ; t [ 3 ] = c [ 0 ] [ 2 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 0 ] ; t [ 4 ] = c [ 0 ] [ 1 ] + c [ 1 ] [ 0 ] + c [ 2 ] [ 2 ] ; t [ 5 ] = c [ 0 ] [ 0 ] + c [ 2 ] [ 1 ] + c [ 1 ] [ 2 ] ; String ans = " Yes " ; for ( int i = 1 ; i < 6 ; i + + ) { if ( t [ i ] ! = t [ 0 ] ) { ans = " No " ; break ; } } System . out . println ( ans ) ; } } import java . math . BigInteger ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] ps = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { ps [ i ] = sc . nextInt ( ) ; } int ans = 1 ; int min = ps [ 0 ] ; for ( int i = 1 ; i < n ; i + + ) { if ( min > = ps [ i ] ) { ans + + ; min = ps [ i ] ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) throws InterruptedException { Scanner sc = new Scanner ( System . in ) ; int n _ customer = sc . nextInt ( ) ; long sold = sc . nextInt ( ) - 1 ; int i = 1 ; int price = 2 ; if ( n _ customer > 1 ) { while ( true ) { int money = sc . nextInt ( ) ; if ( money < price ) i + + ; else if ( money = = price ) { price + + ; i + + ; } else { if ( money % price = = 0 ) { sold + = money / price - 1 ; } else { sold + = money / price ; } i + + ; } if ( i = = n _ customer ) break ; } } System . out . println ( sold ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; for ( int i = 0 ; i < N ; i + + ) { if ( sc . next ( ) . contains ( " Y " ) ) { System . out . println ( " Four " ) ; System . exit ( 0 ) ; } } System . out . println ( " Three " ) ; } } import java . io . IOException ; import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws IOException { new Main ( ) . run ( ) ; } private void run ( ) throws IOException { Scanner scanner = new Scanner ( System . in ) ; n = scanner . nextInt ( ) ; m = scanner . nextInt ( ) ; t = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) t [ i ] = scanner . nextInt ( ) ; d = new int [ 3 ] [ m ] ; for ( int i = 0 ; i < m ; i + + ) for ( int j = 0 ; j < 3 ; j + + ) { int a = scanner . nextInt ( ) ; d [ j ] [ i ] = a ; } dp = new int [ n ] [ m ] ; for ( int [ ] dp1 : dp ) Arrays . fill ( dp1 , - 1 ) ; int ans = 0 ; for ( int i = 0 ; i < m ; i + + ) { if ( t [ 0 ] < d [ 0 ] [ i ] | | d [ 1 ] [ i ] < t [ 0 ] ) continue ; ans = Math . max ( ans , slove ( 1 , i ) ) ; } System . out . println ( ans ) ; } private int slove ( int day , int x ) { if ( day = = n ) return 0 ; if ( dp [ day ] [ x ] ! = - 1 ) return dp [ day ] [ x ] ; int ret = 0 ; for ( int i = 0 ; i < m ; i + + ) { if ( t [ day ] < d [ 0 ] [ i ] | | d [ 1 ] [ i ] < t [ day ] ) continue ; ret = Math . max ( ret , slove ( day + 1 , i ) + Math . abs ( d [ 2 ] [ x ] - d [ 2 ] [ i ] ) ) ; } return dp [ day ] [ x ] = ret ; } int n , m ; int [ ] t ; int [ ] [ ] d , dp ; } import java . util . * ; public class Main { public static void main ( String [ ] args ) { solve _ 152 _ C ( ) ; return ; } private static void solve _ 152 _ C ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int P [ ] = new int [ N ] ; int count = 0 ; Boolean judge = false ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = sc . nextInt ( ) ; } int max = P [ 0 ] ; for ( int i = 0 ; i < N ; i + + ) { int value = P [ i ] ; if ( value < = max ) count + + ; max = Math . min ( max , value ) ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; scanner . nextLine ( ) ; String [ ] c = scanner . nextLine ( ) . split ( " " ) ; for ( int i = 0 ; i < N ; i + + ) { if ( c [ i ] . charAt ( 0 ) = = ' Y ' ) { System . out . println ( " Four " ) ; return ; } } System . out . println ( " Three " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int in _ num = Integer . parseInt ( sc . next ( ) ) ; int [ ] l = new int [ in _ num ] ; for ( int i = 0 ; i < in _ num ; i + + ) { l [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int count = 0 ; int mi = Integer . MAX _ VALUE ; for ( int i = 0 ; i < in _ num ; i + + ) { if ( l [ i ] < = mi ) { count + + ; mi = l [ i ] ; } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) , S = sc . nextInt ( ) , Z ; int count = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { Z = S - i - j ; if ( Z > = 0 & & Z < = K ) count + + ; Z = 0 ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] a = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { a [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] x = new int [ 3 ] ; int [ ] y = new int [ 3 ] ; x [ 0 ] = 0 ; for ( int i = 0 ; i < 3 ; i + + ) { y [ i ] = a [ 0 ] [ i ] - x [ 0 ] ; } for ( int i = 0 ; i < 3 ; i + + ) { x [ i ] = a [ i ] [ 0 ] - y [ 0 ] ; } boolean ok = true ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( a [ i ] [ j ] ! = x [ i ] + y [ j ] ) ok = false ; } } if ( ok ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int [ ] in = new int [ a ] ; for ( int i = 0 ; i < a ; i + + ) { in [ i ] = sc . nextInt ( ) ; } int b = 0 ; int c = in [ 0 ] ; for ( int i = 0 ; i < a ; i + + ) { c = Math . min ( c , in [ i ] ) ; if ( c > = in [ i ] ) { b + + ; } } System . out . println ( b ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int min = Integer . MAX _ VALUE ; int sum = 0 ; for ( int i = 0 ; i < n ; i + + ) { int a = sc . nextInt ( ) ; if ( a < min ) { min = a ; sum + + ; } } System . out . println ( sum ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { if ( x + y < = s & & s - x - y < = k ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] p = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) p [ i ] = sc . nextInt ( ) ; int [ ] min = new int [ n ] ; min [ 0 ] = p [ 0 ] ; for ( int i = 1 ; i < n ; i + + ) { min [ i ] = Math . min ( min [ i - 1 ] , p [ i ] ) ; } int ans = 0 ; for ( int i = 0 ; i < n ; i + + ) { if ( p [ i ] < = min [ i ] ) ans + + ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { private static final String YES = " YES " ; private static final String NO = " NO " ; public static void main ( String [ ] args ) { new Main ( ) . execute ( ) ; } public void execute ( ) { Scanner sc = new Scanner ( System . in ) ; final int N1 = sc . nextInt ( ) ; final int N2 = sc . nextInt ( ) ; final int N3 = sc . nextInt ( ) ; final int N4 = sc . nextInt ( ) ; boolean [ ] b = new boolean [ 10 ] ; b [ N1 ] = true ; b [ N2 ] = true ; b [ N3 ] = true ; b [ N4 ] = true ; if ( b [ 1 ] & & b [ 9 ] & & b [ 7 ] & & b [ 4 ] ) { System . out . println ( YES ) ; } else { System . out . println ( NO ) ; } sc . close ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Set < String > set = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i + + ) set . add ( sc . next ( ) ) ; System . out . println ( set . size ( ) = = 4 ? " Four " : " Three " ) ; } } import java . util . * ; class Main { Scanner sc ; int N ; int [ ] P ; private void calc ( ) { sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; P = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) P [ i ] = sc . nextInt ( ) ; int c = 0 ; int min = Integer . MAX _ VALUE ; for ( int i = 0 ; i < N ; i + + ) { if ( min > P [ i ] ) c + + ; min = Math . min ( min , P [ i ] ) ; } System . out . println ( c ) ; } public static void main ( String [ ] args ) { new Main ( ) . calc ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int count = 1 ; int min = sc . nextInt ( ) ; int [ ] p = new int [ N ] ; p [ 0 ] = min ; for ( int i = 1 ; i < N ; i + + ) { p [ i ] = sc . nextInt ( ) ; if ( min > = p [ i ] ) { count + + ; min = p [ i ] ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { if ( s - ( i + j ) < = k & & 0 < = s - ( i + j ) ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int counter = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( 0 < = z & & z < = k ) { counter + + ; } } } System . out . println ( counter ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int num = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { if ( S - i - j > = 0 & & S - i - j < = K ) num + + ; } } System . out . println ( num ) ; } } import java . io . InputStream ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Solver solver = new Solver ( ) ; solver . solve ( in , out ) ; out . close ( ) ; } static class Solver { public void solve ( Scanner in , PrintWriter out ) { int N = in . nextInt ( ) ; int count = 0 ; int PjMin = Integer . MAX _ VALUE ; for ( int i = 0 ; i < N ; i + + ) { int Pi = in . nextInt ( ) ; if ( Pi < = PjMin ) { count + + ; } if ( PjMin > = Pi ) { PjMin = Pi ; } } out . println ( count ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int d = scan . nextInt ( ) ; int count1 = 0 ; int count2 = 0 ; int count3 = 0 ; int count4 = 0 ; if ( a = = 1 | | b = = 1 | | c = = 1 | | d = = 1 ) { count1 = 1 ; } if ( a = = 9 | | b = = 9 | | c = = 9 | | d = = 9 ) { count2 = 1 ; } if ( a = = 7 | | b = = 7 | | c = = 7 | | d = = 7 ) { count3 = 1 ; } if ( a = = 4 | | b = = 4 | | c = = 4 | | d = = 4 ) { count4 = 1 ; } if ( count1 = = 1 & & count2 = = 1 & & count3 = = 1 & & count4 = = 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String ... args ) { try ( Scanner sc = new Scanner ( System . in ) ) { final int K = sc . nextInt ( ) ; final int S = sc . nextInt ( ) ; int count = 0 ; for ( int X = 0 ; X < = K ; X + + ) { for ( int Y = 0 ; Y < = K ; Y + + ) { if ( X + Y > S ) break ; if ( S - X - Y < = K ) count + + ; } } System . out . println ( count ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int c [ ] [ ] = new int [ 3 ] [ 3 ] ; int z = 0 , y = 0 , fin = 0 , a1 = 0 , a2 = 0 ; while ( z < 3 ) { while ( y < 3 ) { c [ z ] [ y ] = stdIn . nextInt ( ) ; y + + ; } y = 0 ; z + + ; } z = 1 ; a1 = c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] ; a2 = c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] ; while ( z < 3 ) { if ( c [ z ] [ 0 ] - c [ z ] [ 1 ] ! = a1 ) { fin = 1 ; break ; } if ( c [ z ] [ 1 ] - c [ z ] [ 2 ] ! = a2 ) { fin = 1 ; break ; } z + + ; } if ( fin = = 1 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( ( new InputStreamReader ( System . in ) ) ) ; String [ ] l = reader . readLine ( ) . split ( " " ) ; int N = Integer . parseInt ( l [ 0 ] ) ; String [ ] list = reader . readLine ( ) . split ( " " ) ; int [ ] arr = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { arr [ i ] = Integer . parseInt ( list [ i ] ) ; } int [ ] dp = new int [ N ] ; dp [ 0 ] = 1 ; int min = arr [ 0 ] ; for ( int j = 1 ; j < N ; j + + ) { if ( arr [ j ] < min ) { dp [ j ] = 1 + dp [ j - 1 ] ; min = arr [ j ] ; } else { dp [ j ] = dp [ j - 1 ] ; } } System . out . println ( dp [ dp . length - 1 ] ) ; } } import java . util . * ; import java . math . * ; import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = K & & S - i > = 0 ; i + + ) { int sum = S - i ; if ( sum < = K ) { count + = sum + 1 ; } else { int dif = Math . max ( 0 , 2 * K - sum + 1 ) ; count + = dif ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = - 100 ; i < = 100 ; i + + ) { for ( int j = - 100 ; j < = 100 ; j + + ) { for ( int k = - 100 ; k < = 100 ; k + + ) { int [ ] b = new int [ 3 ] ; b [ 0 ] = c [ 0 ] [ 0 ] - i ; b [ 1 ] = c [ 1 ] [ 1 ] - j ; b [ 2 ] = c [ 2 ] [ 2 ] - k ; if ( i + b [ 0 ] = = c [ 0 ] [ 0 ] & & i + b [ 1 ] = = c [ 0 ] [ 1 ] & & i + b [ 2 ] = = c [ 0 ] [ 2 ] & & j + b [ 0 ] = = c [ 1 ] [ 0 ] & & j + b [ 1 ] = = c [ 1 ] [ 1 ] & & j + b [ 2 ] = = c [ 1 ] [ 2 ] & & k + b [ 0 ] = = c [ 2 ] [ 0 ] & & k + b [ 1 ] = = c [ 2 ] [ 1 ] & & k + b [ 2 ] = = c [ 2 ] [ 2 ] ) { System . out . println ( " Yes " ) ; return ; } } } } System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int maxNum = scan . nextInt ( ) ; int sum = scan . nextInt ( ) ; int ans = 0 ; for ( int x = 0 ; x < = maxNum ; + + x ) { for ( int y = 0 ; y < = maxNum ; + + y ) { int z = sum - x - y ; if ( 0 < = z & & z < = maxNum ) { ans = ans + 1 ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < c . length ; i + + ) { for ( int j = 0 ; j < c [ i ] . length ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] a = new int [ 3 ] ; int [ ] b = new int [ 3 ] ; for ( int i = 0 ; i < b . length ; i + + ) { b [ i ] = c [ 0 ] [ i ] ; } for ( int i = 1 ; i < a . length ; i + + ) { a [ i ] = c [ i ] [ 0 ] - b [ 0 ] ; } boolean jdg = true ; outer : for ( int i = 0 ; i < c . length ; i + + ) { for ( int j = 0 ; j < c [ i ] . length ; j + + ) { if ( ! ( jdg = ( a [ i ] + b [ j ] = = c [ i ] [ j ] ) ) ) break outer ; } } System . out . println ( jdg ? " Yes " : " No " ) ; sc . close ( ) ; } } import java . io . * ; import java . util . * ; final class Solver { static final Solver INSTANCE = new Solver ( ) ; void solve ( Iterator < String > sc ) { int K = Integer . parseInt ( sc . next ( ) ) ; int S = Integer . parseInt ( sc . next ( ) ) ; int sum = 0 ; for ( int x = 0 ; x < = K & & x < = S ; x + + ) { int remaining = S - x ; sum + = Math . max ( Math . min ( remaining , K ) - Math . max ( remaining - K , 0 ) + 1 , 0 ) ; } System . out . println ( sum ) ; } } class Main { public static void main ( String ... args ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; Iterator < String > tokens = reader . lines ( ) . map ( s - > s . split ( " " ) ) . flatMap ( Arrays : : stream ) . iterator ( ) ; Solver . INSTANCE . solve ( tokens ) ; } } import static java . lang . System . in ; import static java . lang . System . out ; import java . io . * ; import java . util . * ; public class Main { static final double EPS = 1e-10 ; static final double INF = 1L < < 31 ; static final double PI = Math . PI ; public static Scanner sc = new Scanner ( in ) ; StringBuilder sb = new StringBuilder ( ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; public void run ( ) throws IOException { String input ; String [ ] inputArray ; input = br . readLine ( ) ; inputArray = input . split ( " " ) ; int n = Integer . valueOf ( inputArray [ 0 ] ) ; int [ ] a = new int [ n ] ; long ans = 0L ; a [ 0 ] = Integer . valueOf ( br . readLine ( ) ) ; ans + = ( a [ 0 ] - 1 ) ; int m = 1 ; for ( int i = 1 ; i < n ; i + + ) { a [ i ] = Integer . valueOf ( br . readLine ( ) ) ; if ( a [ i ] = = m + 1 ) m + + ; else if ( a [ i ] > m + 1 ) { ans + = ( a [ i ] - 1 ) / ( m + 1 ) ; } } sb . append ( ans ) ; ln ( sb ) ; } public static void main ( String [ ] args ) throws IOException { new Main ( ) . run ( ) ; } public static void ln ( Object obj ) { out . println ( obj ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int K = Integer . parseInt ( scanner . next ( ) ) ; int S = Integer . parseInt ( scanner . next ( ) ) ; scanner . close ( ) ; int ans = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { int z = S - x - y ; if ( z > = 0 & & z < = K ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > number = new ArrayList < > ( ) ; for ( int i = 0 ; i < 4 ; i + + ) { number . add ( sc . nextInt ( ) ) ; } Collections . sort ( number ) ; if ( number . get ( 0 ) ! = 1 | | number . get ( 3 ) ! = 9 | | number . get ( 2 ) ! = 7 | | number . get ( 1 ) ! = 4 ) { System . out . println ( " NO " ) ; } else { System . out . println ( " YES " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int na = scan . nextInt ( ) ; int [ ] nb = new int [ na ] ; int i = 0 ; for ( i = 0 ; i < na ; i + + ) { nb [ i ] = scan . nextInt ( ) ; } int sum = 0 ; int rul = 0 ; for ( i = 0 ; i < na ; i + + ) { if ( i = = 0 ) { sum = sum + 1 ; rul = nb [ i ] ; } else if ( rul > nb [ i ] ) { sum = sum + 1 ; rul = nb [ i ] ; } } System . out . println ( sum ) ; } } import java . util . * ; class Main { public static void main ( String args [ ] ) throws Exception { Main main = new Main ( ) ; } public Main ( ) { Scanner scanner = new Scanner ( System . in ) ; int N ; N = Integer . parseInt ( scanner . next ( ) ) ; int min = Integer . MAX _ VALUE ; int result = 0 , in ; for ( int i = 0 ; i < N ; i + + ) { in = Integer . parseInt ( scanner . next ( ) ) ; if ( min > = in ) { result + + ; min = in ; } } System . out . println ( result ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { if ( s - ( i + j ) < = k & & 0 < = s - ( i + j ) ) count + + ; } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String args [ ] ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int cnt = 0 ; int curMax = 0 ; for ( int i = 0 ; i < n ; i + + ) { if ( i = = 0 ) { cnt + + ; curMax = sc . nextInt ( ) ; continue ; } int num = sc . nextInt ( ) ; if ( curMax > = num ) { cnt + + ; curMax = num ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N1 = sc . nextInt ( ) ; int N2 = sc . nextInt ( ) ; int N3 = sc . nextInt ( ) ; int N4 = sc . nextInt ( ) ; int a1 = ( N1 - 1 ) * ( N2 - 1 ) * ( N3 - 1 ) * ( N4 - 1 ) ; int a4 = ( N1 - 4 ) * ( N2 - 4 ) * ( N3 - 4 ) * ( N4 - 4 ) ; int a7 = ( N1 - 7 ) * ( N2 - 7 ) * ( N3 - 7 ) * ( N4 - 7 ) ; int a9 = ( N1 - 9 ) * ( N2 - 9 ) * ( N3 - 9 ) * ( N4 - 9 ) ; if ( a1 = = 0 & & a4 = = 0 & & a7 = = 0 & & a9 = = 0 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int c [ ] [ ] = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } int a [ ] = new int [ 3 ] ; int b [ ] = new int [ 3 ] ; boolean ans = false ; for ( int n = 0 ; n < = c [ 0 ] [ 0 ] ; n + + ) { a [ 0 ] = n ; b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] ; b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] ; b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] ; a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] ; a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] ; loop : for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( c [ i ] [ j ] = = a [ i ] + b [ j ] ) { ans = true ; } else { ans = false ; break loop ; } } } } if ( ans ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; sc . close ( ) ; int x = 0 ; int y = 0 ; int z = 0 ; int count = 0 ; for ( x = 0 ; x < = k ; x + + ) { for ( y = 0 ; y < = k ; y + + ) { z = s - ( x + y ) ; if ( z < = k & & z > = 0 ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; Set < Character > set = new HashSet < > ( ) ; for ( int i = 0 ; i < N ; i + + ) { set . add ( sc . next ( ) . charAt ( 0 ) ) ; } System . out . println ( set . size ( ) = = 4 ? " Four " : " Three " ) ; } } import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; int [ ] rx = new int [ 3 ] ; int [ ] ry = new int [ 3 ] ; boolean flag = true ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = scan . nextInt ( ) ; } } ry [ 0 ] = 0 ; for ( int j = 0 ; j < 3 ; j + + ) { rx [ j ] = c [ 0 ] [ j ] - ry [ 0 ] ; } for ( int j = 1 ; j < 3 ; j + + ) { ry [ j ] = c [ j ] [ 0 ] - rx [ 0 ] ; } outside : for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( rx [ j ] + ry [ i ] ! = c [ i ] [ j ] ) { flag = false ; System . out . println ( " No " ) ; break outside ; } } } if ( flag ) { System . out . println ( " Yes " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { a [ i ] = Integer . parseInt ( sc . next ( ) ) ; } sc . close ( ) ; int min = Integer . MAX _ VALUE , ans = 0 ; for ( int i = 0 ; i < N ; i + + ) { min = Math . min ( min , a [ i ] ) ; if ( a [ i ] < = min ) ans + + ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = Integer . parseInt ( sc . next ( ) ) ; int s = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( 0 < = z & & z < = k ) { count + + ; } else if ( z < 0 ) { break ; } } } System . out . println ( count ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int k = scanner . nextInt ( ) , s = scanner . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = k ; i + + ) { int sum = 0 ; for ( int j = 0 ; j < = k ; j + + ) { sum = i + j ; if ( ( s - sum ) > = 0 & & ( s - sum ) < = k ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . * ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int k = s . nextInt ( ) , SUM = s . nextInt ( ) , sum = 0 ; for ( int a = 0 ; a < = k ; a + + ) if ( a < = SUM ) for ( int b = 0 ; b < = k ; b + + ) if ( SUM - a - b > = 0 & & SUM - a - b < = k ) sum + + ; System . out . println ( sum ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { int N = in . nextInt ( ) ; String [ ] S = new String [ N ] ; for ( int i = 0 ; i < N ; i + + ) { S [ i ] = in . next ( ) ; } HashSet < String > set = new HashSet < String > ( ) ; for ( int i = 0 ; i < N ; i + + ) { set . add ( S [ i ] ) ; } System . out . println ( set . size ( ) = = 3 ? " Three " : " Four " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int count = 0 ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; for ( int i = 0 ; i < = k ; i + + ) { for ( int w = 0 ; w < = k ; w + + ) { if ( s - i - w > = 0 & & s - i - w < = k ) { count + + ; } } } System . out . print ( count ) ; } } public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { int max1 = 100 , max2 = 100 , max3 = 100 , a [ ] = new int [ 9 ] ; for ( int i = 0 ; i < 3 ; i + + ) { max1 = Math . min ( max1 , a [ i * 3 ] = scanner . nextInt ( ) ) ; max2 = Math . min ( max2 , a [ i * 3 + 1 ] = scanner . nextInt ( ) ) ; max3 = Math . min ( max3 , a [ i * 3 + 2 ] = scanner . nextInt ( ) ) ; } System . out . println ( ( a [ 0 ] - max1 = = a [ 1 ] - max2 & & a [ 1 ] - max2 = = a [ 2 ] - max3 ) & & ( a [ 3 ] - max1 = = a [ 4 ] - max2 & & a [ 4 ] - max2 = = a [ 5 ] - max3 ) & & ( a [ 6 ] - max1 = = a [ 7 ] - max2 & & a [ 7 ] - max2 = = a [ 8 ] - max3 ) ? " Yes " : " No " ) ; } } import java . util . * ; class Main { static int A ; public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] map = { 1 , 9 , 7 , 4 } ; boolean [ ] visit = new boolean [ 4 ] ; boolean flag = false ; for ( int i = 0 ; i < 4 ; i + + ) { int A = scan . nextInt ( ) ; for ( int j = 0 ; j < 4 ; j + + ) { if ( A = = map [ j ] ) { visit [ j ] = true ; } } } for ( int i = 0 ; i < 4 ; i + + ) { if ( ! visit [ i ] ) flag = true ; } if ( flag ) System . out . println ( " NO " ) ; else System . out . println ( " YES " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int cnt = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { int z = S - x - y ; if ( z > = 0 & & z < = K ) cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String result = " Three " ; for ( int i = 0 ; i < N ; i + + ) { String S = sc . next ( ) ; if ( " Y " . equals ( S ) ) { result = " Four " ; } } System . out . println ( result ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int [ ] ary = new int [ a ] ; for ( int i = 0 ; i < a ; i + + ) { ary [ i ] = sc . nextInt ( ) ; } int ans = 0 ; int min = 2000000 ; int max = 0 ; for ( int i = 0 ; i < a ; i + + ) { if ( ary [ i ] < min ) { ans + + ; min = ary [ i ] ; } else if ( true ) { } } System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; class Main { public static void main ( String args [ ] ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int N = Integer . parseInt ( br . readLine ( ) ) ; String [ ] permutation = br . readLine ( ) . split ( " " ) ; int min = 0 ; int result = 0 ; int tmp = 0 ; for ( int i = 0 ; i < N ; i + + ) { tmp = Integer . parseInt ( permutation [ i ] ) ; if ( i = = 0 ) { min = tmp ; result + + ; } else { if ( min > = tmp ) { result + + ; min = tmp ; } else { continue ; } } } System . out . println ( result ) ; } } } import java . io . * ; import java . util . * ; final class Solver { static final Solver INSTANCE = new Solver ( ) ; void solve ( Iterator < String > sc ) { int K = Integer . parseInt ( sc . next ( ) ) ; int S = Integer . parseInt ( sc . next ( ) ) ; int sum = 0 ; for ( int x = 0 ; x < = K & & x < = S ; x + + ) { int remaining = S - x ; sum + = Math . max ( Math . min ( remaining , K ) - Math . max ( remaining - K , 0 ) + 1 , 0 ) ; } System . out . println ( sum ) ; } } class Main { public static void main ( String ... args ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; Solver . INSTANCE . solve ( new Iterator < String > ( ) { private StringTokenizer tokenizer ; public boolean hasNext ( ) { return true ; } public String next ( ) { if ( tokenizer = = null | | ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } } ) ; } } import java . util . Scanner ; public class Main { @ SuppressWarnings ( " resource " ) public static void main ( String args [ ] ) { Scanner scanner = new Scanner ( System . in ) ; int k = scanner . nextInt ( ) ; int s = scanner . nextInt ( ) ; int ans = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { if ( 0 < = s - x - y & & s - x - y < = k ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; public class Main { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } public String next ( ) { try { while ( st = = null | | ! st . hasMoreElements ( ) ) { st = new StringTokenizer ( br . readLine ( ) ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { String s = " " ; try { s = br . readLine ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return s ; } } public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int k = in . nextInt ( ) ; int s = in . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { if ( s - i - j > = 0 & & s - i - j < = k ) cnt + + ; } } out . println ( cnt ) ; out . flush ( ) ; out . close ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int k = scan . nextInt ( ) ; int s = scan . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { if ( i + j < = s & & ( i + j + k ) > = s ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Main { static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; int N = gi ( ) ; for ( int i = 0 ; i < N ; i + + ) { String s = gs ( ) ; if ( s . equals ( " Y " ) ) { System . out . println ( " Four " ) ; return ; } } System . out . println ( " Three " ) ; } public static long d ( long n ) { String a = String . valueOf ( n ) ; return ( long ) a . length ( ) ; } public static String gs ( ) { return scanner . next ( ) ; } public static int gi ( ) { return Integer . parseInt ( scanner . next ( ) ) ; } public static long gl ( ) { return Long . parseLong ( scanner . next ( ) ) ; } public static double gd ( ) { return Double . parseDouble ( scanner . next ( ) ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import static java . lang . Integer . parseInt ; public class Main { static int [ ] nums ; static boolean [ ] used ; public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line ; String [ ] words ; words = br . readLine ( ) . split ( " " ) ; nums = new int [ 9 ] ; used = new boolean [ 10 ] ; for ( int i = 0 ; i < words . length ; i + + ) { nums [ i ] = parseInt ( words [ i ] ) ; if ( nums [ i ] ! = - 1 ) used [ nums [ i ] ] = true ; } System . out . println ( solve ( 0 ) ) ; } static int solve ( int idx ) { if ( idx = = nums . length ) { if ( check ( ) ) return 1 ; else return 0 ; } int ret = 0 ; if ( nums [ idx ] = = - 1 ) { for ( int k = 1 ; k < = 9 ; k + + ) { if ( ! used [ k ] ) { nums [ idx ] = k ; used [ k ] = true ; ret + = solve ( idx + 1 ) ; nums [ idx ] = - 1 ; used [ k ] = false ; } } } else { ret = solve ( idx + 1 ) ; } return ret ; } static boolean check ( ) { return nums [ 0 ] + nums [ 1 ] * 10 + nums [ 2 ] + nums [ 3 ] * 100 + nums [ 4 ] * 10 + nums [ 5 ] = = nums [ 6 ] * 100 + nums [ 7 ] * 10 + nums [ 8 ] ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; import java . util . Set ; import java . util . HashSet ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( in . readLine ( ) ) ; Set s = new HashSet < String > ( ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < n ; i + + ) { s . add ( str [ i ] ) ; } System . out . println ( s . size ( ) = = 4 ? " Four " : " Three " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int sum = 0 ; int count = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { sum = s - ( i + j ) ; if ( sum > = 0 & & sum < = k ) { count + + ; } } } System . out . println ( count ) ; } } } import java . io . * ; import java . util . * ; import java . math . * ; public class Main { FastReader sc ; void solve ( ) throws IOException { int n = sc . ni ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { a [ i ] = sc . ni ( ) ; } int min = a [ 0 ] ; int ans = 1 ; for ( int i = 1 ; i < n ; i + + ) { if ( a [ i ] < = min ) ans + + ; min = Math . min ( min , a [ i ] ) ; } System . out . println ( ans ) ; } Main ( ) { try { sc = new FastReader ( ) ; } catch ( Exception e ) { System . out . println ( e ) ; } } public static void main ( String [ ] args ) throws IOException { new Main ( ) . solve ( ) ; } static class FastReader { BufferedReader br ; StringTokenizer st ; FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { System . out . println ( e ) ; } } FastReader ( String s ) { try { br = new BufferedReader ( new FileReader ( s ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { System . out . println ( e ) ; } } String ns ( ) { if ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { System . out . println ( e ) ; } } return st . nextToken ( ) ; } int ni ( ) { return Integer . parseInt ( ns ( ) ) ; } long nl ( ) { return Long . parseLong ( ns ( ) ) ; } double nd ( ) { return Double . parseDouble ( ns ( ) ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] grid = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { grid [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int a1 = 0 ; a1 < = Math . min ( grid [ 0 ] [ 0 ] , Math . min ( grid [ 0 ] [ 1 ] , grid [ 0 ] [ 2 ] ) ) ; a1 + + ) { for ( int a2 = 0 ; a2 < = Math . min ( grid [ 1 ] [ 0 ] , Math . min ( grid [ 1 ] [ 1 ] , grid [ 1 ] [ 2 ] ) ) ; a2 + + ) { for ( int a3 = 0 ; a3 < = Math . min ( grid [ 2 ] [ 0 ] , Math . min ( grid [ 2 ] [ 1 ] , grid [ 2 ] [ 2 ] ) ) ; a3 + + ) { if ( ( grid [ 0 ] [ 0 ] - a1 ! = grid [ 1 ] [ 0 ] - a2 ) | | ( grid [ 1 ] [ 0 ] - a2 ! = grid [ 2 ] [ 0 ] - a3 ) ) { continue ; } if ( ( grid [ 0 ] [ 1 ] - a1 ! = grid [ 1 ] [ 1 ] - a2 ) | | ( grid [ 1 ] [ 1 ] - a2 ! = grid [ 2 ] [ 1 ] - a3 ) ) { continue ; } if ( ( grid [ 0 ] [ 2 ] - a1 ! = grid [ 1 ] [ 2 ] - a2 ) | | ( grid [ 1 ] [ 2 ] - a2 ! = grid [ 2 ] [ 2 ] - a3 ) ) { continue ; } System . out . println ( " Yes " ) ; return ; } } } System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int cnt = 0 , z = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { z = S - x - y ; if ( z > = 0 & & z < = K ) cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] grid = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { grid [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 1 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { grid [ i ] [ j ] - = grid [ 0 ] [ j ] ; } } boolean ans = false ; if ( grid [ 1 ] [ 0 ] = = grid [ 1 ] [ 1 ] & & grid [ 1 ] [ 1 ] = = grid [ 1 ] [ 2 ] & & grid [ 2 ] [ 0 ] = = grid [ 2 ] [ 1 ] & & grid [ 2 ] [ 1 ] = = grid [ 2 ] [ 2 ] ) ans = true ; if ( ans ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . util . function . * ; import java . math . * ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int K = s . nextInt ( ) ; int S = s . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < K + 1 ; i + + ) { if ( i > S ) break ; for ( int j = 0 ; j < K + 1 ; j + + ) { if ( 0 < = S - i - j & & S - i - j < = K ) count + + ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = in . nextInt ( ) ; } } int [ ] sum = new int [ 6 ] ; sum [ 0 ] = c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] ; sum [ 1 ] = c [ 0 ] [ 1 ] + c [ 1 ] [ 2 ] + c [ 2 ] [ 0 ] ; sum [ 2 ] = c [ 0 ] [ 2 ] + c [ 1 ] [ 0 ] + c [ 2 ] [ 1 ] ; sum [ 3 ] = c [ 0 ] [ 0 ] + c [ 1 ] [ 2 ] + c [ 2 ] [ 1 ] ; sum [ 4 ] = c [ 0 ] [ 1 ] + c [ 1 ] [ 0 ] + c [ 2 ] [ 2 ] ; sum [ 5 ] = c [ 0 ] [ 2 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 0 ] ; boolean takahashi = true ; for ( int i = 1 ; i < 6 ; i + + ) { if ( sum [ 0 ] ! = sum [ i ] ) { takahashi = false ; break ; } } if ( takahashi ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; in . close ( ) ; } } import java . util . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } String result = " No " ; for ( int a1 = - 200 ; a1 < = 200 ; a1 + + ) { boolean bool = true ; int b1 = c [ 0 ] [ 0 ] - a1 ; int b2 = c [ 0 ] [ 1 ] - a1 ; int b3 = c [ 0 ] [ 2 ] - a1 ; int a2 = c [ 1 ] [ 0 ] - b1 ; int a3 = c [ 2 ] [ 0 ] - b1 ; if ( c [ 1 ] [ 1 ] ! = a2 + b2 ) bool = false ; if ( c [ 1 ] [ 2 ] ! = a2 + b3 ) bool = false ; if ( c [ 2 ] [ 1 ] ! = a3 + b2 ) bool = false ; if ( c [ 2 ] [ 2 ] ! = a3 + b3 ) bool = false ; if ( bool ) { result = " Yes " ; break ; } } System . out . println ( result ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int array [ ] [ ] = new int [ 3 ] [ 3 ] ; int a [ ] = new int [ 3 ] ; int b [ ] = new int [ 3 ] ; int c [ ] [ ] = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { array [ i ] [ j ] = scan . nextInt ( ) ; } } a [ 0 ] = 0 ; b [ 0 ] = array [ 0 ] [ 0 ] - a [ 0 ] ; b [ 1 ] = array [ 0 ] [ 1 ] - a [ 0 ] ; b [ 2 ] = array [ 0 ] [ 2 ] - a [ 0 ] ; a [ 1 ] = array [ 1 ] [ 0 ] - b [ 0 ] ; a [ 2 ] = array [ 2 ] [ 0 ] - b [ 0 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( array [ i ] [ j ] ! = a [ i ] + b [ j ] ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } } System . out . println ( " Yes " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int sum = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { int z = S - ( x + y ) ; if ( z < = K & & z > = 0 ) { sum + + ; } } } System . out . println ( sum ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { A [ i ] = sc . nextInt ( ) ; } long ans = A [ 0 ] - 1 ; int max = 2 ; for ( int i = 1 ; i < N ; i + + ) { if ( A [ i ] = = max ) max + + ; else if ( A [ i ] > max ) { ans + = ( A [ i ] - 1 ) / max ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; int P [ ] = new int [ N ] ; int sum = 1 ; boolean flag = true ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = scan . nextInt ( ) ; } int pre _ min = P [ 0 ] ; for ( int i = 1 ; i < N ; i + + ) { flag = true ; if ( P [ i ] < pre _ min ) { sum + = 1 ; pre _ min = P [ i ] ; } } System . out . print ( sum ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] e = new int [ 10 ] ; e [ 1 ] = 0 ; e [ 9 ] = 0 ; e [ 4 ] = 0 ; e [ 7 ] = 0 ; for ( int i = 0 ; i < 4 ; i + + ) { int a = sc . nextInt ( ) ; if ( a = = 1 | | a = = 9 | | a = = 7 | | a = = 4 ) { e [ a ] + + ; } } if ( e [ 1 ] > = 1 & & e [ 9 ] > = 1 & & e [ 7 ] > = 1 & & e [ 4 ] > = 1 ) { System . out . println ( " YES " ) ; return ; } System . out . println ( " NO " ) ; } } import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; public class Main implements Runnable { private static int MOD = 1 _ 000 _ 000 _ 007 ; public static void main ( String [ ] args ) { Thread thread = new Thread ( null , new Main ( ) , " " , 32 * 1024 * 1024 ) ; thread . start ( ) ; } @ Override public void run ( ) { final Scanner scanner = new Scanner ( System . in ) ; solve ( scanner ) ; } static void solve ( Scanner scanner ) { int N = Integer . parseInt ( scanner . next ( ) ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { A [ i ] = Integer . parseInt ( scanner . next ( ) ) ; } int min = A [ 0 ] ; int ans = 1 ; for ( int i = 1 ; i < N ; i + + ) { if ( A [ i ] < = min ) { ans + + ; } min = Math . min ( min , A [ i ] ) ; } System . out . println ( ans ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] a = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { a [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 0 ; i < = 100 ; i + + ) { for ( int j = 0 ; j < = 100 ; j + + ) { for ( int k = 0 ; k < = 100 ; k + + ) { if ( a [ 0 ] [ 0 ] - i = = a [ 1 ] [ 0 ] - j & & a [ 1 ] [ 0 ] - j = = a [ 2 ] [ 0 ] - k & & a [ 2 ] [ 0 ] - k = = a [ 0 ] [ 0 ] - i ) { if ( a [ 0 ] [ 1 ] - i = = a [ 1 ] [ 1 ] - j & & a [ 1 ] [ 1 ] - j = = a [ 2 ] [ 1 ] - k & & a [ 2 ] [ 1 ] - k = = a [ 0 ] [ 1 ] - i ) { if ( a [ 0 ] [ 2 ] - i = = a [ 1 ] [ 2 ] - j & & a [ 1 ] [ 2 ] - j = = a [ 2 ] [ 2 ] - k & & a [ 2 ] [ 2 ] - k = = a [ 0 ] [ 2 ] - i ) { System . out . println ( " Yes " ) ; return ; } } } } } } System . out . println ( " No " ) ; } } import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] P = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = sc . nextInt ( ) ; } int ans = 0 ; int min = 1000000 ; for ( int i = 0 ; i < N ; i + + ) { if ( P [ i ] < min ) { ans + + ; } min = Math . min ( min , P [ i ] ) ; } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = 0 ; for ( int i = 0 ; i < = a ; i + + ) { for ( int j = 0 ; j < = a ; j + + ) { if ( b - i - j > = 0 & & b - i - j < = a ) { c + + ; } } } System . out . println ( c ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int mini = 1000000 ; int ans = 0 ; for ( int i = 0 ; i < n ; i + + ) { int a = sc . nextInt ( ) ; if ( a < = mini ) { mini = a ; ans + + ; } } System . out . println ( ans ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; String line ; ArrayList < Integer > n = new ArrayList < Integer > ( ) ; for ( int i = 0 ; cin . hasNext ( ) ; i + + ) { line = cin . nextLine ( ) ; if ( i = = 0 ) { String [ ] _ n = line . split ( " " , 0 ) ; for ( int j = 0 ; j < 4 ; j + + ) { n . add ( Integer . parseInt ( _ n [ j ] ) ) ; } } else { } } Collections . sort ( n ) ; String res = " NO " ; if ( n . get ( 0 ) = = 1 & & n . get ( 1 ) = = 4 & & n . get ( 2 ) = = 7 & & n . get ( 3 ) = = 9 ) { res = " YES " ; } System . out . println ( res ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int N = stdIn . nextInt ( ) ; int [ ] P = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = stdIn . nextInt ( ) ; } stdIn . close ( ) ; int count = 1 ; int min = P [ 0 ] ; for ( int i = 1 ; i < N ; i + + ) { if ( P [ i ] < min ) { min = P [ i ] ; count + + ; } } System . out . println ( count ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; if ( a [ 0 ] = = 1 & & a [ 1 ] = = 4 & & a [ 2 ] = = 7 & & a [ 3 ] = = 9 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long p [ ] = new long [ N ] ; long min = sc . nextLong ( ) ; long max = min ; long ans = 1 ; for ( int i = 1 ; i < p . length ; i + + ) { p [ i ] = sc . nextLong ( ) ; if ( min > p [ i ] ) { ans + + ; min = p [ i ] ; } if ( max < p [ i ] ) { max = p [ i ] ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sca = new Scanner ( System . in ) ; int n = sca . nextInt ( ) ; int [ ] pi = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { pi [ i ] = sca . nextInt ( ) ; } int ans = 0 ; int min = 300000 ; for ( int i = 0 ; i < n ; i + + ) { if ( min > pi [ i ] ) { min = pi [ i ] ; ans + + ; } else { } } System . out . println ( ans ) ; sca . close ( ) ; } } import java . util . * ; import java . io . PrintWriter ; import static java . lang . Integer . * ; import static java . lang . Long . * ; import static java . lang . Math . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { int i , j ; Scanner sc = new Scanner ( in ) ; int k = parseInt ( sc . next ( ) ) ; int s = parseInt ( sc . next ( ) ) ; sc . close ( ) ; int cnt = 0 ; int z = 0 ; for ( i = 0 ; i < = k ; i + + ) { for ( j = 0 ; j < = k ; j + + ) { z = s - ( i + j ) ; if ( 0 < = z & & z < = k ) cnt + + ; } } out . println ( cnt ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long count = 0 ; int price = 1 ; for ( int i = 0 ; i < n ; i + + ) { int x = sc . nextInt ( ) ; if ( x = = price ) { price + + ; continue ; } int d = ( x - 1 ) / price ; count + = d ; if ( price = = 1 ) { price + + ; } } System . out . println ( count ) ; } } import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] $ ) { Scanner s = new Scanner ( System . in ) ; int N = s . nextInt ( ) ; int [ ] P = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = s . nextInt ( ) ; } int min = N + 1 ; int count = 0 ; for ( int i = 0 ; i < N ; i + + ) { if ( min > P [ i ] ) { min = P [ i ] ; count + + ; } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; int check = 0 ; int [ ] a = new int [ 9 ] ; for ( int i = 0 ; i < a . length ; + + i ) { a [ i ] = scn . nextInt ( ) ; } int x1 = 0 ; int x2 = 0 ; int y1 = 0 ; int y2 = 0 ; x1 = a [ 3 ] - a [ 0 ] ; x2 = a [ 6 ] - a [ 3 ] ; y1 = a [ 1 ] - a [ 0 ] ; y2 = a [ 2 ] - a [ 1 ] ; if ( a [ 4 ] ! = a [ 1 ] + x1 ) { check = 1 ; } if ( a [ 5 ] ! = a [ 2 ] + x1 ) { check = 1 ; } if ( a [ 7 ] ! = a [ 4 ] + x2 ) { check = 1 ; } if ( a [ 8 ] ! = a [ 5 ] + x2 ) { check = 1 ; } if ( check = = 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] p = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = sc . nextInt ( ) ; } int j , cnt = 0 ; int min = 999999999 ; for ( int i = 0 ; i < n ; i + + ) { min = Math . min ( min , p [ i ] ) ; if ( min = = p [ i ] ) cnt + + ; } System . out . println ( cnt ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int [ ] [ ] arr = new int [ 3 ] [ 3 ] ; int [ ] A = new int [ 2 ] ; int [ ] B = new int [ 2 ] ; Arrays . fill ( A , 101 ) ; Arrays . fill ( B , 101 ) ; String ans = " Yes " ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { arr [ i ] [ j ] = reader . nextInt ( ) ; } } A [ 0 ] = arr [ 0 ] [ 0 ] - arr [ 1 ] [ 0 ] ; A [ 1 ] = arr [ 1 ] [ 0 ] - arr [ 2 ] [ 0 ] ; B [ 0 ] = arr [ 0 ] [ 0 ] - arr [ 0 ] [ 1 ] ; B [ 1 ] = arr [ 0 ] [ 1 ] - arr [ 0 ] [ 2 ] ; for ( int i = 1 ; i < 3 ; i + + ) { for ( int j = 1 ; j < 3 ; j + + ) { if ( arr [ i - 1 ] [ j ] - A [ i - 1 ] ! = arr [ i ] [ j ] | | arr [ i ] [ j - 1 ] - B [ j - 1 ] ! = arr [ i ] [ j ] ) { ans = " No " ; } } } System . out . print ( ans ) ; reader . close ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] min = new long [ n ] ; int count = 1 ; min [ 0 ] = sc . nextLong ( ) ; for ( int i = 1 ; i < n ; i + + ) { long p = sc . nextLong ( ) ; if ( p < = min [ i - 1 ] ) { min [ i ] = p ; count + + ; } else { min [ i ] = min [ i - 1 ] ; } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) , s = sc . nextInt ( ) ; int cnt = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { if ( s - x - y > = 0 & & s - x - y < = k ) cnt + + ; } } System . out . println ( cnt ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int min = Integer . MAX _ VALUE ; int ans = 0 ; for ( int i = 0 ; i < n ; i + + ) { int a = sc . nextInt ( ) ; if ( min > = a ) { ans + + ; min = a ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { static char [ ] [ ] c ; public static void main ( String [ ] args ) throws InterruptedException { Scanner scan = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = scan . nextInt ( ) ; } } for ( int i = 0 ; i < 3 ; i + + ) { if ( c [ i ] [ 0 ] - c [ i ] [ 1 ] ! = c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] | | c [ i ] [ 1 ] - c [ i ] [ 2 ] ! = c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] ) { System . out . println ( " No " ) ; return ; } } for ( int i = 0 ; i < 3 ; i + + ) { if ( c [ 0 ] [ i ] - c [ 1 ] [ i ] ! = c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] | | c [ 1 ] [ i ] - c [ 2 ] [ i ] ! = c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { if ( ( S - x - y > = 0 ) & & ( S - x - y < = K ) ) { count + + ; } } } System . out . println ( count ) ; } } import java . io . PrintStream ; import java . util . Scanner ; public class Main { private static final PrintStream so = System . out ; private static final Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { int z = S - ( x + y ) ; if ( 0 < = z & & z < = K ) { count + + ; } } } so . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int cnt = 0 ; for ( int x = 0 ; x < = k & & x < = s ; x + + ) { for ( int y = 0 ; y < = k & & x + y < = s ; y + + ) { if ( s - x - y < = k ) cnt + + ; } } System . out . println ( cnt ) ; sc . close ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { int k = S - i - j ; if ( k > = 0 & & k < = K ) count + + ; } } System . out . println ( count ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . Arrays ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; int [ ] unko = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) { unko [ i ] = sc . nextInt ( ) ; } Arrays . sort ( unko ) ; if ( unko [ 0 ] = = 1 & & unko [ 1 ] = = 4 & & unko [ 2 ] = = 7 & & unko [ 3 ] = = 9 ) { pl ( " YES " ) ; } else { pl ( " NO " ) ; } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void pl ( ) { System . out . println ( ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer = = null | | ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } } import java . util . * ; import static java . lang . Integer . * ; import static java . lang . Long . parseLong ; import static java . lang . Math . * ; import static java . lang . System . * ; import java . io . PrintWriter ; public class Main { public static void main ( String [ ] args ) { int i , j ; Scanner sc = new Scanner ( in ) ; int n = parseInt ( sc . next ( ) ) ; HashSet < String > s = new HashSet < > ( ) ; for ( i = 0 ; i < n ; i + + ) { s . add ( sc . next ( ) ) ; } sc . close ( ) ; out . println ( s . size ( ) = = 3 ? " Three " : " Four " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int K = in . nextInt ( ) ; int S = in . nextInt ( ) ; int answer = 0 ; if ( S > K * 3 ) { System . out . println ( 0 ) ; return ; } for ( int i = K ; i > = 0 ; i -- ) { int tmp1 = S - i ; if ( tmp1 > K + K ) { break ; } for ( int j = K ; j > = 0 ; j -- ) { int tmp2 = tmp1 - j ; if ( tmp2 < 0 ) { continue ; } else if ( tmp2 > K ) { break ; } answer + + ; } } System . out . println ( answer ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int num = sc . nextInt ( ) ; int array [ ] = new int [ num ] ; int array _ min [ ] = new int [ num ] ; int min = num + 1 ; for ( int i = 0 ; i < num ; i + + ) { array [ i ] = sc . nextInt ( ) ; if ( min > array [ i ] ) { min = array [ i ] ; } array _ min [ i ] = min ; } int count = 0 ; for ( int i = 0 ; i < num ; i + + ) { if ( array _ min [ i ] > = array [ i ] ) { count + + ; } } System . out . println ( count ) ; } } import java . util . * ; import java . util . stream . Collectors ; import java . io . * ; import java . nio . charset . StandardCharsets ; public class Main { public static void main ( String [ ] args ) throws IOException { InputStreamReader reader = new InputStreamReader ( System . in , StandardCharsets . UTF _ 8 ) ; BufferedReader in = new BufferedReader ( reader ) ; Main ins = new Main ( in ) ; ins . calc ( ) ; ins . showResult ( ) ; } Main ( BufferedReader in ) throws IOException { int N = Integer . parseInt ( in . readLine ( ) ) ; String [ ] S = in . readLine ( ) . split ( " " ) ; Set < String > set = new HashSet < > ( ) ; for ( int i = 0 ; i < N ; + + i ) { set . add ( S [ i ] ) ; } if ( set . size ( ) = = 3 ) { System . out . println ( " Three " ) ; } else { System . out . println ( " Four " ) ; } } void calc ( ) { } void showResult ( ) { } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int retu = scan . nextInt ( ) ; Integer [ ] jun = new Integer [ retu ] ; int count = 0 ; for ( int i = 0 ; i < retu ; i + + ) { jun [ i ] = scan . nextInt ( ) ; } int re = 1 ; int min = jun [ 0 ] ; for ( int i = 0 ; i < retu ; i + + ) { if ( min > = jun [ i ] ) { count + + ; } min = Math . min ( min , jun [ i ] ) ; } System . out . println ( count ) ; scan . close ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { int com = s - ( i + j ) ; if ( com > = 0 & & k > = com ) count + + ; } } System . out . println ( count ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = Integer . parseInt ( scan . next ( ) ) ; int counter = 0 ; int min = Integer . MAX _ VALUE ; ArrayList < Integer > pi = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n ; + + i ) { int numPi = Integer . parseInt ( scan . next ( ) ) ; if ( i = = 0 ) { counter + + ; } else { if ( numPi < = min ) { counter + + ; } } if ( min > numPi ) { min = numPi ; } } System . out . println ( counter ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int D = sc . nextInt ( ) , N = sc . nextInt ( ) ; int [ ] T = new int [ D ] ; int [ ] A = new int [ N ] ; int [ ] B = new int [ N ] ; int [ ] C = new int [ N ] ; int [ ] curr = new int [ N ] ; int [ ] next = new int [ N ] ; for ( int i = 0 ; i < D ; i + + ) T [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < N ; i + + ) { A [ i ] = sc . nextInt ( ) ; B [ i ] = sc . nextInt ( ) ; C [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < D - 1 ; i + + ) { for ( int j = 0 ; j < N ; j + + ) { if ( A [ j ] < = T [ i ] & & T [ i ] < = B [ j ] ) for ( int k = 0 ; k < N ; k + + ) { if ( A [ k ] < = T [ i + 1 ] & & T [ i + 1 ] < = B [ k ] ) { int currNext = 0 ; currNext + = curr [ j ] ; currNext + = Math . abs ( C [ j ] - C [ k ] ) ; if ( currNext > next [ k ] ) next [ k ] = currNext ; } } } for ( int j = 0 ; j < N ; j + + ) { curr [ j ] = next [ j ] ; next [ j ] = 0 ; } } int max = curr [ 0 ] ; for ( int i = 1 ; i < N ; i + + ) max = Math . max ( max , curr [ i ] ) ; System . out . println ( max ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int ans = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( z > = 0 & & z < = k ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] line = scanner . nextLine ( ) . split ( " " ) ; int k = Integer . parseInt ( line [ 0 ] ) ; int s = Integer . parseInt ( line [ 1 ] ) ; int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( 0 < = z & & z < = k ) count + + ; } } System . out . println ( count ) ; } } import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String ans = " Three " ; for ( int i = 0 ; i < n ; i + + ) { String s = sc . next ( ) ; if ( s . equals ( " Y " ) ) { ans = " Four " ; break ; } } System . out . println ( ans ) ; sc . close ( ) ; } } import java . io . PrintStream ; import java . util . Scanner ; public class Main { private static final PrintStream so = System . out ; private static final Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String s = sc . next ( ) + sc . next ( ) + sc . next ( ) + sc . next ( ) ; if ( s . contains ( " 1 " ) & & s . contains ( " 9 " ) & & s . contains ( " 7 " ) & & s . contains ( " 4 " ) ) { so . println ( " YES " ) ; } else { so . println ( " NO " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveB ( ) ; } private void solveA ( ) { Scanner scanner = null ; String wk = " " ; try { scanner = new Scanner ( System . in ) ; wk = scanner . next ( ) ; System . out . println ( wk . replaceAll ( " , " , " " ) ) ; } finally { if ( scanner ! = null ) { scanner . close ( ) ; } } } private void solveB ( ) { Scanner scanner = null ; int numK = 0 ; int s = 0 ; try { scanner = new Scanner ( System . in ) ; numK = scanner . nextInt ( ) ; s = scanner . nextInt ( ) ; int startK = 0 ; if ( numK < = s / 3 ) { startK = numK ; } int res = 0 ; for ( int i = 0 ; i < = numK ; i + + ) { for ( int j = 0 ; j < = numK ; j + + ) { if ( s - i - j < 0 ) { break ; } else if ( s - i - j < = numK ) { res + + ; } } } System . out . println ( res ) ; } finally { if ( scanner ! = null ) { scanner . close ( ) ; } } } private void solveC ( ) { Scanner scanner = null ; int lineAB = 0 ; int lineBC = 0 ; int lineCA = 0 ; try { scanner = new Scanner ( System . in ) ; lineAB = scanner . nextInt ( ) ; System . out . println ( " " ) ; } finally { if ( scanner ! = null ) { scanner . close ( ) ; } } } private void solveD ( ) { Scanner scanner = null ; int lineAB = 0 ; int lineBC = 0 ; int lineCA = 0 ; try { scanner = new Scanner ( System . in ) ; lineAB = scanner . nextInt ( ) ; System . out . println ( " " ) ; } finally { if ( scanner ! = null ) { scanner . close ( ) ; } } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < 4 ; i + + ) { list . add ( sc . next ( ) ) ; } System . out . println ( list . contains ( " 1 " ) & & list . contains ( " 9 " ) & & list . contains ( " 7 " ) & & list . contains ( " 4 " ) ? " YES " : " NO " ) ; } } import java . math . BigInteger ; import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { int n , i , j , m , k , p , q , o , l , s , tt = 1 ; Double x , y , z ; int ar [ ] , br [ ] ; char ch ; BigInteger an , su , u , v ; String a , b = " " , c = " " , d ; Scanner sc = new Scanner ( System . in ) ; Scanner scc = new Scanner ( System . in ) ; ar = new int [ 200001 ] ; br = new int [ 200001 ] ; n = sc . nextInt ( ) ; k = 50000000 ; for ( i = 0 ; i < n ; i + + ) { o = sc . nextInt ( ) ; if ( k > o ) { k = o ; } ar [ i ] = o ; br [ i ] = k ; } k = 0 ; for ( i = 1 ; i < n ; i + + ) { if ( ar [ i ] < = br [ i ] ) { k + + ; } } System . out . println ( k + 1 ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = Integer . parseInt ( sc . next ( ) ) ; int S = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; int z = 0 ; for ( int x = 0 ; x < K + 1 ; x + + ) { for ( int y = 0 ; y < K + 1 ; y + + ) { z = S - x - y ; if ( z < = K & & z > = 0 ) { count + + ; } } } System . out . print ( count ) ; System . out . println ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] inputs = input . readLine ( ) . split ( " " ) ; int K = Integer . parseInt ( inputs [ 0 ] ) ; int S = Integer . parseInt ( inputs [ 1 ] ) ; int [ ] xPlusY = new int [ 2 * K + 1 ] ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { xPlusY [ x + y ] + = 1 ; } } int count = 0 ; for ( int z = 0 ; z < = K ; z + + ) { int sMinusZ = S - z ; if ( sMinusZ < = 2 * K & & sMinusZ > = 0 ) { count + = xPlusY [ sMinusZ ] ; } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int X , Y = 0 , Z ; int sum = 0 ; for ( Z = 0 ; Z < = K ; Z + + ) { S - = Z ; for ( X = 0 ; X < = K & & X < = S ; X + + ) { Y = S - X ; if ( Y > K ) continue ; sum + + ; } S + = Z ; } System . out . println ( sum ) ; } } import java . util . * ; public class Main { Scanner sc = new Scanner ( System . in ) ; void doIt ( ) { int [ ] c = new int [ 10 ] ; Arrays . fill ( c , 0 ) ; for ( int i = 0 ; i < 4 ; i + + ) { c [ sc . nextInt ( ) ] + + ; } if ( c [ 1 ] = = 1 & & c [ 9 ] = = 1 & & c [ 7 ] = = 1 & & c [ 4 ] = = 1 ) { System . out . println ( " YES " ) ; } else System . out . println ( " NO " ) ; } public static void main ( String [ ] args ) { new Main ( ) . doIt ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int k = scanner . nextInt ( ) , s = scanner . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = Math . min ( k , s ) ; x + + ) { for ( int y = Math . max ( 0 , s - x - k ) ; y < = Math . min ( k , s - x ) ; y + + ) { int z = s - x - y ; if ( ( z > = 0 ) & & ( z < = k ) ) { count + + ; } } } System . out . println ( count ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { if ( ( ( S - x - y ) > = 0 ) & & ( ( S - x - y ) < = K ) ) count + + ; } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int P [ ] = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = sc . nextInt ( ) ; } int ok = Integer . MAX _ VALUE ; int count = 0 ; for ( int j = 0 ; j < N ; j + + ) { ok = Math . min ( ok , P [ j ] ) ; if ( ok = = P [ j ] ) { count + + ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int [ ] a = new int [ 10 ] ; for ( int i = 0 ; i < 4 ; i + + ) { a [ sc . nextInt ( ) ] = 1 ; } if ( a [ 1 ] = = 1 & & a [ 7 ] = = 1 & & a [ 9 ] = = 1 & & a [ 4 ] = = 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = Integer . parseInt ( sc . next ( ) ) ; int S = Integer . parseInt ( sc . next ( ) ) ; sc . close ( ) ; int cnt = 0 ; for ( int X = 0 ; X < = K ; X + + ) { for ( int Y = 0 ; Y < = K ; Y + + ) { if ( S - X - Y < = K & & S - X - Y > = 0 ) { cnt + + ; } } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k , s ; k = sc . nextInt ( ) ; s = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < = Math . min ( k , s ) ; + + i ) { for ( int j = 0 ; j < = k ; + + j ) { if ( s - i - j > = 0 & & s - i - j < = k ) sum + + ; } } System . out . println ( sum ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int result = 0 ; for ( int i = 0 ; i < s + 1 ; i + + ) { int x = i ; for ( int j = 0 ; j < s + 1 - i ; j + + ) { int y = j ; int z = s - x - y ; if ( x > k | | y > k | | z > k ) { continue ; } result + + ; } } System . out . println ( result ) ; } } import java . util . Arrays ; import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Main { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ; ) { new Main ( ) . solve ( sc ) ; } } void solve ( Scanner sc ) { int [ ] ns = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) { ns [ i ] = sc . nextInt ( ) ; } Arrays . sort ( ns ) ; if ( ns [ 0 ] = = 1 & & ns [ 1 ] = = 4 & & ns [ 2 ] = = 7 & & ns [ 3 ] = = 9 ) { System . out . println ( " YES " ) ; return ; } System . out . println ( " NO " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { if ( 0 < = S - i - j & & S - i - j < = K ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String S [ ] = new String [ N ] ; for ( int i = 0 ; i < N ; i + + ) { S [ i ] = sc . next ( ) ; char c [ ] = S [ i ] . toCharArray ( ) ; if ( c [ 0 ] = = ' Y ' ) { System . out . println ( " Four " ) ; sc . close ( ) ; return ; } } sc . close ( ) ; System . out . println ( " Three " ) ; } } import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int data [ ] = new int [ 10 ] ; int x = 0 ; for ( int i = 1 ; i < 10 ; i + + ) { data [ i ] = scan . nextInt ( ) ; } for ( int a = 0 ; a < 101 ; a + + ) { for ( int b = 0 ; b < 101 ; b + + ) { for ( int c = 0 ; c < 101 ; c + + ) { for ( int d = 0 ; d < 101 ; d + + ) { if ( data [ 1 ] = = a + d & & data [ 4 ] = = b + d & & data [ 7 ] = = c + d ) { for ( int e = 0 ; e < 101 ; e + + ) { if ( data [ 2 ] = = a + e & & data [ 5 ] = = b + e & & data [ 8 ] = = c + e ) { for ( int f = 0 ; f < 101 ; f + + ) { if ( data [ 3 ] = = a + f & & data [ 6 ] = = b + f & & data [ 9 ] = = c + f ) { System . out . println ( " Yes " ) ; return ; } } } } } } } } } System . out . println ( " No " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int ans = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - ( x + y ) ; if ( z > = 0 & & z < = k ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . * ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int c [ ] [ ] = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } int w = 0 ; int a [ ] = new int [ 3 ] ; int b [ ] = new int [ 3 ] ; for ( w = 0 ; w < = 100 ; w + + ) { a [ 0 ] = w ; b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] ; b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] ; b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] ; for ( int i = 0 ; i < 3 ; i + + ) { if ( b [ i ] < 0 ) { System . out . println ( " No " ) ; return ; } } int aa [ ] [ ] = new int [ 3 ] [ 3 ] ; for ( int i = 1 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { aa [ i ] [ j ] = c [ i ] [ j ] - b [ j ] ; } } if ( aa [ 1 ] [ 0 ] ! = aa [ 1 ] [ 1 ] | | aa [ 1 ] [ 0 ] ! = aa [ 1 ] [ 2 ] | | aa [ 2 ] [ 0 ] ! = aa [ 2 ] [ 1 ] | | aa [ 2 ] [ 0 ] ! = aa [ 2 ] [ 2 ] ) { continue ; } System . out . println ( " Yes " ) ; return ; } System . out . println ( " No " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int count = 1 ; int min = sc . nextInt ( ) ; for ( int i = 1 ; i < n ; i + + ) { int tmp = sc . nextInt ( ) ; if ( tmp < = min ) { count + + ; min = tmp ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int t = scan . nextInt ( ) , temp = t , counter = 0 ; for ( int count = 0 ; count < t ; count + + ) { int x = scan . nextInt ( ) ; if ( x < = temp ) { temp = x ; counter + + ; } } System . out . println ( counter ) ; scan . close ( ) ; } } import java . util . * ; class Main { void solve ( ) { Scanner scan = new Scanner ( System . in ) ; int k = scan . nextInt ( ) ; int s = scan . nextInt ( ) ; int out = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { int z = s - i - j ; if ( 0 < = z & & z < = k ) out + + ; } } System . out . println ( out ) ; scan . close ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int P [ ] = new int [ N ] ; int min = 0 ; int count = 0 ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = sc . nextInt ( ) ; if ( i > 0 ) { if ( min > = P [ i ] ) { min = P [ i ] ; count + + ; } } else { min = P [ i ] ; count + + ; } } System . out . println ( count ) ; } } import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; System . out . println ( solve ( K , S ) ) ; sc . close ( ) ; } static int solve ( int K , int S ) { return IntStream . rangeClosed ( 0 , K ) . map ( x - > ( int ) IntStream . rangeClosed ( 0 , K ) . filter ( y - > S - x - y > = 0 & & S - x - y < = K ) . count ( ) ) . sum ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { a [ i ] = sc . nextInt ( ) ; } System . out . println ( cal ( n , a ) ) ; } private static long cal ( final int n , final int [ ] a ) { long res = 0L ; int maxP = 0 ; for ( int i = 0 ; i < n ; i + + ) { if ( maxP = = 0 ) { res + = a [ i ] - 1 ; maxP = 1 ; } else { int num = a [ i ] / ( maxP + 1 ) ; if ( a [ i ] = = maxP + 1 ) { maxP + + ; } else if ( a [ i ] % ( maxP + 1 ) = = 0 ) { res + = num - 1 ; } else { res + = num ; } } } return res ; } } import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner stdIn = new Scanner ( System . in ) ; int n = stdIn . nextInt ( ) ; int min = 10000000 ; int count = 0 ; int p [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = stdIn . nextInt ( ) ; if ( min > = p [ i ] ) { count + + ; min = p [ i ] ; } } System . out . println ( count ) ; stdIn . close ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( z > = 0 & & z < = k ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int count = 0 ; int min = 200005 ; for ( int i = 0 ; i < n ; i + + ) { int val = sc . nextInt ( ) ; if ( val < min ) { + + count ; min = val ; } } System . out . println ( count ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskD solver = new TaskD ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskD { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int n = in . nextInt ( ) ; int [ ] values = IOUtils . readIntArray ( in , n , 0 ) ; long res = 0 ; int cost = 1 ; for ( int i = 0 ; i < n ; i + + ) { int canBuy = ( values [ i ] - 1 ) / cost ; res + = canBuy ; int afterBuy = canBuy = = 0 ? values [ i ] : 1 ; cost = Math . max ( cost , afterBuy + 1 ) ; } out . println ( res ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String nextString ( ) { while ( tokenizer = = null | | ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( nextString ( ) ) ; } } static class IOUtils { public static int [ ] readIntArray ( InputReader in , int size , int start ) { int [ ] res = new int [ start + size ] ; for ( int i = start ; i < start + size ; i + + ) res [ i ] = in . nextInt ( ) ; return res ; } } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; CLowElements solver = new CLowElements ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class CLowElements { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int n = in . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { arr [ i ] = in . nextInt ( ) ; } int min = arr [ 0 ] ; int count = 0 ; for ( int i = 0 ; i < n ; i + + ) { if ( arr [ i ] > min ) { count + + ; } min = Math . min ( min , arr [ i ] ) ; } out . println ( n - count ) ; } } } import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str [ ] = br . readLine ( ) . split ( " " ) ; int k = Integer . parseInt ( str [ 0 ] ) ; int s = Integer . parseInt ( str [ 1 ] ) ; int result = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { if ( s - i - j > = 0 & & s - i - j < = k ) result + + ; } } System . out . println ( result ) ; } } import java . util . * ; class Main { final Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { int n = sc . nextInt ( ) ; int min = Integer . MAX _ VALUE ; int ans = 0 ; for ( int i = 0 ; i < n ; i + + ) { int p = sc . nextInt ( ) ; if ( min > p ) ans + + ; min = Math . min ( p , min ) ; } System . out . println ( ans ) ; } } import java . util . * ; import java . math . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( 0 < = z & & z < = k ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { @ SuppressWarnings ( " resource " ) public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] P = new int [ N ] ; int min = 2000001 ; int ans = 0 ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = sc . nextInt ( ) ; if ( P [ i ] < = min ) { ans + + ; if ( P [ i ] < min ) { min = P [ i ] ; } } } System . out . println ( ans ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Set < String > set = new HashSet < String > ( ) ; for ( int i = 0 ; i < n ; i + + ) { set . add ( sc . next ( ) ) ; } System . out . println ( set . size ( ) < 4 ? " Three " : " Four " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; try { int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int ans = 0 ; for ( int a = 0 ; a < = k ; a + + ) { if ( a = = s ) { ans + + ; break ; } int bc = ( int ) Math . ceil ( ( double ) ( s - a ) / 2 ) ; if ( bc < = k ) { for ( int b = 0 ; b < = k ; b + + ) { if ( s - a - b > = 0 & & s - a - b < = k ) { ans + + ; } } } } System . out . println ( ans ) ; } finally { sc . close ( ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int num = 0 ; ArrayList < Integer > List = new ArrayList < > ( ) ; for ( int a = 0 ; a < 4 ; a + + ) List . add ( sc . nextInt ( ) ) ; if ( List . contains ( 1 ) = = true ) num + + ; if ( List . contains ( 9 ) = = true ) num + + ; if ( List . contains ( 7 ) = = true ) num + + ; if ( List . contains ( 4 ) = = true ) num + + ; if ( num = = 4 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } import java . io . InputStream ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . * ; import java . lang . Math . * ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; HashMap < Integer , Integer > mem = new HashMap < > ( ) ; int k = in . nextInt ( ) ; int s = in . nextInt ( ) ; int x = Math . min ( s , k ) ; int total = 0 ; for ( int i = 0 ; i < = x ; i + + ) { for ( int j = 0 ; j < = x ; j + + ) { int sum = i + j ; if ( sum < = s & & sum + x > = s ) total + + ; } } System . out . print ( total ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( 0 < = z & & z < = k ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; int [ ] b = new int [ 3 ] ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; + + i ) { for ( int j = 0 ; j < 3 ; + + j ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } a [ 0 ] = 0 ; for ( int i = 0 ; i < 3 ; + + i ) { b [ i ] = c [ 0 ] [ i ] - a [ 0 ] ; } for ( int i = 0 ; i < 3 ; + + i ) { a [ i ] = c [ i ] [ 0 ] - b [ 0 ] ; } for ( int i = 0 ; i < 3 ; + + i ) { for ( int j = 0 ; j < 3 ; + + j ) { if ( c [ i ] [ j ] ! = a [ i ] + b [ j ] ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String output = " Three " ; int num = sc . nextInt ( ) ; String [ ] color = new String [ num ] ; for ( int i = 0 ; i < num ; i + + ) { color [ i ] = sc . next ( ) ; } sc . close ( ) ; for ( int i = 0 ; i < num ; i + + ) { if ( color [ i ] . equals ( " Y " ) ) { output = " Four " ; break ; } } System . out . println ( output ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String [ ] S = new String [ N ] ; for ( int i = 0 ; i < N ; i + + ) { S [ i ] = sc . next ( ) ; } sc . close ( ) ; String result = " Three " ; for ( int i = 0 ; i < N ; i + + ) { if ( S [ i ] . equals ( " Y " ) ) { result = " Four " ; } } System . out . println ( result ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = input . readLine ( ) ; String [ ] array = str . split ( " " ) ; int a = Integer . parseInt ( array [ 0 ] ) ; int b = Integer . parseInt ( array [ 1 ] ) ; int c = Integer . parseInt ( array [ 2 ] ) ; int d = Integer . parseInt ( array [ 3 ] ) ; int [ ] list = { a , b , c , d } ; Arrays . sort ( list ) ; int [ ] diff = { 1 , 4 , 7 , 9 } ; if ( Arrays . equals ( list , diff ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = k ; + + i ) { for ( int j = 0 ; j < = k ; + + j ) { int num = s - i - j ; if ( num > = 0 & & num < = k ) { + + count ; } } } System . out . println ( count ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import static java . lang . Integer . parseInt ; public class Main { static int [ ] nums ; static boolean [ ] used ; public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line ; String [ ] words ; words = br . readLine ( ) . split ( " " ) ; nums = new int [ 9 ] ; used = new boolean [ 10 ] ; for ( int i = 0 ; i < words . length ; i + + ) { nums [ i ] = parseInt ( words [ i ] ) ; if ( nums [ i ] ! = - 1 ) used [ nums [ i ] ] = true ; } System . out . println ( solve ( 0 ) ) ; } static int solve ( int idx ) { if ( idx = = nums . length ) { int a = nums [ 3 ] * 100 + ( nums [ 1 ] + nums [ 4 ] ) * 10 + nums [ 0 ] + nums [ 2 ] + nums [ 5 ] ; int b = nums [ 6 ] * 100 + nums [ 7 ] * 10 + nums [ 8 ] ; if ( a = = b ) return 1 ; else return 0 ; } int ret = 0 ; if ( nums [ idx ] = = - 1 ) { for ( int k = 1 ; k < = 9 ; k + + ) { if ( ! used [ k ] ) { nums [ idx ] = k ; used [ k ] = true ; ret + = solve ( idx + 1 ) ; nums [ idx ] = - 1 ; used [ k ] = false ; } } } else { ret = solve ( idx + 1 ) ; } return ret ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int K = sc . nextInt ( ) ; final int S = sc . nextInt ( ) ; int ans = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { int z = S - ( x + y ) ; if ( 0 < = z & & z < = K ) ans + + ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k , s , ans = 0 ; k = sc . nextInt ( ) ; s = sc . nextInt ( ) ; sc . close ( ) ; for ( int i = 0 ; i < = k ; + + i ) { for ( int j = 0 ; j < = k ; + + j ) { int tmp = s - i - j ; if ( tmp > = 0 & & tmp < = k ) ans + + ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - ( x + y ) ; if ( z > = 0 & & z < = k ) { count + + ; } } } System . out . println ( count ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { atcode ( ) ; } public static void atcode ( ) { String [ ] info = new Scanner ( System . in ) . nextLine ( ) . split ( " " ) ; Integer max = Integer . valueOf ( info [ 0 ] ) ; Integer sum = Integer . valueOf ( info [ 1 ] ) ; int count = 0 ; for ( int x = 0 ; x < = max ; x + + ) { for ( int y = 0 ; y < = max ; y + + ) { int z = sum - x - y ; if ( z > = 0 & & z < = max ) count + + ; } } System . out . println ( count ) ; } } import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int n = scn . nextInt ( ) ; int a [ ] = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) { a [ i ] = 0 ; } for ( int i = 0 ; i < n ; i + + ) { char buf = scn . next ( ) . charAt ( 0 ) ; switch ( buf ) { case ' P ' : a [ 0 ] + + ; break ; case ' W ' : a [ 1 ] + + ; break ; case ' Y ' : a [ 2 ] + + ; break ; case ' G ' : a [ 3 ] + + ; break ; } } int cnt = 0 ; for ( int i = 0 ; i < 4 ; i + + ) { if ( a [ i ] > 0 ) cnt + + ; } if ( cnt = = 3 ) { System . out . println ( " Three " ) ; } else { System . out . println ( " Four " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; int ans = 0 ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } if ( c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 1 ] [ 1 ] & & c [ 0 ] [ 2 ] - c [ 0 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 2 ] [ 1 ] ) { ans + = 1 ; } if ( c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] = = c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] & & c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] = = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] ) { ans + = 1 ; } if ( c [ 2 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 1 ] [ 1 ] & & c [ 2 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 2 ] [ 2 ] - c [ 1 ] [ 2 ] ) { ans + = 1 ; } if ( c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] & & c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] = = c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] ) { ans + = 1 ; } if ( ans = = 4 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] p = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = sc . nextInt ( ) ; } int min = p [ 0 ] ; int ans = 1 ; for ( int i = 1 ; i < n ; i + + ) { if ( p [ i ] < min ) { ans + + ; min = p [ i ] ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( ( System . in ) ) ; int [ ] x = new int [ 3 ] ; int [ ] y = new int [ 3 ] ; int [ ] z = new int [ 3 ] ; String ans = " No " ; for ( int i = 0 ; i < 3 ; i + + ) { x [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < 3 ; i + + ) { y [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < 3 ; i + + ) { z [ i ] = sc . nextInt ( ) ; } if ( x [ 0 ] - x [ 1 ] = = y [ 0 ] - y [ 1 ] & & z [ 0 ] - z [ 1 ] = = y [ 0 ] - y [ 1 ] & & x [ 0 ] - x [ 1 ] = = z [ 0 ] - z [ 1 ] ) { if ( x [ 1 ] - x [ 2 ] = = y [ 1 ] - y [ 2 ] & & z [ 1 ] - z [ 2 ] = = y [ 1 ] - y [ 2 ] & & x [ 1 ] - x [ 2 ] = = z [ 1 ] - z [ 2 ] ) { if ( x [ 2 ] - x [ 0 ] = = y [ 2 ] - y [ 0 ] & & z [ 2 ] - z [ 0 ] = = y [ 2 ] - y [ 0 ] & & x [ 2 ] - x [ 0 ] = = z [ 2 ] - z [ 0 ] ) { ans = " Yes " ; } } } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } sc . close ( ) ; String result = " Yes " ; int d1 = c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] ; int d2 = c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] ; int d3 = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] ; int d4 = c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] ; int d5 = c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] ; int d6 = c [ 2 ] [ 1 ] - c [ 2 ] [ 2 ] ; if ( d1 ! = d2 | | d2 ! = d3 ) { result = " No " ; } if ( d4 ! = d5 | | d5 ! = d6 ) { result = " No " ; } System . out . println ( result ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int leftTop = sc . nextInt ( ) ; int middleTop = sc . nextInt ( ) ; int rightTop = sc . nextInt ( ) ; int leftMiddle = sc . nextInt ( ) ; int middleMiddle = sc . nextInt ( ) ; int rightMiddle = sc . nextInt ( ) ; int leftDown = sc . nextInt ( ) ; int middleDown = sc . nextInt ( ) ; int rightDown = sc . nextInt ( ) ; String ans = " Yes " ; int [ ] aTop = { 0 , leftTop - middleTop , leftTop - rightTop } ; int [ ] aMiddle = { 0 , leftMiddle - middleMiddle , leftMiddle - rightMiddle } ; int [ ] aDown = { 0 , leftDown - middleDown , leftDown - rightDown } ; int [ ] bLeft = { 0 , leftTop - leftMiddle , leftTop - leftDown } ; int [ ] bMiddle = { 0 , middleTop - middleMiddle , middleTop - middleDown } ; int [ ] bRight = { 0 , rightTop - rightMiddle , rightTop - rightDown } ; if ( ! Arrays . equals ( aTop , aMiddle ) | | ! Arrays . equals ( aTop , aDown ) ) { ans = " No " ; } if ( ! Arrays . equals ( bLeft , bMiddle ) | | ! Arrays . equals ( bLeft , bRight ) ) { ans = " No " ; } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int point = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { int z = s - i - j ; if ( 0 < = z & & z < = k ) { point + + ; } } } System . out . println ( point ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { int count = 0 ; boolean sw = false ; String answer = " " ; int e = 0 ; int f = 0 ; int g = 0 ; int h = 0 ; Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; if ( a = = 1 | | b = = 1 | | c = = 1 | | d = = 1 ) { e = 1 ; } if ( a = = 9 | | b = = 9 | | c = = 9 | | d = = 9 ) { f = 1 ; } if ( a = = 7 | | b = = 7 | | c = = 7 | | d = = 7 ) { g = 1 ; } if ( a = = 4 | | b = = 4 | | c = = 4 | | d = = 4 ) { h = 1 ; } if ( e = = 1 & & f = = 1 & & g = = 1 & & h = = 1 ) { answer = " YES " ; } else { answer = " NO " ; } System . out . println ( answer ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; if ( 3 * k < s ) { System . out . println ( 0 ) ; } else if ( 3 * k = = s ) { System . out . println ( 1 ) ; } else { int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { if ( s - ( x + y ) < = k & & s - ( x + y ) > = 0 ) count + + ; } } System . out . println ( count ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] x = new int [ 3 ] ; int [ ] y = new int [ 3 ] ; x [ 0 ] = 0 ; for ( int i = 0 ; i < 3 ; i + + ) { y [ i ] = c [ 0 ] [ i ] - x [ 0 ] ; } for ( int i = 0 ; i < 3 ; i + + ) { x [ i ] = c [ i ] [ 0 ] - y [ 0 ] ; } for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( c [ i ] [ j ] ! = x [ i ] + y [ j ] ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } } System . out . println ( " Yes " ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] N = new int [ 4 ] ; for ( int i = 0 ; i < N . length ; i + + ) { N [ i ] = sc . nextInt ( ) ; } Arrays . sort ( N ) ; if ( N [ 0 ] = = 1 & & N [ 1 ] = = 4 & & N [ 2 ] = = 7 & & N [ 3 ] = = 9 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = Integer . parseInt ( sc . next ( ) ) ; int s = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { if ( s - i - j > = 0 & & s - i - j < = k ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int [ ] p = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = in . nextInt ( ) ; } int minZ = p [ 0 ] , cnt = 1 ; for ( int i = 1 ; i < n ; i + + ) { if ( minZ > = p [ i ] ) { minZ = p [ i ] ; cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; List < Integer > list = new ArrayList < Integer > ( ) ; List < Integer > compareList = new ArrayList < Integer > ( ) ; compareList . add ( 1 ) ; compareList . add ( 9 ) ; compareList . add ( 7 ) ; compareList . add ( 4 ) ; list . add ( a ) ; list . add ( b ) ; list . add ( c ) ; list . add ( d ) ; if ( list . containsAll ( compareList ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 4 ] ; int [ ] b = new int [ 4 ] ; int [ ] [ ] c = new int [ 4 ] [ 4 ] ; for ( int i = 1 ; i < = 3 ; i + + ) { for ( int j = 1 ; j < = 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } a [ 1 ] = c [ 1 ] [ 1 ] ; a [ 2 ] = c [ 2 ] [ 1 ] ; a [ 3 ] = c [ 3 ] [ 1 ] ; b [ 1 ] = 0 ; b [ 2 ] = c [ 1 ] [ 2 ] - c [ 1 ] [ 1 ] ; b [ 3 ] = c [ 1 ] [ 3 ] - c [ 1 ] [ 1 ] ; boolean ans = true ; int numbers [ ] = { 2 , 3 } ; for ( int i : numbers ) { for ( int j : numbers ) { if ( a [ i ] + b [ j ] = = c [ i ] [ j ] ) ; else ans = false ; } } if ( ans ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Main { static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; String S = gs ( ) + gs ( ) + gs ( ) + gs ( ) ; if ( S . contains ( " 1 " ) & & S . contains ( " 7 " ) & & S . contains ( " 9 " ) & & S . contains ( " 4 " ) ) { System . out . print ( " YES " ) ; } else { System . out . print ( " NO " ) ; } } public static long d ( long n ) { String a = String . valueOf ( n ) ; return ( long ) a . length ( ) ; } public static String gs ( ) { return scanner . next ( ) ; } public static int gi ( ) { return Integer . parseInt ( scanner . next ( ) ) ; } public static long gl ( ) { return Long . parseLong ( scanner . next ( ) ) ; } public static double gd ( ) { return Double . parseDouble ( scanner . next ( ) ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; Long result = 0L ; int k = 1 ; for ( int i = 0 ; i < n ; i + + ) { int a = in . nextInt ( ) ; if ( i = = 0 ) { result + = a - 1 ; k + + ; } else { if ( a = = k ) { k + + ; } else { result + = ( a - 1 ) / k ; } } } System . out . println ( result ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int o = 0 ; int n = sc . nextInt ( ) ; int mini = 2000000 ; for ( int i = 0 ; i < n ; i + + ) { int p = sc . nextInt ( ) ; if ( p < = mini ) { o + + ; mini = p ; } } System . out . println ( o ) ; } } import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; boolean ans = false ; for ( int i = 0 ; i < n ; i + + ) { char c = sc . next ( ) . charAt ( 0 ) ; if ( c = = ' Y ' ) ans = true ; } if ( ans ) System . out . println ( " Four " ) ; else System . out . println ( " Three " ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] n = br . readLine ( ) . split ( " " ) ; br . close ( ) ; String a = " 1974 " ; for ( int i = 0 ; i < 4 ; i + + ) { a = a . replaceAll ( n [ i ] , " " ) ; } if ( a . length ( ) = = 0 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; int k = scn . nextInt ( ) ; int s = scn . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = k ; + + x ) { for ( int y = 0 ; y < = k ; + + y ) { if ( s > = x + y & & s - ( x + y ) < = k ) { count = count + 1 ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int min = Integer . MAX _ VALUE ; int result = 0 ; for ( int i = 0 ; i < n ; i + + ) { int p = sc . nextInt ( ) ; if ( p < min ) { result + + ; min = p ; } } sc . close ( ) ; System . out . println ( result ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { try { Scanner scanner = new Scanner ( System . in ) ; boolean flag = true ; int i = 0 ; int [ ] num = { 0 , 1 , 0 , 0 , 1 , 0 , 0 , 1 , 0 , 1 } ; for ( i = 0 ; i < 4 ; i + + ) { int N = scanner . nextInt ( ) ; num [ N ] -- ; if ( num [ N ] ! = 0 ) { flag = false ; } } if ( flag ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } scanner . close ( ) ; } catch ( Exception e ) { System . out . println ( " 何か入力してください " ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . HashSet ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } public void solve ( ) { Scanner scan = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int N = scan . nextInt ( ) ; HashSet < Character > set = new HashSet < > ( ) ; for ( int i = 0 ; i < N ; i + + ) { String s = scan . next ( ) ; char c = s . toCharArray ( ) [ 0 ] ; set . add ( c ) ; } if ( set . size ( ) = = 3 ) { System . out . println ( " Three " ) ; } else { System . out . println ( " Four " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] arr = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { arr [ i ] [ j ] = sc . nextInt ( ) ; } } if ( arr [ 0 ] [ 0 ] - arr [ 0 ] [ 1 ] = = arr [ 1 ] [ 0 ] - arr [ 1 ] [ 1 ] & & arr [ 1 ] [ 0 ] - arr [ 1 ] [ 1 ] = = arr [ 2 ] [ 0 ] - arr [ 2 ] [ 1 ] ) { if ( arr [ 0 ] [ 1 ] - arr [ 0 ] [ 2 ] = = arr [ 1 ] [ 1 ] - arr [ 1 ] [ 2 ] & & arr [ 1 ] [ 1 ] - arr [ 1 ] [ 2 ] = = arr [ 2 ] [ 1 ] - arr [ 2 ] [ 2 ] ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int cnt = 0 , z ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { z = s - ( x + y ) ; if ( k > = z & & z > = 0 ) cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int N = sc . nextInt ( ) ; int [ ] P = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = sc . nextInt ( ) ; } int count = 0 ; int min = ( int ) 1e9 ; for ( int i = 0 ; i < N ; i + + ) { if ( P [ i ] < min ) { min = P [ i ] ; count + + ; } } System . out . println ( count ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; Stack < Integer > st = new Stack < > ( ) ; int min = 200001 ; int cnt = 0 ; for ( int i = 0 ; i < N ; i + + ) { int p = sc . nextInt ( ) ; if ( p < min ) { min = p ; cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { private static final int MOD = 1 _ 000 _ 000 _ 007 ; private static final String YES = " Yes " ; private static final String NO = " No " ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] P = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = sc . nextInt ( ) ; } System . out . println ( solve ( N , P ) ) ; } private static int solve ( int N , int [ ] P ) { int count = 0 ; int min = N + 1 ; for ( int i = 0 ; i < N ; i + + ) { if ( P [ i ] < min ) { min = P [ i ] ; count + + ; } } return count ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int [ ] c = new int [ 9 ] ; for ( int i = 0 ; i < 9 ; i + + ) { c [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; if ( c [ 3 ] - c [ 0 ] = = c [ 4 ] - c [ 1 ] & & c [ 3 ] - c [ 0 ] = = c [ 5 ] - c [ 2 ] & & c [ 6 ] - c [ 3 ] = = c [ 7 ] - c [ 4 ] & & c [ 6 ] - c [ 3 ] = = c [ 8 ] - c [ 5 ] & & c [ 1 ] - c [ 0 ] = = c [ 4 ] - c [ 3 ] & & c [ 1 ] - c [ 0 ] = = c [ 7 ] - c [ 6 ] & & c [ 2 ] - c [ 1 ] = = c [ 5 ] - c [ 4 ] & & c [ 2 ] - c [ 1 ] = = c [ 8 ] - c [ 7 ] ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner scan = new Scanner ( System . in ) ; int K = scan . nextInt ( ) ; int S = scan . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { if ( 0 < = S - i - j & & S - i - j < = K ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A [ ] = new int [ 10 ] ; for ( int i = 0 ; i < 4 ; i + + ) { int temp = sc . nextInt ( ) ; if ( temp ! = 1 & & temp ! = 9 & & temp ! = 7 & & temp ! = 4 ) { System . out . println ( " NO " ) ; return ; } A [ temp ] + + ; if ( A [ temp ] > 1 ) { System . out . println ( " NO " ) ; return ; } } System . out . println ( " YES " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int c1 = sc . nextInt ( ) ; int c2 = sc . nextInt ( ) ; int c3 = sc . nextInt ( ) ; int c4 = sc . nextInt ( ) ; int c5 = sc . nextInt ( ) ; int c6 = sc . nextInt ( ) ; int c7 = sc . nextInt ( ) ; int c8 = sc . nextInt ( ) ; int c9 = sc . nextInt ( ) ; int sum1 = c1 + c5 + c9 ; int sum2 = c1 + c6 + c8 ; int sum3 = c2 + c4 + c9 ; int sum4 = c2 + c6 + c7 ; int sum5 = c3 + c4 + c8 ; int sum6 = c3 + c5 + c7 ; if ( sum1 = = sum2 & & sum2 = = sum3 & & sum3 = = sum4 & & sum4 = = sum5 & & sum5 = = sum6 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] a = new int [ 3 ] [ 3 ] ; int [ ] x = new int [ 3 ] ; int [ ] y = new int [ 3 ] ; int max = Integer . MIN _ VALUE ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { a [ i ] [ j ] = sc . nextInt ( ) ; if ( a [ i ] [ j ] > max ) { max = a [ i ] [ j ] ; } } } String f = " Yes " ; x [ 0 ] = 0 ; for ( int j = 0 ; j < 3 ; j + + ) { y [ j ] = a [ 0 ] [ j ] - x [ 0 ] ; } for ( int j = 0 ; j < 3 ; j + + ) { x [ j ] = a [ j ] [ 0 ] - y [ 0 ] ; } for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( a [ i ] [ j ] ! = x [ i ] + y [ j ] ) { f = " No " ; } } } System . out . println ( f ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner scanner = new Scanner ( System . in ) ; try { int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = scanner . nextInt ( ) ; } } for ( int i = 0 ; i < 2 ; i + + ) { if ( ! check _ h ( c , i ) ) { System . out . println ( " No " ) ; return ; } } for ( int j = 0 ; j < 2 ; j + + ) { if ( ! check _ v ( c , j ) ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } finally { scanner . close ( ) ; } } private static boolean check _ v ( int [ ] [ ] c , int j ) { for ( int i = 0 ; i < 2 ; i + + ) { if ( c [ i ] [ j + 1 ] - c [ i ] [ j ] ! = c [ i + 1 ] [ j + 1 ] - c [ i + 1 ] [ j ] ) return false ; } return true ; } private static boolean check _ h ( int [ ] [ ] c , int i ) { for ( int j = 0 ; j < 2 ; j + + ) { if ( c [ i + 1 ] [ j ] - c [ i ] [ j ] ! = c [ i + 1 ] [ j + 1 ] - c [ i ] [ j + 1 ] ) return false ; } return true ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { int total = x + y ; if ( ! ( total > S ) & & ( total + K ) > = S ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = Integer . parseInt ( sc . next ( ) ) ; int s = Integer . parseInt ( sc . next ( ) ) ; int ans = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( z > = 0 & & z < = k ) ans + + ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int K = scan . nextInt ( ) ; int S = scan . nextInt ( ) ; int a ; int b ; int cnt = 0 ; for ( a = 0 ; a < = K ; a + + ) { int qw = K ; if ( S - a < qw ) { qw = S - a ; } for ( b = 0 ; b < = qw ; b + + ) { if ( S - a - b < = K ) cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { try ( Scanner in = new Scanner ( System . in ) ) { int K = in . nextInt ( ) ; int S = in . nextInt ( ) ; int count = 0 ; for ( int X = 0 ; X < = K ; X + + ) { for ( int Y = 0 ; Y < = K ; Y + + ) { int Z = S - ( X + Y ) ; if ( ! ( Z > = 0 & & Z < = K ) ) { continue ; } count + + ; } } System . out . println ( count ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] p = new int [ n ] ; for ( int i = 0 ; i < n ; + + i ) p [ i ] = sc . nextInt ( ) ; int ans = 0 ; int min = p [ 0 ] ; for ( int i = 0 ; i < n ; + + i ) { if ( p [ i ] < = min ) { min = p [ i ] ; + + ans ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int sum = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { int z = S - ( x + y ) ; if ( z > = 0 & & z < = K ) { sum + + ; } } } System . out . println ( sum ) ; } } import java . math . BigInteger ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { a [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; long ans = a [ 0 ] - 1 ; int p = 2 ; for ( int i = 1 ; i < n ; i + + ) { if ( a [ i ] ! = p ) { ans + = ( a [ i ] - 1 ) / p ; } else { p + + ; } } System . out . println ( ans ) ; } } import java . util . * ; class Main { public static void main ( String args [ ] ) { try ( Scanner sc = new Scanner ( System . in ) ) { int K = sc . nextInt ( ) , S = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { int k = S - i - j ; if ( 0 < = k & & k < = K ) { ans + + ; } } } System . out . println ( ans ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; for ( int i = 0 ; i < N ; i + + ) { String s = sc . next ( ) ; if ( " Y " . equals ( s ) ) { System . out . println ( " Four " ) ; return ; } } System . out . println ( " Three " ) ; } } import java . util . Scanner ; public class Main { static Scanner sc = new Scanner ( System . in ) ; static int [ ] N = new int [ 10 ] ; public static void main ( String [ ] args ) { for ( int i = 0 ; i < 4 ; i + + ) { N [ sc . nextInt ( ) ] = 1 ; } if ( N [ 1 ] = = 1 & & N [ 7 ] = = 1 & & N [ 4 ] = = 1 & & N [ 9 ] = = 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int limit = scanner . nextInt ( ) ; int target = scanner . nextInt ( ) ; int count = 0 ; int z = 0 ; for ( int i = 0 ; i < = limit ; i + + ) { for ( int j = 0 ; j < = limit ; j + + ) { z = target - i - j ; if ( z > = 0 & & z < = limit ) { count + = 1 ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int p [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = scan . nextInt ( ) ; } int ans = 0 ; int min = n + 1 ; for ( int i = 0 ; i < n ; i + + ) { if ( min > p [ i ] ) { min = p [ i ] ; ans + + ; } } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > all = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < 9 ; i + + ) { all . add ( sc . nextInt ( ) ) ; } boolean takahashi = true ; Integer diff1 = all . get ( 3 ) - all . get ( 0 ) ; Integer diff2 = all . get ( 4 ) - all . get ( 1 ) ; Integer diff3 = all . get ( 5 ) - all . get ( 2 ) ; if ( diff1 ! = diff2 ) { takahashi = false ; } else if ( diff1 ! = diff3 ) { takahashi = false ; } if ( takahashi ) { diff1 = all . get ( 6 ) - all . get ( 3 ) ; diff2 = all . get ( 7 ) - all . get ( 4 ) ; diff3 = all . get ( 8 ) - all . get ( 5 ) ; if ( diff1 ! = diff2 ) { takahashi = false ; } else if ( diff1 ! = diff3 ) { takahashi = false ; } } if ( takahashi ) { diff1 = all . get ( 1 ) - all . get ( 0 ) ; diff2 = all . get ( 4 ) - all . get ( 3 ) ; diff3 = all . get ( 7 ) - all . get ( 6 ) ; if ( diff1 ! = diff2 ) { takahashi = false ; } else if ( diff1 ! = diff3 ) { takahashi = false ; } } if ( takahashi ) { diff1 = all . get ( 2 ) - all . get ( 1 ) ; diff2 = all . get ( 5 ) - all . get ( 4 ) ; diff3 = all . get ( 8 ) - all . get ( 7 ) ; if ( diff1 ! = diff2 ) { takahashi = false ; } else if ( diff1 ! = diff3 ) { takahashi = false ; } } if ( takahashi ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] P = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { P [ i ] = sc . nextInt ( ) ; } int ans = 0 ; int max = N + 1 ; for ( int i = 0 ; i < N ; i + + ) { if ( max > = P [ i ] ) { ans + + ; max = P [ i ] ; } } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; class Main { void solve ( ) { int n = inint ( ) ; int [ ] a = inintar ( n ) ; int count = 0 ; int min = Integer . MAX _ VALUE ; for ( int i = 0 ; i < n ; i + + ) { min = Math . min ( min , a [ i ] ) ; if ( min > = a [ i ] ) count + + ; } out . println ( count ) ; } public static Scanner in = new Scanner ( System . in ) ; public static PrintWriter out = new PrintWriter ( System . out ) ; public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; out . flush ( ) ; } public int inint ( ) { return in . nextInt ( ) ; } public long inlong ( ) { return in . nextLong ( ) ; } public double indouble ( ) { return in . nextDouble ( ) ; } public String instr ( ) { return in . next ( ) ; } public char inchar ( ) { return in . next ( ) . charAt ( 0 ) ; } public int [ ] inintar ( int num ) { int [ ] a = new int [ num ] ; for ( int i = 0 ; i < num ; i + + ) { a [ i ] = in . nextInt ( ) ; } return a ; } public char [ ] incharar ( ) { return in . next ( ) . toCharArray ( ) ; } public char [ ] [ ] incharmap ( int h , int w ) { char [ ] [ ] a = new char [ h ] [ w ] ; for ( int i = 0 ; i < h ; i + + ) { String temp = in . next ( ) ; for ( int j = 0 ; j < w ; j + + ) { a [ i ] [ j ] = temp . charAt ( j ) ; } } return a ; } } import java . io . * ; import java . math . BigInteger ; import java . util . * ; import java . util . ArrayList ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) a [ i ] = sc . nextInt ( ) ; int max = Integer . MAX _ VALUE ; int c = 0 ; for ( int j = 0 ; j < n ; j + + ) { if ( a [ j ] < max ) { max = a [ j ] ; c + + ; } } System . out . println ( c ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; int z = 0 ; for ( int i = 0 ; i < = k & & i < = s ; i + + ) { for ( int j = 0 ; j < = k & & j < = s - i ; j + + ) { z = s - i - j ; if ( z > = 0 & & z < = k ) count + + ; } } System . out . println ( count ) ; } } import java . io . * ; import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] P = new int [ N ] ; for ( int n = 0 ; n < N ; n + + ) P [ n ] = sc . nextInt ( ) ; int ans = 0 ; int min = 1000000 ; for ( int n = 0 ; n < N ; n + + ) { if ( P [ n ] < min ) ans + + ; min = Math . min ( min , P [ n ] ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { int ans = 0 ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; boolean f = false ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { a [ i ] = sc . nextInt ( ) ; } int tmp = n + 1 ; for ( int i = 0 ; i < n ; i + + ) { if ( i = = 0 ) { tmp = a [ i ] ; continue ; } if ( tmp > = a [ i ] ) { tmp = a [ i ] ; ans + + ; } } ans + + ; System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int min = 2000001 ; int count = 0 ; for ( int i = 0 ; i < n ; i + + ) { int tmp = sc . nextInt ( ) ; if ( min > tmp ) { min = tmp ; count + + ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int k = Integer . parseInt ( scanner . next ( ) ) ; int s = Integer . parseInt ( scanner . next ( ) ) ; int res = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - ( x + y ) ; if ( 0 < = z & & z < = k ) res + + ; } } System . out . println ( res ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] T = sc . nextLine ( ) . split ( " " ) ; int K = Integer . parseInt ( T [ 0 ] ) ; int S = Integer . parseInt ( T [ 1 ] ) ; int ans = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { int k = S - i - j ; if ( i + j + k = = S & & k > = 0 & & k < = K ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . * ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner scanner = new Scanner ( System . in ) ; int K = scanner . nextInt ( ) ; int S = scanner . nextInt ( ) ; int sub = 0 ; int count = 0 ; for ( int i = 0 ; i < = K ; i + + ) { if ( i ! = S ) { for ( int j = 0 ; j < = K ; j + + ) { if ( i + j ! = S ) { sub = S - ( i + j ) ; if ( sub > = 0 & & sub < = K ) { count + + ; } } else if ( i + j = = S ) { count + + ; break ; } } } else if ( i = = S ) { count + + ; } } System . out . println ( count ) ; } } import java . util . * ; class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int h = 0 ; h < = k ; h + + ) { if ( s - i - h < = k & & s > = i + h ) { cnt + + ; } } } System . out . println ( cnt ) ; } } import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] p = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { p [ i ] = sc . nextInt ( ) ; } int count = 0 ; int pj = p [ 0 ] ; for ( int i = 0 ; i < N ; i + + ) { if ( p [ i ] < = pj ) { + + count ; pj = p [ i ] ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( z > = 0 & & z < = k ) count + + ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] intArray = new int [ n ] ; int count = 1 ; for ( int i = 0 ; i < n ; i + + ) { intArray [ i ] = sc . nextInt ( ) ; } int min = intArray [ 0 ] ; for ( int i = 1 ; i < intArray . length ; i + + ) { if ( min > intArray [ i ] ) { min = intArray [ i ] ; count + + ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ; ) { solve ( sc ) ; } } public static void solve ( Scanner sc ) { int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( 0 < = z & & z < = k ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; boolean P = false ; boolean W = false ; boolean G = false ; boolean Y = false ; for ( int i = 0 ; i < N ; i + + ) { String c = sc . next ( ) ; if ( c . equals ( " P " ) ) { P = true ; } else if ( c . equals ( " W " ) ) { W = true ; } else if ( c . equals ( " G " ) ) { G = true ; } else if ( c . equals ( " Y " ) ) { Y = true ; } } int answer = 0 ; if ( P = = true ) { answer + + ; } if ( W = = true ) { answer + + ; } if ( G = = true ) { answer + + ; } if ( Y = = true ) { answer + + ; } if ( answer = = 3 ) { System . out . println ( " Three " ) ; } else if ( answer = = 4 ) { System . out . println ( " Four " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] C = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { C [ i ] [ j ] = Integer . parseInt ( sc . next ( ) ) ; } } sc . close ( ) ; int [ ] a = new int [ 3 ] ; int [ ] b = new int [ 3 ] ; a [ 0 ] = 0 ; b [ 0 ] = C [ 0 ] [ 0 ] ; b [ 1 ] = C [ 0 ] [ 1 ] ; b [ 2 ] = C [ 0 ] [ 2 ] ; a [ 1 ] = C [ 1 ] [ 0 ] - b [ 0 ] ; a [ 2 ] = C [ 2 ] [ 0 ] - b [ 0 ] ; String ans = " Yes " ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( a [ i ] + b [ j ] ! = C [ i ] [ j ] ) { ans = " No " ; } } } System . out . println ( ans ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; MyScanner in = new MyScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; C solver = new C ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class C { public void solve ( int testNumber , MyScanner in , PrintWriter out ) { int N = in . nextInt ( ) ; int [ ] P = in . nextIntArray ( N ) ; int max = N + 1 ; int ans = 0 ; for ( int i = 0 ; i < N ; i + + ) { if ( P [ i ] < = max ) { max = P [ i ] ; ans + + ; } } out . println ( ans ) ; } } static class MyScanner { private BufferedReader in ; private StringTokenizer st ; public MyScanner ( InputStream stream ) { in = new BufferedReader ( new InputStreamReader ( stream ) ) ; } public String next ( ) { while ( st = = null | | ! st . hasMoreTokens ( ) ) { try { String rl = in . readLine ( ) ; if ( rl = = null ) { return null ; } st = new StringTokenizer ( rl ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public int [ ] nextIntArray ( int n ) { int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { a [ i ] = nextInt ( ) ; } return a ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int sum = 0 ; int min = - 1 ; ArrayList < Integer > a = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n ; i + + ) { int b = scan . nextInt ( ) ; int [ ] g = put ( b , min ) ; sum + = g [ 0 ] ; min = g [ 1 ] ; } System . out . println ( sum ) ; } public static int [ ] put ( int a , int b ) { int [ ] g = new int [ 2 ] ; if ( b = = - 1 ) { g [ 1 ] = a ; g [ 0 ] = 1 ; return g ; } if ( a < = b ) { g [ 1 ] = a ; g [ 0 ] = 1 ; return g ; } g [ 1 ] = b ; g [ 0 ] = 0 ; return g ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] s = br . readLine ( ) . split ( " " ) ; int max = Integer . parseInt ( s [ 0 ] ) ; int ans = Integer . parseInt ( s [ 1 ] ) ; int result = 0 ; for ( int i = 0 ; i < = max ; i + + ) { for ( int j = 0 ; j < = max ; j + + ) { int k = ans - ( i + j ) ; if ( 0 < = k & & k < = max ) result + + ; } } System . out . println ( result ) ; } } import java . util . * ; class Main { public static void main ( String [ ] args ) { int n ; Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; + + i ) { arr [ i ] = sc . nextInt ( ) ; } long max _ now = arr [ 0 ] ; int ans = 1 ; for ( int i = 1 ; i < n ; + + i ) { if ( arr [ i ] < = max _ now ) { ans + + ; } max _ now = Math . min ( max _ now , arr [ i ] ) ; } System . out . println ( ans ) ; } } public class Main { public static void main ( String [ ] args ) { java . util . Scanner s = new java . util . Scanner ( System . in ) ; System . out . println ( ( Main . calc ( s . nextInt ( ) , s . nextInt ( ) ) ) ) ; } public static int calc ( int k , int s ) { int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( 0 < = z & & z < = k ) { count + + ; } } } return count ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; sc . close ( ) ; int ans = 0 ; for ( int i = 0 ; i < = K ; + + i ) { for ( int j = 0 ; j < = K ; + + j ) { if ( S - i - j > = 0 & & S - i - j < = K ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] p = new int [ n ] ; for ( int i = 0 ; i < p . length ; i + + ) { p [ i ] = sc . nextInt ( ) ; } int min = p [ 0 ] ; int count = 1 ; for ( int i = 0 ; i < p . length ; i + + ) { if ( min > p [ i ] ) { min = p [ i ] ; count + = 1 ; } } System . out . println ( count ) ; } } import java . io . * ; import java . util . * ; public class Main implements Runnable { private void solve ( ) throws IOException { int K = nextInt ( ) ; int S = nextInt ( ) ; long ret = 0L ; for ( int a = 0 ; a < = K ; + + a ) { for ( int b = 0 ; b < = K ; + + b ) { if ( a + b > S ) continue ; int left = S - ( a + b ) ; if ( left < = K ) + + ret ; } } writer . println ( ret ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; public void run ( ) { try { reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; tokenizer = null ; writer = new PrintWriter ( System . out ) ; solve ( ) ; reader . close ( ) ; writer . close ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; System . exit ( 1 ) ; } } int nextInt ( ) throws IOException { return Integer . parseInt ( nextToken ( ) ) ; } long nextLong ( ) throws IOException { return Long . parseLong ( nextToken ( ) ) ; } double nextDouble ( ) throws IOException { return Double . parseDouble ( nextToken ( ) ) ; } short nextShort ( ) throws IOException { return Short . parseShort ( nextToken ( ) ) ; } String nextToken ( ) throws IOException { while ( tokenizer = = null | | ! tokenizer . hasMoreTokens ( ) ) { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } return tokenizer . nextToken ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int ans = 0 ; for ( int x = 0 ; x < = K ; + + x ) { for ( int y = 0 ; y < = K ; + + y ) { int z = S - x - y ; if ( z < 0 | | z > K ) continue ; + + ans ; } } System . out . println ( ans ) ; } } import java . io . * ; class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; String [ ] data = str . split ( " " ) ; int [ ] numdata = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) { numdata [ i ] = Integer . parseInt ( data [ i ] ) ; } int a = 0 , b = 0 , c = 0 , d = 0 , e = 0 ; for ( int i = 0 ; i < 4 ; i + + ) { if ( ! ( e = = 0 ) ) { e = 1 ; break ; } switch ( numdata [ i ] ) { case 1 : if ( a = = 0 ) { a = 1 ; } else { e = 1 ; } break ; case 9 : if ( b = = 0 ) { b = 1 ; } else { e = 1 ; } break ; case 7 : if ( c = = 0 ) { c = 1 ; } else { e = 1 ; } break ; case 4 : if ( d = = 0 ) { d = 1 ; } else { e = 1 ; } break ; default : e = 1 ; break ; } } if ( e = = 0 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] a = new int [ 3 ] ; int [ ] b = new int [ 3 ] ; for ( int i = 0 ; i < = 100 ; i + + ) { b [ 0 ] = i ; a [ 0 ] = c [ 0 ] [ 0 ] - i ; a [ 1 ] = c [ 1 ] [ 0 ] - i ; a [ 2 ] = c [ 2 ] [ 0 ] - i ; b [ 1 ] = c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] + i ; b [ 2 ] = c [ 0 ] [ 2 ] - c [ 0 ] [ 0 ] + i ; int d = 0 ; for ( int j = 1 ; j < = 2 ; j + + ) { for ( int k = 1 ; k < = 2 ; k + + ) { if ( a [ j ] + b [ k ] ! = c [ j ] [ k ] ) d + + ; } } if ( d = = 0 ) { out . println ( " Yes " ) ; break ; } else if ( i = = 100 ) out . println ( " No " ) ; } } } import java . util . * ; public class Main { static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int [ ] n = { scanner . nextInt ( ) , scanner . nextInt ( ) , scanner . nextInt ( ) , scanner . nextInt ( ) } ; Arrays . sort ( n ) ; System . out . println ( Arrays . equals ( n , new int [ ] { 1 , 4 , 7 , 9 } ) ? " YES " : " NO " ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner Input = new Scanner ( System . in ) ; int K = Input . nextInt ( ) ; int S = Input . nextInt ( ) ; int Counter = 0 ; for ( int X = 0 ; X < = K ; X + + ) { for ( int Y = 0 ; Y < = K ; Y + + ) { if ( 0 < = S - ( X + Y ) & & S - ( X + Y ) < = K ) { Counter + + ; } } } System . out . println ( Counter ) ; } } import java . util . Scanner ; public class Main { int count = 0 ; void run ( ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { if ( S - x - y > = 0 & & S - x - y < = K ) { count + + ; } } } System . out . println ( count ) ; sc . close ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long count = 1 ; long l = 0 , x = 0 ; long [ ] array = new long [ n ] ; for ( int i = 0 ; i < n ; i + + ) { array [ i ] = sc . nextInt ( ) ; } x = array [ 0 ] ; for ( int i = 1 ; i < n ; i + + ) { if ( array [ i ] < = x ) { count + + ; x = array [ i ] ; } } if ( count = = 0 ) { System . out . println ( 1 ) ; } else { System . out . println ( count ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { int k , s , l , cnt = 0 ; Scanner sc = new Scanner ( System . in ) ; k = sc . nextInt ( ) ; s = sc . nextInt ( ) ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { l = s - ( i + j ) ; if ( l > = 0 & & l < = k ) cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int K = scan . nextInt ( ) ; int S = scan . nextInt ( ) ; int count = 0 ; for ( int X = 0 ; X < = K ; X + + ) { for ( int Y = 0 ; Y < = K ; Y + + ) { if ( S - X - Y > = 0 & & S - X - Y < = K ) { count + + ; } } } System . out . print ( count ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) , ans = 1 ; int a [ ] ; a = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) a [ i ] = in . nextInt ( ) ; int mmin = a [ 0 ] ; for ( int i = 1 ; i < n ; i + + ) { if ( a [ i ] < mmin ) ans + + ; mmin = Math . min ( mmin , a [ i ] ) ; } System . out . printf ( " % d \ n " , ans ) ; in . close ( ) ; } } import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int [ ] p = IntStream . range ( 0 , sc . nextInt ( ) ) . map ( e - > sc . nextInt ( ) ) . toArray ( ) ; int temp = p [ 0 ] ; int ans = 0 ; for ( int i = 0 ; i < p . length ; i + + ) { if ( p [ i ] < = temp ) { ans + + ; temp = p [ i ] ; } } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] org = new int [ ] { 1 , 4 , 7 , 9 } ; int [ ] arr = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) { arr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( arr ) ; for ( int i = 0 ; i < 4 ; i + + ) { if ( arr [ i ] ! = org [ i ] ) { System . out . println ( " NO " ) ; return ; } } System . out . println ( " YES " ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int K = scan . nextInt ( ) ; int S = scan . nextInt ( ) ; int counter = 0 ; for ( int X = 0 ; X < = K ; X + + ) { for ( int Y = 0 ; Y < = K ; Y + + ) { int Z = S - X - Y ; if ( Z > = 0 & & Z < = K ) { counter + + ; } } } System . out . print ( counter ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int p [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i + + ) { p [ i ] = scan . nextInt ( ) ; } scan . close ( ) ; int cnt = 0 ; int min = Integer . MAX _ VALUE ; for ( int i = 0 ; i < n ; i + + ) { if ( min > p [ i ] ) { cnt + + ; min = p [ i ] ; } } System . out . println ( cnt ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner Input = new Scanner ( System . in ) ; HashMap < String , Integer > HM = new HashMap ( ) ; int N = Input . nextInt ( ) ; for ( int I = 0 ; I < N ; I + + ) { String S = Input . next ( ) ; HM . put ( S , 0 ) ; } if ( HM . size ( ) = = 4 ) { System . out . println ( " Four " ) ; } else if ( HM . size ( ) = = 3 ) { System . out . println ( " Three " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( 0 < = z & & z < = k ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int [ ] [ ] map = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { map [ i ] [ j ] = scanner . nextInt ( ) ; } } int temp2 = map [ 0 ] [ 1 ] - map [ 0 ] [ 0 ] ; int temp3 = map [ 0 ] [ 2 ] - map [ 0 ] [ 0 ] ; if ( map [ 1 ] [ 1 ] - map [ 1 ] [ 0 ] = = temp2 & & map [ 2 ] [ 1 ] - map [ 2 ] [ 0 ] = = temp2 & & map [ 1 ] [ 2 ] - map [ 1 ] [ 0 ] = = temp3 & & map [ 2 ] [ 2 ] - map [ 2 ] [ 0 ] = = temp3 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] ci = new int [ 3 ] [ 3 ] ; for ( int c = 0 ; c < 3 ; c + + ) { ci [ c ] [ 0 ] = sc . nextInt ( ) ; ci [ c ] [ 1 ] = sc . nextInt ( ) ; ci [ c ] [ 2 ] = sc . nextInt ( ) ; } int count = 0 ; for ( int b = 0 ; b < 2 ; b + + ) { if ( ( ci [ b + 1 ] [ 0 ] - ci [ b ] [ 0 ] ) ! = ( ci [ b + 1 ] [ 1 ] - ci [ b ] [ 1 ] ) | | ( ci [ b + 1 ] [ 1 ] - ci [ b ] [ 1 ] ) ! = ( ci [ b + 1 ] [ 2 ] - ci [ b ] [ 2 ] ) ) { count = 1 ; } } for ( int b = 0 ; b < 2 ; b + + ) { if ( ( ci [ 0 ] [ b + 1 ] - ci [ 0 ] [ b ] ) ! = ( ci [ 1 ] [ b + 1 ] - ci [ 1 ] [ b ] ) | | ( ci [ 1 ] [ b + 1 ] - ci [ 1 ] [ b ] ) ! = ( ci [ 2 ] [ b + 1 ] - ci [ 2 ] [ b ] ) ) { count = 1 ; } } if ( count = = 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . * ; import java . util . * ; import java . math . * ; public class Main { public Main ( ) { Scanner sc = new Scanner ( System . in ) ; int N [ ] = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i + + ) { N [ i ] = sc . nextInt ( ) ; } int [ ] ans = new int [ ] { 1 , 7 , 9 , 4 } ; boolean [ ] frag = new boolean [ ] { false , false , false , false } ; loop1 : for ( int i = 0 ; i < 4 ; i + + ) { for ( int j = 0 ; j < 4 ; j + + ) { if ( ans [ i ] = = N [ j ] ) { continue loop1 ; } } System . out . println ( " NO " ) ; return ; } System . out . println ( " YES " ) ; } public static void main ( String [ ] args ) { Main main = new Main ( ) ; } } import java . util . LinkedHashSet ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; char [ ] c = new char [ n ] ; for ( int i = 0 ; i < n ; i + + ) { c [ i ] = sc . next ( ) . charAt ( 0 ) ; } LinkedHashSet < Character > lhs = new LinkedHashSet < Character > ( ) ; for ( int i = 0 ; i < n ; i + + ) { lhs . add ( c [ i ] ) ; } Object [ ] newc = lhs . toArray ( ) ; if ( newc . length = = 3 ) { System . out . println ( " Three " ) ; } else { System . out . println ( " Four " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int c [ ] [ ] = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = sc . nextInt ( ) ; } } int s1 = c [ 0 ] [ 1 ] + c [ 0 ] [ 2 ] + c [ 1 ] [ 2 ] ; int s2 = c [ 1 ] [ 0 ] + c [ 2 ] [ 0 ] + c [ 2 ] [ 1 ] ; int s = c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] ; if ( s1 + s2 = = 2 * s ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int a , b , c ; int count = 0 ; for ( a = 0 ; a < = k ; a + + ) { for ( b = 0 ; b < = k ; b + + ) { c = s - a - b ; if ( c > = 0 & & c < = k ) count + + ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] p = new int [ N ] ; for ( int i = 0 ; i < N ; i + + ) { p [ i ] = sc . nextInt ( ) ; } int temp _ max = p [ 0 ] ; int cnt = 1 ; for ( int i = 1 ; i < N ; i + + ) { if ( temp _ max > p [ i ] ) { temp _ max = p [ i ] ; cnt + + ; } } System . out . print ( cnt ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { if ( S - i - j > = 0 & & S - i - j < = K ) { cnt + + ; } } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { private static void p ( Object x ) { System . out . println ( x ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - x - y ; if ( z > = 0 & & z < = k ) { count + + ; } } } p ( count ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskC solver = new TaskC ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskC { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = in . nextInt ( ) ; } } int [ ] a = new int [ 3 ] ; int [ ] b = new int [ 3 ] ; for ( a [ 0 ] = 0 ; a [ 0 ] < 101 ; a [ 0 ] + + ) { b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] ; for ( a [ 1 ] = 0 ; a [ 1 ] < 101 ; a [ 1 ] + + ) { b [ 1 ] = c [ 1 ] [ 1 ] - a [ 1 ] ; for ( a [ 2 ] = 0 ; a [ 2 ] < 101 ; a [ 2 ] + + ) { b [ 2 ] = c [ 2 ] [ 2 ] - a [ 2 ] ; boolean ok = true ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { if ( c [ i ] [ j ] ! = a [ i ] + b [ j ] ) { ok = false ; } } } if ( ok ) { out . println ( " Yes " ) ; return ; } } } } out . println ( " No " ) ; } } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int cnt = 0 ; for ( int a = 0 ; a < = k ; a + + ) { for ( int b = 0 ; b < = k ; b + + ) { int c = s - a - b ; if ( 0 < = c & & c < = k ) { cnt + + ; } } } System . out . println ( cnt ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < = k ; i + + ) { for ( int j = 0 ; j < = k ; j + + ) { int z = s - i - j ; if ( z > = 0 & & z < = k ) { ans + + ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int a = 0 ; for ( int x = 0 ; x < = k ; + + x ) { for ( int y = 0 ; y < = k ; + + y ) { if ( s - x - y > = 0 & & s - x - y < = k ) { + + a ; } } } System . out . println ( a ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int count1 = 0 ; int count9 = 0 ; int count7 = 0 ; int count4 = 0 ; for ( int i = 0 ; i < 4 ; i + + ) { int N = in . nextInt ( ) ; switch ( N ) { case 1 : count1 + + ; break ; case 9 : count9 + + ; break ; case 7 : count7 + + ; break ; case 4 : count4 + + ; break ; } } String str = " NO " ; if ( count1 = = 1 & & count9 = = 1 & & count7 = = 1 & & count4 = = 1 ) { str = " YES " ; } out . println ( str ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer = = null | | ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int a [ ] = new int [ 3 ] ; int b [ ] = new int [ 3 ] ; int c [ ] [ ] = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i + + ) { for ( int j = 0 ; j < 3 ; j + + ) { c [ i ] [ j ] = scan . nextInt ( ) ; } } int temp1 = c [ 0 ] [ 1 ] - c [ 0 ] [ 2 ] ; int temp2 = c [ 1 ] [ 1 ] - c [ 1 ] [ 2 ] ; int temp3 = c [ 2 ] [ 1 ] - c [ 2 ] [ 2 ] ; int temp4 = c [ 0 ] [ 0 ] - c [ 0 ] [ 1 ] ; int temp5 = c [ 1 ] [ 0 ] - c [ 1 ] [ 1 ] ; int temp6 = c [ 2 ] [ 0 ] - c [ 2 ] [ 1 ] ; boolean ans = true ; if ( temp1 ! = temp2 ) { ans = false ; } if ( temp1 ! = temp3 ) { ans = false ; } if ( temp4 ! = temp5 ) { ans = false ; } if ( temp4 ! = temp6 ) { ans = false ; } if ( ans ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int k = scan . nextInt ( ) ; int s = scan . nextInt ( ) ; int cnt = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { int z = s - ( x + y ) ; if ( 0 < = z & & z < = k ) cnt + + ; } } System . out . println ( cnt ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int K = sc . nextInt ( ) ; final int S = sc . nextInt ( ) ; int counter = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { int k = S - i - j ; if ( 0 < = k & & k < = K ) { counter + + ; } } } System . out . println ( counter ) ; } } import java . io . * ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws Exception { PrintWriter pw = new PrintWriter ( System . out ) ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long min = ( long ) 1e10 ; int ans = 0 ; for ( int i = 0 ; i < n ; i + + ) { long x = sc . nextLong ( ) ; if ( x < = min ) { ans + + ; min = x ; } } System . out . println ( ans ) ; } public static class Scanner { StringTokenizer st ; BufferedReader br ; public Scanner ( InputStream s ) { br = new BufferedReader ( new InputStreamReader ( s ) ) ; } public String next ( ) throws IOException { while ( st = = null | | ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return st . nextToken ( ) ; } public int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } public String nextLine ( ) throws IOException { return br . readLine ( ) ; } public double nextDouble ( ) throws IOException { String x = next ( ) ; StringBuilder sb = new StringBuilder ( " 0 " ) ; double res = 0 , f = 1 ; boolean dec = false , neg = false ; int start = 0 ; if ( x . charAt ( 0 ) = = ' -' ) { neg = true ; start + + ; } for ( int i = start ; i < x . length ( ) ; i + + ) if ( x . charAt ( i ) = = ' .' ) { res = Long . parseLong ( sb . toString ( ) ) ; sb = new StringBuilder ( " 0 " ) ; dec = true ; } else { sb . append ( x . charAt ( i ) ) ; if ( dec ) f * = 10 ; } res + = Long . parseLong ( sb . toString ( ) ) / f ; return res * ( neg ? - 1 : 1 ) ; } public boolean ready ( ) throws IOException , IOException { return br . ready ( ) ; } } } import java . util . Scanner ; import java . util . TreeSet ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; TreeSet < Integer > ts = new TreeSet < Integer > ( ) ; int cnt = 0 ; for ( int i = 0 ; i < N ; + + i ) { int pi = sc . nextInt ( ) ; if ( ! ts . isEmpty ( ) ) { int min = ts . first ( ) ; if ( min > = pi ) { + + cnt ; } } else { + + cnt ; } ts . add ( pi ) ; } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = 0 , y = 0 , z , cnt = 0 ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; for ( x = 0 ; x < = k ; x + + ) { for ( y = 0 ; y < = k ; y + + ) { if ( s - ( x + y ) > = 0 & & s - ( x + y ) < = k ) { cnt + + ; } } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; Scanner sc = new Scanner ( System . in ) ; main . solve ( sc ) ; sc . close ( ) ; } void solve ( Scanner sc ) { int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x < = K ; x + + ) { for ( int y = 0 ; y < = K ; y + + ) { if ( S - x - y < = K & & S > = x + y ) { count + + ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int c = 0 ; for ( int x = 0 ; x < = k ; x + + ) { for ( int y = 0 ; y < = k ; y + + ) { if ( x + y = = s ) { c + + ; } else if ( s - ( x + y ) < = k & & x + y < s ) { c + + ; } } } System . out . println ( c ) ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] n = new int [ 10 ] ; for ( int i = 0 ; i < 4 ; i + + ) { int tmp = sc . nextInt ( ) ; n [ tmp ] + + ; } if ( n [ 1 ] = = 1 & & n [ 9 ] = = 1 & & n [ 7 ] = = 1 & & n [ 4 ] = = 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; import java . io . * ; import java . math . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; HashSet < String > hs = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i + + ) { hs . add ( sc . next ( ) ) ; } if ( hs . size ( ) = = 3 ) { System . out . println ( " Three " ) ; } else { System . out . println ( " Four " ) ; } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveB ( ) ; } private void solveA ( ) { Scanner scanner = null ; String wk = " " ; try { scanner = new Scanner ( System . in ) ; wk = scanner . next ( ) ; System . out . println ( wk . replaceAll ( " , " , " " ) ) ; } finally { if ( scanner ! = null ) { scanner . close ( ) ; } } } private void solveB ( ) { Scanner scanner = null ; int numK = 0 ; int s = 0 ; try { scanner = new Scanner ( System . in ) ; numK = scanner . nextInt ( ) ; s = scanner . nextInt ( ) ; int startK = 0 ; if ( numK < = s / 3 ) { startK = numK ; } int res = 0 ; for ( int i = 0 ; i < = numK ; i + + ) { for ( int j = 0 ; j < = numK ; j + + ) { if ( s - i - j < 0 ) { break ; } startK = s - i - j ; for ( int k = startK ; k < = numK ; k + + ) { if ( i + j + k = = s ) { res + + ; break ; } } } } System . out . println ( res ) ; } finally { if ( scanner ! = null ) { scanner . close ( ) ; } } } private void solveC ( ) { Scanner scanner = null ; int lineAB = 0 ; int lineBC = 0 ; int lineCA = 0 ; try { scanner = new Scanner ( System . in ) ; lineAB = scanner . nextInt ( ) ; System . out . println ( " " ) ; } finally { if ( scanner ! = null ) { scanner . close ( ) ; } } } private void solveD ( ) { Scanner scanner = null ; int lineAB = 0 ; int lineBC = 0 ; int lineCA = 0 ; try { scanner = new Scanner ( System . in ) ; lineAB = scanner . nextInt ( ) ; System . out . println ( " " ) ; } finally { if ( scanner ! = null ) { scanner . close ( ) ; } } } } import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) , S = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < = K ; i + + ) { for ( int j = 0 ; j < = K ; j + + ) { int l = S - i - j ; if ( l > = 0 & & l < = K & & i + j + l = = S ) { count + + ; } } } System . out . println ( count ) ; } public static int sample ( int n ) { return n ; } } import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] array = new int [ n ] ; int count = 0 ; int min = 99999999 ; while ( n -- > 0 ) { int num = sc . nextInt ( ) ; if ( num < min ) { count + + ; min = num ; } } System . out . println ( count ) ; } } import java . io . * ; import java . text . * ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { final int len = 4 ; int [ ] array = new int [ len ] ; int [ ] suc = { 1 , 4 , 7 , 9 } ; String msg = " NO " ; for ( int i = 0 ; i < len ; i + + ) { array [ i ] = sc . nextInt ( ) ; } Arrays . sort ( array ) ; for ( int i = 0 ; i < len ; i + + ) { if ( array [ i ] ! = suc [ i ] ) { break ; } if ( i = = len - 1 ) { msg = " YES " ; } } System . out . println ( msg ) ; } } " use strict " ; function I ( t , i ) { this . _ s = t . split ( " \ n " ) , this . _ c = 0 , this . _ l = 0 , this . _ f = i | | Number } I . prototype . a = function ( t ) { var i = this . _ s [ this . _ l ] ; if ( i ) { var s = i . trim ( ) . split ( " " ) , h = s [ this . _ c ] ; return this . _ c + + , s . length = = = this . _ c & & ( this . _ c = 0 , this . _ l + + ) , t ? t ( h ) : this . _ f ( h ) } } , I . prototype . l = function ( t ) { var i = this . _ s [ this . _ l ] ; if ( i ) return this . _ c = 0 , this . _ l + + , i . split ( " " ) . map ( t | | this . _ f ) } , module . exports = I ; function main ( input ) { var o = new I ( input ) ; var a = o . a ( ) ; var b = o . a ( ) ; if ( a > = 13 ) { console . log ( b ) ; } else if ( a < = 5 ) { console . log ( 0 ) ; } else { console . log ( b / 2 ) ; } } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { var x = parseInt ( chunk . trim ( ) , 10 ) ; console . log ( Math . pow ( x , 3 ) ) ; } ) ; ' use strict ' const main = arg = > { const input = arg . trim ( ) . split ( " \ n " ) ; let A = input [ 0 ] . split ( ' ' ) [ 0 ] let B = input [ 0 ] . split ( ' ' ) [ 1 ] let C = input [ 0 ] . split ( ' ' ) [ 2 ] let D = input [ 0 ] . split ( ' ' ) [ 3 ] console . log ( Math . max ( A * B , C * D ) ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; " use strict " function Main ( input ) { input = input . trim ( ) . split ( ' ' ) . map ( Number ) ; const k = input [ 0 ] ; const s = input [ 1 ] ; let ret = 0 ; for ( let x = 0 ; x < = k ; + + x ) { for ( let y = 0 ; y < = k ; + + y ) { let z = s - x - y ; if ( 0 < = z & & z < = k ) + + ret ; } } console . log ( ret ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " const tan = ( x ) = > { return Math . tan ( x ) ; } function main ( arg ) { let [ A , B , H , M ] = arg . trim ( ) . split ( " \ n " ) [ 0 ] . split ( " " ) . map ( Number ) const aTh = ( H + M / 60 ) * 360 / 12 const bTh = M * 360 / 60 let th = Math . abs ( aTh - bTh ) console . log ( solve ( A , B , th ) ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function solve ( a , b , th ) { let c2 = Math . pow ( a , 2 ) + Math . pow ( b , 2 ) - 2 * a * b * Math . cos ( th * ( Math . PI / 180 ) ) return Math . sqrt ( c2 ) } ' use strict ' const main = input = > { const args = input . trim ( ) . split ( ' ' ) . map ( Number ) console . log ( Math . max ( args [ 0 ] * args [ 1 ] , args [ 2 ] * args [ 3 ] ) ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ' use strict ' ; function Main ( input ) { const A = input . split ( " \ n " ) [ 0 ] const B = input . split ( " \ n " ) [ 1 ] const C = input . split ( " \ n " ) [ 2 ] const D = input . split ( " \ n " ) [ 3 ] const E = input . split ( " \ n " ) [ 4 ] const endA = A . substr ( - 1 , 1 ) const endB = B . substr ( - 1 , 1 ) const endC = C . substr ( - 1 , 1 ) const endD = D . substr ( - 1 , 1 ) const endE = E . substr ( - 1 , 1 ) let endMin = 10 if ( endA < endMin & & endA ! = 0 ) { endMin = endA } if ( endB < endMin & & endB ! = 0 ) { endMin = endB } if ( endC < endMin & & endC ! = 0 ) { endMin = endC } if ( endD < endMin & & endD ! = 0 ) { endMin = endD } if ( endE < endMin & & endE ! = 0 ) { endMin = endE } const roundA = Math . ceil ( A / 10 ) * 10 const roundB = Math . ceil ( B / 10 ) * 10 const roundC = Math . ceil ( C / 10 ) * 10 const roundD = Math . ceil ( D / 10 ) * 10 const roundE = Math . ceil ( E / 10 ) * 10 console . log ( roundA + roundB + roundC + roundD + roundE - 10 + Number ( endMin ) ) } ; Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) ) ; " use strict " function main ( input ) { let nums = input . split ( ' ' ) nums = nums . map ( x = > + x ) nums . sort ( ) . reverse ( ) let num = 0 ; for ( let i = 0 ; i < nums . length ; i + + ) { let red = ( i > = 1 ) ? nums [ i - 1 ] : 0 num + = Math . abs ( nums [ i ] - red ) } num - = nums [ 0 ] console . log ( num ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var inputArray = input . split ( ' ' ) ; var a = inputArray [ 0 ] ; var b = inputArray [ 1 ] ; var c = inputArray [ 2 ] ; var d = inputArray [ 3 ] ; var result = ( a * b > c * d ) ? a * b : c * d ; console . log ( result ) ; function main ( i ) { i = i . split ( ' \ n ' ) ; var a = Number ( i [ 0 ] ) , b = Number ( i [ 1 ] ) , c = Number ( i [ 2 ] ) , d = Number ( i [ 3 ] ) , e = Number ( i [ 4 ] ) , k = Number ( i [ 5 ] ) ; if ( k > = e - a ) { console . log ( ' Yay ! ' ) ; } else { console . log ( ' : ( ' ) ; } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var x = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; console . log ( x * x * x ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { console . log ( Math . pow ( chunk , 3 ) ) ; } ) ; var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . split ( ' \ n ' ) var T = input [ 0 ] var pdReg = / [ \ ? | P ] [ \ ? | D ] / g var dReg = / \ ? / g console . log ( T . replace ( pdReg , ' PD ' ) . replace ( dReg , ' D ' ) ) ( args = > { const [ A , B , H , M ] = args . trim ( ) . split ( ' ' ) . map ( parseFloat ) ; const theta = ( ( H + M / 60 ) / 12.0 - M / 60.0 ) * Math . PI * 2.0 ; const CC = A * A + B * B - 2.0 * A * B * Math . cos ( theta ) ; console . log ( ( Math . sqrt ( CC ) ) . toString ( ) ) ; } ) ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) function main ( input ) { const args = input . split ( ' ' ) . map ( n = > parseInt ( n , 10 ) ) ; let go = 0 ; let nana = 0 ; for ( let i = 0 ; i < args . length ; i + + ) { if ( args [ i ] = = = 5 ) { go + + ; } ; if ( args [ i ] = = = 7 ) { nana + + ; } ; } if ( go = = = 2 & & nana = = = 1 ) { console . log ( ' YES ' ) ; } else { console . log ( ' NO ' ) ; } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( input ) { input = input . split ( " \ n " ) ; var a = parseInt ( input [ 0 ] , 10 ) ; var b = parseInt ( input [ 1 ] , 10 ) ; var c = parseInt ( input [ 2 ] , 10 ) ; var d = parseInt ( input [ 3 ] , 10 ) ; var e = parseInt ( input [ 4 ] , 10 ) ; var k = parseInt ( input [ 5 ] , 10 ) ; var ans = " Yay ! " ; if ( e - a > k ) { ans = " : ( " ; } else if ( d - a > k ) { ans = " : ( " ; } else if ( c - a > k ) { ans = " : ( " ; } else if ( b - a > k ) { ans = " : ( " ; } if ( e - b > k ) { ans = " : ( " ; } else if ( d - b > k ) { ans = " : ( " ; } else if ( c - b > k ) { ans = " : ( " ; } if ( e - c > k ) { ans = " : ( " ; } else if ( d - c > k ) { ans = " : ( " ; } if ( e - d > k ) { ans = " : ( " ; } console . log ( ans ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var main = function main ( input ) { var N = + input for ( var x = 2 ; x < 100 ; x = x * 2 ) { if ( x > N ) break ; } console . log ( x / 2 ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf-8 ' ) ) function main ( input ) { const a = input . split ( " " ) ; console . log ( Math . max ( a [ 0 ] * a [ 1 ] , a [ 2 ] * a [ 3 ] ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; inp = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . split ( ' \ n ' ) [ 0 ] * 1 console . log ( inp * 800 - ~ ~ ( inp / 15 ) * 200 ) process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { const n = chunk . toString ( ) ; const a = n * n * n ; console . log ( a ) ; } ) ; function main ( input ) { var args = input . split ( " \ n " ) ; var a = parseInt ( args [ 0 ] , 10 ) ; var b = parseInt ( args [ 1 ] , 10 ) ; var c = parseInt ( args [ 2 ] , 10 ) ; var d = parseInt ( args [ 3 ] , 10 ) ; var e = parseInt ( args [ 4 ] , 10 ) ; var k = parseInt ( args [ 5 ] , 10 ) ; if ( e - a < = k ) { if ( e - b < = k ) { if ( e - c < = k ) { if ( e - d < = k ) { if ( d - a < = k ) { if ( d - b < = k ) { if ( d - c < = k ) { if ( c - a < = k ) { if ( c - b < = k ) { if ( b - a < = k ) { console . log ( " Yay ! " ) ; } else { console . log ( " : ( " ) ; } } else { console . log ( " : ( " ) ; } } else { console . log ( " : ( " ) ; } } else { console . log ( " : ( " ) ; } } else { console . log ( " : ( " ) ; } } else { console . log ( " : ( " ) ; } } else { console . log ( " : ( " ) ; } } else { console . log ( " : ( " ) ; } } else { console . log ( " : ( " ) ; } } else { console . log ( " : ( " ) ; } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' ; function Main ( INPUT ) { const input = INPUT . split ( " \ n " ) [ 0 ] . split ( " " ) . map ( n = > Number ( n ) ) ; console . log ( Math . ceil ( ( input [ 0 ] + input [ 1 ] ) / 2 ) ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { let arr = input . split ( ' ' ) . map ( Number ) ; let min1 = arr [ 0 ] * 60 + arr [ 1 ] ; let min2 = arr [ 2 ] * 60 + arr [ 3 ] ; console . log ( min2 - min1 - arr [ 4 ] ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . trim ( ) in put = input . split ( " " ) . map ( Number ) ; console . log ( Math . ceil ( ( input [ 1 ] + input [ 0 ] ) / 2 ) ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var GET = ( function ( ) { function f ( s ) { return new g ( s ) ; } function g ( s ) { this . _ s = s . trim ( ) . split ( " \ n " ) ; this . _ y = 0 ; } g . prototype . a = function ( f ) { var s = this . _ s , y = this . _ y , r ; if ( typeof s [ y ] = = = " string " ) s [ y ] = s [ y ] . split ( " " ) . reverse ( ) ; r = s [ y ] . pop ( ) ; if ( ! s [ y ] . length ) this . _ y + + ; return f ? r : + r ; } ; g . prototype . l = function ( f ) { var s = this . _ s [ this . _ y + + ] . split ( " " ) ; return f ? s : s . map ( a = > + a ) ; } ; g . prototype . m = function ( n , f ) { var r = this . _ s . slice ( this . _ y , this . _ y + = n ) . map ( a = > a . split ( " " ) ) ; return f ? r : r . map ( a = > a . map ( a = > + a ) ) ; } ; g . prototype . r = function ( n , f ) { var r = this . _ s . slice ( this . _ y , this . _ y + = n ) ; return f ? r : r . map ( a = > + a ) ; } ; return f ; } ) ( ) ; var o = GET ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; console . log ( main ( ) ) ; function main ( ) { var s = o . a ( 1 ) ; var y = " Heisei " ; var n = " TBD " ; if ( s [ 5 ] > 0 ) return n ; if ( s [ 6 ] > 4 ) return n ; return y ; } function main ( input ) { let [ A , B , H , M ] = input . split ( ' ' ) . map ( Number ) ; const minute = H * 60 + M ; const theata = ( 11 * minute ) / 360 * Math . PI const a = Math . sqrt ( A * A + B * B - 2 * A * B * Math . cos ( theata ) ) ; console . log ( a ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . trim ( ) ) ; var fs = require ( ' fs ' ) , length = fs . fstatSync ( process . stdin . fd ) . size , buffer = new Buffer ( length ) , bytesRead = fs . readSync ( process . stdin . fd , buffer , 0 , length , 0 ) , input = buffer . toString ( ' utf8 ' , 0 , bytesRead ) . split ( ' \ n ' ) ; main ( ) ; function transTime ( t ) { var temp = t . split ( ' : ' ) ; return + temp [ 0 ] * 60 + + temp [ 1 ] ; } function main ( ) { var temp = input [ 0 ] . split ( ' ' ) , n = + temp [ 0 ] , t = + temp [ 1 ] ; temp = input [ 1 ] . split ( ' ' ) ; var time1 = transTime ( temp [ 0 ] ) , sta1 = temp [ 1 ] , time2 = transTime ( temp [ 2 ] ) , sta2 = temp [ 3 ] , ans = [ ] ; for ( var i = 2 ; i < = n ; i + + ) { temp = input [ i ] . split ( ' ' ) ; time1 = transTime ( temp [ 0 ] ) ; if ( t < = time1 - time2 ) { ans . push ( [ sta2 , time1 - time2 ] ) ; } sta1 = temp [ 1 ] ; time2 = transTime ( temp [ 2 ] ) ; sta2 = temp [ 3 ] ; } console . log ( ans . length ) ; for ( i = 0 ; i < ans . length ; i + + ) { console . log ( ans [ i ] [ 0 ] + ' ' + ans [ i ] [ 1 ] ) } } function factorial ( num ) { if ( num = = = 1 ) { return 1 ; } else { return num * factorial ( num - 1 ) ; } } function Main ( input ) { var N = input [ 0 ] . trim ( ) ; var x = [ ] ; var y = [ ] ; for ( var i = 0 ; i < N ; i + + ) { var tmp = input [ i + 1 ] . split ( " " ) ; x [ i ] = parseInt ( tmp [ 0 ] , 10 ) ; y [ i ] = parseInt ( tmp [ 1 ] , 10 ) ; } var kyori = 0 ; for ( var u = 0 ; u < N ; u + + ) { for ( var v = 0 ; v < N ; v + + ) { if ( u ! = v ) { var z = Math . sqrt ( ( x [ u ] - x [ v ] ) * ( x [ u ] - x [ v ] ) + ( y [ u ] - y [ v ] ) * ( y [ u ] - y [ v ] ) ) ; kyori + = z ; } } } var all = factorial ( N ) ; console . log ( " % s " , ( kyori * ( all / N ) ) / all ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . split ( " \ n " ) ) ; const input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) let cin = input . split ( / | \ n / ) , cid = 0 const next = ( ) = > cin [ cid + + ] const nexts = ( n ) = > cin . slice ( cid , cid + = n ) . map ( i = > parseInt ( i ) ) const [ H1 , M1 , H2 , M2 , K ] = nexts ( 5 ) ; const time = H2 * 60 + M2 - ( H1 * 60 + M1 ) - K time > 0 ? console . log ( time ) : console . log ( 0 ) function Main ( input ) { input = input . split ( " " ) . map ( e = > Number ( e ) ) . sort ( ) ; console . log ( input [ 0 ] = = = 1 & & input [ 1 ] = = = 4 & & input [ 2 ] = = = 7 & & input [ 3 ] = = = 9 ? ' YES ' : ' NO ' ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( lines ) { const [ A , B , H , M ] = splitN ( lines [ 0 ] ) ; const hR = ( H / 12 + M / 60 / 12 ) * 2 * Math . PI , mR = M / 60 * 2 * Math . PI , r = Math . max ( hR , mR ) - Math . min ( hR , mR ) , res = Math . sqrt ( ( A * * 2 ) + ( B * * 2 ) - ( 2 * A * B * Math . cos ( r ) ) ) ; console . log ( res ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) . split ( " \ n " ) ) ; function splitN ( s ) { return s . split ( ' ' ) . map ( Number ) ; } var fs = require ( ' fs ' ) , length = fs . fstatSync ( process . stdin . fd ) . size , buffer = new Buffer ( length ) , bytesRead = fs . readSync ( process . stdin . fd , buffer , 0 , length , 0 ) , input = buffer . toString ( ' utf8 ' , 0 , bytesRead ) . split ( ' \ n ' ) ; main ( ) ; function main ( ) { var num = parseInt ( input ) ; var answer = num * num * num ; console . log ( answer ) ; } var stdin = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ; stdin = stdin . trim ( ) . split ( " \ n " ) ; var stdout = [ ] ; function print ( x ) { stdout . push ( x ) } ; var menu = stdin . map ( n = > parseInt ( n ) ) ; var dmin = 9 var ans = 0 for ( i = 0 ; i < 5 ; i + + ) { dmin = Math . min ( ( menu [ i ] - 1 ) % 10 , dmin ) ans + = parseInt ( ( menu [ i ] + 9 ) / 10 ) * 10 } print ( ans - 10 + dmin + 1 ) ; stdout = stdout . join ( " \ n " ) ; console . log ( stdout ) ; function Main ( input ) { var xs = input . trim ( ) . split ( ' ' ) . map ( v = > parseInt ( v , 10 ) ) ; if ( xs [ 0 ] + xs [ 1 ] > = xs [ 2 ] ) { console . log ( " Yes " ) ; } else { console . log ( " No " ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( a ) { console . log ( a [ 0 ] * a [ 1 ] * a [ 2 ] = = 175 ? ' YES ' : ' NO ' ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . split ( ' ' ) ) ; function main ( input ) { var A = parseInt ( input . split ( " " ) [ 0 ] , 10 ) ; var B = parseInt ( input . split ( " " ) [ 1 ] , 10 ) ; var H = parseInt ( input . split ( " " ) [ 2 ] , 10 ) ; var M = parseInt ( input . split ( " " ) [ 3 ] , 10 ) ; rad _ H = ( ( 360 / 12 ) * H + ( ( 360 / 12 ) / 60 ) * M ) * ( Math . PI / 180 ) ; rad _ M = ( 360 / 60 ) * M * ( Math . PI / 180 ) ; console . log ( Math . sqrt ( ( A * A ) + ( B * B ) - 2 * A * B * Math . cos ( rad _ H - rad _ M ) ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { var arr = input . split ( " " ) ; var count5 = 0 ; var count7 = 0 ; for ( var a of arr ) { if ( a = = 5 ) { count5 + + ; } else if ( a = = 7 ) { count7 + + ; } } if ( count5 = = 2 & & count7 = = 1 ) { console . log ( " YES " ) ; } else { console . log ( " NO " ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( r ) { console . log ( r * r ) } Main ( require ( ' fs ' ) . readFileSync ( " / dev / stdin " , ' utf8 ' ) ) function main ( input ) { input = input . trim ( ) ; const N = parseInt ( input . split ( " " ) [ 0 ] , 10 ) ; const arrS = input . split ( ' \ n ' ) [ 1 ] . split ( ' ' ) . map ( ( n ) = > ( n ) ) ; var ans = 0 ; if ( arrS . indexOf ( " P " ) ! = - 1 ) { ans + + } if ( arrS . indexOf ( " W " ) ! = - 1 ) { ans + + } if ( arrS . indexOf ( " G " ) ! = - 1 ) { ans + + } if ( arrS . indexOf ( " Y " ) ! = - 1 ) { ans + + } if ( ans = = 3 ) { console . log ( " Three " ) ; } else { console . log ( " Four " ) ; } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( input ) { const N = input . split ( ' \ n ' ) [ 0 ] ; var a = input . split ( ' \ n ' ) [ 1 ] . split ( ' ' ) . map ( function ( e ) { return Number ( e ) ; } ) . sort ( function ( a , b ) { return a - b ; } ) ; ans = a [ N - 1 ] - a [ 0 ] ; console . log ( ans ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . setEncoding ( ' utf-8 ' ) ; process . stdin . on ( ' data ' , function ( data ) { console . log ( data * data * data ) ; } ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { console . log ( Math . pow ( chunk , 3 ) ) ; } ) ; function Main ( input ) { input = input . split ( " \ n " ) ; tmp0 = input [ 0 ] . split ( " " ) ; N = Number ( tmp0 [ 0 ] ) D = Number ( tmp0 [ 1 ] ) num = [ ] for ( var i = 1 ; i < = N ; i + + ) { tmp = input [ i ] . split ( " " ) x = [ ] for ( var j = 1 ; j < = D ; j + + ) { x . push ( Number ( tmp [ j - 1 ] ) ) } num . push ( x ) } ans = 0 for ( var i = 1 ; i < N ; i + + ) { for ( var j = i + 1 ; j < = N ; j + + ) { var tmp = 0 for ( var k = 0 ; k < D ; k + + ) { tmp + = Math . pow ( Math . abs ( num [ i - 1 ] [ k ] - num [ j - 1 ] [ k ] ) , 2 ) } if ( Math . round ( Math . sqrt ( tmp ) ) = = = Math . sqrt ( tmp ) ) { ans + + } } } console . log ( ans ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var square = function ( x ) { return Math . pow ( x , 3 ) ; } process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( x ) { console . log ( square ( x ) ) ; } ) ; " use strict " ; var input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ; var cin = input . split ( / | \ n / ) , cid = 0 ; function next ( a ) { return a ? cin [ cid + + ] : + cin [ cid + + ] ; } function nexts ( n , a ) { return a ? cin . slice ( cid , cid + = n ) : cin . slice ( cid , cid + = n ) . map ( a = > + a ) ; } function nextm ( h , w , a ) { var r = [ ] , i = 0 ; if ( a ) for ( ; i < h ; i + + ) r . push ( cin . slice ( cid , cid + = w ) ) ; else for ( ; i < h ; i + + ) r . push ( cin . slice ( cid , cid + = w ) . map ( a = > + a ) ) ; return r ; } function xArray ( v ) { var a = arguments , l = a . length , r = " Array ( a [ " + -- l + " ] ) .fill ( ) .map ( x = > { return " + v + " ; } ) " ; while ( -- l ) r = " Array ( a [ " + l + " ] ) .fill ( ) .map ( x = > " + r + " ) " ; return eval ( r ) ; } var myOut = main ( ) ; if ( myOut ! = = undefined ) console . log ( myOut ) ; function main ( ) { var x = BigInt ( next ( ) ) ; for ( var a = 1n ; a < 1000n ; a + + ) { var A = a * a * a * a * a ; for ( var b = - a ; b < a ; b + + ) { var B = b * b * b * b * b ; if ( A - B = = = x ) return a . toString ( ) + " " + b . toString ( ) ; } } } function Scanner ( input ) { var self = this ; self . itemNo = 0 ; self . orgStr = input ; self . splitedStrs = ( function ( target ) { var result = [ ] ; var target = target . replace ( / [ \ n \ t ] + / g , " " ) ; var strs = target . split ( " " ) ; for ( var i = 0 , len = strs . length ; i < len ; i + + ) { result . push ( strs [ i ] ) ; } return result ; } ( input ) ) ; self . next = function ( ) { var result = self . splitedStrs [ self . itemNo ] ; self . itemNo + + ; return ( result ! = null ) ? result : null ; } self . nextInt = function ( ) { var result = self . splitedStrs [ self . itemNo ] ; self . itemNo + + ; return ( result ! = null ) ? parseInt ( result ) : null ; } self . nextBigDecimal = function ( ) { var result = self . splitedStrs [ self . itemNo ] ; self . itemNo + + ; return ( result ! = null ) ? parseFloat ( result ) : null ; } self . nextByte = function ( ) { var result = self . splitedStrs [ self . itemNo ] ; self . itemNo + + ; return ( result ! = null ) ? new Int8Array ( result ) : null ; } } function Main ( sc ) { var A = sc . nextInt ( ) ; var B = sc . nextInt ( ) ; var H = sc . nextInt ( ) ; var M = sc . nextInt ( ) ; var radH = H * 30 + M * 0.5 ; var radM = M * 6 ; var radC = radH - radM ; if ( radC < 0 ) radC = - 1 * radC ; C2 = Math . pow ( A , 2 ) + Math . pow ( B , 2 ) - 2 * A * B * Math . cos ( radC * ( Math . PI / 180 ) ) ; C = Math . sqrt ( C2 ) ; console . log ( C ) ; } Main ( new Scanner ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ) ; function Main ( input ) { var n = input ; var ans = 1 ; for ( i = 1 ; i < = n ; i = i * 2 ) { ans = i ; } console . log ( ans ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { const inp = input . split ( " " ) ; const sum = parseInt ( inp [ 0 ] , 10 ) + parseInt ( inp [ 1 ] , 10 ) + parseInt ( inp [ 2 ] , 10 ) ; var ans = sum = = = 17 ? " YES " : " NO " ; console . log ( ans ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; a = ( " " + require ( " fs " ) . readFileSync ( 0 ) ) . split ` ` . sort ( ( a , b ) = > a - b ) ; console . log ( a [ 2 ] - a [ 0 ] ) ' use strict ' function main ( n ) { let a0 = n . split ( " \ n " ) [ 0 ] . split ( " " ) ; let a1 = n . split ( " \ n " ) [ 1 ] . split ( " " ) ; let a2 = n . split ( " \ n " ) [ 2 ] . split ( " " ) ; let a0SumCheck = ( a0 . reduce ( ( n , m ) = > { return n * 1 + m * 1 } ) ) % 3 ; let a1SumCheck = ( a1 . reduce ( ( n , m ) = > { return n * 1 + m * 1 } ) ) % 3 ; let a2SumCheck = ( a2 . reduce ( ( n , m ) = > { return n * 1 + m * 1 } ) ) % 3 ; let b0SumCheck = ( a0 [ 0 ] * 1 + a1 [ 0 ] * 1 + a2 [ 0 ] * 1 ) % 3 ; let b1SumCheck = ( a0 [ 1 ] * 1 + a1 [ 1 ] * 1 + a2 [ 1 ] * 1 ) % 3 ; let b2SumCheck = ( a0 [ 2 ] * 1 + a1 [ 2 ] * 1 + a2 [ 2 ] * 1 ) % 3 ; let aCheck = ( ( a0SumCheck = = a1SumCheck ) & & ( a1SumCheck = = a2SumCheck ) ) ; let bCheck = ( ( b0SumCheck = = b1SumCheck ) & & ( b1SumCheck = = b2SumCheck ) ) ; if ( aCheck & & bCheck ) { console . log ( " Yes " ) ; } else { console . log ( " No " ) ; } } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " ; const main = arg = > { arg = arg . trim ( ) . split ( " \ n " ) ; const X = parseInt ( arg [ 0 ] . split ( " " ) [ 0 ] ) ; for ( let i = - 200 ; i < 200 ; i + + ) { for ( let j = - 200 ; j < 200 ; j + + ) { if ( Math . pow ( i , 5 ) - Math . pow ( j , 5 ) = = = X ) { console . log ( i + " " + j ) ; return ; } } } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' ; ( function ( stdin ) { var lines = stdin . toString ( ) . split ( ' \ n ' ) ; var x = parseInt ( lines [ 0 ] , 10 ) ; console . log ( Math . pow ( x , 3 ) ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; " use strict " function Main ( input ) { const args = input . trim ( ) . split ( ' \ n ' ) ; const n = args [ 0 ] ; const p = args [ 1 ] . split ( ' ' ) . map ( Number ) ; let max = 1e10 ; let cnt = 0 ; for ( let i = 0 ; i < n ; i + + ) { if ( p [ i ] < max ) cnt + + , max = p [ i ] ; } console . log ( cnt ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' const main = ( input ) = > { input = input . split ( ' ' ) . map ( v = > parseInt ( v ) ) const a = input [ 0 ] const b = input [ 1 ] const c = input [ 2 ] const d = input [ 3 ] if ( a * b > = c * d ) { console . log ( a * b ) } else { console . log ( c * d ) } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf-8 ' ) ) const input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) ; const inp = input . split ( ' ' ) . map ( val = > Number ( val ) ) ; const alice = inp [ 0 ] , bob = inp [ 1 ] ; const tsuyosa = [ 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 1 ] ; const aliceT = tsuyosa . indexOf ( alice ) , bobT = tsuyosa . indexOf ( bob ) ; if ( aliceT = = bobT ) { console . log ( ' Draw ' ) ; } else if ( aliceT > bobT ) { console . log ( ' Alice ' ) ; } else if ( aliceT < bobT ) { console . log ( ' Bob ' ) ; } require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) . split ( ' \ n ' ) . map ( function ( i ) { f = function ( a , b ) { return b - a } ; a = [ ] , c = i . split ( " , " ) . sort ( f ) ; c . map ( function ( j ) { a [ j ] ? a [ j ] + + : a [ j ] = 1 } ) ; a . sort ( f ) ; l = a [ 0 ] , n = a [ 1 ] ; console . log ( l = = 4 ? " four card " : l = = 3 ? ( n = = 2 ? " full house " : " three card " ) : l = = 2 ? ( n = = 2 ? " two pair " : " one pair " ) : 4 = = c [ 0 ] - c [ 4 ] | | ( c [ 0 ] - c [ 3 ] = = 3 & & + c [ 4 ] = = 1 ) ? " straight " : " null " ) } ) ' use strict ' ; console . log ( function ( args ) { const tmp = args . trim ( ) . split ( ' \ n ' ) ; const N = tmp [ 0 ] | 0 ; const x = [ ] , y = [ ] ; for ( let i = 0 ; i < N ; i + + ) { const cood = tmp [ i + 1 ] . split ( ' ' ) . map ( v = > v | 0 ) ; x [ i ] = cood [ 0 ] , y [ i ] = cood [ 1 ] ; } let sumL = 0 , nL = 0.0 ; function travel ( trail , length , current ) { for ( let next = 0 ; next < N ; next + + ) { if ( trail & 1 < < next ) continue ; const l = Math . sqrt ( Math . pow ( x [ current ] - x [ next ] , 2.0 ) + Math . pow ( y [ current ] - y [ next ] , 2.0 ) ) ; if ( ( trail | 1 < < next ) = = = ( 1 < < N ) - 1 ) { sumL + = length + l ; nL = nL + 1.0 ; return ; } travel ( trail | 1 < < next , length + l , next ) ; } } for ( let i = 0 ; i < N ; i + + ) { travel ( 1 < < i , 0.0 , i ) ; } return ( sumL / nL ) . toString ( ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; ' use strict ' function main ( s ) { const table = s . split ( ' \ n ' ) . slice ( 0 , - 1 ) . map ( el = > el . split ( ' ' ) . map ( x = > Number ( x ) ) ) ; let ans = ' Yes ' ; for ( let i = 0 ; i < 2 ; i + + ) { for ( let j = 0 ; j < 2 ; j + + ) { const col _ diff = ( ( table [ i ] [ j ] - table [ i ] [ j + 1 ] ) = = = ( table [ i + 1 ] [ j ] - table [ i + 1 ] [ j + 1 ] ) ) ; const row _ diff = ( ( table [ i ] [ j ] - table [ i + 1 ] [ j ] ) = = = ( table [ i ] [ j + 1 ] - table [ i + 1 ] [ j + 1 ] ) ) ; if ( ! ( col _ diff & & row _ diff ) ) { ans = ' No ' ; break ; } } } console . log ( ans ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { if ( new Date ( ' 2019 / 04 / 30 ' ) > = new Date ( input ) ) { console . log ( ' Heisei ' ) ; } else { console . log ( ' TBD ' ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' function main ( s ) { s = s . split ( ' \ n ' ) [ 0 ] . split ( ' ' ) . map ( n = > Number ( n ) ) ; let a = s [ 0 ] ; let b = s [ 1 ] ; if ( a = = = 1 ) a + = 13 ; if ( b = = = 1 ) b + = 13 ; let ans = ' ' ; if ( a > b ) ans = ' Alice ' ; if ( a < b ) ans = ' Bob ' ; if ( a = = = b ) ans = ' Draw ' ; console . log ( ans ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; var inputs = input [ 1 ] . split ( " " ) ; function avg ( args ) { var num = 0 ; for ( var n of args ) { num + = Number ( n ) ; } return num / args . length ; } var average = Math . round ( avg ( inputs ) ) ; var useStamina = 0 ; for ( var point of inputs ) { useStamina + = Math . pow ( average - point , 2 ) ; } console . log ( useStamina ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' function Main ( input ) { let arr = input . split ( " \ n " ) [ 0 ] . split ( " " ) ; let ans = 0 ; if ( arr [ 1 ] ! = 1 ) { ans = arr [ 0 ] - arr [ 1 ] ; } console . log ( ans ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' function Main ( input ) { let v = input . trim ( ) . split ( ' \ n ' ) . map ( ( v ) = > parseInt ( v ) ) ; let amari = [ ] ; for ( let i = 0 ; i < 5 ; i + + ) { amari . push ( { v : v [ i ] , a : ( v [ i ] + 9 ) % 10 } ) ; } amari . sort ( ( a , b ) = > ( a . a - b . a ) ) ; let sum = 0 ; for ( let i = 1 ; i < 5 ; i + + ) { if ( amari [ i ] . a % 10 = = = 9 ) { sum + = amari [ i ] . v ; } else { sum + = Math . floor ( amari [ i ] . v / 10 ) * 10 + 10 } } sum + = amari [ 0 ] . v ; console . log ( sum ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; const zeroPadding = ( num , length ) = > { return ( ' 0000000000 ' + num ) . slice ( - length ) ; } ; const Main = ( input ) = > { input = input . split ( ' \ n ' ) ; input . shift ( ) ; const cities = input . map ( ( line , index ) = > { if ( line . length = = = 0 ) return null ; const lineArray = line . split ( ' ' ) ; const ken = lineArray [ 0 ] ; const year = lineArray [ 1 ] ; return { index : index , ken : ken , year : year , } ; } ) . filter ( ( data ) = > { return data ; } ) ; const kenArray = [ ] ; cities . concat ( ) . sort ( ( a , b ) = > { return a . year - b . year ; } ) . forEach ( ( city ) = > { if ( ! kenArray [ city . ken ] ) kenArray [ city . ken ] = [ ] ; kenArray [ city . ken ] . push ( city ) ; cities [ city . index ] . cityId = zeroPadding ( city . ken , 6 ) + zeroPadding ( kenArray [ city . ken ] . length , 6 ) ; } ) ; cities . forEach ( ( city ) = > { console . log ( city . cityId ) ; } ) ; } ; Main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( r ) { console . log ( r * r ) } Main ( require ( ' fs ' ) . readFileSync ( " / dev / stdin " , ' utf8 ' ) ) process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; var lines = [ ] ; var reader = require ( ' readline ' ) . createInterface ( { input : process . stdin , output : process . stdout } ) ; reader . on ( ' line ' , ( line ) = > { lines . push ( line ) ; } ) ; reader . on ( ' close ' , ( ) = > { " use strict " const A = + lines [ 0 ] . split ( " " ) [ 0 ] ; const B = + lines [ 0 ] . split ( " " ) [ 1 ] ; if ( A > = 13 ) { console . log ( B ) } else if ( A > = 6 ) { console . log ( B / 2 ) } else { console . log ( 0 ) } } ) ; function Main ( input ) { input = input . split ( ' \ n ' ) var tmp = input [ 0 ] . split ( ' ' ) var N = tmp [ 0 ] var D = tmp [ 1 ] var calc = 0 var result = 0 for ( var i = 0 ; i < N - 1 ; i + + ) { var number1 = input [ i + 1 ] . split ( ' ' ) for ( var j = 0 ; j < N - 1 - i ; j + + ) { calc = 0 var number2 = input [ i + 2 + j ] . split ( ' ' ) for ( var k = 0 ; k < D ; k + + ) { calc = calc + Math . pow ( Math . abs ( number1 [ k ] - number2 [ k ] ) , 2 ) } if ( Number . isInteger ( Math . sqrt ( calc ) ) ) { result + + } } } console . log ( ' % d ' , result ) } Main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) function main ( input ) { input = input . split ( " \ n " ) ; var a = parseInt ( input [ 0 ] , 10 ) ; var b = parseInt ( input [ 1 ] , 10 ) ; var c = parseInt ( input [ 2 ] , 10 ) ; var d = parseInt ( input [ 3 ] , 10 ) ; var e = parseInt ( input [ 4 ] , 10 ) ; var k = parseInt ( input [ 5 ] , 10 ) ; var ans = " Yay ! " ; if ( e - a > k ) { ans = " : ( " ; } console . log ( ans ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { input = new Date ( input ) ; if ( input . getFullYear ( ) < = 2019 & & input . getMonth ( ) < = 3 & & input . getDate ( ) < = 30 ) console . log ( " Heisei " ) ; else console . log ( " TBD " ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { var date = new Date ( input ) ; var base = new Date ( ' 2019 / 4 / 30 ' ) ; console . log ( date < = base ? " Heisei " : " TBD " ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var x = input . trim ( ) . split ( " " ) . map ( Number ) ; var cnt = 0 ; for ( var a = 1 ; a < = 9 ; a + + ) { for ( var b = 1 ; b < = 9 ; b + + ) { for ( var c = 1 ; c < = 9 ; c + + ) { for ( var d = 1 ; d < = 8 ; d + + ) { for ( var e = 1 ; e < = 9 ; e + + ) { for ( var f = 1 ; f < = 9 ; f + + ) { var z = ( ( a + c + f + ( b + e ) * 10 + d * 100 ) + " " ) . split ( " " ) . map ( Number ) ; if ( z . length ! = 3 ) continue ; z = [ a , b , c , d , e , f ] . concat ( z ) ; var flag = z . every ( function ( v , i ) { return ( x [ i ] = = v | | x [ i ] = = - 1 ) & & ( z . indexOf ( i + 1 ) > = 0 ) ; } ) ; if ( flag ) cnt + + ; } } } } } } console . log ( cnt ) ; function Main ( input ) { input = input . split ( " \ n " ) ; var n = parseInt ( input [ 0 ] , 10 ) ; var total = 0 ; var X = [ ] ; Y = [ ] ; for ( i = 1 ; i < = n ; i + + ) { tmp = input [ i ] . split ( " " ) ; var l = i ; var xl = parseInt ( tmp [ 0 ] , 10 ) ; var yl = parseInt ( tmp [ 1 ] , 10 ) ; X [ i ] = xl ; Y [ i ] = yl ; } for ( f = 1 ; f < = n ; f + + ) { for ( i = 1 ; i < n ; i + + ) { var a = f ; b = a + i ; if ( b > n ) { break ; } { var p = Math . pow ( ( X [ a ] - X [ b ] ) , 2 ) ; var q = Math . pow ( ( Y [ a ] - Y [ b ] ) , 2 ) ; var r = Math . sqrt ( p + q ) ; total = total + r ; } } } function factorialize ( n ) { var j = 1 ; for ( var i = 1 ; i < = n ; i + + ) { j * = i ; } return j ; } console . log ( total * 2 / n ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ( function ( ) { ' use strict ' ; var fs = require ( ' fs ' ) ; var contents = fs . readFileSync ( ' / dev / stdin ' , ' utf-8 ' ) ; var cubic = function ( s ) { var x = parseInt ( s ) ; return x * x * x ; } console . log ( cubic ( contents ) ) ; } ) ( ) ; ' use strict ' ; const X = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf-8 ' ) - 0 ; const pow = Math . pow function main ( ) { for ( let A = 150 ; A ; A -- ) for ( let B = A ; A + B ; B -- ) if ( pow ( A , 5 ) - pow ( B , 5 ) = = = X ) { console . log ( A + ' ' + B ) ; return ; } } main ( ) ; let n = Number ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; console . log ( 800 * n - 200 * ~ ~ ( n / 15 ) ) ; function main ( input ) { let args = input . split ( " \ n " ) ; let n = args . length ; for ( let i = 0 ; i < n ; i + + ) { if ( args [ i ] = = = " 0 " ) { break ; } let ret = 0 ; for ( let j = 0 ; j < args [ i ] . length ; j + + ) { ret + = Number ( args [ i ] [ j ] ) ; } console . log ( ret ) ; } } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { var array = input . split ( ' ' ) ; var sortedArray = array . sort ( compareNumbers ) ; var counter = 0 ; for ( var i = 1 ; i < sortedArray . length ; i + + ) { counter + = sortedArray [ i ] - sortedArray [ i - 1 ] ; } console . log ( counter ) ; } function compareNumbers ( a , b ) { return a - b ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( input ) { const args = input . split ( ' \ n ' ) ; const N = args [ 0 ] ; const ary = args [ 1 ] . split ( ' ' ) ; let ans = ' Three ' ; ary . forEach ( elm = > { if ( elm = = = ' Y ' ) { ans = ' Four ' } ; } ) ; console . log ( ans ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' const Main = ( input ) = > { const [ A , B , H , M ] = input . trim ( ) . split ( ' ' ) . map ( Number ) const thetaH = ( ( H + M / 60 ) / 12 ) * Math . PI * 2 const thetaM = ( M / 60 ) * Math . PI * 2 const theta = thetaH - thetaM let result = Math . sqrt ( Math . pow ( A , 2 ) + Math . pow ( B , 2 ) - ( 2 * A * B * Math . cos ( theta ) ) ) console . log ( result ) return result } Main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) function Main ( input ) { input = input . split ( ' ' ) . map ( num = > Number ( num ) ) ; input . sort ( function ( a , b ) { if ( a < b ) return - 1 ; if ( a > b ) return 1 ; return 0 ; } ) ; if ( input . toString ( ) = = = [ 5 , 5 , 7 ] . toString ( ) ) { console . log ( ' YES ' ) ; } else { console . log ( ' NO ' ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( s ) { const set = new Set ( s . split ( ' \ n ' ) [ 1 ] . split ( ' ' ) ) ; const ans = ( [ ... set ] . length = = = 4 ) ? ' Four ' : ' Three ' ; console . log ( ans ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; const x = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; console . log ( Math . pow ( x , 3 ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; tmp = input [ 0 ] . split ( " " ) ; var max = parseInt ( tmp [ 0 ] , 10 ) ; var sum = parseInt ( tmp [ 1 ] , 10 ) ; var count = 0 ; if ( sum - 2 * max > = 0 ) { for ( i = sum - 2 * max ; i < = max ; i + + ) { if ( sum - max - i > = 0 ) { count + = 2 * max - sum + i + 1 ; } else { count + = sum - i + 1 ; } } } else if ( sum > = max ) { for ( i = 0 ; i < = max ; i + + ) { if ( sum - max - i > = 0 ) { count + = 2 * max - sum + i + 1 ; } else { count + = sum - i + 1 ; } } } else { for ( i = 0 ; i < = sum ; i + + ) { count + = sum - i + 1 ; } } console . log ( count ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var A = parseInt ( input . split ( " " ) [ 0 ] ) ; var B = parseInt ( input . split ( " " ) [ 1 ] ) ; var C = parseInt ( input . split ( " " ) [ 2 ] ) ; var sevenCount = 0 ; var fiveCount = 0 ; if ( A = = 5 ) { fiveCount + + ; } else if ( A = = 7 ) { sevenCount + + ; } if ( B = = 5 ) { fiveCount + + ; } else if ( B = = 7 ) { sevenCount + + ; } if ( C = = 5 ) { fiveCount + + ; } else if ( C = = 7 ) { sevenCount + + ; } if ( fiveCount = = 2 & & sevenCount = = 1 ) { console . log ( " YES " ) ; } else { console . log ( " NO " ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' const main = arg = > { arg = arg . trim ( ) . split ( " \ n " ) const K = ~ ~ arg [ 0 ] . split ( " " ) [ 0 ] ; const S = ~ ~ arg [ 0 ] . split ( " " ) [ 1 ] ; let answer = 0 ; for ( let i = 0 ; i < = K ; i + + ) { for ( let j = 0 ; j < = K ; j + + ) { let z = S - i - j ; if ( 0 < = z & & z < = K ) { answer + + ; } } } console . log ( answer ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf-8 ' ) ) function Main ( input ) { const data = input . split ( " \ n " ) . slice ( 0 , 5 ) . map ( val = > parseInt ( val , 10 ) ) ; var min = data . map ( function ( i ) { if ( i % 10 = = = 0 ) { return 0 ; } else { return ( 10 - i % 10 ) } } ) ; var max = Math . max ( ... min ) ; var sum = 0 ; data . forEach ( function ( e ) { sum + = e ; } ) ; min . forEach ( function ( f ) { sum + = f ; } ) ; var result = sum + max ; console . log ( parseInt ( sum - max , 10 ) ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { if ( input = = " " ) { input = " 2 \ n 10000 JPY \ n 0.10000000 BTC " ; } input = input . split ( " \ n " ) ; var S = input [ 0 ] . split ( " / " ) ; var ans = " Heisei " ; if ( parseInt ( S [ 0 ] ) > = 2020 | | ( parseInt ( S [ 0 ] ) > = 2019 & & parseInt ( S [ 1 ] ) > = 5 ) ) { ans = " TBD " ; } console . log ( ' % s ' , ans ) ; } function debug ( ) { var input = document . getElementById ( " input " ) . value ; Main ( input ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var n = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; console . log ( Math . pow ( n , 3 ) ) ; var fs = require ( ' fs ' ) , length = fs . fstatSync ( process . stdin . fd ) . size , buffer = new Buffer ( length ) , bytesRead = fs . readSync ( process . stdin . fd , buffer , 0 , length , 0 ) , input = buffer . toString ( ' utf8 ' , 0 , bytesRead ) . split ( ' \ n ' ) ; main ( ) ; function main ( ) { console . log ( Math . pow ( input [ 0 ] , 3 ) ) ; } function Main ( input ) { const A = parseInt ( input [ 0 ] ) ; const E = parseInt ( input [ 4 ] ) ; const K = parseInt ( input [ 5 ] ) ; console . log ( ( E - A > K ) ? " : ( " : " Yay ! " ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) . split ( / \ n | \ s / ) ) ; function Main ( t ) { let characters = t . split ( " " ) ; for ( let i = 0 ; characters [ i ] ; i + + ) if ( characters [ i ] = = " ? " ) characters [ i ] = " D " ; let joined = characters . join ( " " ) ; console . log ( joined ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; var lines = [ ] var reader = require ( ' readline ' ) . createInterface ( { input : process . stdin , output : process . stdout } ) ; reader . on ( ' line ' , ( line ) = > { lines . push ( line ) ; } ) ; reader . on ( ' close ' , ( ) = > { var n = Number ( lines [ 0 ] ) ; var info = [ ] ; for ( i = 1 ; i < = n ; i + + ) { var num = i ; var count = 0 ; while ( num % 2 = = 0 ) { count + + ; num = num / 2 ; } info . push ( count ) ; } var max = Math . max ( ... info ) ; var index = info . indexOf ( max ) ; console . log ( index + 1 ) ; } ) ; " use strict " ; const main = arg = > { arg = arg . trim ( ) . split ( " \ n " ) ; const N = ~ ~ arg [ 0 ] ; const a = arg [ 1 ] . split ( " " ) . map ( n = > ~ ~ n ) . sort ( ( a , b ) = > a - b ) ; console . log ( Math . max ( ... a ) - Math . min ( ... a ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( input ) { const args = input . split ( " \ n " ) ; const [ A , B , H , M ] = args [ 0 ] . split ( " " ) . map ( ( n ) = > parseInt ( n , 10 ) ) ; const min = H * 60 + M ; console . log ( Math . sqrt ( A * A + B * B - ( 2 * A * B * Math . cos ( 11 * Math . PI * min / 360 ) ) ) ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( arg ) { const array = arg . trim ( ) . split ( " " ) ; const A = parseInt ( array [ 0 ] ) ; const B = parseInt ( array [ 1 ] ) ; const H = parseInt ( array [ 2 ] ) ; const M = parseInt ( array [ 3 ] ) ; const PI = Math . PI ; const th = ( ( H * 60 + M ) / 720 ) * 2 * PI ; const tm = ( M / 60 ) * 2 * PI ; let xh = A * Math . cos ( th ) ; let yh = A * Math . sin ( th ) ; let xm = B * Math . cos ( tm ) ; let ym = B * Math . sin ( tm ) ; let dx = xh - xm ; let dy = yh - ym ; let result = Math . sqrt ( dx * dx + dy * dy ) ; console . log ( result ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf-8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { console . log ( Math . pow ( chunk , 3 ) ) ; } ) ; function main ( input ) { const args = input . split ( ' / ' ) ; var Y = parseInt ( args [ 0 ] , 10 ) ; var M = parseInt ( args [ 1 ] , 10 ) ; var D = parseInt ( args [ 2 ] , 10 ) ; if ( Y < 2019 ) { console . log ( ' Heisei ' ) } else if ( Y = = = 2019 & & M < 4 ) { console . log ( ' Heisei ' ) } else if ( Y = = = 2019 & & M = = = 4 & & D < = 30 ) { console . log ( ' Heisei ' ) } else { console . log ( ' TBD ' ) } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; tmp = input [ 0 ] . split ( " / " ) ; var D = tmp [ 0 ] + tmp [ 1 ] + tmp [ 2 ] ; var d = parseInt ( D , 10 ) ; if ( d < = 20190430 ) { console . log ( ' Heisei ' ) } else { console . log ( ' TBD ' ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function MainB ( input ) { input = input . split ( " \ n " ) ; var mod10 = 10 ; var dish = 0 ; var total = 0 ; for ( var i in input ) { var tmp = input [ i ] % 10 ; if ( tmp ! = 0 & & tmp < mod10 ) { mod10 = tmp ; dish = i ; } total + = Math . ceil ( input [ i ] / 10 ) * 10 ; } if ( mod10 ! = 10 ) total = total - 10 + mod10 ; console . log ( ' % d ' , total ) ; } MainB ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { const strList = input . split ( " \ n " ) . filter ( v = > v ! = " " ) ; strList . pop ( ) ; const ans = strList . map ( str = > { return sumChar ( str ) ; } ) . join ( " \ n " ) ; console . log ( ans ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function sumChar ( str ) { const chars = str . split ( " " ) ; const sum = chars . reduce ( ( memo , value ) = > { memo + = Number ( value ) ; return memo ; } , 0 ) ; return sum ; } function main ( lines ) { const input = lines . split ( ' ' ) . map ( Number ) const A = input [ 0 ] const B = input [ 1 ] const H = input [ 2 ] const C = input [ 3 ] const theta = ( 360 ) * H / 12 + 0.5 * C - ( 360 ) * C / 60 const output = Math . sqrt ( A * A + B * B - 2 * A * B * Math . cos ( theta * Math . PI / 180 ) ) console . log ( output . toFixed ( 9 ) ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var inputArray = input . split ( ' ' ) ; var a = inputArray [ 0 ] ; var b = inputArray [ 1 ] ; var c = inputArray [ 2 ] ; var d = inputArray [ 3 ] ; var result = ( a * b > c * d ) ? a * b : c * d ; console . log ( result ) ; function Main ( input ) { tmp = input . split ( " \ n " ) ; tmp = tmp . map ( Number ) ; sum = 0 ; c = 99 ; for ( i = 0 ; i < tmp . length ; i + + ) { kurai = String ( tmp [ i ] ) . substr ( - 1 , 1 ) if ( Number ( kurai ) ! = = 0 ) { c = Math . min ( kurai , c ) ; } sum + = Math . ceil ( tmp [ i ] / 10 ) * 10 ; } if ( c ! = = 99 ) { sum = sum - 10 + Number ( c ) ; } console . log ( sum ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; var x = parseInt ( input [ 0 ] , 10 ) ; console . log ( " % d " , x * x * x ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( args ) { var input = args . split ( " " ) ; var K = parseInt ( input [ 0 ] , 10 ) ; var S = parseInt ( input [ 1 ] , 10 ) ; var count = 0 ; for ( var i = 0 ; i < = K ; i + + ) { for ( var j = 0 ; j < = K ; j + + ) { if ( 0 < = S - i - j & & S - i - j < = K ) { count + + ; } } } console . log ( count ) ; } ' use strict ' ; function Main ( input ) { input = input . split ( " \ n " ) ; let tmp = input [ 0 ] . split ( " " ) ; for ( let i = 0 ; i < 5 ; i + + ) { for ( let j = i ; j < 5 ; j + + ) { if ( Math . abs ( input [ i ] - input [ j ] ) > input [ 5 ] ) { console . log ( " : ( " ) ; return ; } } } console . log ( " Yay ! " ) ; return ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { console . log ( input * input * input ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var cube = function ( x ) { return x * x * x ; } ; var lines = [ ] ; var reader = require ( ' readline ' ) . createInterface ( { input : process . stdin , output : process . stdout } ) ; reader . on ( ' line ' , function ( line ) { var num _ str = line . split ( / \ n / ) [ 0 ] ; if ( num _ str . match ( / \ d { 1,3 } / ) ) { var num = parseInt ( num _ str , 10 ) ; if ( num > 0 ) { if ( num < 101 ) { console . log ( cube ( num ) ) ; } } } } ) ; const x = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) console . log ( Math . pow ( parseInt ( x , 10 ) , 3 ) ) const readline = require ( " readline " ) ; const rl = readline . createInterface ( { input : process . stdin , output : process . stdout } ) ; totalMins = 0 ; let stratFrom = 0 ; rl . on ( ' line ' , function ( data ) { data = data . split ( ' ' ) ; let from = parseInt ( data [ 0 ] ) * 60 + parseInt ( data [ 1 ] ) ; let to = parseInt ( data [ 2 ] ) * 60 + parseInt ( data [ 3 ] ) ; totalMins = to - from ; stratFrom = totalMins - parseInt ( data [ 4 ] ) ; rl . close ( ) ; } ) ; rl . on ( ' close ' , function ( ) { console . log ( ` $ { stratFrom } ` ) ; } ) ' use strict ' const main = input = > { const args = input . split ( ' \ n ' ) . map ( arg = > arg . split ( ' ' ) ) const a = parseInt ( args [ 0 ] [ 0 ] , 10 ) const e = parseInt ( args [ 4 ] [ 0 ] , 10 ) const k = parseInt ( args [ 5 ] [ 0 ] , 10 ) if ( e - a < = k ) console . log ( ' Yay ! ' ) else console . log ( ' : ( ' ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) function Main ( input ) { var s , K , ref ; ref = input . split ( " \ n " ) , s = ref [ 0 ] , K = parseInt ( ref [ 1 ] ) ; console . log ( Array . from ( s ) . map ( ( v , i , arr ) = > { var code = v . charCodeAt ( ) ; if ( i = = = arr . length - 1 ) { code + = K % 26 ; code - = code > 122 ? 26 : 0 ; return String . fromCharCode ( code ) ; } else { if ( v = = = " a " ) return v ; return 123 - code < = K ? ( ( K - = 123 - code ) , " a " ) : v ; } } ) . join ( " " ) ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( x ) { console . log ( x * x ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var a , b , c , d , e , k ; a = Number ( input . split ( ' \ n ' ) [ 0 ] ) ; b = Number ( input . split ( ' \ n ' ) [ 1 ] ) ; c = Number ( input . split ( ' \ n ' ) [ 2 ] ) ; d = Number ( input . split ( ' \ n ' ) [ 3 ] ) ; e = Number ( input . split ( ' \ n ' ) [ 4 ] ) ; k = Number ( input . split ( ' \ n ' ) [ 5 ] ) ; if ( Math . max ( e - a , e - b , d - a , e - c , d - b , c - a , e - d , d - c , c - b , b - a ) > k ) { console . log ( ' : ( ' ) ; } else { console . log ( ' Yay ! ' ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var stdin = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var x = parseInt ( stdin , 10 ) ; console . log ( x * x * x ) ; function main ( input ) { var N = input [ 0 ] . split ( " " ) [ 0 ] - 0 ; var M = input [ 0 ] . split ( " " ) [ 1 ] - 0 ; var list = [ ] ; for ( var i = 1 ; i < = M ; i + + ) { list . push ( input [ i ] . split ( " " ) . map ( v = > v - 0 ) ) ; } list = list . sort ( ( a , b ) = > ( a [ 0 ] - b [ 0 ] ) | | ( a [ 1 ] - b [ 1 ] ) ) ; var map = { } ; list . forEach ( ( v , i ) = > { var c = v [ 0 ] ; var y = v [ 1 ] ; if ( ! map [ c ] ) { map [ c ] = { len : 0 } ; } map [ c ] [ y ] = + + map [ c ] . len ; } ) ; for ( var i = 1 ; i < = M ; i + + ) { var c = input [ i ] . split ( " " ) [ 0 ] ; var y = input [ i ] . split ( " " ) [ 1 ] ; var num = map [ c ] [ y ] ; console . log ( ( " 000000 " + c ) . slice ( - 6 ) + ( " 000000 " + num ) . slice ( - 6 ) ) ; } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . trim ( ) . split ( " \ n " ) ) ' use strict ' ; function main ( input ) { const inputs = input . split ( ' ' ) . map ( ( x ) = > x | 0 ) ; const sum = inputs . reduce ( ( a , b ) = > a + b ) ; if ( sum ! = 17 ) { console . log ( ' NO ' ) ; return ; } let i = inputs . shift ( ) ; while ( i ) { if ( i ! = 5 & & i ! = 7 ) { console . log ( ' NO ' ) ; return ; } i = inputs . shift ( ) ; } console . log ( ' YES ' ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { var N , M ; input = input . split ( " \ n " ) ; input = input [ 0 ] . split ( " " ) ; N = input [ 0 ] ; M = input [ 1 ] ; var mod = 1000000000 + 7 ; var result = 1 ; if ( Math . abs ( N - M ) > = 2 ) { console . log ( 0 ) ; } else if ( Math . abs ( N - M ) = = 1 ) { for ( var i = 1 ; i < = N ; i + + ) { result * = i ; result % = mod ; } for ( var i = 1 ; i < = M ; i + + ) { result * = i ; result % = mod ; } console . log ( result ) ; } else if ( Math . abs ( N - M ) = = 0 ) { result = 1 ; for ( var i = 1 ; i < = N ; i + + ) { result * = i ; result % = mod ; } for ( var i = 1 ; i < = M ; i + + ) { result * = i ; result % = mod ; } result * = 2 ; result % = mod ; console . log ( result ) ; } } function factorial ( n ) { var result = 1 ; for ( var i = 1 ; i < = n ; i + + ) { result = ( result * i ) % 1000000007 ; } return result ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' ; ( function ( stdin ) { var inputs = stdin . toString ( ) ; var x = inputs . trim ( ) . split ( ' \ n ' ) . map ( Number ) [ 0 ] ; console . log ( Math . pow ( x , 3 ) ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; var x = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; console . log ( Math . pow ( x , 3 ) ) ; var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . split ( / \ s / g ) ; var a = input [ 0 ] - 0 ; var b = input [ 1 ] - 0 ; console . log ( Math . ceil ( ( a + b ) / 2 ) ) ; ' use strict ' function Main ( input ) { input = input . split ( " \ n " ) ; let nums = input [ 1 ] . split ( " " ) ; let max = Math . max . apply ( null , nums ) ; let min = Math . min . apply ( null , nums ) ; let a = parseInt ( nums [ 0 ] ) ; let result = ( a - min ) + ( max - a ) ; console . log ( result ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' function main ( s ) { s = s . split ( ' \ n ' ) [ 0 ] . split ( ' ' ) ; const a = Number ( s [ 0 ] ) ; const b = Number ( s [ 1 ] ) ; const ans = Math . ceil ( ( a + b ) / 2 ) ; console . log ( ans ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' function Main ( input ) { const tmp = input . trim ( ) . split ( ' \ n ' ) ; const NM = tmp [ 0 ] . split ( ' ' ) ; const N = Number ( NM [ 0 ] ) const M = Number ( NM [ 1 ] ) const AB = tmp . splice ( 1 ) ; const A = AB . slice ( 0 , N ) ; const B = AB . slice ( - M ) ; const joinB = B . join ( ' ' ) ; for ( let y = 0 ; y < ( N - M + 1 ) ; y + + ) { for ( let x = 0 ; x < ( N - M + 1 ) ; x + + ) { if ( A [ y ] [ x ] = = = joinB [ 0 ] ) { let joinA = ' ' ; for ( let i = 0 ; i < M ; i + + ) { joinA + = A [ y + i ] . slice ( x , x + M ) } if ( joinA = = = joinB ) { console . log ( ' Yes ' ) ; return ; } } } } console . log ( ' No ' ) ; return ; } Main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( s ) { s = s . split ( " \ n " ) ; const n = + s [ 0 ] ; var ans = 0 ; var m = 1e10 ; for ( var i = 0 ; i < n ; i + + ) { var a = s [ i + 1 ] . split ( " " ) . map ( a = > + a ) ; if ( a [ 0 ] > a [ 1 ] ) m = Math . min ( m , a [ 1 ] ) ; ans + = a [ 0 ] ; } if ( m = = = 1e10 ) ans = 0 ; else ans - = m ; console . log ( ans ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " ; function main ( input ) { const r = input . replace ( " \ n " , " " ) ; console . log ( r * * 2 ) ; return ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { var ans = " Three " ; if ( input . match ( / Y / ) ) ans = " Four " ; console . log ( ans ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' const main = ( input ) = > { const n = parseInt ( input ) console . log ( 800 * n - 200 * Math . floor ( n / 15 ) ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf-8 ' ) ) function main ( input ) { const formatted _ input = input . split ( ' \ n ' ) . map ( x = > parseInt ( x ) ) ; var tmp _ minimum = 0 ; var result = 0 ; for ( var i = 0 ; i < 5 ; i + + ) { if ( formatted _ input [ i ] % 10 = = 0 ) { result + = formatted _ input [ i ] } else { result + = ( formatted _ input [ i ] - formatted _ input [ i ] % 10 ) if ( tmp _ minimum = = 0 ) { tmp _ minimum = formatted _ input [ i ] % 10 } else { result + = 10 ; tmp _ minimum = Math . min ( tmp _ minimum , formatted _ input [ i ] % 10 ) } } } result + = tmp _ minimum ; console . log ( result ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { var inp = input . split ( " " ) ; var a = parseInt ( inp [ 0 ] ) ; var b = parseInt ( inp [ 1 ] ) ; var c = Math . ceil ( ( a + b ) / 2 ) ; console . log ( ' % d ' , c ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( s ) { s = s . split ( ' \ n ' ) [ 0 ] . split ( ' ' ) . map ( x = > Number ( x ) ) ; console . log ( s [ 0 ] * 800 - ( s [ 0 ] / 15 | 0 ) * 200 ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( input ) { const args = input . split ( ' ' ) . map ( n = > parseInt ( n , 10 ) ) ; const A = args [ 0 ] ; const B = args [ 1 ] ; const cards = { 1 : 2 , 2 : 3 , 3 : 4 , 4 : 5 , 5 : 6 , 6 : 7 , 7 : 8 , 8 : 9 , 9 : 10 , 10 : 11 , 11 : 12 , 12 : 13 , 13 : 14 , 1 : 15 } if ( cards [ A ] > cards [ B ] ) { console . log ( ' Alice ' ) ; } else if ( cards [ A ] = = = cards [ B ] ) { console . log ( ' Draw ' ) ; } else { console . log ( ' Bob ' ) ; } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var lines = [ ] ; var reader = require ( ' readline ' ) . createInterface ( { input : process . stdin , output : process . stdout } ) ; reader . on ( ' line ' , function ( line ) { lines . push ( line ) ; } ) ; reader . on ( ' close ' , function ( ) { if ( lines . length = = = 1 ) { var date _ int = lines [ 0 ] . replace ( / \ if ( date _ int < = 20190430 ) { console.log ( ' Heisei ' ) ; return ; } } console.log ( ' TBD ' ) ; } ) ; ' use strict ' ; ( function ( stdin ) { var inputs = stdin . toString ( ) ; var x = inputs . trim ( ) . split ( ' \ n ' ) . map ( Number ) [ 0 ] ; console . log ( Math . pow ( x , 3 ) ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; var lines = [ ] ; var result = " " ; var readline = require ( ' readline ' ) ; var rl = readline . createInterface ( { input : process . stdin , output : process . stdout , } ) ; rl . on ( ' line ' , function ( x ) { lines . push ( x ) ; } ) ; rl . on ( ' close ' , function ( ) { var s = lines [ 0 ] . split ( " " ) ; var K = Number ( lines [ 1 ] ) ; var len = s . length ; var s _ code = Array ( len ) . fill ( 0 ) for ( var i = 0 ; i < len ; i + + ) { s _ code [ i ] = s [ i ] . charCodeAt ( 0 ) ; } for ( var i = 0 ; i < len ; i + + ) { if ( i = = = len - 1 ) { K = K % 26 ; s _ code [ i ] + K > " z " . charCodeAt ( 0 ) ? s _ code [ i ] = 97 + s _ code [ i ] + K - " z " . charCodeAt ( 0 ) - 1 : s _ code [ i ] + = K ; } else { if ( " z " . charCodeAt ( 0 ) - s _ code [ i ] + 1 < = K & & s _ code [ i ] ! = = " a " . charCodeAt ( 0 ) ) { K - = " z " . charCodeAt ( 0 ) - s _ code [ i ] + 1 ; s _ code [ i ] = " a " . charCodeAt ( 0 ) ; } } if ( K < = 0 ) { break } ; } for ( var i = 0 ; i < len ; i + + ) { result + = String . fromCharCode ( s _ code [ i ] ) ; } console . log ( result ) ; } ) ; function Main ( input ) { input = input . split ( " \ n " ) tmp0 = input [ 0 ] . split ( " " ) S = tmp0 [ 0 ] . split ( " / " ) yyyy = Number ( S [ 0 ] ) mm = Number ( S [ 1 ] ) dd = Number ( S [ 2 ] ) if ( yyyy < = 2019 & & mm < = 4 & & dd < = 30 ) { console . log ( " Heisei " ) } else { console . log ( " TBD " ) } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' ; ( function ( stdin ) { var inputs = stdin . toString ( ) . trim ( ) . split ( ' \ n ' ) ; ( function ( x ) { console . log ( Math . pow ( x , 3 ) ) ; } ) ( parseInt ( inputs [ 0 ] , 10 ) ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var kotae = input * input * input ; console . log ( kotae ) ; function main ( s ) { s = s . split ( " " ) ; var a , b ; a = parseInt ( s [ 0 ] ) ; b = parseInt ( s [ 1 ] ) ; console . log ( Math . floor ( ( a + b ) / 2 + .5 ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; " use strict " ; const main = arg = > { const times = arg . trim ( ) . split ( " \ n " ) . map ( n = > parseInt ( n ) ) ; let min = 10 ; let sum = 0 ; for ( let i = 0 ; i < times . length ; i + + ) { let digitOne = String ( times [ i ] ) . split ( " " ) ; digitOne = parseInt ( digitOne [ digitOne . length - 1 ] ) ; let digitMinus = 10 - digitOne ; sum + = parseInt ( times [ i ] ) ; if ( digitMinus ! = = 10 ) { sum + = digitMinus ; } if ( digitMinus ! = = 10 & & digitOne < min ) { min = digitOne ; } } console . log ( parseInt ( sum - ( 10 - min ) ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; const fs = require ( ' fs ' ) , length = fs . fstatSync ( process . stdin . fd ) . size , buffer = new Buffer ( length ) , bytesRead = fs . readSync ( process . stdin . fd , buffer , 0 , length , 0 ) , input = buffer . toString ( ' utf8 ' , 0 , bytesRead ) . split ( ' \ n ' ) ; main ( ) ; function main ( ) { const data = input const x = Number ( data [ 0 ] ) console . log ( x * x * x ) } function main ( input ) { const a = input . split ( " " ) . map ( Number ) ; console . log ( ( a [ 0 ] * a [ 1 ] * a [ 2 ] = = 175 ? " YES " : " NO " ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( arg ) { const lines = arg . trim ( ) . split ( ' \ n ' ) ; const INF = Math . pow ( 10 , 100 ) ; const times = lines . map ( Number ) ; const ceilTimes = times . map ( ( v ) = > parseInt ( Math . ceil ( v / 10 ) * 10 ) ) ; const sum = ( acc , v ) = > acc + v ; let ans = INF ; for ( let i = 0 ; i < 5 ; i + + ) { let sumTimes = 0 ; sumTimes + = ceilTimes . reduce ( sum ) - ceilTimes [ i ] ; sumTimes + = times [ i ] ; ans = Math . min ( ans , sumTimes ) ; } console . log ( ans ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { var cards = input . split ( " " ) ; var cardA = parseInt ( cards [ 0 ] ) ; var cardB = parseInt ( cards [ 1 ] ) ; if ( cardA = = 1 ) { cardA = 14 ; } if ( cardB = = 1 ) { cardB = 14 ; } if ( cardA > cardB ) { console . log ( " Alice " ) ; } else if ( cardA < cardB ) { console . log ( " Bob " ) ; } else if ( cardA = = cardB ) console . log ( " Draw " ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var lines = [ ] ; var readline = require ( ' readline ' ) ; var rl = readline . createInterface ( { input : process . stdin , output : process . stdout , } ) ; rl . on ( ' line ' , function ( x ) { lines . push ( x ) ; } ) ; rl . on ( ' close ' , function ( ) { var x = lines [ 0 ] . split ( " " ) . map ( value = > Number ( value ) ) ; console . log ( Math . ceil ( ( x [ 0 ] + x [ 1 ] ) / 2 ) ) } ) ; function Main ( input ) { input = input . trim ( ) ; input = input . trim ( ) . split ( " " ) . map ( ( a ) = > Number ( a ) ) ; if ( input [ 0 ] + input [ 1 ] > = input [ 2 ] ) { console . log ( " Yes " ) ; } else { console . log ( " No " ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' ; function Main ( input ) { const tmp = input . split ( " \ n " ) [ 0 ] . split ( " " ) ; let A = parseInt ( tmp [ 0 ] , 10 ) ; let B = parseInt ( tmp [ 1 ] , 10 ) ; if ( A = = 1 ) { A + = 13 ; } if ( B = = 1 ) { B + = 13 ; } if ( A = = B ) { console . log ( " Draw " ) ; } else if ( A > B ) { console . log ( " Alice " ) ; } else { console . log ( " Bob " ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function rotatePoint2D ( nRadians , nX , nY ) { var nSin = Math . sin ( nRadians ) ; var nCos = Math . cos ( nRadians ) ; var x = nCos * nX - nSin * nY ; var y = nSin * nX + nCos * nY ; return { x : x , y : y } ; } function Main ( input ) { const inputLines = input . split ( " \ n " ) ; const line0 = inputLines [ 0 ] ; const line0vars = line0 . split ( " " ) ; const a = parseInt ( line0vars [ 0 ] , 10 ) ; const b = parseInt ( line0vars [ 1 ] , 10 ) ; const h = parseInt ( line0vars [ 2 ] , 10 ) ; const m = parseInt ( line0vars [ 3 ] , 10 ) ; var output ; var aRad = ( h * 30 + m * 0.5 ) * ( Math . PI / 180 ) ; var bRad = m * 6 * ( Math . PI / 180 ) ; var x1 , y1 , x2 , y2 ; resultA = rotatePoint2D ( aRad , 0 , a ) ; resultB = rotatePoint2D ( bRad , 0 , b ) ; x1 = resultA . x ; y1 = resultA . y ; x2 = resultB . x ; y2 = resultB . y ; output = Math . sqrt ( Math . pow ( x2 - x1 , 2 ) + Math . pow ( y2 - y1 , 2 ) ) ; console . log ( output ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; const input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; const nenn = Number ( input . split ( ' ' ) . slice ( 0 , 4 ) . join ( ' ' ) ) ; const month = Number ( input . split ( ' ' ) . slice ( 5 , 7 ) . join ( ' ' ) ) ; const hi = Number ( input . split ( ' ' ) . slice ( 8 , 10 ) . join ( ' ' ) ) ; if ( nenn < 2019 ) { console . log ( ' Heisei ' ) ; } else if ( month < 5 ) { console . log ( ' Heisei ' ) ; } else { console . log ( ' TBD ' ) ; } ( function Main ( input ) { var input = input . split ( ' \ n ' ) , X = input [ 1 ] . split ( ' ' ) . map ( Number ) , result = 0 , avg = function ( data ) { var sum = 0 , len = data . length ; for ( var i = 0 ; i < len ; i + + ) { sum + = data [ i ] ; } return Math . round ( sum / len ) ; } ( X ) ; for ( var i = 0 ; i < X . length ; i + + ) { result + = Math . pow ( X [ i ] - avg , 2 ) ; } console . log ( result ) ; } ) ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { var x = parseInt ( chunk . trim ( ) , 10 ) ; console . log ( x * x * x ) ; } ) ; function Main ( input ) { input = input . split ( " " ) . map ( a = > ~ ~ a ) ; return Math . min ( ... [ " 012 " , " 021 " , " 102 " , " 120 " , " 201 " , " 210 " ] . map ( function ( a ) { a = a . split ( " " ) . map ( a = > ~ ~ a ) ; return Math . abs ( input [ a [ 0 ] ] - input [ a [ 1 ] ] ) + Math . abs ( input [ a [ 1 ] ] - input [ a [ 2 ] ] ) } ) ) } ( ( b , c , d ) = > " undefined " ! = typeof require ? console . log ( Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ) : [ b = b . split ( " \ n " ) . slice ( 1 , - 1 ) . join ( " \ n " ) , c = function ( ) { try { return Main ( b ) } catch ( f ) { return f . stack | | f . message } } ( ) , d = typeof c , " string " = = d | | ( c = JSON . stringify ( c ) ) , $ ( " < form > " ) . append ( [ [ 10 , b ] , 0 , [ 1 , d ] , 0 , [ 10 , c ] ] . map ( f = > $ ( f ? " < textarea > " : " < br > " , f & & { rows : f [ 0 ] , cols : 40 , text : f [ 1 ] } ) ) ) . appendTo ( " body " ) ] ) ( ` ` ) ; " use strict " function Main ( input ) { input = input . trim ( ) . split ( ' \ n ' ) ; let h = input [ 0 ] . trim ( ) . split ( ' ' ) . map ( Number ) ; let m = input [ 1 ] . trim ( ) . split ( ' ' ) . map ( Number ) ; let l = input [ 2 ] . trim ( ) . split ( ' ' ) . map ( Number ) ; let x = [ m [ 0 ] - h [ 0 ] , m [ 1 ] - h [ 1 ] , m [ 2 ] - h [ 2 ] ] let y = [ l [ 0 ] - m [ 0 ] , l [ 1 ] - m [ 1 ] , l [ 2 ] - m [ 2 ] ] if ( x [ 0 ] = = = x [ 1 ] & & x [ 1 ] = = = x [ 2 ] ) { if ( y [ 0 ] = = = y [ 1 ] & & y [ 1 ] = = = y [ 2 ] ) { console . log ( ' Yes ' ) ; return ; } } console . log ( ' No ' ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { const N = input ; var ans = 1 ; var cnt = 0 ; var maxCnt = 0 ; for ( var i = 1 ; i < = N ; i + + ) { cnt = 0 ; var tmp = i ; while ( true ) { if ( tmp % 2 = = = 0 ) { cnt = cnt + 1 ; tmp = tmp / 2 ; } else { break ; } } if ( maxCnt < cnt ) { maxCnt = cnt ; ans = i ; } } console . log ( ans ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' function Main ( input ) { const tmp = input . trim ( ) . split ( ' \ n ' ) [ 0 ] . split ( ' ' ) ; const K = Number ( tmp [ 0 ] ) ; const S = Number ( tmp [ 1 ] ) ; let result = 0 ; for ( let x = 0 ; x < = K ; x + + ) { for ( let y = 0 ; y < = K ; y + + ) { const z = S - x - y ; if ( z > = 0 & & z < = K ) { result + + ; } } } console . log ( result ) ; } Main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ( function ( stdin ) { var lines = stdin . trim ( ) . split ( ' \ n ' ) ; lines . forEach ( function ( line ) { var numbers = line . trim ( ) . split ( ' ' ) . map ( Number ) ; console . log ( numbers [ 0 ] + numbers [ 1 ] ) ; } ) ; } ) ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' function main ( s ) { const n = Number ( s ) ; let i = 0 ; while ( Math . pow ( 2 , i ) < = n ) { i + = 1 ; } const ans = Math . pow ( 2 , i - 1 ) ; console . log ( ans ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' const main = input = > { const line = input . split ( ' ' ) . map ( v = > v - 0 ) const cost = Math . max ( ... line ) - Math . min ( ... line ) console . log ( cost ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) function Main ( input ) { input = input . split ( " \ n " ) ; input = input [ 1 ] . split ( " " ) . map ( Number ) ; console . log ( Math . max . apply ( null , input ) - Math . min . apply ( null , input ) ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) ) ; function main ( input ) { var x = parseInt ( input . split ( " \ n " ) [ 0 ] , 10 ) ; var hoge = [ ] ; for ( var i = 0 ; i < 150 ; i + + ) { hoge . push ( Math . pow ( i , 5 ) ) ; } var fuga = hoge . concat ( ) ; for ( var i = 0 ; i < hoge . length ; i + + ) { for ( var j = 0 ; j < fuga . length ; j + + ) { var a5 = hoge [ i ] ; var b5 = fuga [ j ] ; if ( a5 - b5 = = x ) { console . log ( i + " " + j ) ; return ; } b5 = b5 * - 1 ; if ( a5 - b5 = = x ) { console . log ( i + " " + " - " + j ) ; return ; } } } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; var N1 = parseInt ( input [ 0 ] . split ( " " ) [ 0 ] ) ; var N2 = parseInt ( input [ 0 ] . split ( " " ) [ 1 ] ) ; var N3 = parseInt ( input [ 0 ] . split ( " " ) [ 2 ] ) ; var N4 = parseInt ( input [ 0 ] . split ( " " ) [ 3 ] ) ; N = new Array ( N1 , N2 , N3 , N4 ) ; var ans = " NO " ; N . sort ( function ( a , b ) { return a - b ; } ) ; NN = ( parseInt ( N . join ( " " ) ) ) ; if ( NN = = 1479 ) { ans = " YES " ; } console . log ( ' % s ' , ans ) ; } function debug ( ) { var input = document . getElementById ( " input " ) . value ; Main ( input ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; var x = parseInt ( input [ 0 ] , 10 ) ; console . log ( " % d " , x * x * x ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { console . log ( Math . pow ( Number ( input ) , 3 ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { const n = chunk . toString ( ) ; const r = n . split ( " \ n " ) . filter ( x = > x ! = 0 ) ; r . forEach ( x = > sp ( x ) ) ; } ) ; function sp ( rep ) { const x = rep . split ( " " ) . map ( x = > Number ( x ) ) ; var acc = 0 ; if ( x . length = = = 1 ) { return console . log ( x [ 0 ] ) ; } for ( var i = 0 ; i < x . length ; i + + ) { acc + = x [ i ] ; } console . log ( acc ) ; } ' use strict ' function main ( input ) { input = input . trim ( ) . split ( ' \ n ' ) let size = input . shift ( ) . split ( ' ' ) . map ( val = > Number ( val ) ) let sizeDiff = size [ 0 ] - size [ 1 ] let N = [ ] let M = [ ] let result = 0 for ( let i = 0 ; i < size [ 0 ] ; i + + ) { N . push ( input . shift ( ) ) } for ( let i = 0 ; i < size [ 1 ] ; i + + ) { M . push ( input . shift ( ) ) } for ( let i = 0 ; i < = sizeDiff ; i + + ) { while ( result ! = = - 1 ) { result = N [ i ] . indexOf ( M [ 0 ] , result ) if ( result ! = = - 1 ) { let check = true for ( let j = 1 ; j < size [ 1 ] ; j + + ) { if ( check ) { check = N [ i + j ] . indexOf ( M [ j ] , result ) = = = result } } if ( check ) { console . log ( ' Yes ' ) return } } if ( result ! = = - 1 ) result + + } result = 0 } console . log ( ' No ' ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' ; function main ( input ) { var P = input . split ( ' \ n ' ) [ 1 ] . split ( ' ' ) ; var min = 2 * Math . pow ( 10 , 5 ) + 1 ; var cnt = 0 ; for ( var p of P ) { p = parseInt ( p ) ; if ( p < min ) { + + cnt ; min = p ; } } console . log ( cnt ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; " use strict " function main ( input ) { let nums = input . split ( ' ' ) nums = nums . map ( x = > + x ) nums . sort ( ) let num = 0 ; for ( let i = 0 ; i < nums . length ; i + + ) { let red = ( i > = 1 ) ? nums [ i - 1 ] : 0 num + = Math . abs ( nums [ i ] - red ) } num - = nums [ 0 ] console . log ( num ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' ; process . stdin . on ( ' data ' , function ( chunk ) { var inputs = chunk . toString ( ) ; var X = Number ( inputs ) ; console . log ( Math . pow ( X , 3 ) ) ; } ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; ( function ( stdin ) { var lines = stdin . toString ( ) . split ( ' \ n ' ) ; var x = parseInt ( lines [ 0 ] , 10 ) ; console . log ( Math . pow ( x , 3 ) ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; ' use strict ' const main = ( INPUT ) = > { const N = Number ( INPUT . split ( ' \ n ' ) [ 0 ] ) let ans = N * 800 ans - = Math . floor ( N / 15 ) * 200 console . log ( ans ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) function main ( s ) { var a = s . split ( " " ) ; for ( var i = 0 ; i < a . length ; i + + ) a [ i ] = parseInt ( a [ i ] ) ; if ( a [ 0 ] + a [ 1 ] > = a [ 2 ] ) console . log ( " Yes \ n " ) ; else console . log ( " No \ n " ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var i = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; console . log ( i * i * i ) ; inp = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . split ( ' \ n ' ) temp = inp . shift ( ) . split ( ' ' ) a = temp [ 0 ] * 1 b = temp [ 1 ] * 1 console . log ( Math . ceil ( ( a + b ) / 2 ) ) ' use strict ' ; const main = input = > { const n = parseInt ( input [ 0 ] ) ; let x = new Array ( n ) , y = new Array ( n ) ; for ( let i = 0 ; i < n ; i + + ) { let k = input [ i + 1 ] . split ( ' ' ) . map ( val = > parseInt ( val ) ) ; x [ i ] = k [ 0 ] , y [ i ] = k [ 1 ] ; } let distanceSum = 0 ; for ( let i = 0 ; i < n - 1 ; i + + ) { for ( let j = i ; j < n ; j + + ) { distanceSum + = Math . sqrt ( ( x [ i ] - x [ j ] ) * ( x [ i ] - x [ j ] ) + ( y [ i ] - y [ j ] ) * ( y [ i ] - y [ j ] ) ) ; } } console . log ( distanceSum / n * 2 ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . split ( ' \ n ' ) ) ; " use strict " function Main ( input ) { input = Number ( input . trim ( ) ) ; console . log ( input * input ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var inp = input . split ( ' \ n ' ) ; var c1 = inp [ 0 ] . split ( ' ' ) . map ( n = > { return parseInt ( n . trim ( ) ) } ) ; var c2 = inp [ 1 ] . split ( ' ' ) . map ( n = > { return parseInt ( n . trim ( ) ) } ) ; var c3 = inp [ 2 ] . split ( ' ' ) . map ( n = > { return parseInt ( n . trim ( ) ) } ) ; var C = [ ] ; C [ 0 ] = c1 ; C [ 1 ] = c2 ; C [ 2 ] = c3 ; var x = [ ] ; var y = [ ] ; x [ 0 ] = 0 ; for ( var i = 0 ; i < 3 ; i + + ) { y [ i ] = C [ 0 ] [ i ] - x [ 0 ] ; } for ( var i = 0 ; i < 3 ; i + + ) { x [ i ] = C [ i ] [ 0 ] - y [ 0 ] ; } var good = true ; for ( var i = 0 ; i < 3 ; i + + ) { for ( var j = 0 ; j < 3 ; j + + ) { if ( x [ i ] + y [ j ] ! = = C [ i ] [ j ] ) { good = false ; } } } if ( good ) { console . log ( ' Yes ' ) ; } else { console . log ( ' No ' ) ; } } Main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( arg ) { arg = arg . trim ( ) ; arg = Number ( arg ) var r = arg * arg , i = 1 * 1 ; var out = r / i ; console . log ( out ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; var x = parseInt ( input [ 0 ] , 10 ) ; console . log ( " % d " , x * x * x ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; let x = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' UTF-8 ' ) ; console . log ( x * x * x ) ; function Main ( input ) { input = input . split ( " " ) ; var A = parseInt ( input [ 0 ] ) ; var B = parseInt ( input [ 1 ] ) ; var result ; if ( 13 < = A & & A < = 100 ) { result = B ; } else if ( 6 < = A & & A < = 12 ) { result = B / 2 ; } else if ( 0 < = A & & A < = 5 ) { result = 0 ; } console . log ( result ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ' use strict ' let input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ; input = input . split ( ' \ n ' ) . map ( x = > x * 1 ) ; let oneKetaMin = Math . min ( ... input . map ( x = > x % 10 ) . filter ( x = > x ! = 0 ) ) ; let Sum = input . map ( x = > Math . ceil ( x / 10 ) * 10 ) . reduce ( ( x , a ) = > a + = x ) ; if ( isFinite ( oneKetaMin ) ) { Sum = Sum - 10 + oneKetaMin } console . log ( Sum ) ; ' use strict ' function main ( input ) { input = input . trim ( ) . split ( ' ' ) . map ( Number ) const k = input [ 0 ] const s = input [ 1 ] let count = 0 for ( let xi = 0 ; xi < = k ; xi + + ) { for ( let yi = 0 ; yi < = k ; yi + + ) { const diff = s - xi - yi if ( diff > = 0 & & diff < = k ) count + + } } console . log ( count ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) const main = input = > { const [ a , b , c , d ] = input . trim ( ) . split ( " " ) . map ( e = > Number . parseInt ( e ) ) const h = ( 360 / 12 / 60 ) * ( Math . PI / 180 ) ; const m = ( 360 / 60 ) * ( Math . PI / 180 ) ; const x1 = b * Math . cos ( m * d ) const x2 = a * Math . cos ( h * ( c * 60 + d ) ) const y1 = b * Math . sin ( m * d ) const y2 = a * Math . sin ( h * ( c * 60 + d ) ) return Math . sqrt ( ( x1 - x2 ) * * 2 + ( y1 - y2 ) * * 2 ) } console . log ( main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) function Main ( input ) { input = input . split ( " " ) . map ( Number ) . sort ( ( a , b ) = > a - b ) ; console . log ( input [ 2 ] - input [ 0 ] ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { var line = chunk . toString ( ) ; var output = line * line * line ; console . log ( output ) ; } ) ; process . stdin . setEncoding ( ' utf-8 ' ) ; process . stdin . on ( ' data ' , num = > { console . log ( num * num * num ) ; } ) ; if ( ! String . prototype . padStart ) { String . prototype . padStart = function padStart ( targetLength , padString ) { targetLength = targetLength > > 0 ; padString = String ( ( typeof padString ! = = ' undefined ' ? padString : ' ' ) ) ; if ( this . length > targetLength ) { return String ( this ) ; } else { targetLength = targetLength - this . length ; if ( targetLength > padString . length ) { padString + = padString . repeat ( targetLength / padString . length ) ; } return padString . slice ( 0 , targetLength ) + String ( this ) ; } } ; } function Main ( input ) { const data = input . split ( " \ n " ) const a = data . shift ( ) . split ( " " ) const N = a [ 0 ] const M = a [ 1 ] const pref = [ ] data . forEach ( ( d , i ) = > { if ( d . length = = = 0 ) { return ; } const x = d . split ( " " ) const I = x [ 0 ] const Y = x [ 1 ] var P = pref [ I ] if ( P = = = undefined ) { pref [ I ] = [ [ i , Y ] ] } else { P . push ( [ i , Y ] ) } } ) const r = [ ] ; pref . forEach ( ( p , pi ) = > { if ( ! Array . isArray ( p ) ) { return ; } p . sort ( ( a , b ) = > { const a1 = parseInt ( a [ 1 ] ) , b1 = parseInt ( b [ 1 ] ) return a1 > b1 ? 1 : a1 = = = b1 ? 0 : - 1 } ) p . forEach ( ( m , mi ) = > { r [ m [ 0 ] ] = ( " " + pi ) . padStart ( 6 , " 0 " ) + ( " " + ( mi + 1 ) ) . padStart ( 6 , " 0 " ) } ) } ) ; console . log ( r . join ( " \ n " ) ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " ; function Main ( input ) { let lines = input . split ( " \ n " ) ; let nm = lines . shift ( ) . split ( / \ s / ) . map ( ( v ) = > v - 0 ) ; let N = nm [ 0 ] , M = nm [ 1 ] ; const MAX _ N = 1e5 + 1 ; let V = new Array ( MAX _ N ) . fill ( 0 ) . map ( ( ) = > [ ] ) ; for ( let m = 0 ; m < M ; m + + ) { let py = lines . shift ( ) . split ( / \ s / ) . map ( ( v ) = > v - 0 ) ; V [ py [ 0 ] ] . push ( [ py [ 1 ] , m ] ) ; } const d6 = ( n ) = > ( ' 000000 ' + n . toString ( ) ) . slice ( - 6 ) ; const d12 = ( p , y ) = > d6 ( p ) + d6 ( y ) ; let ans = new Array ( M ) ; for ( let m = 0 ; m < MAX _ N ; m + + ) { V [ m ] . sort ( ( a , b ) = > a [ 0 ] - b [ 0 ] ) ; let v = V [ m ] ; for ( let n = 0 ; n < v . length ; n + + ) { ans [ v [ n ] [ 1 ] ] = d12 ( m , n + 1 ) ; } } for ( let m = 0 ; m < M ; m + + ) { console . log ( ans [ m ] ) ; } } if ( typeof window = = " undefined " ) Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' function main ( s ) { s = s . split ( ' \ n ' ) [ 0 ] . split ( ' ' ) . map ( n = > Number ( n ) ) ; const K = s [ 0 ] ; const S = s [ 1 ] ; let counter = 0 ; for ( let x = 0 ; x < = K ; x + + ) { for ( let y = 0 ; y < = K ; y + + ) { const z = S - x - y ; if ( z < 0 | | z > K ) continue ; if ( ( x + y + z ) = = = S ) { counter + = 1 ; } } } console . log ( counter ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var a = input [ 0 ] . split ( " " ) . sort ( ( a , b ) = > a - b ) . join ( " " ) ; console . log ( a = = " 557 " ? " YES " : " NO " ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) . split ( " \ n " ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; N = Number ( input [ 0 ] ) ; let An = input [ 1 ] . split ( " " ) . map ( Number ) ; if ( gcd ( An ) ! = = 1 ) { console . log ( " not coprime " ) ; return ; } let freq = Array ( 1000001 ) . fill ( 0 ) ; for ( let A of An ) { if ( A = = = 1 ) continue ; freq [ A ] + + ; } for ( let i = 2 ; i < = 1000001 ; i + + ) { let tmp = 0 ; for ( let j = i ; j < = 1000001 ; j + = i ) { tmp + = freq [ j ] ; if ( tmp > = 2 ) { console . log ( " setwise coprime " ) ; return ; } } } console . log ( " pairwise coprime " ) ; } function gcd ( arg ) { let f = ( a , b ) = > b ? f ( b , a % b ) : a let ans = arg [ 0 ] ; for ( let i = 1 ; i < arg . length ; i + + ) { ans = f ( ans , arg [ i ] ) ; } return ans ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var inputs = input . trim ( ) ; var items = input . split ( " " ) . map ( ( item ) = > { return parseInt ( item ) ; } ) ; items . sort ( ) ; var target = [ 5 , 5 , 7 ] ; var flag = true ; for ( var i = 0 ; i < 3 ; + + i ) { if ( items [ i ] ! = target [ i ] ) { flag = false ; break ; } } console . log ( flag ? " YES " : " NO " ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( s ) { s = s . split ( " " ) ; for ( var i = 0 ; i < 4 ; i + + ) s [ i ] = parseInt ( s [ i ] ) ; console . log ( ( s [ 0 ] * s [ 1 ] > s [ 2 ] * s [ 3 ] ) ? ( s [ 0 ] * s [ 1 ] ) : ( s [ 2 ] * s [ 3 ] ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { const inputLines = input . split ( " \ n " ) ; const line0 = inputLines [ 0 ] ; const line0vars = line0 . split ( " " ) ; const line1 = inputLines [ 1 ] ; const line1vars = line1 . split ( " " ) ; const line2 = inputLines [ 2 ] ; const a = parseInt ( line0vars [ 0 ] , 10 ) ; const v = parseInt ( line0vars [ 1 ] , 10 ) ; const b = parseInt ( line1vars [ 0 ] , 10 ) ; const w = parseInt ( line1vars [ 1 ] , 10 ) ; const t = parseInt ( line2 , 10 ) ; if ( v < = w ) { console . log ( ( a = = = b ) ? " YES " : " NO " ) ; return ; } const time = Math . abs ( b - a ) / Math . abs ( v - w ) ; console . log ( ( 0 < time & & time < = t ) ? " YES " : " NO " ) ; return ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( ' ' ) . map ( num = > parseInt ( num , 10 ) ) ; A = input [ 0 ] ; B = input [ 1 ] ; C = input [ 2 ] ; ( A + B ) > = C ? console . log ( ' Yes ' ) : console . log ( ' No ' ) ; } Main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { main ( chunk . trim ( ) ) ; } ) ; function main ( chunk ) { var lines = chunk . split ( " \ n " ) ; for ( var i in lines ) { console . log ( Number ( lines [ i ] . split ( " " ) [ 0 ] ) + Number ( lines [ i ] . split ( " " ) [ 1 ] ) ) ; } } " use strict " ; function main ( arg ) { const S = arg . split ( " \ n " ) [ 0 ] . split ( " / " ) ; let answer ; if ( parseInt ( S [ 0 ] ) < 2019 ) { answer = " TBD " ; } else if ( parseInt ( S [ 0 ] ) = = 2019 & & parseInt ( S [ 1 ] ) > 4 ) { answer = " TBD " ; } else { answer = " Heisei " ; } console . log ( answer ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { input = input . split ( ' \ n ' ) ; var arare = input [ 1 ] . slice ( ' ' ) ; if ( arare . indexOf ( ' Y ' ) ! = - 1 ) console . log ( ' Four ' ) ; else console . log ( ' Three ' ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; const BKRT = " \ n " ; const SPAC = " " ; const NOSP = " " ; function Main ( input ) { input = [ ] . concat ( ... input . split ( BKRT ) . map ( a = > a . split ( SPAC ) ) ) ; const strShift = ( ) = > input . shift ( ) ; const intShift = ( ) = > ~ ~ input . shift ( ) ; return ~ ~ Math . ceil ( ( intShift ( ) + intShift ( ) ) / 2 ) ; } ( ( b , c , d ) = > " undefined " ! = typeof require ? console . log ( Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ) : [ b = b . split ( " \ n " ) . slice ( 1 , - 1 ) . join ( " \ n " ) , c = function ( ) { try { return Main ( b ) } catch ( f ) { return f . stack | | f . message } } ( ) , d = typeof c , " string " = = d | | ( c = JSON . stringify ( c ) ) , $ ( " < form > " ) . append ( [ [ 10 , b ] , 0 , [ 1 , d ] , 0 , [ 10 , c ] ] . map ( f = > $ ( f ? " < textarea > " : " < br > " , f & & { rows : f [ 0 ] , cols : 40 , text : f [ 1 ] } ) ) ) . appendTo ( " body " ) ] ) ( ` ` ) ; function Main ( input ) { console . log ( Math . pow ( parseInt ( input . split ( " \ n " ) ) , 3 ) ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " ; const main = arg = > { arg = arg . trim ( ) . split ( " \ n " ) ; const A = parseInt ( arg [ 0 ] . split ( " " ) [ 0 ] ) ; const B = parseInt ( arg [ 1 ] . split ( " " ) [ 0 ] ) ; const C = parseInt ( arg [ 2 ] . split ( " " ) [ 0 ] ) ; const D = parseInt ( arg [ 3 ] . split ( " " ) [ 0 ] ) ; const E = parseInt ( arg [ 4 ] . split ( " " ) [ 0 ] ) ; const list = [ A , B , C , D , E ] ; let last = Infinity ; let lastIdx = - 1 ; for ( let i = 0 ; i < 5 ; i + + ) { let temp = list [ i ] % 10 ; if ( temp ! = = 0 ) { if ( last > temp ) { lastIdx = i ; last = temp ; } } } let answer = 0 ; for ( let i = 0 ; i < 5 ; i + + ) { let temp = list [ i ] % 10 ; if ( i = = = lastIdx ) { answer + = list [ i ] ; } else { if ( temp ! = = 0 ) { answer + = list [ i ] + ( 10 - temp ) ; } else { answer + = list [ i ] ; } } } console . log ( answer ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' ; ( function ( stdin ) { var inputs = stdin . toString ( ) . trim ( ) . split ( ' \ n ' ) ; ( function ( x ) { console . log ( Math . pow ( x , 3 ) ) ; } ) ( parseInt ( inputs [ 0 ] , 10 ) ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; " use strict " ; main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . replace ( / \ r ? \ n $ / , " " ) . split ( / \ r ? \ n / ) ) ; function main ( lines ) { lines . some ( function ( line ) { if ( line = = " 0 " ) return true ; console . log ( line . split ( " " ) . reduce ( function ( a , b ) { return a + + b ; } , 0 ) ) ; } ) ; } function main ( input ) { let args = input . split ( ' \ n ' ) ; let x = 0 ; let [ a , v ] = args [ x + + ] . split ( ' ' ) ; let [ b , w ] = args [ x + + ] . split ( ' ' ) ; let t = BigInt ( args [ x + + ] ) ; let maxA = BigInt ( a ) + BigInt ( v ) * t ; let maxB = BigInt ( b ) + BigInt ( w ) * t ; let minA = BigInt ( a ) - BigInt ( v ) * t ; let minB = BigInt ( b ) - BigInt ( w ) * t ; if ( maxA < maxB | | minA > minB ) { console . log ( ' NO ' ) ; } else { console . log ( ' YES ' ) ; } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var output ; var input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) . split ( " \ n " ) ; var obj = { " list " : input , " index " : 0 , " max " : input . length , " next " : function ( ) { if ( ! this . hasNext ( ) ) { return null ; } var returnObj = this . list [ this . index ] ; this . index + + ; return returnObj ; } , " hasNext " : function ( ) { return ( this . index < this . max ) ; } } Main ( ) ; function next ( ) { return obj . next ( ) ; } function hasNext ( ) { return obj . hasNext ( ) ; } function myout ( t ) { console . log ( t ) ; } function myerr ( t ) { console . error ( t ) ; } function myconv ( i , no ) { try { switch ( no ) { case 1 : return parseInt ( i ) ; case 2 : return i . split ( " " ) ; case 4 : return i . split ( " " ) . map ( ( a ) = > Number ( a ) ) ; case 6 : return i . split ( " " ) ; case 7 : return i . split ( " " ) . map ( ( a ) = > Number ( a ) ) ; case 8 : return i . join ( " " ) ; case 9 : return i . join ( " \ n " ) ; case 0 : return i . join ( " " ) ; default : return i ; } } catch ( e ) { return " error " ; } } function Main ( ) { var N = myconv ( next ( ) , 1 ) ; var list = myconv ( next ( ) , 4 ) ; var output = 0 ; var last = 0 ; for ( var i = 0 ; i < N ; i + + ) { if ( i = = 0 ) { output + + ; last = list [ i ] ; } else { if ( last > list [ i ] ) { output + + ; last = list [ i ] ; } } } myout ( output ) ; } ' use strict ' function Main ( input ) { let line = input . split ( ' ' ) . map ( x = > Number ( x ) ) ; line . sort ( ) ; let answer = 0 ; answer = Math . abs ( line [ 1 ] - line [ 0 ] ) + Math . abs ( line [ 2 ] - line [ 1 ] ) ; console . log ( answer ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; if ( input [ input . length - 1 ] = = = " " ) { input . pop ( ) ; } var min = 10 ; var total = 0 ; for ( var i = 0 ; i < input . length ; i + + ) { var r = input [ i ] % 10 ; if ( r > 0 & & r < min ) { min = r ; } total + = ( Math . ceil ( input [ i ] / 10 ) * 10 ) ; } if ( min < 10 ) { total = total - 10 + min ; } console . log ( total ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " ; function Main ( input ) { var x = parseInt ( input ) ; console . log ( x * x * x ) ; } function debug ( ) { var input = document . getElementById ( ' input ' ) . value ; Main ( input ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var arr = ( input . trim ( ) ) . split ( " \ n " ) ; while ( true ) { var nm = arr . shift ( ) ; if ( nm = = " 0 0 " ) break ; nm = nm . split ( " " ) . map ( Number ) ; var n = nm [ 0 ] ; var m = nm [ 1 ] ; var ary = [ ] ; for ( var i = 0 ; i < = n ; i + + ) ary [ i ] = true ; var i = 1 ; var j = 0 ; var cnt = 0 ; while ( true ) { if ( ary [ i ] ) { j + + ; if ( j = = m ) { ary [ i ] = false ; j = 0 ; cnt + + ; if ( cnt = = ary . length - 2 ) break ; } } i + + ; if ( ary . length - 1 < i ) i = 1 ; } for ( var i = 1 ; i < = n ; i + + ) { if ( ary [ i ] ) console . log ( i ) ; } } ' use strict ' let input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ; input = input . trim ( ) . split ( ' \ n ' ) . map ( x = > x * 1 ) ; let ans = " Yay ! " ; let amount = input . pop ( ) ; for ( let i = 0 ; i < input . length ; i + + ) { for ( let j = 0 ; j < input . length ; j + + ) { if ( i = = j ) { continue } else if ( Math . abs ( input [ i ] - input [ j ] ) > amount ) { ans = " : ( " ; break ; } ; } } console . log ( ans ) ; ( function ( a ) { console . log ( a [ 0 ] * a [ 1 ] * a [ 2 ] = = 175 ? ' YES ' : ' NO ' ) } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . split ( ' ' ) ) ) ; process . stdin . on ( ' data ' , function ( chunk ) { var inputs = chunk . toString ( ) ; var x = Number ( inputs ) ; console . log ( Math . pow ( x , 3 ) ) ; } ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; ' use strict ' function main ( input ) { input = input . trim ( ) . split ( ' ' ) . map ( v = > Number ( v ) ) const k = input [ 0 ] const s = input [ 1 ] let count = 0 for ( let xi = 0 ; xi < = k ; xi = ( xi + 1 ) | 0 ) { for ( let yi = 0 ; yi < = k ; yi = ( yi + 1 ) | 0 ) { const tmp = s - ( xi + yi ) if ( tmp > = 0 & & tmp < = k ) count + + } } console . log ( count ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' ) ; var x = parseInt ( input ) ; console . log ( Math . pow ( x , 3 ) ) process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { const input = Number ( chunk ) ; console . log ( input * input * input ) ; } ) ; ' use strict ' ; function Main ( stdin ) { const input = stdin . trim ( ) . split ( / \ r ? \ n / g ) ; const A _ V = input [ 0 ] . split ( ' ' ) . map ( str = > BigInt ( str ) ) ; const A = A _ V [ 0 ] , V = A _ V [ 1 ] ; const B _ W = input [ 1 ] . split ( ' ' ) . map ( str = > BigInt ( str ) ) ; const B = B _ W [ 0 ] , W = B _ W [ 1 ] ; const T = BigInt ( input [ 2 ] ) ; let result = ' NO ' ; let kyori ; const tidimu = V - W ; if ( tidimu > 0 ) { if ( A > 0 & & B < 0 ) { kyori = A + BigInt ( String ( B ) . slice ( 1 ) ) ; } else if ( A < 0 & & B > 0 ) { kyori = B + BigInt ( String ( A ) . slice ( 1 ) ) ; } else { kyori = A - B ; if ( kyori < 0 ) kyori = BigInt ( String ( kyori ) . slice ( 1 ) ) ; } if ( tidimu * T > = kyori ) result = ' YES ' ; } console . log ( result ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function longAngle ( m ) { return m * 6 } function shortAngle ( h , m ) { return 30 * ( h + m / 60 ) } function cosTheo ( a , b , A ) { return Math . sqrt ( Math . abs ( a * a + b * b - 2 * Math . cos ( A ) * a * b ) ) } function main ( input ) { const inputs = input . split ( ' ' ) const a = Number ( inputs [ 0 ] ) const b = Number ( inputs [ 1 ] ) const h = Number ( inputs [ 2 ] ) const m = Number ( inputs [ 3 ] ) let angle = ( Math . abs ( longAngle ( m ) - shortAngle ( h , m ) ) ) * Math . PI / 180 let rad = Math . PI * 2 * ( h / 12.0 + ( m / 60.0 ) / 12.0 - m / 60.0 ) console . log ( cosTheo ( a , b , angle ) ) } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { const formatted _ input = input . split ( ' \ n ' ) . map ( x = > parseInt ( x ) ) ; var tmp _ minimum = 0 ; var result = 0 ; for ( var i = 0 ; i < 5 ; i + + ) { result + = ( formatted _ input [ i ] - formatted _ input [ i ] % 10 ) if ( formatted _ input [ i ] % 10 = = 0 ) { } else { if ( tmp _ minimum = = 0 ) { tmp _ minimum = formatted _ input [ i ] % 10 } else { result + = 10 ; tmp _ minimum = Math . min ( tmp _ minimum , formatted _ input [ i ] % 10 ) } } } result + = tmp _ minimum ; console . log ( result ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( input ) { const ary = input . split ( ' ' ) . sort ( ) . map ( n = > parseInt ( n , 10 ) ) ; console . log ( Math . abs ( ary [ 0 ] - ary [ 1 ] ) + Math . abs ( ary [ 1 ] - ary [ 2 ] ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' function main ( input ) { const n = Number ( input ) let ans = 0 let tmpmax = 0 if ( n = = 1 ) { console . log ( 1 ) return } for ( let i = 1 ; i < = n ; i + + ) { if ( i % 2 > 0 ) { continue } else { let j = i let cnt = 0 while ( j % 2 = = 0 ) { cnt + + j = j / 2 } if ( tmpmax < cnt ) { tmpmax = cnt ans = i } } } console . log ( ans ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . setEncoding ( ' utf-8 ' ) ; process . stdin . on ( ' data ' , function ( data ) { console . log ( data * data * data ) ; } ) ; ' use strict ' ; ( function ( stdin ) { var inputs = stdin . toString ( ) . trim ( ) . split ( ' \ n ' ) ; ( function ( x ) { console . log ( x * x * x ) ; } ) ( parseInt ( inputs [ 0 ] , 10 ) ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; " use strict " ; const main = arg = > { let K = arg . split ( " " ) [ 0 ] ; let S = arg . split ( " " ) [ 1 ] ; let cnt = 0 ; for ( let x = 0 ; x < = K ; x + + ) { for ( let y = 0 ; y < = K ; y + + ) { let z = S - ( x + y ) ; if ( ( z < = K ) & & ( z > = 0 ) ) { cnt + + ; } } } console . log ( cnt ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' ; var x = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; console . log ( Math . pow ( x , 3 ) ) ; function Main ( input ) { input = input . split ( " \ n " ) A = Number ( input [ 0 ] ) B = Number ( input [ 1 ] ) C = Number ( input [ 2 ] ) D = Number ( input [ 3 ] ) E = Number ( input [ 4 ] ) list _ 1 = [ ] list _ 1 . push ( Number ( String ( A ) . split ( " " ) . slice ( - 1 ) [ 0 ] ) = = = 0 ? 10 : Number ( String ( A ) . split ( " " ) . slice ( - 1 ) [ 0 ] ) ) list _ 1 . push ( Number ( String ( B ) . split ( " " ) . slice ( - 1 ) [ 0 ] ) = = = 0 ? 10 : Number ( String ( B ) . split ( " " ) . slice ( - 1 ) [ 0 ] ) ) list _ 1 . push ( Number ( String ( C ) . split ( " " ) . slice ( - 1 ) [ 0 ] ) = = = 0 ? 10 : Number ( String ( C ) . split ( " " ) . slice ( - 1 ) [ 0 ] ) ) list _ 1 . push ( Number ( String ( D ) . split ( " " ) . slice ( - 1 ) [ 0 ] ) = = = 0 ? 10 : Number ( String ( D ) . split ( " " ) . slice ( - 1 ) [ 0 ] ) ) list _ 1 . push ( Number ( String ( E ) . split ( " " ) . slice ( - 1 ) [ 0 ] ) = = = 0 ? 10 : Number ( String ( E ) . split ( " " ) . slice ( - 1 ) [ 0 ] ) ) min _ index = list _ 1 . indexOf ( Math . min ( ... list _ 1 ) ) Num _ list = [ A , B , C , D , E ] ans = 0 for ( var i = 0 ; i < 5 ; i + + ) { if ( i ! = = min _ index ) { ans + = Math . ceil ( Num _ list [ i ] / 10 ) * 10 } } ans + = Num _ list [ min _ index ] console . log ( ans ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { const data = input . split ( " \ n " ) . map ( ( val ) = > parseInt ( val , 10 ) ) ; const k = data [ 5 ] ; var result = " Yay ! " ; for ( var i = 0 ; i < 4 ; i + + ) { if ( k < data [ 4 ] - data [ i ] ) { result = " : ( " ; } } console . log ( result ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var ab = input . split ( " " ) ; ab [ 0 ] = parseInt ( ab [ 0 ] ) ; ab [ 0 ] = parseInt ( ab [ 0 ] ) ; if ( ab [ 0 ] = = 1 ) { ab [ 0 ] = 14 ; } if ( ab [ 1 ] = = 1 ) { ab [ 1 ] = 14 ; } if ( ab [ 0 ] > ab [ 1 ] ) { process . stdout . write ( " Alice " ) ; } else if ( ab [ 0 ] < ab [ 1 ] ) { process . stdout . write ( " Bob " ) ; } else { process . stdout . write ( " Draw " ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { " use strict " const temp = input . split ( " \ n " ) ; const n = parseInt ( temp . shift ( ) ) ; const positions = temp . shift ( ) . split ( " " ) . map ( x = > parseInt ( x ) ) ; let minVariance = Infinity for ( let i = 1 ; i < = 100 ; i + + ) { const variance = positions . map ( x = > ( x - i ) * ( x - i ) ) . reduce ( ( a , b ) = > a + b ) minVariance = Math . min ( minVariance , variance ) } console . log ( minVariance ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function cube ( input ) { var x = parseInt ( input ) ; console . log ( x * x * x ) ; } input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) cube ( input ) inp = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . split ( ' \ n ' ) [ 0 ] . split ( ' ' ) A = inp . shift ( ) * 1 B = inp . shift ( ) * 1 C = inp . shift ( ) * 1 D = inp . shift ( ) * 1 console . log ( A * B > C * D ? A * B : C * D ) process . stdin . resume ( ) process . stdin . setEncoding ( ' utf8 ' ) process . stdin . on ( ' data ' , function ( chunk ) { console . log ( Math . pow ( chunk , 3 ) ) } ) ' use strict ' const main = input = > { const args = input . split ( ' \ n ' ) . map ( arg = > arg . split ( ' ' ) ) const N = parseInt ( args [ 0 ] [ 0 ] , 10 ) const K = parseInt ( args [ 0 ] [ 1 ] , 10 ) console . log ( N % K ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) function main ( s ) { s = s . split ( " " ) ; var a , b ; a = parseInt ( s [ 0 ] ) ; b = parseInt ( s [ 1 ] ) ; console . log ( Math . round ( ( a + b ) / 2 ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { var array = input . trim ( ) . split ( " \ n " ) ; array = array . map ( val = > parseInt ( val , 10 ) ) ; var amount = 0 ; var longestWaitTime = 0 ; for ( var i = 0 ; i < array . length ; i + + ) { var ceil = Math . ceil ( array [ i ] / 10 ) * 10 ; amount + = ceil ; longestWaitTime = ceil - array [ i ] > longestWaitTime ? ceil - array [ i ] : longestWaitTime ; } console . log ( amount - longestWaitTime ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; inp = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . trim ( ) . split ( ' \ n ' ) in p = inp . shift ( ) . split ( " " ) . map ( ( x ) = > + x ) A = inp . shift ( ) B = inp . shift ( ) H = inp . shift ( ) M = inp . shift ( ) p = 10e10 h = H / 12 * 360 + M / 60 * 360 / 12 h = h * ( Math . PI / 180 ) m = M / 60 * 360 m = m * ( Math . PI / 180 ) t = function ( n ) { return Math . round ( n * p ) / p } ax = A * t ( Math . cos ( h ) ) ay = A * t ( Math . sin ( h ) ) bx = B * t ( Math . cos ( m ) ) by = B * t ( Math . sin ( m ) ) c = Math . sqrt ( ( ax - bx ) * ( ax - bx ) + ( ay - by ) * ( ay - by ) ) console . log ( c ) function Main ( input ) { input = parseInt ( input . trim ( ) ) ; var output = 1 ; var maxCount = 0 ; for ( var i = 1 ; i < = input ; i + + ) { var tmp = i ; var count = 0 ; while ( tmp % 2 ! = 1 ) { tmp = tmp / 2 ; count + + ; } if ( maxCount < count ) { output = i ; maxCount = count ; } } console . log ( output ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; const rl = require ( " readline " ) . createInterface ( process . stdin , process . stdout ) ; rl . once ( " line " , function ( str ) { var c = Math . pow ( str , 3 ) ; console . log ( c ) ; process . exit ( ) ; } ) ; function Main ( input ) { input = input . split ( " \ n " ) ; var line = input [ 0 ] . split ( " " ) ; var K = parseInt ( line [ 0 ] ) ; var S = parseInt ( line [ 1 ] ) ; var roop = Math . min ( K , S ) ; var ans = 0 ; for ( var A = 0 ; A < = roop ; A + + ) { if ( S - K - A > = 0 & & 2 * K - S + A + 1 > 0 ) { ans + = 2 * K - S + A + 1 ; } else if ( S - K - A < 0 & & S - A + 1 > 0 ) { ans + = S - A + 1 ; } } console . log ( ans ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var num = Number ( input ) ; console . log ( num * num ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' function main ( input ) { input = input . trim ( ) . split ( ' \ n ' ) const distance = input . pop ( ) in put = input . map ( ( val , index ) = > { let result = true for ( let i = index ; i < input . length ; i + + ) { if ( result ) { result = input [ i ] - val < = distance } } return result } ) console . log ( input . filter ( result = > result = = = false ) . length = = = 0 ? ' Yay ! ' : ' : ( ' ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { var N = parseInt ( input [ 0 ] . split ( / \ s / ) [ 0 ] , 10 ) ; var D = parseInt ( input [ 0 ] . split ( / \ s / ) [ 1 ] , 10 ) ; var X = input . slice ( 1 ) . map ( x = > { return x . split ( / \ s / ) . map ( num = > parseInt ( num , 10 ) ) ; } ) ; var result = 0 ; for ( var i = 0 ; i < N - 1 ; i + + ) { for ( var j = i + 1 ; j < N ; j + + ) { var dist = 0 ; var distSum = 0 ; for ( var d = 0 ; d < D ; d + + ) { distSum + = Math . pow ( ( X [ j ] [ d ] - X [ i ] [ d ] ) , 2 ) ; } dist = Math . sqrt ( distSum ) ; if ( Number . isInteger ( dist ) ) { result + + ; } } } console . log ( result ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) . split ( / \ n / ) ) ; const inputNumbers = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . split ( / \ s / ) . map ( Number ) ; const ret = Math . ceil ( ( inputNumbers [ 0 ] + inputNumbers [ 1 ] ) / 2 ) ; console . log ( ret ) ; function Main ( input ) { input = input . split ( " \ n " ) ; var a = parseInt ( input [ 0 ] , 10 ) ; console . log ( ' % d ' , a * a ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { input = input . trim ( ) ; const [ a , b ] = input . split ( " " ) . map ( Number ) ; if ( a > b ) { if ( b = = 1 ) { console . log ( " Bob " ) ; } else { console . log ( " Alice " ) ; } } else if ( a < b ) { if ( a = = 1 ) { console . log ( " Alice " ) ; } else { console . log ( " Bob " ) ; } } else { console . log ( " Draw " ) ; } } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Vector ( x , y ) { this . x = x ; this . y = y ; } Vector . prototype . sub = function ( v ) { return new Vector ( this . x - v . x , this . y - v . y ) ; } ; Vector . prototype . product = function ( v ) { return this . x * v . y - this . y * v . x ; } ; ( function ( input ) { var line = input . replace ( / \ n $ / , ' ' ) . split ( ' \ n ' ) ; while ( line . length > 0 ) { var p = line . shift ( ) . split ( ' ' ) . map ( Number ) ; var v1 = new Vector ( p . shift ( ) , p . shift ( ) ) ; var v2 = new Vector ( p . shift ( ) , p . shift ( ) ) ; var v3 = new Vector ( p . shift ( ) , p . shift ( ) ) ; var p = new Vector ( p . shift ( ) , p . shift ( ) ) ; var v12 = v2 . sub ( v1 ) ; var v2p = p . sub ( v2 ) ; var v23 = v3 . sub ( v2 ) ; var v3p = p . sub ( v3 ) ; var v31 = v1 . sub ( v3 ) ; var v1p = p . sub ( v1 ) ; var c1 = v12 . product ( v2p ) ; var c2 = v23 . product ( v3p ) ; var c3 = v31 . product ( v1p ) ; if ( ( c1 > 0 & & c2 > 0 & & c3 > 0 ) | | ( c1 < 0 & & c2 < 0 & & c3 < 0 ) ) { console . log ( ' YES ' ) ; continue ; } console . log ( ' NO ' ) ; } } ) ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { var inputList = input . split ( " " ) ; var x = 0 ; var y = 0 ; for ( i = 0 ; i < inputList . length ; i + + ) { inputList [ i ] = parseInt ( inputList [ i ] , 10 ) ; } for ( i = 0 ; i < inputList . length ; i + + ) { if ( inputList [ i ] = = = 5 ) { x = x + 1 ; } else if ( inputList [ i ] = = = 7 ) { y = y + 1 ; } } if ( x = = = 2 & & y = = = 1 ) { console . log ( " YES " ) ; } else { console . log ( " NO " ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; inp = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . split ( ' \ n ' ) arr = inp . shift ( ) . split ( ' ' ) . map ( a = > a * 1 ) . sort ( ( a , b ) = > a - b ) console . log ( arr [ 2 ] - arr [ 0 ] ) var input = ' ' ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { input + = chunk ; var match = input . match ( / ^ ( \ d + ) \ n / ) ; if ( match ) { var num = match [ 1 ] ; console . log ( num * num * num ) ; } } ) ; " use strict " ; const main = arg = > { const input = arg . trim ( ) . split ( " \ n " ) ; const x = parseInt ( input [ 0 ] ) ; for ( let a = - 120 ; a < = 120 ; a + + ) { for ( let b = - 120 ; b < = 120 ; b + + ) { let tmp = a * a * a * a * a - b * b * b * b * b if ( x = = = tmp ) { console . log ( ` $ { a } $ { b } ` ) return } } } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( input ) { input = input . trim ( ) . split ( " " ) ; var r = parseInt ( input [ 0 ] , 10 ) ; console . log ( r * r ) } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var stdin = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var x = Number ( stdin ) ; console . log ( x * x * x ) ; " use strict " process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( data ) { var x = Number ( data ) ; console . log ( x * x * x ) ; } ) ; ' use strict ' function Main ( input ) { const arr = input . split ( " " ) ; let count5 = 0 , count7 = 0 ; for ( const a of arr ) { if ( a = = 5 ) { count5 + + ; } else if ( a = = 7 ) { count7 + + ; } } ; console . log ( count5 = = = 2 & & count7 = = = 1 ? ' YES ' : ' NO ' ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; const main = ( input ) = > { input = input . trim ( ) . split ( " \ n " ) ; var p = input . filter ( ( v , i ) = > i < 5 ) ; var k = input [ 5 ] ; var ans = true ; for ( var i = 0 ; i < = 4 ; i + + ) { for ( var j = i + 1 ; j < = 4 ; j + + ) { if ( Math . abs ( p [ i ] - p [ j ] ) > k ) ans = false ; } } console . log ( ans ? " Yay ! " : " : ( " ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' UTF-8 ' ) ) ; function main ( input ) { input = input . trim ( ) ; const a = parseInt ( input . split ( " " ) [ 0 ] , 10 ) ; const b = parseInt ( input . split ( " " ) [ 1 ] , 10 ) ; c = a + b ; if ( c % 2 = = 1 ) { console . log ( Math . floor ( ( a + b ) / 2 ) + 1 ) } else { console . log ( c / 2 ) ; } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( input ) { const nums = input . split ( " " ) ; var count5 = 0 , count7 = 0 ; nums . forEach ( num = > { if ( num = = 5 ) { count5 + = 1 ; } if ( num = = 7 ) { count7 + = 1 ; } } ) console . log ( count5 = = 2 & & count7 = = 1 ? " YES " : " NO " ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function f ( x , y , z ) { return Math . abs ( y - x ) + Math . abs ( y - z ) ; } function main ( input ) { input = input . split ( ' ' ) . map ( Number ) ; a = input [ 0 ] , b = input [ 1 ] , c = input [ 2 ] , d = 1000001 ; if ( f ( a , b , c ) < d ) d = f ( a , b , c ) ; if ( f ( a , c , b ) < d ) d = f ( a , c , b ) ; if ( f ( b , a , c ) < d ) d = f ( b , a , c ) ; if ( f ( b , c , a ) < d ) d = f ( b , c , a ) ; if ( f ( c , a , b ) < d ) d = f ( c , a , b ) ; if ( f ( c , b , a ) < d ) d = f ( c , b , a ) ; console . log ( d ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { var numbers = chunk . toString ( ) . split ( " " ) ; var S = parseInt ( numbers . pop ( ) ) , K = parseInt ( numbers . pop ( ) ) ; var c = 0 ; for ( var X = 0 ; X < = K ; X + + ) for ( var Y = 0 ; Y < = K ; Y + + ) { var Z = S - X - Y ; if ( Z > = 0 & & Z < = K ) { c + + ; } } process . stdout . write ( c . toString ( ) ) ; process . exit ( ) ; } ) ; ' use strict ' ; function Main ( input ) { const tmp = input . split ( " \ n " ) [ 0 ] . split ( " " ) ; const one = tmp [ 0 ] * tmp [ 1 ] ; const two = tmp [ 2 ] * tmp [ 3 ] ; if ( one < two ) { console . log ( two ) ; } else { console . log ( one ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " function main ( arg ) { let [ H1 , M1 , H2 , M2 , K ] = arg . trim ( ) . split ( " \ n " ) [ 0 ] . split ( " " ) . map ( Number ) let H1x = H1 * 60 + M1 let H2x = H2 * 60 + M2 console . log ( H2x - H1x - K ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; " use strict " ; function main ( arg ) { arg = arg . split ( " \ n " ) [ 0 ] . split ( " " ) . map ( n = > parseInt ( n ) ) ; console . log ( Math . ceil ( ( arg [ 0 ] + arg [ 1 ] ) / 2 ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( s ) { n = Number ( s . split ( " \ n " ) [ 0 ] ) ; console . log ( n < 2 ? 1 : n < 4 ? 2 : n < 8 ? 4 : n < 16 ? 8 : n < 32 ? 16 : n < 64 ? 32 : 64 ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " ; const main = arg = > { arg = arg . trim ( ) . split ( " \ n " ) ; const c = arg . map ( n = > n . split ( " " ) . map ( l = > parseInt ( l ) ) ) ; for ( let a1 = 0 ; a1 < = 100 ; a1 + + ) { const b1 = c [ 0 ] [ 0 ] - a1 ; const b2 = c [ 1 ] [ 0 ] - a1 ; const b3 = c [ 2 ] [ 0 ] - a1 ; for ( let a2 = 0 ; a2 < = 100 ; a2 + + ) { if ( a2 + b1 ! = = c [ 0 ] [ 1 ] ) continue ; if ( a2 + b2 ! = = c [ 1 ] [ 1 ] ) continue ; if ( a2 + b3 ! = = c [ 2 ] [ 1 ] ) continue ; for ( let a3 = 0 ; a3 < = 100 ; a3 + + ) { if ( a3 + b1 ! = = c [ 0 ] [ 2 ] ) continue ; if ( a3 + b2 ! = = c [ 1 ] [ 2 ] ) continue ; if ( a3 + b3 ! = = c [ 2 ] [ 2 ] ) continue ; console . log ( " Yes " ) ; return ; } } } console . log ( " No " ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var stdin = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var inputs = stdin . toString ( ) . trim ( ) ; var x = parseInt ( inputs , 10 ) ; console . log ( x * x * x ) ; function Main ( input ) { input = input . split ( " " ) ; one = false ; nana = false ; nine = false ; four = false ; for ( i = 0 ; i < 4 ; i + + ) { if ( Number ( input [ i ] ) = = = 1 ) one = true ; if ( parseInt ( input [ i ] ) = = 7 ) nana = true ; if ( parseInt ( input [ i ] ) = = 4 ) four = true ; if ( Number ( input [ i ] ) = = 9 ) nine = true ; } if ( one & & nana & & nine & & four ) { console . log ( ' YES ' ) } else { console . log ( ' NO ' ) } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var antena = input . slice ( 0 , 5 ) . map ( i = > parseInt ( i , 10 ) ) ; var K = parseInt ( input [ 5 ] , 10 ) ; var result = ' Yay ! ' ; for ( var i = 1 ; i < antena . length ; i + + ) { for ( var j = 0 ; j < i ; j + + ) { if ( ( antena [ i ] - antena [ j ] ) > K ) { result = ' : ( ' ; } } } console . log ( result ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) . split ( / \ n | \ s / ) ) ; function Main ( input ) { var inputs = input . split ( " / " ) ; for ( i = 0 ; i < = 2 ; i + + ) { inputs [ i ] = parseInt ( inputs [ i ] , 10 ) ; } if ( inputs [ 0 ] < = 2019 ) { if ( inputs [ 1 ] < = 4 ) { if ( inputs [ 2 ] < = 30 ) { console . log ( " Heisei " ) } else { console . log ( " TBD " ) ; } } else { console . log ( " TBD " ) ; } } else { console . log ( " TBD " ) ; } } Main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var arr = input . trim ( ) . split ( " \ n " ) ; var n = arr . shift ( ) - 0 ; var a = arr . shift ( ) . split ( " " ) . map ( Number ) ; var q = arr . shift ( ) - 0 ; var s = " " ; for ( var i = 0 ; i < q ; i + + ) { var [ c , b , e ] = arr [ i ] . split ( " " ) . map ( Number ) ; var m = a [ b ] ; if ( c = = 0 ) { for ( var j = b ; j < e ; j + + ) m = Math . min ( m , a [ j ] ) ; } else { for ( var j = b ; j < e ; j + + ) m = Math . max ( m , a [ j ] ) ; } s + = m + " \ n " ; } console . log ( s . trim ( ) ) ; " use strict " ; process . stdin . resume ( ) ; process . stdin . setEncoding ( " utf8 " ) ; var reader = require ( " readline " ) . createInterface ( { input : process . stdin , output : process . stdout } ) ; reader . on ( " line " , line = > { let arr = [ 1 , 4 , 7 , 9 ] ; let n = line . split ( / \ s / ) . map ( x = > parseInt ( x ) ) . sort ( ( a , b ) = > a - b ) ; let ans = true ; for ( let i = 0 ; i < arr . length ; i + + ) { if ( arr [ i ] ! = n [ i ] ) { ans = false ; break ; } } if ( ans ) console . log ( " YES " ) ; else console . log ( " NO " ) ; } ) ; " use strict " ; process . stdin . resume ( ) ; process . stdin . setEncoding ( " utf8 " ) ; var lines = [ ] ; var reader = require ( " readline " ) . createInterface ( { input : process . stdin , output : process . stdout } ) ; reader . on ( " line " , line = > { lines . push ( line . split ( / \ s / ) . map ( x = > parseInt ( x ) ) ) ; } ) ; reader . on ( " close " , ( ) = > { let n = lines . shift ( ) ; let a = lines . shift ( ) ; let b = lines . shift ( ) ; let aSum = a . reduce ( ( a , i ) = > a + i ) ; let bSum = b . reduce ( ( a , i ) = > a + i ) ; if ( aSum < bSum ) { console . log ( - 1 ) ; return ; } let count = 0 ; let positiveArr = [ ] ; let positiveSum = 0 ; let negativeSum = 0 ; let index = 0 ; for ( let i = 0 ; i < n ; i + + ) { let tmp = a [ i ] - b [ i ] ; if ( tmp > 0 ) positiveArr . push ( tmp ) ; else if ( tmp < 0 ) { count + = 1 ; negativeSum + = tmp ; } } positiveArr . sort ( ( a , b ) = > b - a ) ; while ( positiveSum + negativeSum < 0 ) { positiveSum + = positiveArr [ index ] ; index + + ; } console . log ( count + index ) ; } ) ; function Main ( input ) { var A = parseInt ( input [ 0 ] , 10 ) ; var B = parseInt ( input [ 1 ] , 10 ) ; var sum = A + B ; console . log ( sum % 2 = = = 0 ? sum / 2 : sum / 2 + 0.5 ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) . split ( / \ n | \ s / ) ) ; var stdin = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var inputs = stdin . toString ( ) . trim ( ) ; var x = parseInt ( inputs , 10 ) ; console . log ( Math . pow ( x , 3 ) ) ; " use strict " ; function Main ( input ) { const params = input . split ( " " ) . map ( Number ) ; const K = params [ 0 ] ; const S = params [ 1 ] ; let count = 0 ; for ( let x = 0 ; x < = K ; x + + ) { for ( let y = 0 ; y < = K ; y + + ) { const z = S - ( x + y ) ; if ( 0 < = z & & z < = K ) { count + + ; } } } console . log ( count ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . trim ( ) ; if ( input > " 2019 / 04 / 30 " ) { console . log ( " TBD " ) ; } else { console . log ( " Heisei " ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var lines = [ ] ; var readline = require ( ' readline ' ) ; var rl = readline . createInterface ( { input : process . stdin , output : process . stdout , } ) ; rl . on ( ' line ' , function ( x ) { lines . push ( x ) ; } ) ; rl . on ( ' close ' , function ( ) { var A = Number ( lines [ 0 ] . split ( " " ) [ 0 ] ) ; var B = Number ( lines [ 0 ] . split ( " " ) [ 1 ] ) ; var C = Number ( lines [ 0 ] . split ( " " ) [ 2 ] ) ; if ( A + B > = C ) { console . log ( " Yes " ) } else { console . log ( " No " ) } } ) ; config = { input : ' / dev / stdin ' , newline : ' \ n ' } ; n = Number ( require ( ' fs ' ) . readFileSync ( config . input , ' ascii ' ) ) ; console . log ( n * n * n ) ; ' use strict ' function main ( s ) { const nums = s . split ( ' \ n ' ) [ 0 ] . split ( ' ' ) . map ( n = > Number ( n ) ) ; const ans = Math . max ( ... nums ) - Math . min ( ... nums ) ; console . log ( ans ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { function compareFunc ( a , b ) { return a - b ; } input = input . trim ( ) . split ( ' ' ) ; input . sort ( compareFunc ) ; a = input [ 1 ] - input [ 0 ] ; b = input [ 2 ] - input [ 1 ] ; ans = a + b ; console . log ( ans ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { console . log ( Math . pow ( chunk , 3 ) ) ; } ) ; ' use strict ' ; ( function ( stdin ) { var inputs = stdin . toString ( ) ; var x = inputs . trim ( ) . split ( ' \ n ' ) . map ( Number ) [ 0 ] ; console . log ( Math . pow ( x , 3 ) ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; function Main ( input ) { var tmp = input . split ( ' \ n ' ) [ 0 ] var A = parseInt ( tmp . split ( ' ' ) [ 0 ] ) ; var V = parseInt ( tmp . split ( ' ' ) [ 1 ] ) ; tmp = input . split ( ' \ n ' ) [ 1 ] var B = parseInt ( tmp . split ( ' ' ) [ 0 ] ) ; var W = parseInt ( tmp . split ( ' ' ) [ 1 ] ) ; var T = parseInt ( input . split ( ' \ n ' ) [ 2 ] ) ; var D = A - B ; if ( D < 0 ) { D = - D ; } if ( ( D + W * T ) < = V * T ) { console . log ( ' YES ' ) ; } else { console . log ( ' NO ' ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { var x = parseInt ( chunk . trim ( ) , 10 ) ; console . log ( Math . pow ( x , 3 ) ) ; } ) ; var Main = input = > { input = input . split ( " \ n " ) ; tmp1 = input [ 0 ] . split ( " " ) ; var N = parseInt ( tmp1 [ 0 ] , 10 ) ; var D = parseInt ( tmp1 [ 1 ] , 10 ) ; var X = [ ] ; for ( var i = 0 ; i < N ; i + + ) { X [ i ] = input [ i + 1 ] . split ( " " ) ; } var count = 0 ; for ( var i = 0 ; i < N ; i + + ) { for ( var j = 0 ; j < N ; j + + ) { if ( i = = = j ) { break ; } else { var diff = [ ] ; var value = 0 ; for ( var k = 0 ; k < D ; k + + ) { diff [ k ] = Math . pow ( X [ i ] [ k ] - X [ j ] [ k ] , 2 ) ; } value = Math . sqrt ( diff . reduce ( ( total , data ) = > { return total + data } ) ) ; if ( Number . isInteger ( value ) ) { count + + ; } } } } console . log ( count ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " ; function main ( arg ) { const coins = arg . split ( " \ n " ) [ 0 ] . split ( " " ) . map ( n = > parseInt ( n ) ) ; console . log ( coins [ 0 ] + coins [ 1 ] > = coins [ 2 ] ? " Yes " : " No " ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' ; ( function ( stdin ) { var inputs = stdin . toString ( ) ; ( function ( x ) { console . log ( Math . pow ( x , 3 ) ) ; } ( parseInt ( inputs . trim ( ) , 10 ) ) ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; function Main ( input ) { var array = input . trim ( ) . split ( " \ n " ) ; array = array . map ( val = > parseInt ( val , 10 ) ) ; var waitTimeAry = [ ] ; var amount = 0 ; var ceilArray = [ ] ; for ( var i = 0 ; i < array . length ; i + + ) { var ceil = Math . ceil ( array [ i ] / 10 ) * 10 ; waitTimeAry . push ( ceil - array [ i ] ) ; ceilArray . push ( ceil ) ; } var maxWait = Math . max ( ... waitTimeAry ) ; var index = waitTimeAry . indexOf ( maxWait ) ; ceilArray . splice ( index , 1 ) ; ceilArray . splice ( ceilArray . length , 0 , array [ index ] ) ; for ( var j = 0 ; j < ceilArray . length ; j + + ) { amount + = ceilArray [ j ] ; } console . log ( amount ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var patternOne = " 5 7 5 " ; var patternTwo = " 5 5 7 " ; var patternThree = " 7 5 5 " ; input = input . split ( " " ) ; var fiveNum = 0 ; var sevenNum = 0 ; for ( var i = 0 ; i < input . length ; i + + ) { if ( Number ( input [ i ] ) = = = 5 ) { fiveNum + + ; } else if ( Number ( input [ i ] ) = = = 7 ) { sevenNum + + ; } } if ( fiveNum = = = 2 & & sevenNum = = = 1 ) { console . log ( " YES " ) ; } else { console . log ( " NO " ) } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' ; ( function ( stdin ) { var inputs = stdin . toString ( ) ; ( function ( x ) { console . log ( Math . pow ( x , 3 ) ) ; } ( parseInt ( inputs . trim ( ) , 10 ) ) ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; " use strict " ; const main = arg = > { const N = arg . split ( " \ n " ) [ 0 ] ; let list = [ 1 , 2 , 4 , 8 , 16 , 32 , 64 ] ; console . log ( Math . max ( ... list . filter ( n = > n < = N ) ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( arg ) { var N = arg . split ( " \ n " ) [ 0 ] - 0 ; var P = arg . split ( " \ n " ) [ 1 ] . split ( " " ) . map ( v = > v - 0 ) ; var max = N ; var ans = 0 ; for ( var i = 0 ; i < N ; i + + ) { if ( max > = P [ i ] ) { ans + + ; max = P [ i ] ; } } console . log ( ans ) ; return ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ; var numbers = input . split ( ' ' ) ; var sum = 0 ; numbers . forEach ( function ( number ) { sum + = Number ( number ) ; } ) ; console . log ( Math . ceil ( sum / numbers . length ) ) ; function sum _ arr ( arr ) { return arr . reduce ( function ( prev , current , i , arr ) { return prev + current ; } ) ; } ; function main ( arg ) { arg = arg . split ( " \ n " ) var N = arg [ 0 ] . split ( " " ) [ 0 ] var A = arg [ 1 ] . split ( " " ) . map ( e = > Number ( e ) ) var B = arg [ 2 ] . split ( " " ) . map ( e = > Number ( e ) ) var diffs = [ ] var diff _ m = 0 var counter = 0 for ( var i = 0 ; i < A . length ; i + + ) { var tmp = A [ i ] - B [ i ] if ( tmp < 0 ) { diff _ m + = tmp counter + + } else { diffs . push ( tmp ) } } if ( diff _ m > = 0 ) { console . log ( 0 ) return } diffs . sort ( ( a , b ) = > b - a ) for ( var i = 0 ; i < diffs . length ; i + + ) { diff _ m + = diffs [ i ] counter + + if ( diff _ m > 0 ) { break } } if ( diff _ m < = 0 ) { console . log ( - 1 ) return ; } console . log ( counter ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( input ) { var arr = [ ] var input = input . split ( " " ) var result = 0 in put . forEach ( function ( element ) { arr . push ( parseInt ( element , 10 ) ) } ) delete input arr . sort ( function ( a , b ) { if ( a > b ) { return 1 } else { return - 1 } } ) for ( var i = 1 ; i < arr . length ; i + + ) { result + = arr [ i ] - arr [ i - 1 ] } console . log ( result ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var x = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; console . log ( Math . pow ( x , 3 ) ) ; var input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ; input = input . split ( " \ n " ) ; var x = ( + input . shift ( ) ) ; console . log ( x * x * x ) ; ' use strict ' ; ( function ( stdin ) { var inputs = stdin . toString ( ) . trim ( ) ; console . log ( Math . pow ( inputs , 3 ) ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; function Main ( input ) { tmp = input . split ( " " ) ; var a = parseInt ( tmp [ 0 ] , 10 ) ; var b = parseInt ( tmp [ 1 ] , 10 ) ; var c = parseInt ( tmp [ 2 ] , 10 ) ; var bool = false ; var ans = " NO " ; if ( a = = = 7 & & b = = = 5 & & c = = = 5 ) { bool = true ; } else if ( a = = = 5 & & b = = = 7 & & c = = = 5 ) { bool = true ; } else if ( a = = = 5 & & b = = = 5 & & c = = = 7 ) { bool = true ; } if ( bool ) { ans = " YES " ; } console . log ( ans ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( f ) { console . log ( f * f * f ) ; } ) ; function main ( input ) { console . log ( input * input ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( input ) { var A = parseInt ( input . split ( " " ) [ 0 ] , 10 ) ; var B = parseInt ( input . split ( " " ) [ 1 ] , 10 ) ; var H = parseInt ( input . split ( " " ) [ 2 ] , 10 ) ; var M = parseInt ( input . split ( " " ) [ 3 ] , 10 ) ; rad _ H = ( ( 360 / 12 ) * H + ( ( 360 / 12 ) / 60 ) * M ) * ( Math . PI / 180 ) ; rad _ M = ( 360 / 60 ) * M * ( Math . PI / 180 ) ; console . log ( Math . sqrt ( ( A * A ) + ( B * B ) - 2 * A * B * Math . cos ( rad _ H - rad _ M ) ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { var tmp = input . split ( " \ n " ) ; var a = [ ] ; for ( var i = 0 ; i < 5 ; i + + ) { a . push ( parseInt ( tmp [ i ] ) ) ; } var k = parseInt ( tmp [ 5 ] ) ; var max = Math . max ( ... a ) ; var min = Math . min ( ... a ) ; if ( max - min > k ) { console . log ( " : ( " ) } else { console . log ( " Yay ! " ) } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var stdin = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var inputs = stdin . toString ( ) . trim ( ) ; var x = parseInt ( inputs , 10 ) ; console . log ( x * x * x ) ; function Main ( input ) { var x = parseInt ( input ) ; x = x * x * x ; console . log ( x ) ; } function debug ( ) { var input = document . getElementById ( " input " ) . value ; Main ( input ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var args = input . split ( " \ n " ) . filter ( f = > ! ! f ) ; var times = args . map ( t = > parseInt ( t ) ) ; var timeMods = times . map ( t = > ( t - 1 ) % 10 ) ; var timeSep = times . map ( t = > Math . ceil ( t / 10 ) * 10 ) ; var min = null ; var minDef ; var sum = 0 ; for ( var i = 0 ; i < timeMods . length ; i + + ) { if ( min = = = null | | timeMods [ i ] < min ) { min = timeMods [ i ] ; minDef = times [ i ] - timeSep [ i ] ; } sum + = timeSep [ i ] ; } console . log ( ( sum + minDef ) ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var ans = 0 ; var map = { } ; input [ 1 ] . split ( " " ) . forEach ( v = > { if ( ! map [ v ] ) ans + + ; map [ v ] = true ; } ) ; console . log ( ans = = 3 ? " Three " : " Four " ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . split ( " \ n " ) ) ; " use strict " ; function main ( input ) { let arr = input . trim ( ) . split ( ' ' ) . sort ( ) ; if ( arr [ 0 ] = = 5 & & arr [ 1 ] = = 5 & & arr [ 2 ] = = 7 ) console . log ( " YES " ) ; else console . log ( " NO " ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) lines = input . split ( ' \ n ' ) S = lines . shift ( ) console . log ( new Date ( S ) < new Date ( ' 2019 / 05 / 01 ' ) ? ' Heisei ' : ' TBD ' ) " use strict " ; const input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . split ( " \ n " ) ; const X = parseInt ( input [ 0 ] ) ; let i = 0 ; const resultStockList = [ ] ; while ( true ) { const result = Math . pow ( i , 5 ) ; resultStockList . push ( result ) ; for ( let j = 0 ; j < resultStockList . length ; j + + ) { if ( result - resultStockList [ j ] = = = X | | resultStockList [ j ] - result = = = X ) { console . log ( ` $ { i } $ { j } ` ) ; return ; } if ( result + resultStockList [ j ] = = = X ) { console . log ( ` $ { i } $ { - j } ` ) ; return ; } } i + + ; } function Main ( input ) { var str = input ; var ans = " " ; var str = str . split ( " \ n " ) ; var num1 = str [ 0 ] . split ( " " ) ; var num2 = str [ 1 ] . split ( " " ) ; var num3 = str [ 2 ] . split ( " " ) ; var a = Number ( num1 [ 0 ] ) ; var v = Number ( num1 [ 1 ] ) ; var b = Number ( num2 [ 0 ] ) ; var w = Number ( num2 [ 1 ] ) ; var t = Number ( num3 [ 0 ] ) ; var k = Math . abs ( b - a ) ; if ( v > w ) { var m = v - w ; if ( t > = k / m ) { ans = " YES " ; } else { ans = " NO " ; } } else { ans = " NO " ; } console . log ( ans ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = parseInt ( input ) ; let x = input ; let y = Math . floor ( input / 2 ) ; let arr = { } ; for ( let i = y ; i < = x ; i + + ) { let B = yakusu ( i ) ; arr [ i ] = B ; } var keys = [ ] ; for ( var key in arr ) keys . push ( key ) ; function Compare ( a , b ) { return arr [ a ] - arr [ b ] ; } keys . sort ( Compare ) ; console . log ( parseInt ( keys [ keys . length - 1 ] ) ) ; } function yakusu ( num ) { let result = 0 ; while ( num > 0 ) { if ( num % 2 = = = 0 ) { result + + ; num = num / 2 ; } else { break ; } } return result ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " ; function main ( input ) { input = input . trim ( ) . split ( " " ) ; const H = parseInt ( input [ 2 ] ) - parseInt ( input [ 0 ] ) ; const M = parseInt ( input [ 3 ] ) - parseInt ( input [ 1 ] ) ; let minute = H * 60 ; minute = minute + M - parseInt ( input [ 4 ] ) ; console . log ( minute ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf-8 " ) ) ; ' use strict ' const main = ( input ) = > { const items = input . split ( ' \ n ' ) [ 1 ] . split ( ' ' ) const itemSet = new Set ( items ) if ( itemSet . size = = = 4 ) { console . log ( ' Four ' ) } else { console . log ( ' Three ' ) } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf-8 ' ) ) ' use strict ' const main = ( ) = > { let arr2 = [ ] ; const arr = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ; const a = arr . split ( " \ n " ) ; const k = a [ 5 ] ; arr2 . push ( Math . abs ( a [ 0 ] - a [ 1 ] ) ) ; arr2 . push ( Math . abs ( a [ 0 ] - a [ 2 ] ) ) ; arr2 . push ( Math . abs ( a [ 0 ] - a [ 3 ] ) ) ; arr2 . push ( Math . abs ( a [ 0 ] - a [ 4 ] ) ) ; arr2 . push ( Math . abs ( a [ 1 ] - a [ 2 ] ) ) ; arr2 . push ( Math . abs ( a [ 1 ] - a [ 3 ] ) ) ; arr2 . push ( Math . abs ( a [ 1 ] - a [ 4 ] ) ) ; arr2 . push ( Math . abs ( a [ 2 ] - a [ 3 ] ) ) ; arr2 . push ( Math . abs ( a [ 2 ] - a [ 3 ] ) ) ; arr2 . push ( Math . abs ( a [ 3 ] - a [ 4 ] ) ) ; let c ; arr2 . map ( ( val ) = > { if ( val > k ) { c = 0 ; } } ) ; if ( c = = 0 ) { console . log ( " : ( " ) ; } else { console . log ( " Yay ! " ) ; } } ; main ( ) ; function myout ( text ) { console . log ( text ) ; } function Main ( input ) { input = input . trim ( ) ; input = input . trim ( ) . split ( " \ n " ) ; var s = input [ 0 ] ; var N = parseInt ( input [ 1 ] ) ; var sList = new Array ( s . length ) ; var conv = " abcdefghijklmnopqrstuvwxyz " . split ( " " ) ; var convList = { } ; for ( var i = 0 ; i < conv . length ; i + + ) { convList [ conv [ i ] ] = i ; } for ( var i = 0 ; i < s . length ; i + + ) { sList [ i ] = convList [ s . slice ( i , i + 1 ) ] ; } for ( var i = 0 ; i < s . length ; i + + ) { if ( sList [ i ] = = 0 & & i ! = s . length - 1 ) { continue ; } if ( i = = s . length - 1 ) { sList [ i ] = ( sList [ i ] + N ) % 26 ; continue ; } if ( N = = 0 ) { break ; } else if ( N < ( 26 - sList [ i ] ) ) { continue ; } else { var add = 26 - sList [ i ] ; sList [ i ] = ( sList [ i ] + add ) % 26 ; N - = add ; } } var output = " " ; for ( var i = 0 ; i < s . length ; i + + ) { output + = conv [ sList [ i ] ] ; } myout ( output ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var A = parseInt ( input . split ( " " ) [ 0 ] , 10 ) ; var B = parseInt ( input . split ( " " ) [ 1 ] , 10 ) ; if ( A > = 13 ) { console . log ( B ) ; } else if ( A > = 6 & & A < = 12 ) { console . log ( B / 2 ) ; } else { console . log ( 0 ) ; } } Main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( input ) { var inputs = input . split ( " " ) . map ( x = > parseInt ( x , 10 ) ) ; var a = inputs [ 0 ] ; var b = inputs [ 1 ] ; var c = inputs [ 2 ] ; console . log ( a + b > = c ? " Yes " : " No " ) } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' function main ( s ) { s = s . split ( ' \ n ' ) [ 0 ] . split ( ' ' ) ; const a = Number ( s [ 0 ] ) ; const b = Number ( s [ 1 ] ) ; const c = Number ( s [ 2 ] ) ; const ans = ( ( a + b ) > = c ) ? ' Yes ' : ' No ' ; console . log ( ans ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ( stdin = > { const identity = v = > v const always = v = > _ = > v const join = sep = > array = > array . join ( sep ) const split = sep = > str = > str . split ( sep ) const print = fun = > ( f , v ) = > fun ( f ( v ) ) const power = m = > n = > Math . pow ( n , m ) const inputs = stdin . toString ( ) . trim ( ) . split ( ' \ n ' ) const n = parseInt ( inputs [ 0 ] , 10 ) const result = power ( 3 ) ( n ) const display = print ( console . log ) display ( identity , result ) } ) ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) function Main ( input ) { var lines = input . split ( " \ n " ) . filter ( v = > v ! = = ' ' ) var body = lines . slice ( 1 ) var n = + lines . slice ( 0 , 1 ) var poss = body . map ( s = > s . split ( ' ' ) . map ( v = > + v ) ) var cache = { } var sum = 0 var diff = ( x1 , y1 , x2 , y2 ) = > { var v = Math . sqrt ( ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) ) return v } var f = ( past _ poss , use _ poss ) = > { if ( use _ poss . length = = 0 ) { var d = 0 ; for ( var i = 1 ; i < past _ poss . length ; i + + ) { var x = + past _ poss [ i - 1 ] [ 0 ] var y = + past _ poss [ i - 1 ] [ 1 ] var _ x = + past _ poss [ i ] [ 0 ] var _ y = + past _ poss [ i ] [ 1 ] sum + = diff ( x , y , _ x , _ y ) } return } use _ poss . forEach ( _ pos = > { f ( [ ... past _ poss , _ pos ] , use _ poss . filter ( _ _ pos = > _ _ pos . toString ( ) ! = _ pos . toString ( ) ) ) } ) } poss . forEach ( _ pos = > { f ( [ _ pos ] , poss . filter ( _ _ pos = > _ _ pos . toString ( ) ! = _ pos . toString ( ) ) ) } ) var b = 1 for ( ; n > 0 ; n -- ) { b * = n } console . log ( sum / b ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var x = input . trim ( ) - 0 ; console . log ( x * x * x ) ; function Main ( input ) { var arr = input . split ( " " ) . map ( x = > parseInt ( x , 10 ) ) ; var a = Math . max . apply ( null , arr ) ; var b = Math . min . apply ( null , arr ) ; console . log ( a - b ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { const lines = input . split ( / \ n / ) ; console . log ( Number ( lines [ 4 ] ) - Number ( lines [ 0 ] ) < = Number ( lines [ 5 ] ) ? ' Yay ! ' : ' : ( ' ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( " utf8 " ) ; process . stdin . on ( " data " , function ( chunk ) { var datas = chunk . trim ( ) . split ( " \ n " ) ; for ( var i = 0 ; i < datas . length ; i + + ) { var ab = datas [ i ] . trim ( ) . split ( " " ) ; var a = parseInt ( ab [ 0 ] ) ; var b = parseInt ( ab [ 1 ] ) ; console . log ( a + b ) ; } } ) ; const BKRT = " \ n " ; const SPAC = " " ; const NOSP = " " ; function Main ( input ) { input = [ ] . concat ( ... input . split ( BKRT ) . map ( a = > a . split ( SPAC ) ) ) ; const strShift = ( ) = > input . shift ( ) ; const intShift = ( ) = > ~ ~ input . shift ( ) ; return intShift ( ) + intShift ( ) > = intShift ( ) ? " Yes " : " No " ; } ( ( b , c , d ) = > " undefined " ! = typeof require ? console . log ( Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ) : [ b = b . split ( " \ n " ) . slice ( 1 , - 1 ) . join ( " \ n " ) , c = function ( ) { try { return Main ( b ) } catch ( f ) { return f . stack | | f . message } } ( ) , d = typeof c , " string " = = d | | ( c = JSON . stringify ( c ) ) , $ ( " < form > " ) . append ( [ [ 10 , b ] , 0 , [ 1 , d ] , 0 , [ 10 , c ] ] . map ( f = > $ ( f ? " < textarea > " : " < br > " , f & & { rows : f [ 0 ] , cols : 40 , text : f [ 1 ] } ) ) ) . appendTo ( " body " ) ] ) ( ` ` ) ; " use strict " ; const main = arg = > { arg = arg . trim ( ) . split ( " \ n " ) ; const N = parseInt ( arg [ 0 ] . split ( " " ) [ 0 ] ) ; const bonus = Math . floor ( N / 15 ) * 200 ; const x = ( N * 800 ) ; console . log ( x - bonus ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; " use strict " ; const main = arg = > { arg = arg . trim ( ) . split ( " \ n " ) ; const N = parseInt ( arg [ 0 ] . split ( " " ) [ 0 ] ) ; const M = parseInt ( arg [ 0 ] . split ( " " ) [ 1 ] ) ; const PY = arg . slice ( 1 , M + 1 ) . map ( n = > n . split ( " " ) . map ( l = > parseInt ( l ) ) ) ; const list = [ ] ; for ( let i in PY ) { let map = { p : PY [ i ] [ 0 ] , y : PY [ i ] [ 1 ] , originIdx : i } ; list . push ( map ) ; } list . sort ( ( a , b ) = > ( a . p - b . p ) | | ( a . y - b . y ) ) ; const addZero = n = > { const zeros = [ ] ; for ( let i = 0 ; i < 6 - String ( n ) . length ; i + + ) { zeros . push ( " 0 " ) ; } return zeros . join ( " " ) + String ( n ) ; } let temp = [ ] ; let oldness = 1 ; for ( let i in list ) { if ( list [ i - 1 ] & & list [ i - 1 ] . p ! = = list [ i ] . p ) { oldness = 1 ; } let first = addZero ( list [ i ] . p ) ; let last = addZero ( oldness ) ; let map = { id : first + last , originIdx : list [ i ] . originIdx } temp . push ( map ) ; oldness + + ; } temp . sort ( ( a , b ) = > a . originIdx - b . originIdx ) ; let answer = [ ] ; for ( let i in temp ) { answer . push ( temp [ i ] . id ) ; } console . log ( answer . join ( " \ n " ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' const main = ( input ) = > { input = input . split ( ' \ n ' ) . map ( i = > Number ( i ) ) const k = input [ input . length - 2 ] const array = input . slice ( 0 , 5 ) const max = Math . max ( ... array ) const min = Math . min ( ... array ) if ( max - min < = k ) { console . log ( ' Yay ! ' ) } else { console . log ( ' : ( ' ) } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf-8 ' ) ) function main ( input ) { input = input . split ( " " ) ; console . log ( ' % d ' , Math . max ( input [ 0 ] * input [ 1 ] , input [ 2 ] * input [ 3 ] ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' UTF-8 ' ) ) ; function main ( s ) { var n = parseInt ( s ) ; console . log ( n * 800 - Math . floor ( n / 15 ) * 200 ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( input ) { input = input . trim ( ) ; const N = parseInt ( input . split ( " " ) [ 0 ] , 10 ) ; console . log ( 800 * N - Math . floor ( ( N / 15 ) ) * 200 ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' ; const main = input = > { const n = parseInt ( input [ 0 ] . split ( ' ' ) [ 0 ] ) , m = parseInt ( input [ 0 ] . split ( ' ' ) [ 1 ] ) ; input . shift ( ) ; let py = new Array ( m ) ; for ( let i = 0 ; i < m ; i + + ) { py [ i ] = new Array ( 4 ) . fill ( 0 ) ; input [ i ] = input [ i ] . split ( ' ' ) . map ( val = > parseInt ( val , 10 ) ) ; py [ i ] = [ input [ i ] [ 0 ] , input [ i ] [ 1 ] , i , 0 ] ; } py . sort ( ( a , b ) = > b [ 0 ] - a [ 0 ] > 0 ? - 1 : a [ 0 ] - b [ 0 ] > 0 ? 1 : b [ 1 ] - a [ 1 ] > 0 ? - 1 : a [ 1 ] - b [ 1 ] > 0 ? 1 : 0 ) ; let count = 1 ; for ( let i = 0 ; i < m - 1 ; i + + ) { py [ i ] [ 3 ] = count ; if ( py [ i ] [ 0 ] = = py [ i + 1 ] [ 0 ] ) { count + + ; } else { count = 1 ; } } py [ m - 1 ] [ 3 ] = count ; py . sort ( ( a , b ) = > b [ 2 ] - a [ 2 ] > 0 ? - 1 : a [ 2 ] - b [ 2 ] > 0 ? 1 : 0 ) ; for ( let i = 0 ; i < m ; i + + ) { console . log ( ( " 000000 " + py [ i ] [ 0 ] ) . slice ( - 6 ) + ( " 000000 " + py [ i ] [ 3 ] ) . slice ( - 6 ) ) ; } } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . split ( ' \ n ' ) ) ; ( function Main ( input ) { var input = input . split ( ' \ n ' ) , X = input [ 1 ] . split ( ' ' ) . map ( Number ) , len = X . length , result = 0 , avg = function ( data ) { var sum = 0 ; for ( var i = 0 ; i < len ; i + + ) { sum + = data [ i ] ; } return Math . round ( sum / len ) ; } ( X ) ; for ( var i = 0 ; i < len ; i + + ) { result + = Math . pow ( X [ i ] - avg , 2 ) ; } console . log ( result ) ; } ) ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; for ( t in l = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . split ( " \ n " ) , c = { 0 : { } , 1 : { } } , l [ 1 ] . split ( " " ) . forEach ( ( s , e ) = > { t = c [ 1 & e ] , t [ s ] = t [ s ] ? t [ s ] + 1 : 1 } ) , s = { } , c ) s [ t ] = Object . keys ( c [ t ] ) . sort ( ( s , e ) = > c [ t ] [ e ] - c [ t ] [ s ] ) ; g = ( ( t , e ) = > s [ t ] [ e ] ? c [ t ] [ s [ t ] [ e ] ] : 0 ) , s [ 0 ] [ 0 ] ! = s [ 1 ] [ 0 ] & & ( s [ 1 ] [ 1 ] = s [ 1 ] [ 0 ] ) , console . log ( l [ 0 ] - Math . max ( g ( 0 , 0 ) + g ( 1 , 1 ) , g ( 0 , 1 ) + g ( 1 , 0 ) ) ) ; ' use strict ' function Main ( input ) { const arr = input . split ( " " ) ; let count5 = 0 , count7 = 0 ; arr . forEach ( a = > { if ( a = = 5 ) { count5 + + ; } else if ( a = = 7 ) { count7 + + ; } } ) ; console . log ( count5 = = = 2 & & count7 = = = 1 ? ' YES ' : ' NO ' ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { console . log ( Math . pow ( chunk , 3 ) ) ; } ) ; function main ( input ) { console . log ( input * input * input ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' function main ( inp ) { let ans = inp . split ( ' ? ' ) . join ( ' D ' ) ; console . log ( ans ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function C168 ( _ input ) { var lines = _ input . split ( " \ n " ) ; var [ a , b , H , M ] = lines . shift ( ) . split ( ' ' ) . map ( v = > v * 1 ) ; var min = ( H * 60 + M ) ; const radA = ( min * 0.5 ) * ( Math . PI / 180 ) ; const radB = ( M * 6 ) * ( Math . PI / 180 ) ; var posA = { x : Math . cos ( radA ) * a , y : Math . sin ( radA ) * a } ; var posB = { x : Math . cos ( radB ) * b , y : Math . sin ( radB ) * b } ; const x = ( posB . x - posA . x ) * ( posB . x - posA . x ) ; const y = ( posB . y - posA . y ) * ( posB . y - posA . y ) ; console . log ( Math . sqrt ( x + y ) ) ; } C168 ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var stdin = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ; stdin = stdin . trim ( ) . split ( " \ n " ) . reverse ( ) ; function input ( ) { return stdin . pop ( ) } var stdout = [ ] ; s = input ( ) . split ( " / " ) if ( parseInt ( s [ 1 ] , 10 ) < 5 ) { stdout . push ( " Heisei " ) } else { stdout . push ( " TBD " ) } stdout = stdout . join ( " " ) ; console . log ( stdout ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { console . log ( Math . pow ( chunk , 3 ) ) ; } ) ; function main ( input ) { input = input . trim ( ) ; const a = parseInt ( input . split ( " " ) [ 0 ] , 10 ) ; const b = parseInt ( input . split ( " " ) [ 1 ] , 10 ) ; const c = parseInt ( input . split ( " " ) [ 2 ] , 10 ) ; const d = parseInt ( input . split ( " " ) [ 3 ] , 10 ) ; console . log ( Math . max . apply ( null , [ a * b , c * d ] ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; inp = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . split ( ' \ n ' ) [ 0 ] . split ( ' ' ) A = inp . shift ( ) * 1 B = inp . shift ( ) * 1 if ( A = = B ) { ans = ' Draw ' } else { if ( A = = 1 ) { ans = ' Alice ' } else if ( B = = 1 ) { ans = ' Bob ' } else if ( A > B ) { ans = ' Alice ' } else { ans = ' Bob ' } } console . log ( ans ) ' use strict ' function main ( input ) { input = input . trim ( ) . split ( ' ' ) . map ( v = > Number ( v ) ) const k = input [ 0 ] const s = input [ 1 ] let count = 0 for ( let xi = 0 ; xi < = k ; xi + + ) { for ( let yi = 0 ; yi < = k ; yi + + ) { const tmp = s - ( xi + yi ) if ( tmp > = 0 & & tmp < = k ) count + + } } console . log ( count ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) lines = input . split ( ' \ n ' ) a = lines . shift ( ) * 1 b = lines . shift ( ) * 1 c = lines . shift ( ) * 1 d = lines . shift ( ) * 1 e = lines . shift ( ) * 1 k = lines . shift ( ) * 1 console . log ( e - a < = k ? ' Yay ! ' : ' : ( ' ) function Main ( input ) { input = input . split ( " \ n " ) ; var tmp = input [ 0 ] . split ( " " ) ; var N = parseInt ( tmp [ 0 ] , 10 ) ; var M = parseInt ( tmp [ 1 ] , 10 ) ; var inputArray = getInputArray ( input , N , M ) ; sortEachCol ( inputArray ) ; setCode2InputArray ( inputArray ) ; sortEachColIndex ( inputArray ) ; for ( var i = 0 ; i < inputArray . length ; i + + ) { console . log ( zeroPaddingSixDigit ( inputArray [ i ] . p ) + zeroPaddingSixDigit ( inputArray [ i ] . code ) ) ; } } function setCode2InputArray ( inputArraySorted ) { var indexArray = new Array ( inputArraySorted . length ) ; inputArraySorted . forEach ( function ( element ) { var p = element . p ; indexArray [ p ] = indexArray [ p ] = = = undefined ? 0 : indexArray [ p ] + 1 ; element . code = indexArray [ p ] + 1 ; } ) ; } function sortEachCol ( inputArray ) { inputArray . sort ( function ( a , b ) { return a . value - b . value ; } ) ; } function sortEachColIndex ( inputArray ) { inputArray . sort ( function ( a , b ) { return a . index - b . index ; } ) ; } function getInputArray ( input , N , M ) { var inputArray = [ ] ; for ( var i = 0 ; i < M ; i + + ) { var tmp = input [ i + 1 ] . split ( " " ) ; if ( tmp . length ! = = 2 ) { continue ; } var p = parseInt ( tmp [ 0 ] , 10 ) ; var value = parseInt ( tmp [ 1 ] , 10 ) ; inputArray . push ( { index : i , value : value , p : p } ) ; } return inputArray ; } function zeroPaddingSixDigit ( num ) { return ( ' 000000 ' + num ) . slice ( - 6 ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var N = Number ( input ) ; if ( N = = 1 ) { var record = [ 1 , 0 ] ; } else { var record = [ 0 , 0 ] ; } for ( var i = 1 ; i < = N ; i + + ) { var count = 0 ; count = check ( i , count ) ; if ( record [ 1 ] < count ) { record = [ i , count ] ; } } function check ( i , t ) { if ( i % 2 = = 0 ) { + + t ; return check ( i / 2 , t ) ; } else { return t ; } } console . log ( record [ 0 ] ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var x = parseInt ( input ) ; console . log ( x * x * x ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function length _ plus ( moji ) { moji = String ( moji ) ; while ( moji . length < 6 ) { moji = " 0 " + moji ; } return ( moji ) ; } function Main ( input ) { input = input . split ( " \ n " ) ; tmp1 = input [ 0 ] . split ( " " ) ; N = parseInt ( tmp1 [ 0 ] ) ; M = parseInt ( tmp1 [ 1 ] ) ; var hairetu = [ ] ; for ( i = 1 ; i < M + 1 ; i + + ) { i _ nojyoho = input [ i ] . split ( " " ) hairetu . push ( { kuni : parseInt ( i _ nojyoho [ 0 ] ) , shi : i , nen : parseInt ( i _ nojyoho [ 1 ] ) } ) ; } hairetu . sort ( function ( a , b ) { if ( a . kuni < b . kuni ) return - 1 ; if ( a . kuni > b . kuni ) return 1 ; if ( a . nen < b . nen ) return - 1 ; if ( a . nen > b . nen ) return 1 ; return 0 ; } ) ; for ( i = 0 ; i < hairetu . length ; i + + ) { if ( i = = = 0 | | hairetu [ i ] . kuni ! = = hairetu [ i - 1 ] . kuni ) { hairetu [ i ] . jyun = 1 ; } else { hairetu [ i ] . jyun = hairetu [ i - 1 ] . jyun + 1 ; } } for ( i = 0 ; i < hairetu . length ; i + + ) { bangou = length _ plus ( hairetu [ i ] . kuni ) + length _ plus ( hairetu [ i ] . jyun ) ; hairetu [ i ] . bangou = bangou ; } hairetu . sort ( function ( a , b ) { if ( a . shi < b . shi ) return - 1 ; if ( a . shi > b . shi ) return 1 ; return 0 ; } ) ; for ( i = 0 ; i < hairetu . length ; i + + ) { console . log ( hairetu [ i ] . bangou ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . split ( / \ s / g ) ; var a = input [ 0 ] - 0 ; var b = input [ 1 ] - 0 ; var c = input [ 2 ] - 0 ; var d = input [ 3 ] - 0 ; var x = a * b ; var y = c * d ; console . log ( Math . max ( x , y ) ) ; function Main ( s ) { s = s . split ( " " ) . map ( a = > parseInt ( a ) ) ; console . log ( s [ 0 ] + s [ 1 ] > = s [ 2 ] ? " Yes " : " No " ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) ) ; ' use strict ' ; process . stdin . on ( ' data ' , function ( chunk ) { var inputs = chunk . toString ( ) ; var x = Number ( inputs ) ; console . log ( Math . pow ( x , 3 ) ) ; } ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; console . log ( Math . pow ( input , 3 ) ) ; function Main ( input ) { var five = ( input . match ( / 5 / g ) | | [ ] ) . length ; var seven = ( input . match ( / 7 / g ) | | [ ] ) . length ; ( five = = 2 & & seven = = 1 ) ? console . log ( " YES " ) : console . log ( " NO " ) ; } var character = " " ; process . stdin . on ( ' data ' , function ( char ) { character + = char } ) ; process . stdin . on ( ' end ' , function ( ) { Main ( character ) ; } ) ; process . on ( ' SIGINT ' , function ( ) { Main ( character ) ; process . exit ( 0 ) ; } ) ; " use strict " ; ( inp = > { inp = inp . split ( " " ) ; console . log ( Math . ceil ( ( + inp [ 0 ] + + inp [ 1 ] ) / 2 ) ) ; } ) ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { var n = parseInt ( input [ 0 ] ) ; var a = input [ 1 ] . split ( ' ' ) . map ( s = > parseInt ( s ) ) ; var b = input [ 2 ] . split ( ' ' ) . map ( s = > parseInt ( s ) ) ; if ( a . reduce ( ( n , sum ) = > n + sum , 0 ) < b . reduce ( ( n , sum ) = > n + sum , 0 ) ) { console . log ( - 1 ) ; return ; } var count = 0 ; var diff = 0 ; var arr = [ ] ; for ( var i = 0 ; i < n ; i + + ) { if ( a [ i ] < b [ i ] ) { count + + ; diff + = b [ i ] - a [ i ] ; arr . push ( 0 ) ; } else { arr . push ( a [ i ] - b [ i ] ) ; } } arr = arr . sort ( ( k , j ) = > j - k ) ; var aa = 0 ; var i = 0 ; while ( aa < diff ) { aa + = arr [ i + + ] ; count + + ; } console . log ( count ) ; } var input = ' ' ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { input + = chunk ; } ) ; process . stdin . on ( ' end ' , function ( ) { input = input . split ( ' \ n ' ) ; main ( input ) ; } ) ; " use strict " ; function I ( t , i ) { this . _ s = t . split ( " \ n " ) , this . _ c = 0 , this . _ l = 0 , this . _ f = i | | Number } I . prototype . a = function ( t ) { var i = this . _ s [ this . _ l ] ; if ( i ) { var s = i . trim ( ) . split ( " " ) , h = s [ this . _ c ] ; return this . _ c + + , s . length = = = this . _ c & & ( this . _ c = 0 , this . _ l + + ) , t ? t ( h ) : this . _ f ( h ) } } , I . prototype . l = function ( t ) { var i = this . _ s [ this . _ l ] ; if ( i ) return this . _ c = 0 , this . _ l + + , i . split ( " " ) . map ( t | | this . _ f ) } , module . exports = I ; function main ( input ) { var o = new I ( input ) ; var a = o . a ( ) ; var b = o . a ( ) ; if ( a > = 13 ) { console . log ( b ) ; } else if ( a < = 5 ) { console . log ( 0 ) ; } else { console . log ( b / 2 ) ; } } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " ; var input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ; var cin = input . split ( / | \ n / ) , cid = 0 ; function next ( ) { return + cin [ cid + + ] ; } function nextstr ( ) { return cin [ cid + + ] ; } function nextbig ( ) { return BigInt ( cin [ cid + + ] ) ; } function nexts ( n , a ) { return a ? cin . slice ( cid , cid + = n ) : cin . slice ( cid , cid + = n ) . map ( a = > + a ) ; } function nextsbig ( n ) { return cin . slice ( cid , cid + = n ) . map ( a = > BigInt ( a ) ) ; } function nextm ( h , w , a ) { var r = [ ] , i = 0 ; if ( a ) for ( ; i < h ; i + + ) r . push ( cin . slice ( cid , cid + = w ) ) ; else for ( ; i < h ; i + + ) r . push ( cin . slice ( cid , cid + = w ) . map ( a = > + a ) ) ; return r ; } function xArray ( v ) { var a = arguments , l = a . length , r = " Array ( a [ " + -- l + " ] ) .fill ( ) .map ( x = > { return " + v + " ; } ) " ; while ( -- l ) r = " Array ( a [ " + l + " ] ) .fill ( ) .map ( x = > " + r + " ) " ; return eval ( r ) ; } console . log ( main ( ) . toString ( ) ) ; function main ( ) { let n = next ( ) ; let i ; for ( i = 1 ; i * 2 < = n ; i = i * 2 ) { } return i } process . stdin . on ( ' data ' , function ( chunk ) { console . log ( Math . pow ( chunk , 3 ) ) ; } ) ; function main ( i ) { i = i . split ( ' \ n ' ) ; const a = [ ] ; f = i . map ( n = > { if ( Number ( n ) % 10 = = = 0 ) { return [ Number ( n ) , 10 ] ; } return [ Number ( n ) , Number ( n ) % 10 ] ; } ) ; f . sort ( ( a , b ) = > a [ 1 ] - b [ 1 ] ) ; var answer = 0 ; f . forEach ( ( item , index ) = > { if ( index = = = 0 ) { answer + = item [ 0 ] ; } else { answer + = Math . ceil ( item [ 0 ] / 10 ) * 10 ; } } ) ; console . log ( answer ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { var x = parseInt ( chunk ) ; console . log ( x * x * x ) ; } ) ; inp = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . split ( ' \ n ' ) l = inp . shift ( ) . split ( ' ' ) a = l [ 0 ] * 1 b = l [ 1 ] * 1 console . log ( Math . ceil ( ( a + b ) / 2 ) ) ' use strict ' function Main ( input ) { input = input . split ( " " ) ; const A = input [ 0 ] ; const B = input [ 1 ] ; let result = B ; if ( 6 < = A & & A < = 12 ) result = B / 2 ; else if ( A < = 5 ) result = 0 console . log ( result ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var ans = input * input ; console . log ( ans ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " ; function Main ( input ) { input = input . split ( " \ n " ) ; let n = Number ( input [ 0 ] ) ; let place _ array = input [ 1 ] . split ( " " ) . map ( Number ) ; let min = 0 ; for ( let cp = 0 ; cp < 100 ; cp + + ) { let tmp _ total = 0 ; for ( let i = 0 ; i < n ; i + + ) { tmp _ total + = Math . pow ( ( cp - place _ array [ i ] ) , 2 ) ; } if ( cp = = = 0 ) min = tmp _ total ; min = min < tmp _ total ? min : tmp _ total ; } console . log ( min ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; var tmp = input [ 1 ] . split ( " " ) ; var n = parseInt ( input [ 0 ] , 10 ) ; var ns = new Array ( n ) ; var min = 100000000 ; for ( var k = 0 ; k < = 100 ; k + + ) { var sum = 0 ; for ( var i = 0 ; i < n ; i + + ) { ns [ i ] = parseInt ( tmp [ i ] , 10 ) ; sum + = Math . pow ( ns [ i ] - k , 2 ) ; } if ( min > sum ) { min = sum ; } } console . log ( min ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; const input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) const lines = input . split ( ' \ n ' ) const [ A , B , H , M ] = lines [ 0 ] . split ( ' ' ) . map ( Number ) const radH = ( H * 30 + M / 2 ) * ( Math . PI / 180 ) const radM = M * 6 * ( Math . PI / 180 ) const posHX = Math . cos ( radH ) * A const posHY = Math . sin ( radH ) * A const posMX = Math . cos ( radM ) * B const posMY = Math . sin ( radM ) * B const dist = Math . sqrt ( Math . pow ( posHX - posMX , 2 ) + Math . pow ( posHY - posMY , 2 ) ) console . log ( dist ) function Main ( input ) { input = input . split ( " \ n " ) ; N = Number ( input [ 0 ] ) ; let An = input [ 1 ] . split ( " " ) . map ( Number ) ; if ( gcd ( An ) ! = = 1 ) { console . log ( " not coprime " ) ; return ; } let freq = Array ( 1000001 ) . fill ( 0 ) ; for ( let A of An ) { if ( A = = = 1 ) continue ; freq [ A ] + + ; if ( freq [ A ] > 1 ) { console . log ( " setwise coprime " ) ; return ; } } for ( let i = 2 ; i < = 1000001 ; i + + ) { let tmp = 0 ; for ( let j = i ; j < = 1000001 ; j + = i ) { tmp + = freq [ j ] ; if ( tmp > = 2 ) { console . log ( " setwise coprime " ) ; return ; } } } console . log ( " pairwise coprime " ) ; } function gcd ( arg ) { let f = ( a , b ) = > b ? f ( b , a % b ) : a let ans = arg [ 0 ] ; for ( let i = 1 ; i < arg . length ; i + + ) { ans = f ( ans , arg [ i ] ) ; } return ans ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( r ) { console . log ( r * r ) } Main ( require ( ' fs ' ) . readFileSync ( " / dev / stdin " , ' utf8 ' ) ) function setUp ( input ) { input = input . split ( " \ n " ) ; a = Number ( input [ 0 ] ) ; b = Number ( input [ 1 ] ) ; c = Number ( input [ 2 ] ) ; d = Number ( input [ 3 ] ) ; e = Number ( input [ 4 ] ) ; main ( ) ; } function main ( ) { var total = ceil ( a ) + ceil ( b ) + ceil ( c ) + ceil ( d ) + ceil ( e ) ; var firstArray = [ first ( a ) , first ( b ) , first ( c ) , first ( d ) , first ( e ) ] ; var minFirst ; debugger ; firstArray . forEach ( function ( d , i ) { if ( d ! = = 0 & & ( ! minFirst | | minFirst > d ) ) { minFirst = d ; } } ) ; if ( minFirst ) { total - = ( 10 - minFirst ) ; } console . log ( total ) ; } function ceil ( num ) { return Math . ceil ( num / 10 ) * 10 ; } function first ( num ) { var str = num . toString ( ) ; return Number ( str . substring ( str . length - 1 ) ) ; } setUp ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var x = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; console . log ( x * x * x ) ; function Main ( input ) { var str = input ; var tmp = str . split ( " \ n " ) ; var a = tmp [ 0 ] ; var b = tmp [ 1 ] ; var c = tmp [ 2 ] ; var d = tmp [ 3 ] ; var e = tmp [ 4 ] ; var a1 = parseInt ( a . slice ( - 1 ) , 10 ) ; var b1 = parseInt ( b . slice ( - 1 ) , 10 ) ; var c1 = parseInt ( c . slice ( - 1 ) , 10 ) ; var d1 = parseInt ( d . slice ( - 1 ) , 10 ) ; var e1 = parseInt ( e . slice ( - 1 ) , 10 ) ; var array = [ a1 , b1 , c1 , d1 , e1 ] ; for ( i = 0 ; i < 5 ; i + + ) { if ( array [ i ] = = 0 ) { array [ i ] = 10 ; } } var min _ index = array . indexOf ( Math . min . apply ( null , array ) ) ; var kekka = 0 ; for ( i = 0 ; i < 5 ; i + + ) { if ( i = = min _ index ) { tmp [ i ] = parseInt ( tmp [ i ] , 10 ) ; } else { tmp [ i ] = Math . ceil ( tmp [ i ] / 10 ) * 10 ; } } function sum ( a ) { return a . reduce ( function ( x , y ) { return x + y ; } ) ; } var kekka = sum ( tmp ) ; console . log ( kekka ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ( function ( ) { ' use strict ' ; var lines = [ ] ; require ( ' readline ' ) . createInterface ( { input : process . stdin , output : process . stdout } ) . on ( ' line ' , function ( line ) { lines . push ( line ) ; } ) ; process . stdin . on ( ' end ' , function ( ) { main ( lines ) ; } ) ; } ) ( ) ; String . prototype . replaceAt = function ( index , character ) { return this . substr ( 0 , index ) + character + this . substr ( index + character . length ) ; } function main ( lines ) { var input = lines [ 0 ] , numOps = lines [ 1 ] ; for ( var i = 0 ; i < input . length ; i + + ) { var distToA = ( 123 - input . charCodeAt ( i ) ) % 26 ; if ( numOps > = distToA ) { input = input . replaceAt ( i , ' a ' ) ; numOps - = distToA ; } if ( numOps = = = 0 ) { break ; } } numOps = numOps % 26 ; input = input . replaceAt ( input . length - 1 , String . fromCharCode ( input . charCodeAt ( input . length - 1 ) + numOps ) ) ; console . log ( input ) ; } " use strict " ; const main = input = > { const n = parseInt ( input [ 0 ] . split ( ' ' ) [ 0 ] ) , d = parseInt ( input [ 0 ] . split ( ' ' ) [ 1 ] ) ; let x = new Array ( ) ; for ( let i = 0 ; i < n ; i + + ) { x [ i ] = input [ i + 1 ] . split ( ' ' ) . map ( val = > parseInt ( val ) ) ; } let ans = 0 ; for ( let i = 0 ; i < n - 1 ; i + + ) { for ( let j = i + 1 ; j < n ; j + + ) { let value = 0 ; for ( let k = 0 ; k < d ; k + + ) { value + = Math . pow ( Math . abs ( x [ i ] [ k ] - x [ j ] [ k ] ) , 2 ) ; } value = Math . pow ( value , 0.5 ) ; if ( Number . isInteger ( value ) ) { ans + + ; } } } console . log ( ans ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . split ( ' \ n ' ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( " utf8 " ) ; const reader = require ( " readline " ) . createInterface ( { input : process . stdin , output : process . stdout , } ) ; let lines = [ ] ; reader . on ( " line " , ( line ) = > { lines . push ( line ) ; } ) ; reader . on ( " close " , ( ) = > { const x = Number ( lines [ 0 ] ) ; console . log ( Math . pow ( x , 3 ) ) } ) ; function Main ( input ) { input = input . split ( " \ n " ) ; tmp0 = input [ 0 ] . split ( " " ) ; tmp1 = input [ 1 ] . split ( " " ) ; var n = parseInt ( tmp0 [ 0 ] , 10 ) ; var X = [ ] ; for ( i = 0 ; i < n ; i + + ) { var r = parseInt ( tmp1 [ i ] , 10 ) ; X [ i ] = r ; } var min = Math . min ( ... X ) ; var max = Math . max ( ... X ) ; var XX = [ ] ; var total = 0 ; for ( l = min ; l < = max ; l + + ) { for ( i = 0 ; i < n ; i + + ) { var x = X [ i ] ; var a = x - l ; total = total + a * a ; } XX [ l ] = total ; var total = 0 ; } XX . splice ( 0 , min ) ; var ans = Math . min ( ... XX ) ; console . log ( ans ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( num ) { var paid = num * 800 ; var counter = 0 ; for ( num ; num > = 15 ; num - = 15 ) { counter + = 1 } var returned = ( counter * 200 ) ; console . log ( paid - returned ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; function Main ( input ) { var tmp = input . split ( " \ n " ) ; var N = Number ( tmp [ 0 ] ) ; var pos = 0 ; var pay = 0 ; for ( var i = 1 ; i < = N ; i + + ) { pay + = 800 ; if ( i % 15 = = 0 ) pay - = 200 ; } console . log ( pay ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( ) { const num = parseInt ( input [ 0 ] , 10 ) ; console . log ( num * num * num ) ; } var input = ' ' ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { input + = chunk ; } ) ; process . stdin . on ( ' end ' , function ( ) { input = input . split ( ' \ n ' ) ; main ( ) ; } ) ; function Main ( input ) { input = input . split ( " " ) ; var max = Number ( input [ 0 ] ) ; var sum = Number ( input [ 1 ] ) ; var result = 0 ; var average = Math . ceil ( sum / 3 ) ; var remain = 0 ; for ( var i = 0 ; i < = average ; i + + ) { remain = sum - i ; for ( var j = i ; j < = max ; j + + ) { var k = remain - j ; if ( j < = k & & k < = max ) { if ( i = = = j & & i = = = k ) { result + + ; } else if ( i = = = j | | i = = = k | | k = = = j ) { result = result + 3 ; } else { result = result + 6 ; } } } } console . log ( result ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; const input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; const lines = input . trim ( ) . split ( ' \ n ' ) ; while ( line = lines . shift ( ) ) { const x = parseInt ( line ) ; console . log ( x * x * x ) ; } var main = function main ( input ) { var args = input . split ( ' ' ) var average = ( + args [ 0 ] + + args [ 1 ] ) / 2 var point = average % 1 if ( point > = 0.5 ) { average = average + 0.5 var point2 = average % 1 average = average - point2 } else { average = average - point } console . log ( average ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf-8 ' ) ) function Main ( input ) { var input = input . split ( ' ' ) . map ( n = > parseInt ( n ) ) ; var a = input [ 0 ] ; var b = input [ 1 ] ; var av = ( a + b ) / 2 ; console . log ( Math . ceil ( av ) ) ; } Main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { console . log ( Math . pow ( chunk , 3 ) ) ; } ) ; ' use strict ' function main ( input ) { input = input . split ( / \ n / ) const n = ~ ~ input [ 0 ] let houses = input [ 1 ] . split ( ' ' ) . map ( v = > ~ ~ v ) . filter ( ( v , i , self ) = > { return self . indexOf ( v ) = = = i } ) . sort ( ( a , b ) = > a - b ) const ans = houses [ houses . length - 1 ] - houses [ 0 ] console . log ( ans ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) " use strict " function main ( arg ) { var data = arg . trim ( ) . split ( " \ n " ) [ 1 ] . split ( " " ) . map ( Number ) var N = data . length data = data . sort ( ( a , b ) = > b - a ) var sum = 0 for ( var i = 0 ; i < data . length ; i + + ) { sum + = data [ i ] } var tmp = Math . floor ( sum / N ) console . log ( Math . min ( calc ( data , tmp ) , calc ( data , tmp + 1 ) ) ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function calc ( data , p ) { var sum = 0 for ( var i = 0 ; i < data . length ; i + + ) { sum + = Math . pow ( ( data [ i ] - p ) , 2 ) } return sum } function Main ( input ) { var inp = input . trim ( ) . split ( ' \ n ' ) ; var N = parseInt ( inp [ 0 ] . trim ( ) ) ; var S = inp [ 1 ] . split ( ' ' ) ; var answer = ' Three ' ; for ( var i = 0 ; i < S . length ; i + + ) { if ( S [ i ] = = = ' Y ' ) { answer = ' Four ' ; } } console . log ( answer ) ; } Main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var stdin = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var input = stdin . toString ( ) . trim ( ) . split ( ' \ n ' ) ; var x = parseInt ( input [ 0 ] , 10 ) ; console . log ( Math . pow ( x , 3 ) ) ; var stdin = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var input = stdin . toString ( ) . trim ( ) . split ( ' \ n ' ) ; var x = parseInt ( input [ 0 ] , 10 ) console . log ( Math . pow ( x , 3 ) ) ; function main ( input ) { const n = input . split ( " " ) . map ( Number ) ; let a = n [ 0 ] * 800 ; let b = Math . floor ( n [ 0 ] / 15 ) * 200 ; console . log ( a - b ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { const inputData = input . replace ( / \ s * $ / g , ' ' ) . split ( / \ s + / ) . map ( v = > parseInt ( v ) ) ; const [ a , b , h , m ] = inputData ; const hRad = ( h + m / 60 ) * Math . PI / 6 ; const mRad = m * Math . PI / 30 ; const hDeg = h * 30 ; const mDeg = m * 6 ; const vecA = { x : a * Math . sin ( hRad ) , y : a * Math . cos ( hRad ) } ; const vecB = { x : b * Math . sin ( mRad ) , y : b * Math . cos ( mRad ) } ; const res = Math . sqrt ( ( vecA . x - vecB . x ) * * 2 + ( vecA . y - vecB . y ) * * 2 ) ; console . log ( res ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var fs = require ( ' fs ' ) var contents = fs . readFileSync ( ' / dev / stdin ' , ' utf-8 ' ) ; var cubic = function ( s ) { var x = parseInt ( s ) ; return x * x * x ; } console . log ( cubic ( contents ) ) " use strict " ; let myFunc = ( input ) = > { input = input . split ( " \ n " ) ; let S = input [ 1 ] . split ( " " ) ; let N = parseInt ( input [ 0 ] ) ; let P , W , G , Y ; P = W = G = Y = 0 ; for ( let i = 0 ; i < N ; i + + ) { if ( S [ i ] = = = ' P ' ) P = 1 ; if ( S [ i ] = = = ' W ' ) W = 1 ; if ( S [ i ] = = = ' G ' ) G = 1 ; if ( S [ i ] = = = ' Y ' ) Y = 1 ; } if ( P + W + G + Y = = = 3 ) console . log ( " Three " ) ; if ( P + W + G + Y = = = 4 ) console . log ( " Four " ) ; } ; myFunc ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' const main = ( INPUT ) = > { const N = INPUT . split ( ' \ n ' ) [ 0 ] . split ( ' ' ) . map ( n = > Number ( n ) ) if ( N [ 0 ] < = 5 ) { console . log ( 0 ) } else if ( N [ 0 ] < = 12 ) { console . log ( N [ 1 ] / 2 ) } else { console . log ( N [ 1 ] ) } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) function main ( input ) { const NK = input . split ( ' ' ) . map ( x = > parseInt ( x ) ) if ( NK [ 1 ] = = 1 ) { console . log ( 0 ) ; } else { console . log ( NK [ 0 ] - NK [ 1 ] ) ; } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( arg ) { arg = arg . split ( " \ n " ) . map ( Number ) var k = arg [ 5 ] var data = [ arg [ 0 ] , arg [ 1 ] , arg [ 2 ] , arg [ 3 ] , arg [ 4 ] ] var flag = true for ( var i = 0 ; i < data . length ; i + + ) { for ( var j = i + 1 ; j < data . length ; j + + ) { var ans = Math . abs ( data [ j ] - data [ i ] ) if ( ans > k ) { flag = false } } } if ( flag ) { console . log ( ' Yay ! ' ) } else { console . log ( ' : ( ' ) } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( arg ) { arg = arg . split ( " \ n " ) [ 0 ] arg = Number ( arg . split ( " / " ) . join ( " " ) ) if ( arg < = 20190430 ) { console . log ( " Heisei " ) } else { console . log ( " TBD " ) } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; var N = parseInt ( input [ 0 ] . split ( " " ) [ 0 ] ) ; var M = parseInt ( input [ 0 ] . split ( " " ) [ 1 ] ) ; C = new Array ( M ) ; P = new Array ( 0 ) ; for ( i = 0 ; i < M ; i + + ) { tmp = input [ i + 1 ] . split ( " " ) ; Csub = [ parseInt ( tmp [ 0 ] ) , parseInt ( tmp [ 1 ] ) , i ] ; C [ i ] = Csub ; } C . sort ( ( a , b ) = > ( a [ 0 ] - b [ 0 ] | | a [ 1 ] - b [ 1 ] ) ) ; for ( i = 0 ; i < M ; i + + ) { var y = " " ; c = ` $ { C [ i ] [ 0 ] } ` . slice ( - 6 ) ; if ( i = = 0 ) { var cnt = 1 ; } else if ( C [ i ] [ 0 ] ! = C [ i - 1 ] [ 0 ] ) { cnt = 1 ; } else { cnt + + ; } y = ` $ { cnt } ` . slice ( - 6 ) ; P . push ( [ ` $ { c } $ { y } ` , C [ i ] [ 2 ] ] ) ; } P . sort ( ( a , b ) = > a [ 1 ] - b [ 1 ] ) ; var ans = " " ; for ( i = 0 ; i < M ; i + + ) { if ( i ! = M - 1 ) { ans = ans + P [ i ] [ 0 ] + " \ n " ; } else { ans = ans + P [ i ] [ 0 ] ; } } console . log ( ' % s ' , ans ) ; } function debug ( ) { var input = document . getElementById ( " input " ) . value ; Main ( input ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( " " ) ; var a = parseInt ( input [ 0 ] , 10 ) ; var b = parseInt ( input [ 1 ] , 10 ) ; var c = parseInt ( input [ 2 ] , 10 ) ; var s = a + b if ( s > = c ) { console . log ( " Yes " ) ; } else { console . log ( " No " ) } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { input = input . split ( ' ' ) ; var K = parseInt ( input [ 0 ] , 10 ) ; var S = parseInt ( input [ 1 ] , 10 ) ; var ans = 0 ; for ( var x = 0 ; x < = K ; x + + ) for ( var y = 0 ; y < = K ; y + + ) { z = S - ( x + y ) if ( z > = 0 & & z < = K ) ans + + } console . log ( ans ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' function main ( input ) { const x = parseInt ( input / 15 ) ; console . log ( input * 800 - x * 200 ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " ; function main ( input ) { input = input . split ( / \ n / ) ; const n = input [ 0 ] ; input = input [ 1 ] . split ( " " ) ; let ans = " Three " ; for ( let v in input ) { if ( input [ v ] = = " Y " ) { ans = " Four " ; break ; } } console . log ( ans ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var x = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; x = parseInt ( x , 10 ) ; console . log ( x * x * x ) ; function Main ( input ) { var A = parseInt ( input [ 0 ] , 10 ) ; var B = parseInt ( input [ 1 ] , 10 ) ; if ( A > = 13 ) { console . log ( B ) ; } else if ( 6 < = A & & A < = 12 ) { console . log ( B / 2 ) ; } else { console . log ( ' 0 ' ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) . split ( / \ n | \ s / ) ) ; " use strict " const Main = ( input ) = > { const Array = input . split ( " " ) const A = parseInt ( Array [ 0 ] , 10 ) const B = parseInt ( Array [ 1 ] , 10 ) const C = parseInt ( Array [ 2 ] , 10 ) const Answer = ( A + B ) > = C ? " Yes " : " No " console . log ( Answer ) } Main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { input = input . replace ( / \ n / g , ' ' ) ; input = input . split ( " " ) ; var A = Number ( input [ 0 ] ) ; var B = Number ( input [ 1 ] ) ; var C = Number ( input [ 2 ] ) ; var D = Number ( input [ 3 ] ) ; var E = Number ( input [ 4 ] ) ; if ( A > C ) { C + = 24 ; } var a = A * 60 + B ; var b = C * 60 + D ; console . log ( b - a - E ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' ; var fs = require ( ' fs ' ) ; var input = Buffer . alloc ( 0x100000 ) ; var length = fs . readSync ( 0 , input , 0 , 0x100000 ) ; var text = input . toString ( ) . slice ( 0 , length ) . trim ( ) ; var dp = Array ( text . length + 1 ) . fill ( false ) ; dp [ 0 ] = true ; for ( var index = 5 ; index < = text . length ; index + + ) { if ( dp [ index - 5 ] = = = true & & text . slice ( index - 5 , index ) = = = ' dream ' ) { dp [ index ] = true ; continue ; } if ( dp [ index - 7 ] = = = true & & text . slice ( index - 7 , index ) = = = ' dreamer ' ) { dp [ index ] = true ; continue ; } if ( dp [ index - 5 ] = = = true & & text . slice ( index - 5 , index ) = = = ' erase ' ) { dp [ index ] = true ; continue ; } if ( dp [ index - 6 ] = = = true & & text . slice ( index - 6 , index ) = = = ' eraser ' ) { dp [ index ] = true ; continue ; } } console . log ( dp [ text . length ] ? ' YES ' : ' NO ' ) ; function Main ( input ) { ans = 0 in put = input . trim ( ) . split ( " \ n " ) ; s = input [ 0 ] . split ( ' ' ) . map ( ( n ) = > ( parseInt ( n ) ) ) s . sort ( function ( a , b ) { return b - a } ) for ( i = 2 ; i > 0 ; i -- ) { ans + = Math . abs ( s [ i ] - s [ i - 1 ] ) } console . log ( ans ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( arg ) { arg = arg . trim ( ) ; arg = parseInt ( arg , 10 ) ; var i = 1 * 1 ; var r = ( ( arg * arg ) / i ) ; console . log ( r ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; const a = + ( ' ' + require ( ' fs ' ) . readFileSync ( 0 ) ) console . log ( a * a * a ) process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { var x = parseInt ( chunk . trim ( ) , 10 ) ; console . log ( Math . pow ( x , 3 ) ) ; } ) ; function Main ( input ) { input = input . split ( " " ) ; var a = Number ( input [ 0 ] ) ; var b = Number ( input [ 1 ] ) ; console . log ( Math . ceil ( ( a + b ) / 2 ) ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' function main ( input ) { input = input . trim ( ) . split ( ' ' ) . map ( v = > Number ( v ) ) const k = input [ 0 ] const s = input [ 1 ] let count = 0 for ( let xi = 0 ; xi < = k ; xi + + ) { for ( let yi = 0 ; yi < = k ; yi + + ) { const tmp = s - ( xi + yi ) if ( tmp > = 0 & & tmp < = k ) count + + } } console . log ( count ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) function Main ( input ) { input = input . split ( " \ n " ) ; tmp = input [ 0 ] . split ( " " ) ; tmp . sort ( function ( a , b ) { if ( a < b ) return - 1 ; if ( a > b ) return 1 ; return 0 ; } ) result = tmp . toString ( ) = = [ 1 , 4 , 7 , 9 ] ? ' YES ' : ' NO ' ; console . log ( result ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; var inputValue = input [ 0 ] ; var mostDivideCount = 0 ; var mostValue = 0 for ( var i = 0 ; i < = inputValue ; i + + ) { var divideCount = 0 ; var t = i ; while ( t > = 2 & & t % 2 = = 0 ) { divideCount + = 1 ; t = t / 2 ; } if ( divideCount > = mostDivideCount ) { mostDivideCount = divideCount ; mostValue = i ; } } console . log ( ' % d ' , mostValue ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; tmp0 = input [ 0 ] . split ( " " ) ; A = Number ( tmp0 [ 0 ] ) ; B = Number ( tmp0 [ 1 ] ) ; ans = 0 ; if ( A < = 5 ) { ans = 0 ; } else if ( 6 < = A & & A < = 12 ) { ans = B / 2 } else { ans = B } console . log ( ans ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { inputs = input . split ( ' \ n ' ) ; if ( inputs [ 4 ] - inputs [ 0 ] < = inputs [ 5 ] ) { console . log ( ' Yay ! ' ) ; } else { console . log ( ' : ( ' ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { var N = parseInt ( input [ 0 ] ) ; console . log ( 800 * N - 200 * Math . floor ( N / 15 ) ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . split ( " \ n " ) ) ; function Main ( input ) { var num = input . split ( " / " ) ; for ( var n = 0 ; n < num . length ; n + + ) { num [ n ] = parseInt ( num [ n ] ) ; } var output ; if ( num [ 0 ] < 2019 ) { output = " Heisei " } else { if ( num [ 1 ] < 5 ) { output = " Heisei " } else { output = " TBD " } } console . log ( output ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . trim ( ) in put = input . split ( " " ) ; if ( input [ 0 ] * input [ 1 ] > input [ 2 ] * input [ 3 ] ) { console . log ( input [ 0 ] * input [ 1 ] ) } else { console . log ( input [ 2 ] * input [ 3 ] ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var Arr = ( input . trim ( ) ) . split ( " \ n " ) ; while ( Arr . length ! = 0 ) { var result = [ ] ; var NT = ( Arr . shift ( ) ) . split ( " " ) . map ( Number ) ; for ( var i = 0 ; i < NT [ 0 ] ; i + + ) { var arr = ( Arr . shift ( ) ) . split ( " " ) ; var a = arr [ 0 ] . split ( " : " ) . map ( function ( v ) { return parseInt ( v , 10 ) ; } ) ; if ( i > 0 ) { var A = a [ 0 ] * 60 + a [ 1 ] ; var B = b [ 0 ] * 60 + b [ 1 ] ; if ( A - B > = NT [ 1 ] ) result . push ( c + " " + ( A - B ) ) ; } var b = arr [ 2 ] . split ( " : " ) . map ( function ( v ) { return parseInt ( v , 10 ) ; } ) ; var c = arr [ 3 ] ; } console . log ( result . length ) ; result . forEach ( function ( v ) { console . log ( v ) ; } ) ; } process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf-8 ' ) ; var input _ string = ' ' ; process . stdin . on ( ' data ' , function ( chunk ) { input _ string + = chunk ; } ) ; process . stdin . on ( ' end ' , function ( ) { var lines = input _ string . split ( ' \ n ' ) ; main ( lines . slice ( 0 , lines . length - 1 ) ) ; } ) ; var main = function ( lines ) { lines . forEach ( function ( x ) { console . log ( Math . pow ( parseInt ( x ) , 3 ) ) ; } ) ; } ; function Main ( input ) { var tmp = input . split ( " " ) ; var a = parseInt ( tmp [ 0 ] , 10 ) ; var b = parseInt ( tmp [ 1 ] , 10 ) ; var payed _ price = 0 ; if ( a > = 13 ) { payed _ price = b ; } else if ( a > = 6 ) { payed _ price = b / 2 ; } else { payed _ price = 0 ; } console . log ( payed _ price ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; const input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ; ( input = > { const lines = input . split ( ' \ n ' ) const map = [ ] for ( let i = 0 ; i < 3 ; i + + ) { map [ i ] = lines [ i ] . split ( ' ' ) . map ( Number ) } let diff1 = 0 let diff2 = 0 diff1 = map [ 0 ] [ 0 ] - map [ 0 ] [ 1 ] diff2 = map [ 0 ] [ 1 ] - map [ 0 ] [ 2 ] for ( var i = 1 ; i < 3 ; i + + ) { if ( diff1 ! = = map [ i ] [ 0 ] - map [ i ] [ 1 ] ) break if ( diff2 ! = = map [ i ] [ 1 ] - map [ i ] [ 2 ] ) break } console . log ( i = = = 3 ? ' Yes ' : ' No ' ) } ) ( input ) const main = input = > { const r = parseInt ( input ) ; console . log ( r * r ) ; } ; main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; var lines = [ ] ; var reader = require ( ' readline ' ) . createInterface ( { input : process . stdin , output : process . stdout } ) ; reader . on ( ' line ' , ( line ) = > { lines . push ( line ) ; } ) ; reader . on ( ' close ' , ( ) = > { const a = + lines [ 0 ] ; const e = + lines [ 4 ] ; const k = + lines [ 5 ] ; console . log ( e - a < = k ? " Yay ! " : " : ( " ) ; } ) ; function main ( input ) { input = input . trim ( ) ; const a = input . split ( " " ) . map ( Number ) ; console . log ( Math . ceil ( ( a [ 0 ] + a [ 1 ] ) / 2 ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( arg ) { arg = arg . trim ( ) . split ( " \ n " ) . map ( Number ) var k = arg . pop ( ) var data = arg for ( var i = 0 ; i < data . length ; i + + ) { for ( var j = i + 1 ; j < data . length ; j + + ) { var ans = Math . abs ( data [ i ] - data [ j ] ) if ( ans > k ) { console . log ( ' : ( ' ) return } } } console . log ( ' Yay ! ' ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var arr = input . trim ( ) . split ( " \ n " ) ; var nrl = arr . shift ( ) . split ( " " ) . map ( Number ) ; var n = nrl [ 0 ] ; var L = nrl [ 2 ] ; var t = [ ] ; var max = [ 0 , 0 ] ; var time = 0 ; for ( var i = 0 ; i < n ; i + + ) t [ i ] = [ 0 , 0 , i ] ; arr . push ( [ 1 , L , 0 ] . join ( " " ) ) ; arr . forEach ( function ( v ) { v = v . split ( " " ) . map ( Number ) ; var d = v [ 0 ] - 1 ; var T = v [ 1 ] ; var x = v [ 2 ] ; t [ max [ 0 ] ] [ 1 ] + = T - time ; time = T ; t [ d ] [ 0 ] + = x ; if ( x > 0 ) { if ( t [ d ] [ 0 ] > max [ 1 ] ) max = [ d , t [ d ] [ 0 ] ] ; else if ( t [ d ] [ 0 ] = = max [ 1 ] & & d < = max [ 0 ] ) max = [ d , t [ d ] [ 0 ] ] ; } else if ( x < 0 & & max [ 0 ] = = d ) { var MAX = 0 ; var m = 0 ; t . forEach ( function ( V , index ) { if ( MAX < V [ 0 ] ) m = index ; } ) ; max = [ m , t [ m ] [ 0 ] ] ; } } ) ; t . sort ( function ( a , b ) { if ( a [ 1 ] = = b [ 1 ] ) return a [ 2 ] - b [ 2 ] ; else return b [ 1 ] - a [ 1 ] ; } ) ; console . log ( t [ 0 ] [ 2 ] + 1 ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { var x = parseInt ( chunk . trim ( ) , 10 ) ; console . log ( x * x * x ) ; } ) ; function Main ( input ) { input = input . split ( " " ) ; var A = parseInt ( input [ 0 ] , 10 ) ; var B = parseInt ( input [ 1 ] , 10 ) ; var C = parseInt ( input [ 2 ] , 10 ) ; var five = 2 ; if ( A + B + C ! = 17 ) { console . log ( " NO " ) ; } else { if ( A = = 5 ) { five -- ; } if ( B = = 5 ) { five -- ; } if ( C = = 5 ) { five -- ; } if ( five = = 0 ) { console . log ( " YES " ) ; } else { console . log ( " NO " ) ; } } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' ; function main ( arg ) { arg = arg . split ( " " ) . sort ( ( a , b ) = > a - b ) ; let ans = 0 ; for ( let i = 0 ; i < arg . length - 1 ; i + + ) { ans = ans + ( arg [ i + 1 ] - arg [ i ] ) ; } console . log ( ans ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var tbd = " TBD " ; var hs = " Heisei " ; function Main ( input ) { input = input . split ( " / " ) . map ( a = > ~ ~ a ) ; var y = input [ 0 ] ; var m = input [ 1 ] ; var d = input [ 2 ] ; if ( y > = 2020 ) return tbd ; if ( y < = 2018 ) return hs ; if ( m > = 5 ) return tbd ; return hs ; } ( ( b , c , d ) = > " undefined " ! = typeof require ? console . log ( Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ) : [ b = b . split ( " \ n " ) . slice ( 1 , - 1 ) . join ( " \ n " ) , c = function ( ) { try { return Main ( b ) } catch ( f ) { return f . stack | | f . message } } ( ) , d = typeof c , " string " = = d | | ( c = JSON . stringify ( c ) ) , $ ( " < form > " ) . append ( [ [ 10 , b ] , 0 , [ 1 , d ] , 0 , [ 10 , c ] ] . map ( f = > $ ( f ? " < textarea > " : " < br > " , f & & { rows : f [ 0 ] , cols : 40 , text : f [ 1 ] } ) ) ) . appendTo ( " body " ) ] ) ( ` ` ) ; " use strict " ; function main ( input ) { input = input . split ( / \ n | \ s / ) . map ( v = > ~ ~ v ) ; console . log ( input [ 0 ] + input [ 1 ] - input [ 2 ] > = 0 ? " Yes " : " No " ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; const input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) const lines = input . split ( ' \ n ' ) let n = lines [ 0 ] . trim ( ) - 0 let v = lines [ 1 ] . trim ( ) . split ( ' ' ) . map ( Number ) const s = { } const b = { } for ( let i = 0 ; i < n ; i + = 2 ) { s [ v [ i ] ] = s [ v [ i ] ] ? s [ v [ i ] ] + 1 : 1 b [ v [ i + 1 ] ] = b [ v [ i + 1 ] ] ? b [ v [ i + 1 ] ] + 1 : 1 } const a1 = [ ] for ( let key in s ) { a1 . push ( [ key , s [ key ] ] ) } const a2 = [ ] for ( let key in b ) { a2 . push ( [ key , b [ key ] ] ) } a1 . sort ( ( a , b ) = > b [ 1 ] - a [ 1 ] ) a2 . sort ( ( a , b ) = > b [ 1 ] - a [ 1 ] ) let as = 0 if ( a1 [ 0 ] [ 0 ] ! = = a2 [ 0 ] [ 0 ] ) { as = a1 [ 0 ] [ 1 ] + a2 [ 0 ] [ 1 ] } else { as = Math . max ( a1 [ 0 ] [ 1 ] + ( a2 [ 1 ] ? a2 [ 1 ] [ 1 ] : 0 ) , ( a1 [ 1 ] ? a1 [ 1 ] [ 1 ] : 0 ) + a2 [ 0 ] [ 1 ] ) } console . log ( n - as ) function Main ( input ) { tmp = input . split ( " \ n " ) ; var a = parseInt ( tmp [ 0 ] ) ; var b = parseInt ( tmp [ 1 ] ) ; var c = parseInt ( tmp [ 2 ] ) ; var d = parseInt ( tmp [ 3 ] ) ; var e = parseInt ( tmp [ 4 ] ) ; var k = parseInt ( tmp [ 5 ] ) ; var err = 0 ; if ( b - a > k ) { err + + ; } if ( c - a > k ) { err + + ; } if ( d - a > k ) { err + + ; } if ( e - a > k ) { err + + ; } if ( c - b > k ) { err + + ; } if ( d - b > k ) { err + + ; } if ( e - b > k ) { err + + ; } if ( d - c > k ) { err + + ; } if ( e - c > k ) { err + + ; } if ( e - d > k ) { err + + ; } if ( err > = 1 ) { console . log ( " : ( " ) ; } else { console . log ( " Yay ! " ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " ; ( inp = > { inp = inp . split ( " " ) ; const A = + inp [ 0 ] ; const B = + inp [ 1 ] ; console . log ( Math . ceil ( ( A + B ) / 2 ) ) ; } ) ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; let [ a , b ] = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . split ( " " ) . map ( Number ) ; console . log ( Math . ceil ( ( a + b ) / 2 ) ) ; ( ( input ) = > { const data = input . split ( ' \ n ' ) ; const line1 = data [ 0 ] . split ( ' ' ) ; const N = + line1 [ 0 ] ; const D = + line1 [ 1 ] ; const coords = data . slice ( 1 , N + 1 ) . map ( ( line ) = > line . replace ( / \ s \ s / g , ' ' ) . split ( ' ' ) . filter ( Boolean ) . map ( Number ) ) ; console . log ( coords . reduce ( ( total , coord1 , i ) = > ( total + coords . slice ( i + 1 ) . reduce ( ( count , coord2 ) = > ( Number . isInteger ( distance ( coord1 , coord2 , D ) ) ? count + 1 : count ) , 0 ) ) , 0 ) ) ; } ) ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function distance ( coords1 , coords2 , D ) { var sum = 0 ; for ( var i = 0 ; i < D ; i + = 1 ) { sum + = Math . pow ( coords1 [ i ] - coords2 [ i ] , 2 ) ; } return Math . sqrt ( sum ) ; } " use strict " ; const main = ( input ) = > { const spi = input . split ( ' \ n ' ) ; const [ a , b , h , m ] = spi [ 0 ] . split ( ' ' ) . map ( e = > parseInt ( e ) ) ; const sho = h * 30 + m * 0.5 ; const lon = 6 * m ; const kakudo = sho - lon ; const ans = a * a + b * b - 2 * a * b * Math . cos ( Math . PI / 180 * kakudo ) ; console . log ( Math . sqrt ( ans ) ) ; } ; main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ( function ( a ) { console . log ( a [ 0 ] * a [ 1 ] * a [ 2 ] = = 175 ? ' YES ' : ' NO ' ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . split ( ' ' ) ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf-8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { console . log ( Math . pow ( chunk , 3 ) ) ; } ) ; function main ( input ) { const nums = input . split ( " " ) const age = parseInt ( nums [ 0 ] , 10 ) const B = parseInt ( nums [ 1 ] , 10 ) if ( age > = 13 ) { console . log ( B ) } else if ( age > = 6 ) { console . log ( B / 2 ) } else { console . log ( 0 ) } } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) function Main ( inputData ) { init ( inputData ) ; var a = inI ( ) ; var b = inI ( ) ; var c = inI ( ) ; var d = inI ( ) ; out ( Math . max ( a * b , c * d ) ) ; } var input , inputCnt ; function debug ( ) { Main ( document . getElementById ( " input " ) . value ) ; } function init ( inputData ) { input = inputData . replace ( / \ n / g , " " ) ; input = input . split ( " " ) ; inputCnt = 0 ; } const out = ( output ) = > { console . log ( output ) } const outln = ( output ) = > { console . log ( output + " \ n " ) } const inS = ( ) = > { return input [ inputCnt + + ] } ; const inI = ( ) = > { return parseInt ( inS ( ) , 10 ) } ; const inF = ( ) = > { return parseFloat ( inS ( ) ) } ; Array . prototype . rsort = function ( ) { return this . sort ( function ( a , b ) { return ( a < b ? 1 : - 1 ) ; } ) ; } Array . prototype . max = function ( ) { return Math . max . apply ( null , this ) ; } Array . prototype . min = function ( ) { return Math . min . apply ( null , this ) ; } function values ( array ) { var values = [ ] ; if ( array ) for ( var key in array ) values . push ( array [ key ] ) ; return values ; } ; function keys ( array ) { var keys = [ ] ; if ( array ) for ( var key in array ) keys . push ( key ) ; return keys ; } ; Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; const input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; const n = Number ( input ) ; console . log ( n * n * n ) ; function Main ( input ) { input = input . split ( " " ) ; var a = parseInt ( input [ 0 ] , 10 ) ; var b = parseInt ( input [ 1 ] , 10 ) ; var c = parseInt ( input [ 2 ] , 10 ) ; var ans = " " ; if ( a = = = 5 & & b = = = 5 & & c = = = 7 ) { ans = " YES " ; } else if ( a = = = 5 & & b = = = 7 & & c = = = 5 ) { ans = " YES " ; } else if ( a = = = 7 & & b = = = 5 & & c = = = 5 ) { ans = " YES " ; } else { ans = " NO " ; } console . log ( ' % s ' , ans ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " ; function Main ( stdin ) { stdin = stdin . split ( " \ n " ) ; var sum = 0 , ans = " " ; for ( var i = 0 ; sum = 0 , i < stdin . length ; i + + ) { stdin [ i ] . split ( " " ) ; if ( stdin [ i ] [ 0 ] = = = " 0 " ) break ; for ( var o = 0 ; o < stdin [ i ] . length ; o + + ) { sum + = parseInt ( stdin [ i ] [ o ] ) ; } ans + = sum + " \ n " ; } console . log ( ans . trim ( ) ) ; } function debug ( ) { var input = document . getElementById ( " input " ) . value ; Main ( input ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' ; ( function ( input ) { input = input . trim ( ) . split ( / \ s + / ) . map ( x = > x - 0 ) ; if ( input [ 1 ] = = = 1 ) { console . log ( 0 ) ; return ; } else { console . log ( input [ 0 ] - input [ 1 ] ) ; } } ) ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ( stdin = > { const Number = n = > Math . pow ( n , 3 ) const inputs = stdin . toString ( ) . trim ( ) . split ( ' \ n ' ) const X = parseInt ( inputs [ 0 ] , 10 ) console . log ( Number ( X ) ) } ) ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) function main ( input ) { var a = parseInt ( input . split ( " \ n " ) [ 0 ] . split ( " " ) [ 0 ] ) ; var b = parseInt ( input . split ( " \ n " ) [ 0 ] . split ( " " ) [ 1 ] ) ; var c = parseInt ( input . split ( " \ n " ) [ 0 ] . split ( " " ) [ 2 ] ) ; var d = parseInt ( input . split ( " \ n " ) [ 0 ] . split ( " " ) [ 3 ] ) ; if ( a * b > = c * d ) { console . log ( a * b ) ; } else { console . log ( c * d ) ; } } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " ; const main = arg = > { arg = arg . trim ( ) . split ( " \ n " ) ; const A = parseInt ( arg [ 0 ] . split ( " " ) [ 0 ] ) ; const B = parseInt ( arg [ 0 ] . split ( " " ) [ 1 ] ) ; const H = parseInt ( arg [ 0 ] . split ( " " ) [ 2 ] ) ; const M = parseInt ( arg [ 0 ] . split ( " " ) [ 3 ] ) ; let angleA = ( 360 / 12 ) * ( H % 12 ) ; const angleB = ( 360 / 60 ) * M ; angleA + = 30 * ( M / 60 ) ; const absAB = Math . abs ( angleA - angleB ) ; const angle = Math . min ( absAB , 360 - absAB ) ; let answer ; answer = ( Math . pow ( A , 2 ) + Math . pow ( B , 2 ) ) - ( 2 * A * B ) * ( Math . cos ( angle * ( Math . PI / 180 ) ) ) ; console . log ( Math . sqrt ( answer ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; var lines = [ ] ; var reader = require ( ' readline ' ) . createInterface ( { input : process . stdin , output : process . stdout } ) ; reader . on ( ' line ' , ( line ) = > { lines . push ( line ) ; } ) ; reader . on ( ' close ' , ( ) = > { var array = lines [ 0 ] ; var n1 = array . indexOf ( 1 ) ; if ( n1 ! = = - 1 ) { var n2 = array . indexOf ( 9 ) ; if ( n2 ! = = - 1 ) { var n3 = array . indexOf ( 7 ) ; if ( n3 ! = = - 1 ) { var n4 = array . indexOf ( 4 ) ; if ( n4 ! = = - 1 ) { console . log ( " YES " ) ; } else { console . log ( " NO " ) ; } } else { console . log ( " NO " ) ; } } else { console . log ( " NO " ) ; } } else { console . log ( " NO " ) ; } } ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { console . log ( Math . pow ( chunk . trim ( ) , 3 ) ) ; } ) ; var input = ' ' ; var readable = process . stdin ; readable . resume ( ) ; readable . setEncoding ( ' utf-8 ' ) ; readable . on ( ' data ' , function ( chunk ) { input + = chunk ; } ) ; readable . on ( ' end ' , function ( ) { var data = input . split ( " \ n " ) ; var output = [ ] ; for ( var i = 0 ; i < data . length ; i + + ) { var nums = data [ i ] . split ( ' ' ) . map ( Number ) ; if ( 0 = = nums [ 0 ] ) { break ; } var sum = 0 ; for ( var j = 0 ; j < nums . length ; j + + ) { sum + = nums [ j ] ; } output . push ( sum ) ; } console . log ( output . join ( ' \ n ' ) ) ; } ) ; ( function ( stdin ) { const inputs = stdin . toString ( ) . trim ( ) . split ( ' \ n ' ) ; const result = ( function ( x ) { return Math . pow ( x , 3 ) ; } ( parseInt ( inputs [ 0 ] , 10 ) ) ) ; console . log ( result ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; ' use strict ' ; ( function ( stdin ) { var lines = stdin . toString ( ) . split ( ' \ n ' ) ; var result = ( function ( data ) { return Math . pow ( data , 3 ) ; } ( parseInt ( lines [ 0 ] ) ) ) ; console . log ( result ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; var stdin = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ; stdin = stdin . trim ( ) . split ( " \ n " ) ; var stdout = [ ] ; function print ( x ) { stdout . push ( x ) } ; var menu = stdin . map ( n = > parseInt ( n ) ) ; var d = [ ] ; var ans = 0 for ( i = 0 ; i < 5 ; i + + ) { d . push ( ( menu [ i ] - 1 ) % 10 ) ans + = parseInt ( ( menu [ i ] + 9 ) / 10 ) * 10 } d . sort ( ) print ( ans - 10 + d [ 0 ] + 1 ) ; stdout = stdout . join ( " \ n " ) ; console . log ( stdout ) ; function Main ( input ) { input = input . split ( " \ n " ) ; tmp = input [ 1 ] . split ( " " ) ; var max = 0 ; var min = 1000 ; for ( var i = 0 ; i < tmp . length ; i + + ) { var a = parseInt ( tmp [ i ] , 10 ) ; if ( a > max ) max = a ; if ( a < min ) min = a ; } console . log ( ' % d ' , max - min ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . trim ( ) in put = input . split ( " \ n " ) . map ( Number ) ; var N = input [ 5 ] ; input . pop ( ) ; function compareFunc ( a , b ) { return a - b ; } input . sort ( compareFunc ) ; if ( input [ 4 ] - input [ 0 ] < = N ) console . log ( " Yay ! " ) ; else console . log ( " : ( " ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; var line = input [ 0 ] . split ( " " ) ; var num = parseInt ( line [ 0 ] ) ; var max = 0 ; var min = 10000 ; var data = input [ 1 ] . split ( " " ) ; for ( var i = 0 ; i < num ; i + + ) { data [ i ] = parseInt ( data [ i ] ) ; } for ( var i = 0 ; i < num ; i + + ) { if ( max < data [ i ] ) { max = data [ i ] ; } if ( min > data [ i ] ) { min = data [ i ] ; } } console . log ( max - min ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' const main = input = > { const args = input . split ( ' \ n ' ) [ 0 ] . split ( ' ' ) if ( args [ 0 ] = = = ' 5 ' & & args [ 1 ] = = = ' 5 ' & & args [ 2 ] = = = ' 7 ' ) console . log ( ' YES ' ) else if ( args [ 0 ] = = = ' 7 ' & & args [ 1 ] = = = ' 5 ' & & args [ 2 ] = = = ' 5 ' ) console . log ( ' YES ' ) else if ( args [ 0 ] = = = ' 5 ' & & args [ 1 ] = = = ' 7 ' & & args [ 2 ] = = = ' 5 ' ) console . log ( ' YES ' ) else console . log ( ' NO ' ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ' use strict ' const num = 5 function main ( o ) { o = o . split ( ' \ n ' ) . map ( v = > ~ ~ v ) let foods = o . slice ( 0 , num ) let foods1 = [ ] let foods2 = [ ] for ( let i = 0 ; i < num ; i + + ) { if ( foods [ i ] % 10 > 0 ) { foods1 . push ( foods [ i ] ) } else { foods2 . push ( foods [ i ] ) } } foods1 . sort ( ( a , b ) = > { return a % 10 < b % 10 } ) let time = 0 if ( foods1 . length ) { for ( let i = 0 ; i < foods1 . length - 1 ; i + + ) { time + = foods1 [ i ] + ( 10 - ( foods1 [ i ] % 10 ) ) } } for ( let i = 0 ; i < foods2 . length ; i + + ) { time + = foods2 [ i ] } if ( foods1 . length ) { for ( let i = foods1 . length - 1 ; i < foods1 . length ; i + + ) { time + = foods1 [ i ] } } console . log ( time ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var Arr = ( input . trim ( ) ) . split ( " \ n " ) ; var I = 0 ; while ( true ) { var nS = Arr [ I ] . split ( " " ) . map ( Number ) ; I + + ; var n = nS [ 0 ] ; var S = nS [ 1 ] ; if ( n = = 0 & & S = = 0 ) break ; var arr = [ ] ; for ( var i = 0 ; i < n ; i + + ) { var r = Arr [ I ] - 0 ; I + + ; arr . push ( r ) ; } arr . sort ( function ( a , b ) { return a - b ; } ) ; var cnt = 0 ; for ( var i = 0 ; i < n ; i + + ) { for ( var j = i + 1 ; j < n ; j + + ) { if ( arr [ i ] + arr [ j ] > S ) { cnt + = n - j ; break ; } } } console . log ( cnt ) ; } ' use strict ' function main ( input ) { input = input . split ( ' ' ) let a = input [ 0 ] * input [ 1 ] let b = input [ 2 ] * input [ 3 ] if ( a < = b ) { console . log ( b ) } else { console . log ( a ) } } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " ; const input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ; const X = Number ( input . trim ( ) ) ; const memo = { } ; const pow5 = ( n ) = > { if ( ! memo [ n ] ) { memo [ n ] = Math . pow ( n , 5 ) ; } return memo [ n ] ; } ; const MAX = 120 ; const resultList = [ ] ; for ( let a = - MAX ; a < = MAX ; a + + ) { for ( let b = - MAX ; b < MAX ; b + + ) { if ( pow5 ( a ) - pow5 ( b ) = = = X ) { resultList . push ( a , b ) ; break ; } } if ( resultList . length ) { break ; } } console . log ( resultList . join ( " " ) ) ; function Main ( input ) { var inputs = input . split ( ' ' ) ; var K = Number ( inputs [ 0 ] ) ; var S = Number ( inputs [ 1 ] ) ; var count = 0 ; for ( var X = 0 ; X < = K ; X + + ) { for ( var Y = 0 ; Y < = K ; Y + + ) { var Z = ( S - X - Y ) ; if ( 0 < = Z & & Z < = K ) { count + + ; } } } console . log ( count ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; tmp = input [ 0 ] . split ( " " ) ; var n = parseInt ( tmp [ 0 ] , 10 ) ; var m = parseInt ( tmp [ 1 ] , 10 ) ; var id = { } for ( var i = 1 ; i < = m ; i + + ) { py = input [ i ] . split ( " " ) ; var p = py [ 0 ] ; var y = py [ 1 ] ; if ( ! ( p in id ) ) { id [ p ] = { } ; } id [ p ] [ y ] = 0 ; } Object . keys ( id ) . forEach ( function ( key ) { var i = 1 ; Object . keys ( id [ key ] ) . sort ( function ( a , b ) { return a - b ; } ) . forEach ( function ( key2 ) { id [ key ] [ key2 ] = i ; i + + ; } ) ; } ) ; for ( var i = 1 ; i < = m ; i + + ) { py = input [ i ] . split ( " " ) ; var p = py [ 0 ] ; var y = py [ 1 ] ; console . log ( ( ' 000000 ' + p ) . slice ( - 6 ) + ( ' 000000 ' + id [ p ] [ y ] ) . slice ( - 6 ) ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; const main = ( standardInput ) = > { const lengthList = standardInput . split ( ' ' ) ; const x = Number . parseInt ( lengthList [ 0 ] ) ; console . log ( x * x * x ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' UTF-8 ' ) ) ; ' use strict ' ; process . stdin . on ( ' data ' , function ( chunk ) { var inputs = chunk . toString ( ) ; var x = Number ( inputs ) ; console . log ( x * x * x ) ; } ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; " use strict " ; function main ( input ) { const args = input . split ( " " ) ; const A = parseInt ( args [ 0 ] ) ; const B = parseInt ( args [ 1 ] ) ; let ans = ' ' ; if ( A < 6 ) { ans = 0 ; } else if ( A < = 12 ) { ans = B / 2 ; } else { ans = B ; } console . log ( ans ) } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' function main ( inp ) { inp = inp . trim ( ) . split ( ' ' ) . map ( x = > x * 1 ) ; let A = inp [ 0 ] ; let B = inp [ 1 ] ; let H = inp [ 2 ] ; let M = inp [ 3 ] ; let Hkaku = H * 30 + M * 0.5 ; let Mkaku = M * 6 ; let kaku = ( Mkaku - Hkaku ) * Math . PI / 180 ; let ans = 0 ; ans = Math . sqrt ( A * A + B * B - 2 * A * B * Math . cos ( kaku ) ) ; console . log ( ans ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var fs = require ( ' fs ' ) , length = fs . fstatSync ( process . stdin . fd ) . size , buffer = new Buffer ( length ) , bytesRead = fs . readSync ( process . stdin . fd , buffer , 0 , length , 0 ) , input = buffer . toString ( ' utf8 ' , 0 , bytesRead ) . split ( ' \ n ' ) ; main ( ) ; function main ( ) { var isMinus = input [ 0 ] [ 0 ] = = = ' - ' , str = isMinus ? input [ 0 ] . slice ( 1 ) : input [ 0 ] , ss1 , ss2 , si1 , si2 , i , ans = 0 ; if ( ( str - 0 ) % 2 = = = 0 ) { ans + + ; } for ( i = 1 ; i < str . length ; i + + ) { ss1 = str . slice ( 0 , i ) ; ss2 = str . slice ( i ) ; if ( ss2 [ 0 ] = = = ' 0 ' ) { continue ; } si1 = ss1 - 0 ; si2 = ss2 - 0 ; if ( si1 > si2 ) { break ; } if ( ( si1 + si2 ) % 2 = = = 0 ) { ans + + ; } } console . log ( ans ) ; } ' use strict ' ; function Main ( inputString ) { let input = inputString . split ( " \ n " ) ; let string = input [ 0 ] ; let point = parseInt ( input [ 1 ] ) ; let which = 0 ; while ( point ) { if ( string . length - 1 = = which ) { point = point % 26 ; var code = ( string [ which ] . charCodeAt ( 0 ) + point ) ; if ( code > 122 ) { code + = ( - 122 + 97 - 1 ) ; } var lastLetter = String . fromCharCode ( code ) ; point = 0 ; string = string . slice ( 0 , which ) + lastLetter + string . slice ( which + 1 ) ; } else { if ( ( 27 - ( string [ which ] . charCodeAt ( 0 ) - 97 + 1 ) ) < = point & & ! ( string [ which ] = = " a " ) ) { point = point - ( 27 - ( string [ which ] . charCodeAt ( 0 ) - 97 + 1 ) ) ; string = string . slice ( 0 , which ) + " a " + string . slice ( which + 1 ) ; } + + which ; } } console . log ( string ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { var reg = / 7 5 5 | 5 7 5 | 5 5 7 / ; reg . test ( input ) ? op ( " YES " ) : op ( " NO " ) ; } function op ( a ) { console . log ( a ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " const create = ( ) = > { const input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) . split ( " \ n " ) ; const res = { " list " : input , " index " : 0 , " max " : input . length , " hasNext " : function ( ) { return this . index < this . max } , " next " : function ( ) { if ( ! this . hasNext ( ) ) { throw " ArrayIndexOutOfBoundsException " ; } else { return this . list [ this . index + + ] ; } } } ; return res ; } const o = create ( ) ; const next = ( ) = > o . next ( ) const nextInt = ( ) = > parseInt ( o . next ( ) ) const nextStrArray = ( ) = > o . next ( ) . split ( " " ) const nextIntArray = ( ) = > o . next ( ) . split ( " " ) . map ( el = > parseInt ( el ) ) const nextCharArray = ( ) = > o . next ( ) . split ( " " ) const hasNext = ( ) = > o . hasNext ( ) const myout = ( ... x ) = > console . log ( ... x ) const dist = ( y , z ) = > { let sum = 0 for ( let i = 0 ; i < y . length ; i + + ) { sum + = ( y [ i ] - z [ i ] ) * * 2 } return Math . sqrt ( sum ) } const Main = ( ) = > { const [ N , D ] = nextIntArray ( ) let x = [ ] while ( hasNext ( ) ) { x . push ( nextIntArray ( ) ) } let cnt = 0 for ( let i = 0 ; i < x . length ; i + + ) { for ( let j = i + 1 ; j < x . length ; j + + ) { if ( i = = j ) continue if ( Number . isInteger ( dist ( x [ i ] , x [ j ] ) ) ) cnt + + } } console . log ( cnt ) } Main ( ) var oturi = [ ] ; for ( var i = 0 ; i < = 500 ; i + + ) { var sum = i ; var cnt = 0 ; while ( sum > = 500 ) { sum - = 500 ; cnt + + ; } while ( sum > = 100 ) { sum - = 100 ; cnt + + ; } while ( sum > = 50 ) { sum - = 50 ; cnt + + ; } while ( sum > = 10 ) { sum - = 10 ; cnt + + ; } while ( sum > = 5 ) { sum - = 5 ; cnt + + ; } while ( sum > = 1 ) { sum - = 1 ; cnt + + ; } oturi [ i ] = cnt ; } var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var arr = input . trim ( ) . split ( " \ n " ) ; while ( true ) { var str = arr . shift ( ) ; if ( str = = " 0 0 0 0 0 0 0 " ) break ; var ary = str . split ( " " ) . map ( Number ) ; var P = ary [ 0 ] ; var min = Infinity ; for ( var i = P ; i < P + 500 ; i + + ) { ( function ( p , a , b , c , d , e , f ) { var sum = i ; var cnt = 0 ; while ( sum > = 500 & & f > 0 ) { sum - = 500 ; f -- ; cnt + + ; } while ( sum > = 100 & & e > 0 ) { sum - = 100 ; e -- ; cnt + + ; } while ( sum > = 50 & & d > 0 ) { sum - = 50 ; d -- ; cnt + + ; } while ( sum > = 10 & & c > 0 ) { sum - = 10 ; c -- ; cnt + + ; } while ( sum > = 5 & & b > 0 ) { sum - = 5 ; b -- ; cnt + + ; } while ( sum > = 1 & & a > 0 ) { sum - = 1 ; a -- ; cnt + + ; } if ( sum = = 0 ) min = Math . min ( cnt + oturi [ i - P ] , min ) ; } ) . apply ( null , ary ) ; } console . log ( min ) ; } " use strict " ; const main = arg = > { const n = parseInt ( arg . split ( " \ n " ) [ 0 ] , 10 ) const xy = arg . split ( " \ n " ) . slice ( 1 ) . map ( e = > e . split ( " " ) ) let total = 0 for ( let i = 0 ; i < n ; i + + ) { for ( let j = i + 1 ; j < n ; j + + ) { const diffx = xy [ j ] [ 0 ] - xy [ i ] [ 0 ] const diffy = xy [ j ] [ 1 ] - xy [ i ] [ 1 ] const r = Math . sqrt ( diffx * diffx + diffy * diffy ) total + = r } } console . log ( total * 2 / n ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( input ) { var nums = input . split ( ' \ n ' ) . map ( ( n ) = > parseInt ( n , 10 ) ) ; var ans = 0 ; for ( var i = 0 ; i < 5 ; i + + ) { if ( nums [ i ] % 10 = = 0 ) { ans + = nums [ i ] ; } else { ans + = 10 * ( 1 + Math . floor ( nums [ i ] / 10 ) ) ; } } var hitoketa = [ ] ; for ( var i = 0 ; i < 5 ; i + + ) { if ( nums [ i ] % 10 ! = 0 ) hitoketa . push ( nums [ i ] % 10 ) } var a = Math . min . apply ( null , hitoketa ) ; if ( hitoketa . length ! = 0 & & a ! = 0 ) { console . log ( ans - 10 + a ) ; } else { console . log ( ans ) ; } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ; var numbers = input . split ( ' ' ) ; var sum = 0 ; numbers . forEach ( function ( number ) { sum + = Number ( number ) ; } ) ; console . log ( Math . ceil ( sum / numbers . length ) ) ; var stdin = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var x = parseInt ( stdin , 10 ) ; console . log ( x * x * x ) ; ' use strict ' const main = ( input ) = > { let tasks = input . split ( ' \ n ' ) [ 0 ] . split ( ' ' ) . map ( i = > parseInt ( i ) ) tasks = tasks . sort ( ( a , b ) = > a - b ) let total = 0 for ( let i = 1 ; i < tasks . length ; i + + ) { total + = tasks [ i ] - tasks [ i - 1 ] } console . log ( total ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf-8 ' ) ) ' use strict ' ; ( function ( stdin ) { var inputs = stdin . toString ( ) . trim ( ) . split ( ' \ n ' ) ; var x = inputs ; var set = x * x * x ; console . log ( parseInt ( set ) ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) console . log ( ( args = > { const [ a , b ] = args . trim ( ) . split ( ' ' ) . map ( v = > v | 0 ) ; return Math . ceil ( a / 2 + b / 2 ) . toFixed ( 0 ) ; } ) ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; " use strict " ; function I ( s , f ) { this . _ s = s . split ( " \ n " ) ; this . _ c = 0 ; this . _ l = 0 ; this . _ f = f | | Number } I . prototype . a = function ( ) { var l = this . _ s [ this . _ l ] ; if ( ! l ) return ; var t = l . trim ( ) . split ( " " ) ; var a = t [ this . _ c ] ; this . _ c + + ; if ( t . length = = = this . _ c ) { this . _ c = 0 ; this . _ l + + } return this . _ f ( a ) } ; I . prototype . l = function ( ) { var l = this . _ s [ this . _ l ] ; if ( ! l ) return ; this . _ c = 0 ; this . _ l + + ; return l . split ( " " ) . map ( this . _ f ) } ; module . exports = I ; function main ( input ) { const o = new I ( input , String ) ; let date = o . a ( ) ; if ( date < = " 2019 / 04 / 30 " ) { console . log ( " Heisei " ) ; } else { console . log ( " TBD " ) ; } } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . trim ( ) . split ( " " ) . map ( ( a ) = > Number ( a ) ) ; input . sort ( function ( a , b ) { return b - a ; } ) ; var output = 0 ; output + = Math . abs ( input [ 0 ] - input [ 1 ] ) ; output + = Math . abs ( input [ 2 ] - input [ 1 ] ) ; console . log ( output ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { input = input . trim ( ) ; var a = parseInt ( input . split ( " " ) [ 0 ] , 10 ) ; var b = parseInt ( input . split ( " " ) [ 1 ] , 10 ) ; if ( a = = 1 ) { a = 1000 } if ( b = = 1 ) { b = 1000 } if ( a = = b ) { console . log ( " Draw " ) ; } else if ( a < b ) { console . log ( " Bob " ) ; } else { console . log ( " Alice " ) ; } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; " use strict " function Main ( input ) { let sum = 0 ; input = input . split ( " " ) . map ( e = > parseInt ( e ) ) . sort ( ( a , b ) = > a < b ? 1 : - 1 ) ; let topvalue = input . shift ( ) ; for ( let val of input ) { sum + = topvalue - val ; topvalue = val ; } console . log ( sum ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( " utf8 " ) ; process . stdin . on ( " data " , function ( chunk ) { var input = chunk . trim ( ) . split ( " \ n " ) ; for ( var i = 0 ; i < input . length ; i + + ) { var pairs = input [ i ] . trim ( ) . split ( " " ) ; var a = parseInt ( pairs [ 0 ] ) ; var b = parseInt ( pairs [ 1 ] ) ; console . log ( a + b ) ; } } ) ; function Main ( input ) { input = input . trim ( ) in put = input . split ( " " ) . map ( Number ) ; if ( input [ 0 ] + input [ 1 ] > = input [ 2 ] ) { console . log ( " Yes " ) } else { console . log ( " No " ) } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { const arr = input . trim ( ) . split ( " \ n " ) ; const AV = arr [ 0 ] . split ( " " ) . map ( Number ) ; const BW = arr [ 1 ] . split ( " " ) . map ( Number ) ; const T = Number ( arr [ 2 ] ) ; if ( Math . abs ( AV [ 0 ] - BW [ 0 ] ) < = T * ( AV [ 1 ] - BW [ 1 ] ) ) { console . log ( " YES " ) ; } else { console . log ( " NO " ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; l = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . split ( ' \ n ' ) [ 0 ] . split ( ' ' ) A = l [ 0 ] * 1 B = l [ 1 ] * 1 X = l [ 2 ] * 1 console . log ( A + B > = X ? ' Yes ' : ' No ' ) function heron ( a , b , c ) { var s = ( a + b + c ) / 2 ; var S = Math . sqrt ( s * ( s - a ) * ( s - b ) * ( s - c ) ) ; return S ; } var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var Arr = ( input . trim ( ) ) . split ( " \ n " ) ; for ( var I = 0 ; I < Arr . length ; I + + ) { var arr = Arr [ I ] . split ( " " ) . map ( Number ) ; var x1 = arr [ 0 ] ; var y1 = arr [ 1 ] ; var x2 = arr [ 2 ] ; var y2 = arr [ 3 ] ; var x3 = arr [ 4 ] ; var y3 = arr [ 5 ] ; var xp = arr [ 6 ] ; var yp = arr [ 7 ] ; var d12 = Math . sqrt ( Math . pow ( x2 - x1 , 2 ) + Math . pow ( y2 - y1 , 2 ) ) ; var d13 = Math . sqrt ( Math . pow ( x1 - x3 , 2 ) + Math . pow ( y1 - y3 , 2 ) ) ; var d23 = Math . sqrt ( Math . pow ( x2 - x3 , 2 ) + Math . pow ( y2 - y3 , 2 ) ) ; var dp1 = Math . sqrt ( Math . pow ( xp - x1 , 2 ) + Math . pow ( yp - y1 , 2 ) ) ; var dp2 = Math . sqrt ( Math . pow ( xp - x2 , 2 ) + Math . pow ( yp - y2 , 2 ) ) ; var dp3 = Math . sqrt ( Math . pow ( xp - x3 , 2 ) + Math . pow ( yp - y3 , 2 ) ) ; var S123 = heron ( d12 , d13 , d23 ) ; var s123 = heron ( d12 , dp1 , dp2 ) + heron ( d13 , dp1 , dp3 ) + heron ( d23 , dp2 , dp3 ) ; console . log ( ( Math . abs ( S123 - s123 ) < 0.0005 ) ? " YES " : " NO " ) ; } function main ( input ) { const x = Number ( input ) for ( let a = - 118 ; a < = 119 ; a + + ) { for ( let b = - 119 ; b < = 118 ; b + + ) { if ( a * * 5 - b * * 5 = = = x ) { console . log ( ` $ { a } $ { b } ` ) return } } } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) function Main ( input ) { input = input . split ( " \ n " ) ; var NM = input [ 0 ] . split ( " " ) ; var N = NM [ 0 ] * 1 ; var M = NM [ 1 ] * 1 ; var prefs = [ ] ; var cities = [ ] ; for ( var i = 0 ; i < M ; i + + ) { var a = input [ i + 1 ] ; var P = a . split ( " " ) [ 0 ] * 1 ; var Y = a . split ( " " ) [ 1 ] * 1 ; if ( prefs [ P ] = = = undefined ) prefs [ P ] = [ ] ; prefs [ P ] . push ( { i : i , pref : P , year : Y } ) ; } for ( var i = 0 ; i < = N ; i + + ) { var pref = prefs [ i ] ; if ( ! pref ) continue ; pref . sort ( function ( a , b ) { return a . year - b . year ; } ) for ( var j = 0 ; j < pref . length ; j + + ) { pref [ j ] . ID = ( " 00000 " + pref [ j ] . pref ) . slice ( - 6 ) + ( " 00000 " + ( j + 1 ) ) . slice ( - 6 ) ; cities . push ( pref [ j ] ) ; } } cities . sort ( function ( a , b ) { return a . i - b . i ; } ) return cities . map ( a = > a . ID ) . join ( " \ n " ) ; } console . log ( Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ) ; ' use strict ' function main ( o ) { o = o . split ( ' \ n ' ) . map ( v = > ~ ~ v ) const k = o [ 5 ] const a = o . slice ( 0 , 5 ) let i2 = 0 for ( let i = 0 ; i < a . length ; i + + ) { for ( let j = i + 1 ; j < a . length ; j + + ) { if ( a [ j ] - a [ i ] > k ) { console . log ( ' : ( ' ) return } } } console . log ( ' Yay ! ' ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ' use strict ' const main = ( input ) = > { input = input . split ( ' ' ) . map ( v = > parseInt ( v ) ) const a = input [ 0 ] const b = input [ 1 ] if ( a = = = 1 ) { if ( b = = = 1 ) { console . log ( ' Draw ' ) return } else { console . log ( ' Alice ' ) return } } if ( b = = = 1 ) { console . log ( ' Bob ' ) return } if ( a > b ) { console . log ( ' Alice ' ) } else if ( a < b ) { console . log ( ' Bob ' ) } else { console . log ( ' Draw ' ) } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf-8 ' ) ) function main ( input ) { const a1 = parseInt ( input . split ( " " ) [ 0 ] , 10 ) ; const a2 = parseInt ( input . split ( " " ) [ 1 ] , 10 ) ; const a3 = parseInt ( input . split ( " " ) [ 2 ] , 10 ) ; var arr = [ a1 , a2 , a3 ] var max = Math . max . apply ( null , arr ) ; var min = Math . min . apply ( null , arr ) ; console . log ( max - min ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { Array . prototype . max = function ( ) { return Math . max . apply ( null , this ) } Array . prototype . min = function ( ) { return Math . min . apply ( null , this ) } num = ( val ) = > Array . isArray ( val ) ? val . map ( ( v ) = > Number ( v ) ) : Number ( val ) print = console . log var line = input . split ( " \ n " ) var n = num ( line [ 0 ] ) var a = num ( line [ 1 ] . split ( " " ) ) print ( a . max ( ) - a . min ( ) ) } function Main ( input ) { const n = Number ( input ) ; console . log ( ` $ { ( n * 800 ) - ( 200 * Math . floor ( n / 15 ) ) } ` ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var args = input . split ( ' \ n ' ) ; var N = parseInt ( args [ 0 ] , 10 ) ; var a = args [ 1 ] . split ( ' ' ) . map ( a = > parseInt ( a , 10 ) ) . sort ( ( a , b ) = > ( a < b ? - 1 : 1 ) ) ; console . log ( a [ N - 1 ] - a [ 0 ] ) ; } var toInt = x = > parseInt ( x , 10 ) ; var toIntArr = arr = > arr . map ( x = > toInt ( x ) ) ; var abs = x = > x > 0 ? x : - x ; function min ( ) { var rest = arguments , val = rest [ 0 ] ; for ( var i = 1 ; i < rest . length ; i + + ) if ( rest [ i ] < val ) val = rest [ i ] ; return val } function max ( ) { var rest = arguments , val = rest [ 0 ] ; for ( var i = 1 ; i < rest . length ; i + + ) if ( rest [ i ] > val ) val = rest [ i ] ; return val } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var input = input . split ( ' \ n ' ) ; input = input [ 0 ] . split ( ' ' ) ; var as = toIntArr ( input ) . sort ( function ( a , b ) { return a - b } ) ; console . log ( as [ 2 ] - as [ 0 ] ) ; } " use strict " ; const main = arg = > { arg = arg . split ( " \ n " ) ; const k = parseInt ( arg . slice ( 5 , 6 ) ) ; const antennas = arg . slice ( 0 , 5 ) . map ( n = > parseInt ( n ) ) ; for ( let i = 0 ; i < antennas . length ; i + + ) { for ( let j = i + 1 ; j < antennas . length ; j + + ) { if ( antennas [ j ] - antennas [ i ] > k ) { console . log ( " : ( " ) ; return ; } } } console . log ( " Yay ! " ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' function Main ( input ) { const arr = input . split ( " " ) ; let count5 = 0 ; let count7 = 0 ; arr . forEach ( a = > { if ( a = = 5 ) { count5 + + ; } else if ( a = = 7 ) { count7 + + ; } } ) ; if ( count5 = = 2 & & count7 = = 1 ) { console . log ( " YES " ) ; } else { console . log ( " NO " ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' function main ( input ) { input = input . trim ( ) . split ( ' \ n ' ) . map ( v = > v . split ( ' ' ) ) const N = parseInt ( input [ 0 ] [ 0 ] , 10 ) const D = parseInt ( input [ 0 ] [ 1 ] , 10 ) const p = input . slice ( 1 ) let count = 0 for ( let i = 0 ; i < N ; i + + ) { for ( let j = i + 1 ; j < N ; j + + ) { let sum = 0 for ( let k = 0 ; k < D ; k + + ) { sum + = Math . pow ( p [ i ] [ k ] - p [ j ] [ k ] , 2 ) } const sqrt = Math . sqrt ( sum ) if ( sqrt = = = Math . floor ( sqrt ) ) count + + } } console . log ( count ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ' use strict ' const main = ( input ) = > { input = input . split ( ' \ n ' ) . slice ( 0 , 5 ) let tmpIndex = 0 ; let tmp = 9 ; input . forEach ( ( item , index ) = > { const num = Number ( item . slice ( - 1 ) ) if ( num < tmp & & num ! = = 0 ) { tmp = num tmpIndex = index } } ) let sum = 0 in put . forEach ( ( item , index ) = > { if ( tmpIndex = = = index ) { sum + = Number ( item ) } else { sum + = Math . ceil ( Number ( item ) / 10 ) * 10 } } ) console . log ( sum ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf-8 ' ) ) function main ( input ) { const tmp = input . trim ( ) . split ( ' \ n ' ) . map ( ( n ) = > parseInt ( n , 10 ) ) if ( tmp [ 4 ] - tmp [ 0 ] < = tmp [ 5 ] ) { console . log ( ' Yay ! ' ) } else { console . log ( ' : ( ' ) } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) function Main ( input ) { input = input . trim ( ) . split ( " \ n " ) . map ( ( input ) = > Number ( input ) ) ; var k = input [ 5 ] ; for ( var i = 0 ; i < 5 ; i + + ) { for ( var j = i + 1 ; j < 5 ; j + + ) { if ( input [ j ] - input [ i ] > k ) { console . log ( " : ( " ) ; return ; } } } console . log ( " Yay ! " ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { var a = input [ 0 ] . split ( " " ) [ 0 ] - 0 ; var b = input [ 0 ] . split ( " " ) [ 1 ] - 0 ; var c = input [ 0 ] . split ( " " ) [ 2 ] - 0 ; console . log ( a + b > = c ? " Yes " : " No " ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . trim ( ) . split ( " \ n " ) ) ' use strict ' const main = arg = > { const input = arg . trim ( ) . split ( " \ n " ) ; let N = Number ( input [ 0 ] . split ( ' ' ) [ 0 ] ) console . log ( N * 800 - Math . floor ( N / 15 ) * 200 ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' const main = input = > { const args = input . split ( ' \ n ' ) const yyyy = args [ 0 ] . slice ( 0 , 4 ) const mm = args [ 0 ] . slice ( 5 , 7 ) const dd = args [ 0 ] . slice ( 8 , 10 ) if ( parseInt ( ` $ { yyyy } $ { mm } $ { dd } ` , 10 ) < = 20190430 ) console . log ( ' Heisei ' ) else console . log ( ' TBD ' ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) function Main ( input ) { input = input . split ( " \ n " ) ; if ( input [ input . length - 1 ] = = = ' ' ) { input . pop ( ) ; } const N = input [ 0 ] . split ( ' ' ) [ 0 ] - 0 ; const P = input [ 1 ] . split ( ' ' ) . map ( e = > { return e - 0 ; } ) ; var min = Infinity ; var ret = 0 ; P . forEach ( e = > { if ( min > = e ) { ret + + ; min = e ; } } ) ; console . log ( ret ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; fs = require ( " fs " ) ; l = fs . readFileSync ( " / dev / stdin " , " utf8 " ) . split ( " \ n " ) ; x = [ ] ; for ( i = 0 ; i < 6 ; i + + ) { x . push ( parseInt ( l [ i ] ) ) ; } if ( x [ 4 ] - x [ 0 ] < = x [ 5 ] ) { console . log ( ' Yay ! ' ) ; } else { console . log ( ' : ( ' ) ; } const input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) const inputNum = parseInt ( input ) console . log ( inputNum * inputNum * inputNum ) function Main ( input ) { const ab = input . split ( " " ) ; const a = parseFloat ( ab [ 0 ] ) ; const b = parseFloat ( ab [ 1 ] ) ; const list = [ 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 1 ] ; const aI = list . indexOf ( a ) ; const bI = list . indexOf ( b ) ; if ( aI < bI ) { console . log ( " Bob " ) ; return ; } if ( bI < aI ) { console . log ( " Alice " ) ; return ; } if ( aI = = bI ) { console . log ( " Draw " ) ; return ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; const input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . split ( ' \ n ' ) . map ( Number ) ; console . log ( Math . pow ( input [ 0 ] , 3 ) ) ; ' use strict ' ; function Main ( input ) { const temp = input . split ( " " ) ; const n = temp [ 0 ] ; const k = temp [ 1 ] ; let ans ; if ( k = = 1 ) ans = 0 ; else ans = n - k ; console . log ( ans ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' const main = input = > { const args = input . split ( ' \ n ' ) . map ( arg = > arg . split ( ' ' ) ) const a = args . slice ( 0 , 5 ) . map ( arg = > parseInt ( arg [ 0 ] , 10 ) ) const k = parseInt ( args [ 5 ] [ 0 ] , 10 ) let flg = true for ( let i = 0 ; i < ( 5 - 1 ) ; i + + ) { for ( let j = ( i + 1 ) ; j < 5 ; j + + ) { if ( a [ j ] - a [ i ] > k ) flg = false } } if ( flg ) console . log ( ' Yay ! ' ) else console . log ( ' : ( ' ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) function Main ( input ) { input = input . split ( " " ) . sort ( ) . join ( " " ) ; console . log ( input = = " 1479 " ? " YES " : " NO " ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) ) ; function main ( input ) { const a = parseInt ( input . split ( " \ n " ) [ 0 ] , 10 ) ; const b = parseInt ( input . split ( " \ n " ) [ 1 ] , 10 ) ; const c = parseInt ( input . split ( " \ n " ) [ 2 ] , 10 ) ; const d = parseInt ( input . split ( " \ n " ) [ 3 ] , 10 ) ; const e = parseInt ( input . split ( " \ n " ) [ 4 ] , 10 ) ; const k = parseInt ( input . split ( " \ n " ) [ 5 ] , 10 ) ; if ( e - a > k ) { console . log ( " : ( " ) ; } else { console . log ( " Yay ! " ) ; } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' function main ( inp ) { inp = inp . trim ( ) . split ( ' \ n ' ) ; const N = Number ( inp . shift ( ) ) in p = inp . map ( r = > r . split ( ' ' ) . map ( n = > Number ( n ) ) ) let sum = 0 for ( let i = 0 ; i < N ; i + + ) { for ( let j = 0 ; j < N ; j + + ) { const x = Math . pow ( inp [ i ] [ 0 ] - inp [ j ] [ 0 ] , 2 ) const y = Math . pow ( inp [ i ] [ 1 ] - inp [ j ] [ 1 ] , 2 ) sum + = Math . sqrt ( x + y ) } } console . log ( sum / N ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { input = input . split ( ' ' ) ; var age = input [ 0 ] ; var few = input [ 1 ] ; if ( age < 6 ) { console . log ( 0 ) ; } else if ( age > 12 ) { console . log ( few ) ; } else { console . log ( few / 2 ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; const input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) let cin = input . split ( / | \ n / ) , cid = 0 const next = ( ) = > cin [ cid + + ] const nexts = ( n ) = > cin . slice ( cid , cid + = n ) . map ( i = > parseInt ( i ) ) const T = next ( ) const array = T . split ( ' ' ) . map ( ( item ) = > { if ( item = = = ' ? ' ) { return ' D ' } else { return item } } ) console . log ( array . join ( ' ' ) ) function Main ( input ) { input = input . split ( " \ n " ) ; if ( input [ input . length - 1 ] = = = ' ' ) { input . pop ( ) ; } const N = input [ 0 ] - 0 ; const X = input [ 1 ] . split ( ' ' ) . map ( e = > { return e - 0 ; } ) ; var sum = 0 ; X . forEach ( e = > { sum + = e ; } ) ; var p = Math . round ( sum / N ) ; sum = 0 ; X . forEach ( e = > { sum + = ( e - p ) * * 2 ; } ) ; console . log ( sum ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( " " ) ; var ages = parseInt ( input [ 0 ] ) ; var price = parseInt ( input [ 1 ] ) ; var show = 0 ; if ( ages > = 13 ) { show = price ; } else if ( ages < = 12 & & ages > = 6 ) { show = price / 2 ; } else { show = 0 ; } console . log ( show ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' const main = arg = > { const input = arg . trim ( ) . split ( " \ n " ) ; console . log ( input * input * input ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ( input = > { input = input . split ( ' ' ) . map ( Number ) ; const a = input [ 0 ] , b = input [ 1 ] ; console . log ( Math . ceil ( ( a + b ) / 2 ) ) } ) ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) " use strict " const main = arg = > { arg = arg . trim ( ) . split ( " \ n " ) ; const n = ~ ~ ( arg [ 0 ] . split ( " " ) [ 0 ] ) ; const m = ~ ~ ( arg [ 0 ] . split ( " " ) [ 1 ] ) ; const a = arg . slice ( 1 , n + 1 ) . map ( n = > n . split ( " " ) ) ; const b = arg . slice ( n + 1 , ( n + 1 ) + ( m + 1 ) ) . map ( n = > n . split ( " " ) ) ; let answer = false ; const A = [ ] ; const B = [ ] ; for ( let i = 0 ; i < m ; i + + ) { for ( let j = 0 ; j < m ; j + + ) { A . push ( i ) ; B . push ( j ) ; } } for ( let i = 0 ; i < n ; i + + ) { for ( let j = 0 ; j < n ; j + + ) { for ( let k = 0 , len = Math . pow ( m , 2 ) ; k < len ; k + + ) { const X = i + A [ k ] ; const Y = j + B [ k ] ; if ( X < 0 | | n < = X ) break ; if ( Y < 0 | | n < = Y ) break ; if ( a [ X ] [ Y ] ! = = b [ A [ k ] ] [ B [ k ] ] ) break ; if ( k = = = ( len - 1 ) ) answer = true ; } } } console . log ( answer ? " Yes " : " No " ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var stdin = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var inputs = stdin . toString ( ) . trim ( ) ; var x = parseInt ( inputs , 10 ) ; console . log ( Math . pow ( x , 3 ) ) ; " use strict " ; var _ _ importDefault = ( this & & this . _ _ importDefault ) | | function ( mod ) { return ( mod & & mod . _ _ esModule ) ? mod : { " default " : mod } ; } ; Object . defineProperty ( exports , " _ _ esModule " , { value : true } ) ; const readline _ 1 = _ _ importDefault ( require ( " readline " ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; const reader = readline _ 1 . default . createInterface ( { input : process . stdin , output : process . stdout , } ) ; const lines = [ ] ; reader . on ( ' line ' , line = > { lines . push ( line ) ; } ) ; reader . on ( ' close ' , ( ) = > { const r = Number ( lines [ 0 ] ) ; console . log ( Math . pow ( r , 2 ) ) ; } ) ; var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var arr = input . trim ( ) . split ( " \ n " ) ; while ( true ) { var [ n , m ] = arr . shift ( ) . split ( " " ) . map ( Number ) ; if ( n = = 0 & & m = = 0 ) break ; var x = m / n ; var sum = 0 ; var a = arr . shift ( ) . split ( " " ) . map ( Number ) ; a . forEach ( v = > { if ( v > = x ) sum + = x ; else sum + = v ; } ) ; console . log ( sum ) ; } function main ( input ) { var inputs = input . split ( " \ n " ) ; var S = inputs . shift ( ) ; console . log ( S < = " 2019 / 04 / 30 " ? " Heisei " : " TBD " ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; var S = input [ 0 ] . split ( " / " ) ; var ans = " Heisei " ; if ( parseInt ( S [ 0 ] ) > = 2020 | | ( parseInt ( S [ 0 ] ) > = 2019 & & parseInt ( S [ 1 ] ) > = 5 ) ) { ans = " TBD " ; } console . log ( ' % s ' , ans ) ; return ans ; } function debug ( n ) { var input = document . getElementById ( " input " + n ) . value ; Main ( input ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' ; ( function ( stdin ) { var inputs = stdin . toString ( ) ; var x = inputs . trim ( ) . split ( ' \ n ' ) . map ( Number ) [ 0 ] ; console . log ( Math . pow ( x , 3 ) ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; function main ( input ) { const a = input . split ( " " ) . map ( Number ) ; console . log ( a [ 0 ] = = a [ 1 ] ? " Draw " : ( a [ 0 ] = = 1 | | ( a [ 1 ] ! = 1 & & a [ 0 ] > a [ 1 ] ) ) ? " Alice " : " Bob " ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var s = input . trim ( ) ; for ( var i = 0 ; i < s . length - 7 ; i + + ) { var arr = [ s [ i ] , s [ i + 1 ] , s [ i + 2 ] , s [ i + 3 ] , s [ i + 4 ] , s [ i + 5 ] , s [ i + 6 ] , s [ i + 7 ] ] ; if ( arr . join ( " " ) = = " AIZUNYAN " ) { i + = 7 ; continue ; } var str = arr . sort ( ) . join ( " " ) ; if ( str = = " AADINNUY " ) { s = s . slice ( 0 , i ) + " AIZUNYAN " + s . slice ( i + 8 , s . length ) ; i + = 7 ; } } console . log ( s ) ; ' use strict ' const main = input = > { const args = input . trim ( ) . split ( ' \ n ' ) const x = [ ] let cnt = 0 for ( let i = 1 ; i < args . length ; i + + ) { x . push ( args [ i ] . split ( ' ' ) . map ( Number ) ) } for ( let i = 0 ; i < x . length ; i + + ) { for ( let j = 0 ; j < x . length ; j + + ) { if ( i > = j ) continue let sum = 0 for ( let k = 0 ; k < x [ i ] . length ; k + + ) { sum + = Math . pow ( x [ i ] [ k ] - x [ j ] [ k ] , 2 ) } if ( Math . sqrt ( sum ) % 1 = = = 0 ) cnt + + } } console . log ( cnt ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) function main ( input ) { const A = parseInt ( input , 10 ) ; console . log ( A * A ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; " use strict " ; var input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ; var cin = input . split ( / | \ n / ) , cid = 0 ; function next ( ) { return + cin [ cid + + ] ; } function nextstr ( ) { return cin [ cid + + ] ; } function nextbig ( ) { return BigInt ( cin [ cid + + ] ) ; } function nexts ( n , a ) { return a ? cin . slice ( cid , cid + = n ) : cin . slice ( cid , cid + = n ) . map ( a = > + a ) ; } function nextm ( h , w , a ) { var r = [ ] , i = 0 ; if ( a ) for ( ; i < h ; i + + ) r . push ( cin . slice ( cid , cid + = w ) ) ; else for ( ; i < h ; i + + ) r . push ( cin . slice ( cid , cid + = w ) . map ( a = > + a ) ) ; return r ; } function xArray ( v ) { var a = arguments , l = a . length , r = " Array ( a [ " + -- l + " ] ) .fill ( ) .map ( x = > { return " + v + " ; } ) " ; while ( -- l ) r = " Array ( a [ " + l + " ] ) .fill ( ) .map ( x = > " + r + " ) " ; return eval ( r ) ; } var myOut = main ( ) ; if ( myOut ! = = undefined ) console . log ( String ( myOut ) ) ; function main ( ) { var [ a , v , b , w , t ] = nexts ( 5 ) ; var l = Math . abs ( a - b ) ; if ( v < = w ) return " NO " ; var dv = v - w ; return l / dv < = t ? " YES " : " NO " ; } ' use strict ' function main ( input ) { const sum = input . split ( / \ s / ) . map ( v = > ~ ~ v ) . reduce ( ( a , b ) = > a + b ) const ans = Math . ceil ( sum / 2 ) console . log ( ans ) } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( " " ) ; var a = input [ 0 ] ; var b = input [ 1 ] ; var c = input [ 2 ] ; var d = input [ 3 ] ; var answer = a * b ; var tmpA = c * d ; if ( answer < tmpA ) answer = tmpA ; console . log ( ' % s ' , answer ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function myOut ( text ) { console . log ( text ) ; } function Main ( input ) { input = input . trim ( ) ; input = input . split ( " \ n " ) . map ( ( a ) = > Number ( a ) ) ; input . sort ( function ( a , b ) { return b % 10 - a % 10 ; } ) ; var zero = [ ] ; var output = 0 ; for ( var i = 0 ; i < input . length ; i + + ) { if ( input [ i ] % 10 = = 0 ) { zero . push ( input [ i ] ) ; input . splice ( i , 1 ) ; i -- ; } } var last = 0 ; if ( input . length ! = 0 ) { last = input [ input . length - 1 ] ; } for ( var i = 0 ; i < input . length - 1 ; i + + ) { output + = input [ i ] + ( 10 - input [ i ] % 10 ) ; } for ( var i = 0 ; i < zero . length ; i + + ) { output + = zero [ i ] ; } myOut ( output + last ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; tmp = input [ 0 ] . split ( " " ) ; var a = parseInt ( tmp [ 0 ] , 10 ) ; var b = parseInt ( tmp [ 1 ] , 10 ) ; var c = parseInt ( tmp [ 2 ] , 10 ) ; var answer = " Yes " ; if ( a + b < c ) { answer = " No " ; } console . log ( answer ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' function main ( input ) { input = input . trim ( ) . split ( ' \ n ' ) in put . shift ( ) let count = [ ] let aMap = new Map in put = input . map ( c = > { let arr = c . split ( ' ' ) . map ( w = > w - 0 ) if ( count [ arr [ 0 ] ] = = = undefined ) count [ arr [ 0 ] ] = [ ] count [ arr [ 0 ] ] . push ( arr [ 1 ] ) aMap . set ( arr [ 1 ] , ' ' ) } ) count . forEach ( ( v , i ) = > { v . sort ( ( a , b ) = > a - b ) v . forEach ( ( y , j ) = > { let id = ( ' 000000 ' + i ) . slice ( - 6 ) id + = ( ' 000000 ' + ( j + 1 ) ) . slice ( - 6 ) aMap . set ( y , id ) } ) } ) aMap . forEach ( v = > console . log ( v ) ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { var num = parseInt ( chunk ) ; console . log ( num * num * num ) ; } ) ; let x = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' UTF-8 ' ) ; console . log ( x * x * x ) ; " use strict " const Main = ( input ) = > { const Array = input . split ( " " ) const A = parseInt ( Array [ 0 ] , 10 ) const B = parseInt ( Array [ 1 ] , 10 ) const C = parseInt ( Array [ 2 ] , 10 ) const Answer = ( A + B ) > = C ? " Yes " : " No " console . log ( Answer ) } Main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; let x = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf-8 " ) ; x = parseInt ( x ) ; const pro = x * x * x ; console . log ( pro ) ; ' use strict ' ; process . stdin . on ( ' data ' , function ( chunk ) { var lines = chunk . toString ( ) . split ( ' \ n ' ) ; var result = ( function ( data ) { return Math . pow ( data , 3 ) ; } ( parseInt ( lines [ 0 ] , 10 ) ) ) ; console . log ( result ) ; } ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; ' use strict ' ; function Main ( INPUT ) { const N = INPUT . split ( " " ) . map ( n = > Number ( n ) ) ; console . log ( ( N [ 0 ] + N [ 1 ] ) - N [ 2 ] > = 0 ? " Yes " : " No " ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " ; function main ( input ) { input = input . trim ( ) . split ( " " ) ; for ( let i = 0 ; i < input . length ; i + + ) { if ( input [ i ] = = " ? " ) { input [ i ] = " D " ; } } console . log ( input . join ( " " ) ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf-8 " ) ) ; var x = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . trim ( ) ; console . log ( Math . pow ( x , 3 ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { var line = chunk . toString ( ) . split ( ' ' ) ; var x = Number ( line [ 0 ] ) ; var y = Math . pow ( x , 3 ) ; console . log ( y ) ; } ) ; ' use strict ' const main = input = > { const args = input . split ( ' ' ) const a = parseInt ( args [ 0 ] , 10 ) const b = parseInt ( args [ 1 ] , 10 ) console . log ( Math . ceil ( ( a + b ) / 2 ) ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) inp = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . trim ( ) . split ( ' \ n ' ) N = inp . shift ( ) * 1 a = inp . shift ( ) . split ( ' ' ) . map ( x = > x - 0 ) min = a [ 0 ] c = 1 for ( i = 1 ; i < N ; i + + ) { if ( min > a [ i ] ) { c + + min = a [ i ] } } console . log ( c ) function Main ( input ) { var min _ amari = 100 ; var sum = 0 ; for ( var i = 0 ; i < 5 ; i + + ) { var time = parseInt ( input [ i ] ) ; min _ amari = Math . min ( min _ amari , ( ( time + 9 ) % 10 ) + 1 ) ; sum + = Math . floor ( ( time + 9 ) / 10 ) * 10 ; } sum = sum - 10 + min _ amari ; console . log ( sum ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) . split ( / \ n | \ s / ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { console . log ( Math . pow ( chunk , 3 ) ) ; } ) ; function Main ( input ) { input = input . split ( " \ n " ) ; var n = parseInt ( input [ 0 ] , 10 ) ; var x = input [ 1 ] . split ( " " ) ; var min = 0 ; var maxx = 0 ; for ( var i = 0 ; i < n ; i + + ) { if ( maxx < x [ i ] ) { maxx = x [ i ] ; } } for ( var j = 1 ; j < = maxx ; j + + ) { var s = 0 ; for ( var k = 0 ; k < n ; k + + ) { s = s + ( ( x [ k ] - j ) * ( x [ k ] - j ) ) ; } if ( min = = 0 | | min > s ) { min = s ; } } console . log ( ' % d ' , min ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " ; function Main ( input ) { const lines = input . split ( " \ n " ) ; var x = parseInt ( lines [ 0 ] ) ; console . log ( Math . pow ( x , 3 ) ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; const main = arg = > { const [ a , b , h , m ] = arg . trim ( ) . split ( ' \ n ' ) [ 0 ] . split ( ' ' ) . map ( x = > Number ( x ) ) ; const minuteDeg = m / 60 ; const hourDeg = ( h / 12 + m / 720 ) ; console . log ( Math . sqrt ( a * * 2 + b * * 2 - 2 * a * b * Math . cos ( Math . abs ( minuteDeg - hourDeg ) * 2 * Math . PI ) ) ) ; } ; main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { var line = input . split ( " \ n " ) ; var N = Number ( line [ 0 ] ) ; var S = line [ 1 ] . split ( " " ) ; var ans = " Three " for ( var i = 0 ; i < N ; i + + ) { if ( S [ i ] = = = " Y " ) ans = " Four " ; } console . log ( ans ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { var lines = input . split ( " " ) . map ( n = > parseInt ( n , 10 ) ) ; var result = ( lines [ 0 ] + lines [ 1 ] + lines . length - 1 ) / lines . length ; console . log ( parseInt ( result , 10 ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' UTF-8 ' ) ) ; " use strict " ; var input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ; var cin = input . split ( / | \ n / ) , cid = 0 ; function next ( a ) { return a ? cin [ cid + + ] : + cin [ cid + + ] ; } function nexts ( n , a ) { return a ? cin . slice ( cid , cid + = n ) : cin . slice ( cid , cid + = n ) . map ( a = > + a ) ; } function nextm ( h , w , a ) { var r = [ ] , i = 0 ; if ( a ) for ( ; i < h ; i + + ) r . push ( cin . slice ( cid , cid + = w ) ) ; else for ( ; i < h ; i + + ) r . push ( cin . slice ( cid , cid + = w ) . map ( a = > + a ) ) ; return r ; } function xArray ( v ) { var a = arguments , l = a . length , r = " Array ( a [ " + -- l + " ] ) .fill ( ) .map ( x = > { return " + v + " ; } ) " ; while ( -- l ) r = " Array ( a [ " + l + " ] ) .fill ( ) .map ( x = > " + r + " ) " ; return eval ( r ) ; } var myOut = main ( ) ; if ( myOut ! = = undefined ) console . log ( myOut ) ; function main ( ) { var n = next ( ) ; var x = nexts ( n ) ; var ans = 1e9 ; for ( var i = 1 ; i < = 100 ; i + + ) { var sum = 0 ; for ( var j = 0 ; j < n ; j + + ) { var t = i - x [ j ] ; sum + = t * t ; } if ( sum < ans ) ans = sum ; } return ans ; } function main ( input ) { console . log ( input * input * input ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; var line = input [ 0 ] . split ( " " ) ; var max = parseInt ( line [ 0 ] ) ; var sum = parseInt ( line [ 1 ] ) ; var count = 0 ; for ( var x = 0 ; x < = max ; x + + ) { for ( var y = 0 ; y < = max ; y + + ) { var z = sum - ( x + y ) ; if ( z > = 0 & & z < = max ) { count + + ; } } } console . log ( count ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( ' ' ) . map ( Number ) ; const a = input [ 0 ] , b = input [ 1 ] ; console . log ( Math . ceil ( ( a + b ) / 2 ) ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; let main = function ( standardInput ) { let lengthList = standardInput . split ( ' ' ) ; let varticalLength = Number . parseInt ( lengthList [ 0 ] ) ; console . log ( varticalLength * varticalLength * varticalLength ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' UTF-8 ' ) ) ; ' use strict ' const main = ( input ) = > { const nums = input . split ( ' \ n ' ) [ 1 ] . split ( ' ' ) . map ( v = > parseInt ( v ) ) . sort ( ( a , b ) = > a - b ) console . log ( nums [ nums . length - 1 ] - nums [ 0 ] ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf-8 ' ) ) var out = function ( x ) { console . log ( x ) ; } var calc = function ( x ) { return x * x * x ; } process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( x ) { console . log ( calc ( x ) ) ; } ) ; var lines = [ ] ; var readline = require ( ' readline ' ) ; var rl = readline . createInterface ( { input : process . stdin , output : process . stdout , } ) ; rl . on ( ' line ' , function ( x ) { lines . push ( x ) ; } ) ; rl . on ( ' close ' , function ( ) { var v = [ ] ; for ( var i = 0 ; i < 5 ; i + + ) { v [ i ] = Number ( lines [ i ] ) ; } var result = Infinity ; var NextTime = Array ( 5 ) ; for ( var i = 0 ; i < 5 ; i + + ) { if ( v [ i ] % 10 = = = 0 ) { NextTime [ i ] = v [ i ] ; } else { NextTime [ i ] = v [ i ] - v [ i ] % 10 + 10 } } for ( var i = 0 ; i < 5 ; i + + ) { var Time = 0 ; for ( var j = 0 ; j < 5 ; j + + ) { i = = = j ? Time + = v [ j ] : Time + = NextTime [ j ] ; } result = Math . min ( result , Time ) ; } console . log ( result ) ; } ) ; const input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; const input _ lines = input . split ( ' \ n ' ) ; input _ lines . forEach ( line = > { if ( line . length > 0 ) { const inputs = line . split ( ' ' ) ; if ( ' 5,5,7 ' = = = inputs . sort ( ) . toString ( ) ) { console . log ( ' YES ' ) ; } else { console . log ( ' NO ' ) ; } } } ) ; a = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . split ( ' / ' ) . map ( Number ) ; console . log ( a [ 0 ] > = 2019 & & a [ 1 ] > = 5 ? ' TBD ' : ' Heisei ' ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { var lines = chunk . toString ( ) . split ( ' ' ) ; var x = 0 ; x = lines [ 0 ] ; console . log ( x * x * x ) ; } ) ; function Main ( input ) { input = input . split ( " " ) ; var K = parseInt ( input [ 0 ] , 10 ) ; var S = parseInt ( input [ 1 ] , 10 ) ; var x ; var y ; var z ; var count = 0 ; for ( var i = 0 ; i < = K ; i + + ) { x = i ; for ( var j = 0 ; j < = K ; j + + ) { y = j ; z = S - ( x + y ) ; if ( ( z > = 0 ) & & ( z < = K ) ) { count + = 1 ; } } } console . log ( count ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var square = function ( x ) { return x * x * x ; } process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( x ) { console . log ( square ( x ) ) ; } ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( x ) { var input = x console . log ( Math . pow ( input , 3 ) ) } ) ( function ( input ) { var a = parse ( input , ' ' ) ; for ( var i = 0 ; i < a . length ; i + + ) { var n = a [ i ] . map ( Number ) ; if ( n . join ( ) = = ' 0 ' ) { return ; } console . log ( n . reduce ( function ( p , c ) { return p + c ; } ) ) } } ) ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function parse ( str , sep , ter ) { sep = typeof ( sep ) ! = = ' undefined ' ? sep : ' ' ; ter = typeof ( ter ) ! = = ' undefined ' ? ter : ' \ n ' ; str = str . replace ( / \ n $ / , ' ' ) ; var a = str . split ( ter ) ; for ( var i = 0 ; i < a . length ; i + + ) { a [ i ] = a [ i ] . split ( sep ) ; } return a ; } function main ( input ) { input = input . trim ( ) ; const [ a , b , c ] = input . split ( ' ' ) . map ( Number ) ; console . log ( a * b * c = = 175 ? ' YES ' : ' NO ' ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function heron ( a , b , c ) { var s = ( a + b + c ) / 2 ; var S = Math . sqrt ( s * ( s - a ) * ( s - b ) * ( s - c ) ) ; return S ; } var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var Arr = ( input . trim ( ) ) . split ( " \ n " ) ; for ( var I = 0 ; I < Arr . length ; I + + ) { var arr = Arr [ I ] . split ( " " ) . map ( Number ) ; var x1 = arr [ 0 ] ; var y1 = arr [ 1 ] ; var x2 = arr [ 2 ] ; var y2 = arr [ 3 ] ; var x3 = arr [ 4 ] ; var y3 = arr [ 5 ] ; var xp = arr [ 6 ] ; var yp = arr [ 7 ] ; var d12 = Math . sqrt ( Math . pow ( x1 - x2 , 2 ) + Math . pow ( y1 - y2 , 2 ) ) ; var d13 = Math . sqrt ( Math . pow ( x1 - x3 , 2 ) + Math . pow ( y1 - y3 , 2 ) ) ; var d23 = Math . sqrt ( Math . pow ( x2 - x3 , 2 ) + Math . pow ( y2 - y3 , 2 ) ) ; var dp1 = Math . sqrt ( Math . pow ( xp - x1 , 2 ) + Math . pow ( yp - y1 , 2 ) ) ; var dp2 = Math . sqrt ( Math . pow ( xp - x2 , 2 ) + Math . pow ( yp - y2 , 2 ) ) ; var dp3 = Math . sqrt ( Math . pow ( xp - x3 , 2 ) + Math . pow ( yp - y3 , 2 ) ) ; var S123 = heron ( d12 , d13 , d23 ) ; var s123 = heron ( d12 , dp1 , dp2 ) + heron ( d13 , dp1 , dp3 ) + heron ( d23 , dp2 , dp3 ) ; console . log ( ( Math . abs ( S123 - s123 ) < 0.0005 ) ? " YES " : " NO " ) ; } ' use strict ' ; ( function ( stdin ) { var inputs = stdin . toString ( ) . trim ( ) . split ( ' \ n ' ) ; ( function ( x ) { console . log ( Math . pow ( x , 3 ) ) ; } ) ( parseInt ( inputs [ 0 ] , 10 ) ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; var x = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf-8 ' ) ; function main ( input ) { var temp = parseInt ( input ) ; var answer = Math . pow ( temp , 3 ) ; console . log ( answer ) ; } main ( x ) ; function main ( input ) { var list = input . split ( " \ n " ) ; var time = 0 ; list = list . map ( ( item ) = > { var min = + item % 10 > 0 ? 10 * ( parseInt ( + item / 10 ) + 1 ) : + item ; return { chori : + item , chumon : min , rug : min - + item } ; } ) ; list . sort ( ( x , y ) = > { return x . rug - y . rug ; } ) ; list . forEach ( ( item , index ) = > { if ( index = = = list . length - 1 ) { time + = item . chori ; } else { time + = item . chumon ; } } ) ; console . log ( time ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var x = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; console . log ( x * x * x ) ; " use strict " ; var input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ; var cin = input . trim ( ) . split ( / | \ n / ) , cid = 0 ; function main ( ) { let X = + cin . shift ( ) ; let s = 0 ; while ( true ) { for ( let a = 0 ; a < = s ; a + + ) { let b = s - a ; let ma = - a ; let mb = - b ; if ( a * * 5 - b * * 5 = = X ) { console . log ( a , b ) ; return ; } if ( a * * 5 - mb * * 5 = = X ) { console . log ( a , mb ) ; return ; } if ( ma * * 5 - b * * 5 = = X ) { console . log ( ma , b ) ; return ; } if ( ma * * 5 - mb * * 5 = = X ) { console . log ( ma , mb ) ; return ; } } s + + ; } } main ( ) ; const main = stdin = > { const dishes = [ A , B , C , D , E ] = stdin . trim ( ) . split ( ' \ n ' ) . map ( ( x ) = > parseInt ( x ) ) let time = 999999 for ( let i = 0 ; i < 5 ; i + + ) { for ( let j = 0 ; j < 5 ; j + + ) { if ( i = = = j ) continue for ( let k = 0 ; k < 5 ; k + + ) { if ( i = = = k | | j = = = k ) continue for ( let l = 0 ; l < 5 ; l + + ) { if ( i = = = l | | j = = = l | | k = = = l ) continue for ( let m = 0 ; m < 5 ; m + + ) { if ( i = = = m | | j = = = m | | k = = = m | | l = = = m ) continue let tmpTime = dishes [ i ] ; if ( tmpTime % 10 ! = = 0 ) { tmpTime + = 10 - tmpTime % 10 } tmpTime + = dishes [ j ] ; if ( tmpTime % 10 ! = = 0 ) { tmpTime + = 10 - tmpTime % 10 } tmpTime + = dishes [ k ] ; if ( tmpTime % 10 ! = = 0 ) { tmpTime + = 10 - tmpTime % 10 } tmpTime + = dishes [ l ] ; if ( tmpTime % 10 ! = = 0 ) { tmpTime + = 10 - tmpTime % 10 } tmpTime + = dishes [ m ] ; time = Math . min ( time , tmpTime ) } } } } } console . log ( time ) } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) const main = ( input ) = > { const s = Number ( input . trim ( ) ) for ( let x = 0 ; x < = 1000 ; x + + ) { for ( let y = - 1000 ; y < = 999 ; y + + ) { if ( x * * 5 - y * * 5 = = = s ) return console . log ( ` $ { x } $ { y } ` ) } } } process . env . MYTEST ? ( process . env . MYTEST = = = ' test ' ? test ( ) : main ( require ( ' fs ' ) . readFileSync ( ' dev / stdin ' , ' utf8 ' ) ) ) : main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) var data = ' ' ; var readable = process . stdin ; readable . resume ( ) ; readable . setEncoding ( ' utf-8 ' ) ; readable . on ( ' data ' , function ( chunk ) { data + = chunk ; } ) readable . on ( ' end ' , function ( ) { var x = parseInt ( data ) ; console . log ( ' % d ' , Math . pow ( x , 3 ) ) ; } ) x = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; console . log ( x * x * x ) ; function Main ( ) { var input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf-8 " ) . trim ( ) ; var items = input . split ( " " ) . map ( function ( item ) { return parseInt ( item ) ; } ) ; items . sort ( ) ; var target = [ 5 , 5 , 7 ] ; var flag = true ; for ( var i = 0 ; i < 3 ; + + i ) { if ( items [ i ] ! = target [ i ] ) { flag = false ; break ; } } console . log ( flag ? " YES " : " NO " ) ; } Main ( ) ; ( function ( stdin ) { const inputs = stdin . toString ( ) . trim ( ) . split ( ' \ n ' ) ; const result = ( function ( a ) { return Math . pow ( a , 3 ) ; } ( parseInt ( inputs [ 0 ] , 10 ) ) ) ; console . log ( result ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; function Main ( input ) { const inputs = input . split ( " " ) ; a = parseInt ( inputs [ 0 ] , 10 ) ; b = parseInt ( inputs [ 1 ] , 10 ) ; console . log ( Math . ceil ( ( a + b ) / 2 ) ) ; } function debug ( ) { var input = document . getElementById ( " input " ) . value ; Main ( input ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; process . stdin . setEncoding ( " utf8 " ) ; process . stdin . on ( " data " , input = > { const inputArr = input . split ( " " ) ; const A = inputArr [ 0 ] ; const B = inputArr [ 1 ] ; const H = inputArr [ 2 ] ; const M = inputArr [ 3 ] ; const result = getResult ( A , B , H , M ) ; console . log ( result ) ; } ) ; const getResult = ( A , B , H , M ) = > { const minuteDegree = ( Math . PI * 2.0 * M ) / 60 ; const hourDegree = Math . PI * 2 * ( H / 12 + M / 60 / 12 ) ; const theta = minuteDegree - hourDegree ; return calcCosinTheorem ( A , B , theta ) ; } ; const calcCosinTheorem = ( A , B , theta ) = > { return Math . sqrt ( A * A + B * B - 2 * A * B * Math . cos ( theta ) ) ; } ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { var a = parseInt ( chunk . trim ( ) , 10 ) ; console . log ( Math . pow ( a , 3 ) ) ; } ) ; ' use strict ' const main = ( input ) = > { input = input . split ( ' \ n ' ) let temp = input [ 0 ] . split ( ' ' ) . map ( i = > parseInt ( i ) ) const N = temp [ 0 ] const M = temp [ 1 ] temp = input . slice ( 1 , M + 1 ) let arr = [ ] let aMap = new Map temp . forEach ( ( v ) = > { let tmp = v . split ( ' ' ) . map ( i = > parseInt ( i ) ) aMap . set ( tmp [ 1 ] , 0 ) if ( arr [ tmp [ 0 ] ] = = = undefined ) { arr [ tmp [ 0 ] ] = [ ] } arr [ tmp [ 0 ] ] . push ( tmp [ 1 ] ) } ) arr . forEach ( ( v , i ) = > { v . sort ( ( a , b ) = > a - b ) v . forEach ( ( num , j ) = > { let def = ( ' 000000 ' + i . toString ( 10 ) ) . slice ( - 6 ) + ( ' 000000 ' + ( j + 1 ) . toString ( 10 ) ) . slice ( - 6 ) aMap . set ( num , def ) } ) } ) aMap . forEach ( val = > console . log ( val ) ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf-8 ' ) ) var fs = require ( ' fs ' ) , length = fs . fstatSync ( process . stdin . fd ) . size , buffer = new Buffer ( length ) , bytesRead = fs . readSync ( process . stdin . fd , buffer , 0 , length , 0 ) , input = buffer . toString ( ' utf8 ' , 0 , bytesRead ) . trim ( ) . split ( ' \ n ' ) ; main ( ) ; function main ( ) { for ( var i = 0 , len = input . length ; i < len ; i + + ) { var iarr = input [ i ] . split ( ' ' ) ; j = 0 ; var v1 = new Vector2D ( iarr [ j + + ] , iarr [ j + + ] ) ; var v2 = new Vector2D ( iarr [ j + + ] , iarr [ j + + ] ) ; var v3 = new Vector2D ( iarr [ j + + ] , iarr [ j + + ] ) ; var vp = new Vector2D ( iarr [ j + + ] , iarr [ j + + ] ) ; var v12 = v2 . sub ( v1 ) ; var v2p = vp . sub ( v2 ) ; var v23 = v3 . sub ( v2 ) ; var v3p = vp . sub ( v3 ) ; var v31 = v1 . sub ( v3 ) ; var v1p = vp . sub ( v1 ) ; var c1 = v12 . cross ( v2p ) ; var c2 = v23 . cross ( v3p ) ; var c3 = v31 . cross ( v1p ) ; if ( ( c1 > 0 & & c2 > 0 & & c3 > 0 ) | | ( c1 < 0 & & c2 < 0 & & c3 < 0 ) ) { console . log ( ' YES ' ) ; } else { console . log ( ' NO ' ) ; } } } function Vector2D ( x , y ) { this . x = x - 0 , this . y = y - 0 ; this . sub = function ( v ) { return new Vector2D ( this . x - v . x , this . y - v . y ) ; } ; this . cross = function ( v ) { return this . x * v . y - this . y * v . x ; } ; } function main ( input ) { const args = input . split ( ' \ n ' ) ; const n = parseInt ( args [ 0 ] , 10 ) ; const x = args [ 1 ] . split ( ' ' ) . map ( n = > parseInt ( n , 10 ) ) ; var ans = - 1 , mn = 1e9 ; for ( var i = 1 ; i < = 100 ; i + + ) { var tmp = 0 ; for ( var j = 0 ; j < n ; j + + ) tmp + = Math . pow ( i - x [ j ] , 2 ) ; if ( tmp < mn ) { mn = tmp ; ans = i ; } } console . log ( mn ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var arr = input . trim ( ) . split ( " \ n " ) ; var nrl = arr . shift ( ) . split ( " " ) . map ( Number ) ; var n = nrl [ 0 ] ; var L = nrl [ 2 ] ; var t = [ ] ; var max = [ 0 , 0 ] ; var time = 0 ; for ( var i = 0 ; i < n ; i + + ) t [ i ] = [ 0 , 0 , i ] ; arr . push ( [ 1 , L , 0 ] . join ( " " ) ) ; arr . forEach ( function ( v ) { v = v . split ( " " ) . map ( Number ) ; var d = v [ 0 ] - 1 ; var T = v [ 1 ] ; var x = v [ 2 ] ; t [ max [ 0 ] ] [ 1 ] + = T - time ; time = T ; t [ d ] [ 0 ] + = x ; if ( x > 0 ) { if ( t [ d ] [ 0 ] > max [ 1 ] ) max = [ d , t [ d ] [ 0 ] ] ; else if ( t [ d ] [ 0 ] = = max [ 1 ] & & d < = max [ 0 ] ) max = [ d , t [ d ] [ 0 ] ] ; } else if ( x < 0 & & max [ 0 ] = = d ) { var MAX = 0 ; var m = 0 ; t . forEach ( function ( V , index ) { if ( MAX < V [ 0 ] ) { m = index ; MAX = V [ 0 ] ; } } ) ; max = [ m , t [ m ] [ 0 ] ] ; } } ) ; t . sort ( function ( a , b ) { if ( a [ 1 ] = = b [ 1 ] ) return a [ 2 ] - b [ 2 ] ; else return b [ 1 ] - a [ 1 ] ; } ) ; console . log ( t [ 0 ] [ 2 ] + 1 ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { console . log ( Math . pow ( chunk , 3 ) ) ; } ) ; function Main ( input ) { var A = parseInt ( input . split ( " " ) [ 0 ] , 10 ) ; var B = parseInt ( input . split ( " " ) [ 1 ] , 10 ) ; if ( A > = 13 ) { console . log ( B ) ; } else if ( A > = 6 & & A < = 12 ) { console . log ( B / 2 ) ; } else { console . log ( 0 ) ; } } Main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' ; const input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . trim ( ) . split ( ' \ n ' ) ; const hands = input [ 0 ] . split ( ' ' ) . map ( Number ) const A = hands [ 0 ] = = 1 ? 14 : hands [ 0 ] ; const B = hands [ 1 ] = = 1 ? 14 : hands [ 1 ] ; console . log ( A = = B ? ' Draw ' : A > B ? ' Alice ' : ' Bob ' ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; var input _ string = " " ; var reader = require ( ' readline ' ) . createInterface ( { input : process . stdin , output : process . stdout } ) ; reader . on ( ' line ' , ( line ) = > { input _ string = line ; } ) ; reader . on ( ' close ' , ( ) = > { var x = input _ string ; console . log ( x * x * x ) ; } ) ; function Main ( input ) { " use strict " ; const lines = input . split ( " \ n " ) ; let nums = lines . map ( s = > parseInt ( s , 10 ) ) ; nums . pop ( ) const smallest _ digit1 = nums . reduce ( ( acc , n ) = > { const x1 = acc % 10 | | 10 ; const x2 = n % 10 | | 10 ; return x1 < = x2 ? acc : n } , 10 ) ; let find = false ; const rest = nums . filter ( n = > { if ( n = = = smallest _ digit1 & & ! find ) { find = true ; return false } return true } ) const answer = rest . reduce ( ( acc , n ) = > { return acc + n + ( n % 10 = = = 0 ? 0 : 10 - n % 10 ) } , 0 ) + smallest _ digit1 ; console . log ( answer ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; inp = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . trim ( ) . split ( ' \ n ' ) l = inp . shift ( ) . split ( ' ' ) N = l . shift ( ) * 1 M = l . shift ( ) * 1 a = [ ] b = [ ] for ( i = 0 ; i < N ; i + + ) { a [ i ] = inp [ i ] . split ( ' ' ) } for ( i = 0 ; i < M ; i + + ) { b [ i ] = inp [ i + N ] . split ( ' ' ) } f = 0 for ( i = 0 ; i < = N - M ; i + + ) { for ( j = 0 ; j < = N - M ; j + + ) { g = 1 for ( k = 0 ; k < M ; k + + ) { for ( l = 0 ; l < M ; l + + ) { if ( a [ i + k ] [ j + l ] ! = b [ k ] [ l ] ) { g = 0 break ; } } if ( ! g ) { break ; } } if ( g ) { f = 1 break ; } } if ( g ) { f = 1 break ; } } console . log ( f ? ' Yes ' : ' No ' ) function Main ( input ) { var values = input . split ( " " ) ; var A = parseInt ( values [ 0 ] , 10 ) ; var B = parseInt ( values [ 1 ] , 10 ) ; var H = parseInt ( values [ 2 ] , 10 ) ; var M = parseInt ( values [ 3 ] , 10 ) ; var hpos = [ A * Math . cos ( ( H + M / 60 ) * 30 * ( Math . PI / 180 ) ) , A * Math . sin ( ( H + M / 60 ) * 30 * ( Math . PI / 180 ) ) ] ; var mpos = [ B * Math . cos ( M * 6 * ( Math . PI / 180 ) ) , B * Math . sin ( M * 6 * ( Math . PI / 180 ) ) ] var dist = Math . sqrt ( Math . pow ( hpos [ 0 ] - mpos [ 0 ] , 2 ) + Math . pow ( hpos [ 1 ] - mpos [ 1 ] , 2 ) ) ; console . log ( ' % d ' , dist ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; " use strict " ; const main = arg = > { const rectangles = arg . split ( " \ n " ) [ 0 ] . split ( " " ) ; const A = rectangles [ 0 ] * rectangles [ 1 ] ; const B = rectangles [ 2 ] * rectangles [ 3 ] ; console . log ( Math . max ( A , B ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function Main ( input ) { var input = input . split ( " \ n " ) ; var tmp = input [ 0 ] . split ( " " ) ; var A = Number ( tmp [ 0 ] ) ; var B = Number ( tmp [ 1 ] ) ; var C = Number ( tmp [ 2 ] ) ; var ans = ( A + B > = C ) ? " Yes " : " No " ; console . log ( ans ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; const numList = input . map ( x = > parseInt ( x , 10 ) ) ; const biggestNum = numList [ 4 ] ; const smallestNum = numList [ 0 ] ; const k = numList [ 5 ] ; if ( smallestNum + k < biggestNum ) { console . log ( ' : ( ' ) ; } else { console . log ( ' Yay ! ' ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input . trim ( ) ; input = input . split ( " \ n " ) ; var N = input [ 0 ] ; var arr = input [ 1 ] . split ( " " ) . map ( Number ) ; var ans = 0 ; var low = 9999999999999999 ; for ( var i = 0 ; i < N ; i + + ) { if ( low > = arr [ i ] ) { ans + + ; low = arr [ i ] ; } } console . log ( ans ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) ) ; function arr1dto2d ( arr ) { for ( var i = 0 ; i < arr . length ; i + + ) { arr [ i ] = arr [ i ] . split ( " " ) . map ( Number ) ; } return arr ; } " use strict " ; function main ( input ) { let output = input * input * input ; console . log ( output ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' function main ( s ) { const n = Number ( s ) ; const ans = ( 800 * n ) - ( Math . floor ( n / 15 ) * 200 ) ; console . log ( ans ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var x = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ; var y = x . split ( " " , 1 ) ; console . log ( y * y * y ) ; function Main ( input ) { var input _ arr = input . split ( " \ n " ) ; var d = input _ arr . map ( x = > parseInt ( x ) ) ; var last = 0 ; var min = d [ 0 ] % 10 ; for ( var i = 0 ; i < 5 ; i + + ) { var tmp = d [ i ] % 10 ; if ( tmp = = = 0 ) { continue ; } if ( tmp < min ) { min = tmp ; last = i } } var ans = 0 ; for ( var i = 0 ; i < 5 ; i + + ) { if ( i = = = last ) { ans + = d [ i ] ; } else { ans + = Math . ceil ( d [ i ] / 10 ) * 10 ; } } console . log ( ans ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var xs = input . trim ( ) . split ( ' ' ) . map ( v = > parseInt ( v , 10 ) ) ; var result = xs . reduce ( function ( previous , current , index , array ) { return previous + current ; } ) ; console . log ( Math . ceil ( result / xs . length ) ) ; } Main ( require ( ' fs ' ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' ; process . stdin . on ( ' data ' , function ( chunk ) { var inputs = chunk . toString ( ) ; var x = Number ( inputs ) ; console . log ( Math . pow ( x , 3 ) ) ; } ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; function main ( input ) { let [ av , bw , t ] = input . trim ( ) . split ( ' \ n ' ) let [ a , v ] = av . split ( ' ' ) . map ( n = > Number ( n ) ) let [ b , w ] = bw . split ( ' ' ) . map ( n = > Number ( n ) ) const dist = Math . abs ( a - b ) const speed = v - w const is _ catchable = ( speed > 0 ) & & ( dist / speed < = Number ( t ) ) console . log ( is _ catchable ? ' YES ' : ' NO ' ) } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ' use strict ' function Main ( input ) { input = input . split ( ) ; let r = input ; let area = r * r ; console . log ( area ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; var lines = [ ] ; var reader = require ( ' readline ' ) . createInterface ( { input : process . stdin , output : process . stdout } ) ; reader . on ( ' line ' , ( line ) = > { lines . push ( line ) ; } ) ; reader . on ( ' close ' , ( ) = > { const meals = lines . map ( Number ) ; const shortenTime = meals . reduce ( ( cur , next ) = > Math . max ( cur , ( 10 - next % 10 ) % 10 ) , 0 ) ; console . log ( meals . reduce ( ( cur , next ) = > cur + Math . ceil ( next / 10 ) * 10 , 0 ) - shortenTime ) ; } ) ; function Main ( input ) { var N , X ; var ans1 = [ ] ; input = input . split ( " \ n " ) ; N = parseInt ( input [ 0 ] , 10 ) ; X = input [ 1 ] . split ( " " ) . map ( inp = > parseInt ( inp , 10 ) ) ; for ( var i = Math . min ( ... X ) ; i < = Math . max ( ... X ) ; i + + ) { var ret = 0 ; for ( var j of X ) { ret + = Math . pow ( i - j , 2 ) ; } ans1 . push ( ret ) ; } console . log ( Math . min ( ... ans1 ) ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { var x = parseInt ( chunk . trim ( ) , 10 ) ; console . log ( Math . pow ( x , 3 ) ) ; } ) ; function Main ( input ) { var args = input . split ( " \ n " ) ; var ret = parseInt ( args [ 4 ] ) - parseInt ( args [ 0 ] ) - parseInt ( args [ 5 ] ) ; console . log ( ret > 0 ? ' : ( ' : ' Yay ! ' ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( " \ n " ) ; var n = parseInt ( input [ 0 ] , 10 ) ; input . shift ( ) ; var sum = 0 ; for ( var i = 0 ; i < n ; i + + ) { var x1 = Number ( input [ i ] . split ( ' ' ) [ 0 ] ) ; var y1 = Number ( input [ i ] . split ( ' ' ) [ 1 ] ) ; for ( var j = 0 ; j < n ; j + + ) { if ( i = = = j ) { continue ; } var x2 = Number ( input [ j ] . split ( ' ' ) [ 0 ] ) ; var y2 = Number ( input [ j ] . split ( ' ' ) [ 1 ] ) ; sum + = Math . sqrt ( Math . pow ( x1 - x2 , 2 ) + Math . pow ( y1 - y2 , 2 ) ) ; } } console . log ( sum / n ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . trim ( ) . split ( " \ n " ) ; var obj = { " list " : input , " index " : 0 , " max " : input . length , " next " : function ( ) { if ( ! this . hasNext ( ) ) { return null ; } var returnObj = this . list [ this . index ] ; this . index + + ; return returnObj ; } , " hasNext " : function ( ) { return ( this . index < this . max ) ; } } function next ( ) { return obj . next ( ) ; } function hasNext ( ) { return obj . hasNext ( ) ; } function Main ( ) { var k = 1 * input [ 0 ] . split ( " " ) [ 0 ] var s = 1 * input [ 0 ] . split ( " " ) [ 1 ] var c = 0 ; for ( var i = 0 ; i < = k ; + + i ) { for ( var j = 0 ; j < = ( s - i ) & & j < = k ; + + j ) { if ( ( s - i - j ) > = 0 & & ( s - i - j ) < = k ) { + + c } } } console . log ( c ) } Main ( ) ; const input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . split ( " \ n " ) . map ( Number ) ; console . log ( Math . pow ( input [ 0 ] , 3 ) ) ; " use strict " ; const make6digit = num = > { num = String ( num ) ; let digit = num . split ( " " ) . length ; if ( digit < 6 ) { for ( let i = 0 ; i < 6 - digit ; i + + ) { num = " 0 " + num ; } } return num ; } const main = arg = > { arg = arg . trim ( ) . split ( " \ n " ) ; const N = parseInt ( arg [ 0 ] . split ( " " ) [ 0 ] ) ; const M = parseInt ( arg [ 0 ] . split ( " " ) [ 1 ] ) ; const cities = arg . slice ( 1 , M + 1 ) ; let data = [ ] ; for ( let i in cities ) { let tempPrefecture = parseInt ( cities [ i ] . split ( " " ) [ 0 ] ) ; let tempBirth = parseInt ( cities [ i ] . split ( " " ) [ 1 ] ) ; data . push ( { prefecture : tempPrefecture , birth : tempBirth , index : i } ) } data . sort ( ( a , b ) = > { if ( a . prefecture < b . prefecture ) { return - 1 ; } if ( a . prefecture > b . prefecture ) { return 1 ; } if ( a . birth < b . birth ) { return - 1 ; } if ( a . birth > b . birth ) { return 1 ; } } ) ; let num = 1 ; for ( let i in data ) { if ( data [ i - 1 ] ) { if ( data [ i ] . prefecture ! = = data [ i - 1 ] . prefecture ) { num = 1 ; } } let firstHalf = make6digit ( data [ i ] . prefecture ) ; let lastHalf = make6digit ( num ) ; const id = firstHalf + lastHalf ; data [ i ] . id = id ; num + + ; } data . sort ( ( a , b ) = > a . index - b . index ) ; for ( let i in data ) { console . log ( data [ i ] . id ) ; } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; var lines = [ ] ; var readline = require ( ' readline ' ) . createInterface ( process . stdin , process . stdout ) ; var parseInt10 = function ( elem ) { return parseInt ( elem , 10 ) ; } var toInt = function ( line ) { var intArray = line . split ( ' ' ) . map ( parseInt10 ) ; if ( intArray . length = = = 1 ) { return intArray [ 0 ] ; } else { return intArray ; } } ; var settings = { } ; var defineRule = function ( index , data , vars ) { settings [ index ] = { } ; for ( var i = 0 ; i < vars . length ; i + = 1 ) { settings [ index ] [ vars [ i ] ] = data [ i ] ; } } ; var calculate = function ( data ) { var v = Math . pow ( data , 3 ) ; console . log ( v ) ; } ; readline . on ( ' line ' , function ( line ) { line = toInt ( line ) ; lines . push ( line ) ; calculate ( line ) ; } ) ; function Main ( input ) { input = input . trim ( ) ; X = parseInt ( input ) ; const array = [ ] for ( var i = 0 ; i < 40000 ; i + + ) { array . push ( Math . pow ( i , 5 ) ) } var A = 0 ; var B = 0 ; var breakFlag = false ; for ( var i = 0 ; i < array . length ; i + + ) { for ( var j = 0 ; j < array . length ; j + + ) { if ( array [ i ] + array [ j ] = = X ) { A = i ; B = - j ; breakFlag = true ; break ; } if ( array [ i ] - array [ j ] = = X ) { A = i ; B = j ; breakFlag = true ; break ; } if ( - array [ i ] + array [ j ] = = X ) { A = - i ; B = - j ; breakFlag = true ; break ; } if ( - array [ i ] - array [ j ] = = X ) { A = - i ; B = + j ; breakFlag = true ; break ; } } if ( breakFlag ) break ; } console . log ( A + " " + B ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' function Main ( input ) { input = input . trim ( ) . split ( ' \ n ' ) const N = parseInt ( input [ 0 ] ) const p = input [ 1 ] . split ( ' ' ) . map ( s = > parseInt ( s ) ) let count = 0 let min = Infinity for ( let i = 0 ; i < N ; + + i ) { if ( p [ i ] < min ) { min = p [ i ] count + + } } console . log ( count ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var row = input . split ( ' \ n ' ) ; var result = [ ] ; for ( var i = 0 ; i < row . length ; i + + ) { var x = row [ i ] . split ( ' ' ) . map ( Number ) ; if ( x [ 0 ] = = = 0 ) { break ; } var total = x . reduce ( function ( a , b ) { return a + b ; } ) ; result . push ( total ) ; } console . log ( result . join ( ' \ n ' ) ) ; function parseInput ( input ) { const values = [ ] in put . split ( ' \ n ' ) . forEach ( row = > { const list = row . split ( ' ' ) list . forEach ( v = > values . push ( v ) ) } ) return values } function getInput ( ) { return parseInput ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) } function spend ( Xi , P ) { return Math . pow ( Xi - P , 2 ) } ; ( function main ( ) { const input = getInput ( ) const N = + input [ 0 ] var min = Number . MAX _ SAFE _ INTEGER for ( var p = 1 ; p < = 100 ; p + + ) { var s = 0 for ( var i = 1 ; i < = N ; i + + ) { s + = spend ( + input [ i ] , p ) } if ( min > s ) { min = s } } console . log ( min ) } ) ( ) function Main ( input ) { var line = input . split ( " " ) ; var max = parseInt ( line [ 0 ] ) ; var sum = parseInt ( line [ 1 ] ) ; var ans = 0 ; var maxover3 = Math . ceil ( sum / 3 ) ; var remain = 0 ; for ( var i = 0 ; i < = maxover3 ; i + + ) { remain = sum - i ; for ( var j = i ; j < = max ; j + + ) { var k = remain - j ; if ( k > = j & & k < = max ) { if ( i = = = j & & i = = = k ) { ans + + ; } else if ( i = = = j | | i = = = k | | k = = = j ) { ans + = 3 ; } else { ans + = 6 ; } } } } console . log ( ans ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { input = input . trim ( ) ; const a = input . split ( " \ n " ) . map ( Number ) ; console . log ( a [ 4 ] - a [ 0 ] > a [ 5 ] ? " : ( " : " Yay ! " ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ( function ( stdin ) { var lines = stdin . toString ( ) . split ( ' \ n ' ) ; var x = parseInt ( lines [ 0 ] , 10 ) ; console . log ( Math . pow ( x , 3 ) ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; function combination ( input ) { var max = parseInt ( input . split ( " " ) [ 0 ] ) ; var sum = parseInt ( input . split ( " " ) [ 1 ] ) ; var count = 0 ; if ( sum < = max ) { for ( var x = 0 ; x < sum + 1 ; x + + ) { for ( var y = 0 ; y < sum + 1 - x ; y + + ) { count + + ; } } } else if ( sum > max ) { for ( var x = 0 ; x < max + 1 ; x + + ) { if ( sum - x < = max ) { for ( var y = 0 ; y < sum + 1 - x ; y + + ) { count + + ; } } else if ( sum - x > max ) { for ( var y = 0 ; y < max + 1 ; y + + ) { if ( sum - x - y < = max ) { count + + ; } else if ( sum - x - y > max ) { } } } } } console . log ( count ) ; } combination ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { tmp = input . split ( " " ) ; var a = parseInt ( tmp [ 0 ] , 10 ) ; var b = parseInt ( tmp [ 1 ] , 10 ) ; var c = parseInt ( tmp [ 2 ] , 10 ) ; if ( ( a > 4 & & b > 4 & & c > 4 ) & & ( a < 8 & & b < 8 & & c < 8 ) ) { if ( a + b + c = = 17 ) { console . log ( " YES " ) ; } else { console . log ( " NO " ) ; } } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; var input _ lines = [ ] ; var reader = require ( ' readline ' ) . createInterface ( { input : process . stdin , output : process . stdout } ) ; let count5 = 0 ; let count7 = 0 ; let result = ' NO ' reader . on ( ' line ' , ( line ) = > { input _ lines = line . split ( " " ) in put _ lines . map ( i = > { if ( i = = 5 ) { count5 + + } if ( i = = 7 ) { count7 + + } } ) if ( count7 = = 1 & & count5 = = 2 ) { result = ' YES ' } } ) ; reader . on ( ' close ' , ( ) = > { console . log ( result ) ; } ) ; function main ( input ) { input = input . trim ( ) ; const a = input . split ( " " ) . map ( Number ) ; console . log ( Math . ceil ( ( a [ 0 ] + a [ 1 ] ) / 2 ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' const main = ( input ) = > { input = input . split ( ' \ n ' ) let temp = input [ 0 ] . split ( ' ' ) . map ( i = > parseInt ( i ) ) const N = temp [ 0 ] const M = temp [ 1 ] temp = input . slice ( 1 , M + 1 ) let arr = [ ] let aMap = new Map temp . forEach ( ( v ) = > { let tmp = v . split ( ' ' ) . map ( i = > parseInt ( i ) ) aMap . set ( tmp [ 1 ] , 0 ) if ( arr [ tmp [ 0 ] ] = = = undefined ) { arr [ tmp [ 0 ] ] = [ ] } arr [ tmp [ 0 ] ] . push ( tmp [ 1 ] ) } ) arr . forEach ( ( v , i ) = > { v . sort ( ( a , b ) = > a - b ) v . forEach ( ( num , j ) = > { let def = ( ' 000000 ' + i . toString ( 10 ) ) . slice ( - 6 ) + ( ' 000000 ' + ( j + 1 ) . toString ( 10 ) ) . slice ( - 6 ) aMap . set ( num , def ) } ) } ) aMap . forEach ( val = > console . log ( val ) ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf-8 ' ) ) inp = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . split ( ' \ n ' ) [ 0 ] . split ( ' ' ) a = [ ] for ( i = 0 ; i < 3 ; i + + ) { a [ inp [ i ] ] = ( a [ inp [ i ] ] | | 0 ) + 1 } console . log ( a [ 5 ] = = 2 & & a [ 7 ] = = 1 ? ' YES ' : ' NO ' ) " use strict " function main ( arg ) { if ( arg . trim ( ) . split ( " \ n " ) [ 0 ] . split ( " " ) . map ( Number ) . sort ( ( a , b ) = > a - b ) . join ( ' ' ) = = ' 557 ' ) { console . log ( ' YES ' ) } else { console . log ( ' NO ' ) } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( input ) { const haiku = [ 5 , 7 , 5 ] ; const inputArr = input . split ( ' ' ) . map ( ( data ) = > { return Number ( data ) ; } ) ; let tempArr = inputArr ; for ( let i = 0 ; i < haiku . length ; i + + ) { const indexOf = tempArr . indexOf ( haiku [ i ] ) ; if ( indexOf > = 0 ) { tempArr . splice ( indexOf , 1 ) ; } } return tempArr . length = = = 0 ? ' YES ' : ' NO ' ; } console . log ( main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ) ; " use strict " ; var input = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ; var cin = input . split ( / | \ n / ) , cid = 0 ; function next ( ) { return + cin [ cid + + ] ; } function nextstr ( ) { return cin [ cid + + ] ; } function nextbig ( ) { return BigInt ( cin [ cid + + ] ) ; } function nexts ( n , a ) { return a ? cin . slice ( cid , cid + = n ) : cin . slice ( cid , cid + = n ) . map ( a = > + a ) ; } function nextm ( h , w , a ) { var r = [ ] , i = 0 ; if ( a ) for ( ; i < h ; i + + ) r . push ( cin . slice ( cid , cid + = w ) ) ; else for ( ; i < h ; i + + ) r . push ( cin . slice ( cid , cid + = w ) . map ( a = > + a ) ) ; return r ; } function xArray ( v ) { var a = arguments , l = a . length , r = " Array ( a [ " + -- l + " ] ) .fill ( ) .map ( x = > { return " + v + " ; } ) " ; while ( -- l ) r = " Array ( a [ " + l + " ] ) .fill ( ) .map ( x = > " + r + " ) " ; return eval ( r ) ; } var myOut = main ( ) ; if ( myOut ! = = undefined ) console . log ( String ( myOut ) ) ; function main ( ) { var n = next ( ) ; var ans = 0 , mn = 1 ; for ( var i = 0 ; i < n ; i + + ) { var t = next ( ) - 1 ; if ( t < mn ) { mn = Math . max ( mn , t + 2 ) ; } else { ans + = t / mn | 0 ; mn = Math . max ( 2 , mn ) ; } } return ans ; } ' use strict ' function main ( input ) { input = input . trim ( ) . split ( ' \ n ' ) in put = input . map ( ( val , index ) = > { let fp = Number ( val . slice ( - 1 ) ) | | 10 return { index : index , val : Number ( val ) , sort : fp , time : 10 - fp + Number ( val ) } } ) . sort ( ( a , b ) = > a . sort < b . sort ) . reduce ( ( prev , current , index ) = > { let time = index ! = = input . length - 1 ? current . time : current . val return prev + time } , 0 ) console . log ( input ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; " use strict " ; const main = ( arg ) = > { const input = arg . trim ( ) . split ( " \ n " ) ; const A = parseInt ( input [ 0 ] . split ( " " ) [ 0 ] ) ; const V = parseInt ( input [ 0 ] . split ( " " ) [ 1 ] ) ; const B = parseInt ( input [ 1 ] . split ( " " ) [ 0 ] ) ; const W = parseInt ( input [ 1 ] . split ( " " ) [ 1 ] ) ; const T = parseInt ( input [ 2 ] ) ; if ( V - W = = = 0 ) return console . log ( " NO " ) ; const time = Math . abs ( A - B ) / ( V - W ) ; console . log ( time > 0 & & time < = T ? " YES " : " NO " ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' ; ( function ( stdin ) { var lines = stdin . toString ( ) . split ( ' \ n ' ) ; var result = ( function ( data ) { return data . filter ( function ( v ) { return parseInt ( v , 10 ) ; } ) . map ( function ( v ) { return v . split ( ' ' ) . map ( Number ) . reduce ( function ( a , b ) { return a + b ; } ) ; } ) . join ( ' \ n ' ) ; } ( lines ) ) ; console . log ( result ) ; } ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ) ; var stdin = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var input = stdin . toString ( ) . trim ( ) . split ( ' \ n ' ) ; var x = parseInt ( input [ 0 ] , 10 ) ; console . log ( Math . pow ( x , 3 ) ) ; " use strict " ; const main = arg = > { arg = arg . split ( " \ n " ) ; const k = parseInt ( arg . slice ( 5 , arg . length ) ) ; const antennas = arg . slice ( 0 , arg . length - 1 ) . map ( n = > parseInt ( n ) ) ; console . log ( antennas [ 4 ] - antennas [ 0 ] > k ? " : ( " : " Yay ! " ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; const min = - 150 ; const max = 150 ; const m = { } ; for ( let i = min ; i < = max ; i + + ) { m [ i ] = i * * 5 ; } const ans = { } ; for ( let i = min ; i < = max ; i + + ) { for ( let k = min ; k < = max ; k + + ) { ans [ m [ i ] - m [ k ] ] = [ i , k ] ; } } const lines = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . split ( ' \ n ' ) ; const X = + lines [ 0 ] ; console . log ( ` $ { ans [ X ] [ 0 ] } $ { ans [ X ] [ 1 ] } ` ) ; function Main ( input ) { input = input . split ( ' \ n ' ) ; var size = input [ 0 ] ; var i , j , pi , xi , yi , xj , yj , d ; var result = 0 ; for ( i = 1 ; i < = size ; i + + ) { pi = input [ i ] . split ( ' ' ) ; xi = pi [ 0 ] ; yi = pi [ 1 ] ; for ( j = i + 1 ; j < = size ; j + + ) { pj = input [ j ] . split ( ' ' ) ; xj = pj [ 0 ] ; yj = pj [ 1 ] ; d = Math . sqrt ( ( xi - xj ) * ( xi - xj ) + ( yi - yj ) * ( yi - yj ) ) result + = d ; } } console . log ( result * 2 / size ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( ' ' ) . map ( num = > Number ( num ) ) ; var a = input [ 0 ] ; var b = input [ 1 ] ; var c = input [ 2 ] ; var d = input [ 3 ] ; var ab = a * b ; var cd = c * d ; if ( ab > = cd ) { console . log ( ab ) ; } else { console . log ( cd ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . trim ( ) ; var N = parseInt ( input , 10 ) ; var maxN = 0 ; var n = 10 ; var A = 0 ; var B = 0 ; while ( true ) { n _ 1 = Math . pow ( n , 5 ) ; n _ 2 = Math . pow ( n - 1 , 5 ) ; if ( n _ 1 - n _ 2 > Math . pow ( 10 , 9 ) ) { maxN = n + 1 ; break ; } n + + ; } for ( var i = - maxN ; i < maxN ; i + + ) { for ( var j = - maxN ; j < maxN ; j + + ) { var a = Math . pow ( i , 5 ) ; var b = Math . pow ( j , 5 ) ; if ( a - b = = = N ) { A = i ; B = j ; console . log ( A , B ) ; return ; } } } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( ) { process . stdin . resume ( ) ; process . stdin . setEncoding ( " utf8 " ) ; var chunks = " " ; process . stdin . on ( " data " , function ( chunk ) { chunks + = chunk ; } ) ; process . stdin . on ( " end " , function ( ) { var inputs = chunks . trim ( ) . split ( " \ n " ) ; var nums = inputs [ 0 ] . split ( " " ) ; var go = 0 ; var shichi = 0 ; nums . forEach ( ( n ) = > { if ( n = = = " 5 " ) { go + = 1 ; } else if ( n = = = " 7 " ) { shichi + = 1 ; } } ) ; go = = = 2 & & shichi = = = 1 ? console . log ( " YES " ) : console . log ( " NO " ) ; } ) ; } main ( ) ; function main ( input ) { const [ a , v ] = input [ 0 ] . trim ( ) . split ( " " ) . map ( i = > parseInt ( i ) ) ; const [ b , w ] = input [ 1 ] . trim ( ) . split ( " " ) . map ( i = > parseInt ( i ) ) ; const t = parseInt ( input [ 2 ] ) ; const result = ( ( v * t ) > = ( ( w * t ) + Math . abs ( b - a ) ) ) console . log ( result ? " YES " : " NO " ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . trim ( ) . split ( " \ n " ) ) ; console . log ( + ( new Date ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ) < = + ( new Date ( " 2019 / 4 / 30 " ) ) ? " Heisei " : " TBD " ) var input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var Arr = ( input . trim ( ) ) . split ( " \ n " ) ; var n = 0 ; var obj = { } ; var abc = [ ] ; for ( var i = 0 ; i < Arr . length ; i + + ) { if ( n = = 0 ) { if ( i ! = 0 ) { abc . sort ( function ( a , b ) { return a - b ; } ) ; for ( var k in obj ) { if ( obj [ k ] = = abc [ 0 ] ) { console . log ( k ) ; break ; } } } if ( Arr [ i ] = = 0 ) break ; n = Arr [ i ] ; abc = [ ] ; obj = { } ; } else { n -- ; var arr = Arr [ i ] . split ( " " ) . map ( Number ) ; var h = arr [ 1 ] / 100 ; var bmi = Math . abs ( 22 - arr [ 2 ] / ( h * h ) ) ; abc . push ( bmi ) ; obj [ arr [ 0 ] ] = bmi ; } } function Main ( input ) { tmp = input . split ( " \ n " ) ; tmp = tmp . map ( Number ) ; k = tmp [ 5 ] ; a = new Array ; for ( i = 0 ; i < 5 ; i + + ) { for ( j = 0 ; j < 5 ; j + + ) { a [ 5 * i + j ] = Math . abs ( tmp [ i ] - tmp [ j ] ) } } if ( Math . max . apply ( null , a ) > k ) { console . log ( " : ( " ) ; } else { console . log ( " Yay ! " ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var out = function ( x ) { console . log ( x ) ; return x ; } var calc = function ( x ) { return x * x * x ; } process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( x ) { console . log ( calc ( x ) ) ; } ) ; function Main ( input ) { input = input . split ( " \ n " ) ; var n = parseInt ( input [ 0 ] , 10 ) ; var str = input [ 1 ] ; var suu = str . split ( " " ) ; for ( var i = 0 ; i < n ; i + + ) { suu [ i ] = parseInt ( suu [ i ] , 10 ) ; } var count = 0 ; var min = 200001 ; for ( var i = 0 ; i < n ; i + + ) { if ( suu [ i ] < min ) { count + + ; min = suu [ i ] ; } } console . log ( count ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . replace ( / \ n / g , ' ' ) ; input = input . split ( " " ) ; var A = input [ 0 ] ; var moji = A . split ( " " ) ; for ( var i = 0 ; i < moji . length ; i + + ) { var p = moji [ i ] ; if ( p = = " ? " ) { if ( i = = 0 ) { if ( i + 1 ! = moji . length ) { if ( moji [ i + 1 ] ! = " P " ) { moji [ i ] = " P " ; } else { moji [ i ] = " D " ; } } else { moji [ i ] = " D " ; } } else if ( i + 1 = = moji . length ) { moji [ i ] = " D " ; } else { if ( moji [ i - 1 ] = = " P " ) { moji [ i ] = " D " ; } else { if ( moji [ i + 1 ] ! = " P " ) { moji [ i ] = " P " ; } else { moji [ i ] = " D " ; } } } } } console . log ( moji . join ( " " ) ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( a ) { a = stn ( a . split ( " " ) ) ; var ss = [ ] ; ss . push ( a [ 0 ] * a [ 1 ] ) ; ss . push ( a [ 2 ] * a [ 3 ] ) ; ss . sort ( function ( a , b ) { return a - b ; } ) ; console . log ( ss [ 1 ] ) ; } function stn ( a ) { return a . map ( function ( x ) { return parseInt ( x , 10 ) ; } ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var list = input . split ( " \ n " ) ; var a = parseInt ( list [ 0 ] , 10 ) ; var e = parseInt ( list [ 4 ] , 10 ) ; var k = parseInt ( list [ 5 ] , 10 ) ; if ( e - a > k ) console . log ( " : ( " ) ; else console . log ( " Yay ! " ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; var stdin = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ; var input = stdin . toString ( ) . trim ( ) . split ( ' \ n ' ) ; var x = parseInt ( input [ 0 ] , 10 ) ; console . log ( Math . pow ( x , 3 ) ) ; ( ( input ) = > { const data = input . split ( ' \ n ' ) ; const line1 = data [ 0 ] . split ( ' ' ) ; const N = + line1 [ 0 ] ; const D = + line1 [ 1 ] ; const coords = data . slice ( 1 , N + 1 ) . map ( ( line ) = > line . replace ( / \ s \ s / g , ' ' ) . split ( ' ' ) . filter ( Boolean ) . map ( Number ) ) ; console . log ( coords . reduce ( ( total , coord1 , i ) = > ( total + coords . slice ( i + 1 ) . reduce ( ( count , coord2 ) = > { const d = distance ( coord1 , coord2 , D ) ; const diff = Math . abs ( Math . round ( d ) - d ) ; return diff < 0.0001 ? count + 1 : count } , 0 ) ) , 0 ) ) ; } ) ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function distance ( coords1 , coords2 , D ) { const diffs = Array ( D ) . fill ( null ) . map ( ( _ , i ) = > ( coords1 [ i ] - coords2 [ i ] ) ) ; var max = Math . max . apply ( null , diffs ) ; if ( max = = = 0 ) max = 1 ; var sum = 0 ; for ( var i = 0 ; i < D ; i + = 1 ) { sum + = Math . pow ( diffs [ i ] / max , 2 ) ; } return Math . sqrt ( sum ) * max ; } function Main ( input ) { var a = parseInt ( input ) ; console . log ( a * a * a ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; function Main ( input ) { var tmp = input . split ( " \ n " ) ; var line0 = tmp [ 0 ] . split ( " " ) ; var input1 = Number ( line0 [ 0 ] ) ; var input2 = Number ( line0 [ 1 ] ) ; var input3 = Number ( line0 [ 2 ] ) ; var a = input1 ; var b = input2 ; var c = input3 ; var ans = 0 ; var min = Math . min . apply ( null , line0 ) ; var max = Math . max . apply ( null , line0 ) ; console . log ( max - min ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' const main = input = > { const args = input . split ( ' \ n ' ) . map ( arg = > arg . split ( ' ' ) ) const A = args [ 0 ] . map ( arg = > parseInt ( arg , 10 ) ) . sort ( ( a , b ) = > a - b ) let sum = 0 sum + = A [ 1 ] - A [ 0 ] sum + = A [ 2 ] - A [ 1 ] console . log ( sum ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( args ) { input = args . split ( " \ n " ) ; const N = parseInt ( input [ 0 ] ) ; var count = 0 ; var maxCount = 0 ; var result = 1 ; for ( var i = 1 ; i < = N ; i + + ) { count = 0 ; var j = i ; while ( true ) { if ( j % 2 = = 0 ) { count + + ; j / = 2 ; } else { break ; } if ( maxCount < count ) { maxCount = count ; result = i ; } } } console . log ( result ) ; } " use strict " ; function Main ( input ) { let lines = input . split ( " \ n " ) ; let nm = lines . shift ( ) . split ( / \ s / ) . map ( ( v ) = > v - 0 ) ; let N = nm [ 0 ] , M = nm [ 1 ] ; const MAX _ N = 1e5 + 1 ; let V = new Array ( MAX _ N ) . fill ( 0 ) . map ( ( ) = > [ ] ) ; for ( let m = 0 ; m < M ; m + + ) { let py = lines . shift ( ) . split ( / \ s / ) . map ( ( v ) = > v - 0 ) ; V [ py [ 0 ] ] . push ( { year : py [ 1 ] , index : m } ) ; } const d6 = ( n ) = > ( ' 000000 ' + n . toString ( ) ) . slice ( - 6 ) ; const d12 = ( p , y ) = > d6 ( p ) + d6 ( y ) ; let ans = new Array ( M ) ; for ( let m = 0 ; m < MAX _ N ; m + + ) { V [ m ] . sort ( ( a , b ) = > a . year - b . year ) ; let v = V [ m ] ; for ( let n = 0 ; n < v . length ; n + + ) { ans [ v [ n ] . index ] = d12 ( m , n + 1 ) ; } } for ( let m = 0 ; m < M ; m + + ) { console . log ( ans [ m ] ) ; } } if ( typeof window = = " undefined " ) Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { lines = input . split ( " \ n " ) N = lines [ 0 ] . split ( ' ' ) [ 0 ] K = lines [ 0 ] . split ( ' ' ) [ 1 ] console . log ( K = = 1 ? 0 : N - K ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; d = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . split ( " \ n " ) ; [ a , v ] = d [ 0 ] . split ( " " ) ; [ b , w ] = d [ 1 ] . split ( " " ) ; t = d [ 2 ] ; d = Math . abs ( a - b ) ; console . log ( d < = ( v - w ) * t ? " YES " : " NO " ) ; function Main ( input ) { const inputLines = input . split ( " \ n " ) ; const line0 = inputLines [ 0 ] ; const line0vars = line0 . split ( " " ) ; const h1 = parseInt ( line0vars [ 0 ] , 10 ) const m1 = parseInt ( line0vars [ 1 ] , 10 ) const h2 = parseInt ( line0vars [ 2 ] , 10 ) const m2 = parseInt ( line0vars [ 3 ] , 10 ) const k = parseInt ( line0vars [ 4 ] , 10 ) const result = h2 * 60 + m2 - h1 * 60 - m1 - k ; console . log ( result ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { var line1 = input [ 0 ] . split ( ' ' ) ; var n = parseInt ( line1 [ 0 ] ) ; var p = parseInt ( line1 [ 1 ] ) ; var ans = 1 ; var arr = primeFactorization ( p ) ; for ( var i = 0 ; i < arr . length ; i + + ) { var r = arr [ i ] . r ; while ( n < = r ) { ans * = arr [ i ] . num ; r = r - n ; } } console . log ( ans ) ; } function parse ( line ) { var ret = [ ] ; var arr = line . split ( ' ' ) ; for ( var i = 0 ; i < arr . length ; i + + ) { ret . push ( parseInt ( arr [ i ] ) ) ; } return ret ; } function primeFactorization ( n ) { var s = Math . floor ( Math . sqrt ( n ) ) ; var r = 0 ; var result = [ ] ; for ( var i = 2 ; i < = s ; i + + ) { if ( ( n % i ) = = 0 ) { r = 0 ; do { r + + ; n = n / i ; } while ( ( n % i ) = = 0 ) ; result . push ( { num : i , r : r } ) ; } } if ( n > s ) { result . push ( { num : n , r : 1 } ) ; } return result ; } var input = ' ' ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { input + = chunk ; } ) ; process . stdin . on ( ' end ' , function ( ) { input = input . split ( ' \ n ' ) ; main ( input ) ; } ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { var numbers = chunk . toString ( ) . split ( " " ) ; var alice = parseInt ( numbers [ 0 ] ) , bob = parseInt ( numbers [ 1 ] ) ; if ( alice = = 1 ) alice + = 13 ; if ( bob = = 1 ) bob + = 13 ; if ( alice > bob ) { process . stdout . write ( " Alice " ) ; } else if ( alice < bob ) { process . stdout . write ( " Bob " ) ; } else { process . stdout . write ( " Draw " ) ; } process . exit ( ) ; } ) ; const input = require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) . split ( ' \ n ' ) const [ A , B , H , M ] = input [ 0 ] . split ( ' ' ) . map ( Number ) const degA = ( H * 30 ) + ( M / 60 * 30 ) const degB = M * 6 const deg = Math . abs ( degA - degB ) const rad = deg * ( Math . PI / 180 ) const height = A * Math . sin ( rad ) const width = A * Math . cos ( rad ) - B const ans = Math . sqrt ( Math . pow ( height , 2 ) + Math . pow ( width , 2 ) ) console . log ( ans ) function Main ( input ) { var inputs = input . split ( " " ) ; var k = Number ( inputs [ 0 ] ) ; var s = Number ( inputs [ 1 ] ) ; var cnt = 0 ; for ( var x = 0 ; x < = k ; x + + ) for ( var y = 0 ; y < = k ; y + + ) if ( s - ( x + y ) > = 0 & & s - ( x + y ) < = k ) cnt + + ; console . log ( cnt ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; ' use strict ' ; function Main ( is ) { const i = is . split ( " \ n " ) ; let s = i [ 0 ] , p = parseInt ( i [ 1 ] ) ; let code , lastLetter ; for ( let i = 0 ; i < s . length ; i + + ) { code = s [ i ] . charCodeAt ( 0 ) ; if ( s . length - 1 = = i ) { code + = p % 26 ; if ( code > 122 ) { code + = ( - 122 + 97 - 1 ) ; } lastLetter = String . fromCharCode ( code ) ; s = s . slice ( 0 , i ) + lastLetter + s . slice ( i + 1 ) ; } else { if ( ( 27 - ( code - 97 + 1 ) ) < = p & & ! ( s [ i ] = = " a " ) ) { p = p - ( 27 - ( code - 97 + 1 ) ) ; s = s . slice ( 0 , i ) + " a " + s . slice ( i + 1 ) ; } } } console . log ( s ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( " " ) ; var a = parseInt ( input [ 0 ] , 10 ) ; var b = parseInt ( input [ 1 ] , 10 ) ; var c = parseInt ( input [ 2 ] , 10 ) ; var total = a + b + c ; if ( total = = = 17 ) { console . log ( ' YES ' ) ; } else { console . log ( ' NO ' ) ; } } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { input = input . split ( " \ n " ) var araresN = parseInt ( input [ 0 ] ) var arares = input [ 1 ] . split ( " " ) console . log ( arares . indexOf ( " Y " ) = = - 1 ? " Three " : " Four " ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var inputs = input . split ( ' ' ) ; var K = Number ( inputs [ 0 ] ) ; var S = Number ( inputs [ 1 ] ) ; var count = 0 ; for ( var X = 0 ; X < = K ; X + + ) { for ( var Y = 0 ; Y < = K ; Y + + ) { var Z = ( S - X - Y ) ; if ( 0 < = Z & & Z < = K ) { count + + ; } } } console . log ( count ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function Main ( input ) { var N = input . split ( " \ n " ) [ 0 ] ; var a = input . split ( " \ n " ) [ 1 ] . split ( " " ) ; var as = a . sort ( ) ; var dev = parseInt ( as [ ( N - 1 ) ] , 10 ) - parseInt ( as [ 0 ] , 10 ) ; console . log ( dev ) } Main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ( function Main ( input ) { var input = input . split ( ' \ n ' ) , X = input [ 1 ] . split ( ' ' ) . map ( Number ) , len = X . length , result = 0 , avg = function ( data ) { var sum = 0 ; for ( var i = 0 ; i < len ; i + + ) { sum + = data [ i ] ; } return Math . round ( sum / len ) ; } ( X ) ; for ( var i = 0 ; i < len ; i + + ) { result + = Math . pow ( X [ i ] - avg , 2 ) ; } console . log ( result ) ; } ) ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function parse ( input ) { return input . trim ( ) . split ( " " ) . map ( item = > parseInt ( item , 10 ) ) } function f ( arr ) { return arr . sort ( ( a , b ) = > b - a ) . reduce ( ( acc , n , i , arr ) = > acc + ( i = = = 0 ? 0 : arr [ i - 1 ] - arr [ i ] ) , 0 ) } module . exports = { parse , f , } function Main ( input ) { const arr = parse ( input ) console . log ( f ( arr ) ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) function main ( input ) { input = input . trim ( ) ; const a = input . split ( " " ) . map ( Number ) ; console . log ( a [ 0 ] + a [ 1 ] > = a [ 2 ] ? " Yes " : " No " ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( input ) { var a = input . trim ( ) . split ( / \ s + / ) . map ( ( e ) = > { return Number ( e ) } ) . sort ( ) ; console . log ( a [ 0 ] = = 5 & & a [ 1 ] = = 5 & & a [ 2 ] = = 7 ? ' YES ' : ' NO ' ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' const main = arg = > { const input = arg . trim ( ) . split ( " \ n " ) ; let Alice = Number ( input [ 0 ] . split ( ' ' ) [ 0 ] ) let Bob = Number ( input [ 0 ] . split ( ' ' ) [ 1 ] ) let cards = [ ] for ( let i = 2 ; i < = 13 ; i + + ) { cards . push ( i ) } cards . push ( 1 ) if ( cards . indexOf ( Alice ) > cards . indexOf ( Bob ) ) { console . log ( ' Alice ' ) } else if ( cards . indexOf ( Alice ) < cards . indexOf ( Bob ) ) { console . log ( ' Bob ' ) } else { console . log ( ' Draw ' ) } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { var x = parseInt ( chunk . trim ( ) , 10 ) ; console . log ( Math . pow ( x , 3 ) ) ; } ) ; " use strict " ; const main = arg = > { const times = arg . split ( " \ n " ) . map ( n = > parseInt ( n ) ) ; let min = 10 ; let sum = 0 ; for ( let i = 0 ; i < 5 ; i + + ) { let digitOne = times [ i ] % 10 ; sum + = parseInt ( times [ i ] ) ; if ( 10 - digitOne ! = = 10 ) { sum + = 10 - digitOne ; } if ( 10 - digitOne ! = = 10 & & digitOne < min ) { min = digitOne ; } } console . log ( parseInt ( sum - ( 10 - min ) ) ) ; } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; " use strict " ; const main = ( input ) = > { const [ a , b ] = input . trim ( ) . split ( " " ) . map ( Number ) ; if ( a = = = b ) { return " Draw " ; } else if ( b = = = 1 ) { return " Bob " ; } else if ( a = = = 1 ) { return " Alice " ; } else if ( a < b ) { return " Bob " ; } else { return " Alice " ; } } ; console . log ( main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ) ; function Main ( input ) { var inputs = input . split ( ' / ' ) ; var y = parseInt ( inputs [ 0 ] , 10 ) ; var m = parseInt ( inputs [ 1 ] , 10 ) ; var d = parseInt ( inputs [ 2 ] , 10 ) ; if ( y < = 2019 & & m < = 04 & & d < = 30 ) { console . log ( ' Heisei ' ) ; } else { console . log ( ' TBD ' ) ; } } Main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; log = console . log ; var stdin = require ( " fs " ) . readFileSync ( " / dev / stdin " , " UTF-8 " ) ; var lines = stdin . split ( " \ n " ) ; var N = Number ( lines [ 0 ] . split ( " " ) [ 0 ] ) ; var M = Number ( lines [ 0 ] . split ( " " ) [ 1 ] ) ; lines = lines . splice ( 1 ) . filter ( v = > v ! = = " " ) ; cities = lines . map ( ( v , i ) = > { P = Number ( v . split ( " " ) [ 0 ] ) ; Y = Number ( v . split ( " " ) [ 1 ] ) ; return { cityIndex : i , prefecture : P , year : Y } ; } ) ; cities . sort ( ( a , b ) = > { return a . year - b . year ; } ) ; count = [ ] ; cities = cities . map ( c = > { count [ c . prefecture ] = = = undefined ? ( count [ c . prefecture ] = 1 ) : ( count [ c . prefecture ] + = 1 ) ; P = " 000000 " + c . prefecture . toString ( ) ; P = P . substr ( P . length - 6 , 6 ) ; id = " 000000 " + count [ c . prefecture ] . toString ( ) ; id = id . substr ( id . length - 6 , 6 ) ; return { cityIndex : c . cityIndex , prefecture : P , year : Y , id : id } ; } ) ; cities . sort ( ( a , b ) = > { return a . cityIndex - b . cityIndex ; } ) ; cities . forEach ( c = > console . log ( c . prefecture . toString ( ) + c . id . toString ( ) ) ) ; " use strict " const fs = require ( " fs " ) ; function main ( input ) { const tmp = input . split ( " \ n " ) ; const n = tmp [ 0 ] ; const xs = tmp [ 1 ] . split ( " " ) . map ( v = > parseInt ( v ) ) ; console . log ( process ( n , xs ) ) ; } function process ( n , xs ) { let ret = 100000000 ; const min = Math . min ( ... xs ) ; const max = Math . max ( ... xs ) ; for ( let p = min ; p < = max ; + + p ) { const sum = xs . reduce ( ( a , c ) = > a + Math . pow ( ( c - p ) , 2 ) , 0 ) ; if ( ret > sum ) ret = sum ; } return ret ; } main ( fs . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; ' use strict ' ; function Main ( input ) { let ary = input . split ( " " ) ; ary . sort ( ) ; ( ary [ 0 ] = = 5 & & ary [ 1 ] = = 5 & & ary [ 2 ] = = 7 ) ? console . log ( " YES " ) : console . log ( " NO " ) ; } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( input ) { var a = parseInt ( input ) ; console . log ( a * a * a ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( ) { var x = input [ 0 ] ; console . log ( x * x * x ) ; } var input = ' ' ; process . stdin . resume ( ) ; process . stdin . setEncoding ( ' utf8 ' ) ; process . stdin . on ( ' data ' , function ( chunk ) { input + = chunk ; } ) ; process . stdin . on ( ' end ' , function ( ) { input = input . split ( ' \ n ' ) ; main ( ) ; } ) ; " use strict " function main ( arg ) { var data = arg . trim ( ) . split ( " \ n " ) var tmp = data . shift ( ) . split ( ' ' ) . map ( Number ) var N = tmp [ 0 ] var D = tmp [ 1 ] data = data . map ( e = > e . split ( ' ' ) . map ( Number ) ) var ans = 0 for ( var i = 0 ; i < N ; i + + ) { for ( var j = i ; j < N ; j + + ) { if ( i = = = j ) continue var row1 = data [ i ] var row2 = data [ j ] var yz = 0 for ( var d = 0 ; d < D ; d + + ) { var t = Math . abs ( row1 [ d ] - row2 [ d ] ) yz + = t * t } var tAns = Math . sqrt ( yz ) if ( ! ( String ( tAns ) . split ( ' . ' ) . length > 1 ) ) { ans + + } } } console . log ( ans ) } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; function main ( input ) { const y = input . split ( " / " ) [ 0 ] ; const m = input . split ( " / " ) [ 1 ] ; const d = input . split ( " / " ) [ 2 ] ; var aaa = y + m + d ; aaa = parseInt ( aaa , 10 ) ; if ( aaa < 20190500 ) { console . log ( " Heisei " ) ; } else { console . log ( " TBD " ) ; } } main ( require ( ' fs ' ) . readFileSync ( ' / dev / stdin ' , ' utf8 ' ) ) ; " use strict " ; function Main ( input ) { let lines = input . split ( ' \ n ' ) let N = lines [ 0 ] . split ( ' ' ) [ 0 ] * 1 let D = lines [ 0 ] . split ( ' ' ) [ 1 ] * 1 lines . shift ( ) let ans = 0 let line = lines . map ( ( l ) = > { return l . split ( ' ' ) } ) for ( let i = 0 ; i < N - 1 ; i + + ) { for ( let j = i + 1 ; j < N ; j + + ) { let t = 0 ; for ( let k = 0 ; k < D ; k + + ) { t + = Math . pow ( ( line [ i ] [ k ] - line [ j ] [ k ] ) , 2 ) ; } if ( Math . sqrt ( t ) % 1 = = 0 ) { ans + + ; } } } console . log ( ans ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; line = require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) . split ( " \ n " ) , n = parseInt ( line [ 0 ] ) , v = line [ 1 ] . split ( " " ) ; for ( var odds = { } , even = { } , i = 0 ; i < v . length ; i + + ) di = 1 & i ? even : odds , di [ v [ i ] ] = di [ v [ i ] ] ? di [ v [ i ] ] + 1 : 1 ; var a = [ ] , b = [ ] ; for ( var k in odds ) a . push ( { v : k , n : odds [ k ] } ) ; for ( var k in even ) b . push ( { v : k , n : even [ k ] } ) ; a . sort ( ( n , i ) = > i . n - n . n ) , b . sort ( ( n , i ) = > i . n - n . n ) , a [ 0 ] . v ! = b [ 0 ] . v & & ( b [ 1 ] = b [ 0 ] ) , log = console . log , log ( n - Math . max ( a [ 0 ] . n + ( b [ 1 ] ? b [ 1 ] . n : 0 ) , ( a [ 1 ] ? a [ 1 ] . n : 0 ) + b [ 0 ] . n ) ) ; function Main ( input ) { lines = input . split ( ' \ n ' ) N = lines [ 0 ] . split ( ' ' ) [ 0 ] * 1 D = lines [ 0 ] . split ( ' ' ) [ 1 ] * 1 lines . shift ( ) ans = 0 lines = lines . map ( ( l ) = > { return l . split ( ' ' ) } ) for ( i = 0 ; i < N - 1 ; i + + ) { for ( j = i + 1 ; j < N ; j + + ) { t = 0 for ( k = 0 ; k < D ; k + + ) { t + = ( lines [ i ] [ k ] - lines [ j ] [ k ] ) * ( lines [ i ] [ k ] - lines [ j ] [ k ] ) } r = Math . sqrt ( t ) if ( r = = parseInt ( r ) ) { ans + + } } } console . log ( ans ) } Main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; function main ( a ) { console . log ( a * 800 - ~ ~ ( a / 15 ) * 200 ) ; } main ( require ( " fs " ) . readFileSync ( " / dev / stdin " , " utf8 " ) ) ; < ? php while ( $ line = fgets ( STDIN ) ) { $ array [ ] = trim ( $ line ) ; for ( $ i = 0 ; $ i < count ( $ array ) ; $ i + + ) { $ array [ $ i ] = ( int ) $ array [ $ i ] ; } } $ large _ yen = $ array [ 0 ] ; $ middle _ yen = $ array [ 1 ] ; $ small _ yen = $ array [ 2 ] ; $ balance = $ array [ 3 ] ; $ count = 0 ; for ( $ a = 0 ; $ a < = $ large _ yen ; $ a + + ) { for ( $ b = 0 ; $ b < = $ middle _ yen ; $ b + + ) { for ( $ c = 0 ; $ c < = $ small _ yen ; $ c + + ) { $ total = $ a * 500 + $ b * 100 + $ c * 50 ; if ( $ total = = $ balance ) $ count + + ; } } } echo ( $ count ) ; < ? php fscanf ( STDIN , " % d " , $ a ) ; fscanf ( STDIN , " % d " , $ b ) ; fscanf ( STDIN , " % d " , $ c ) ; fscanf ( STDIN , " % d " , $ x ) ; $ ans = 0 ; for ( $ i = 0 ; $ i < $ a + 1 ; $ i + + ) { for ( $ j = 0 ; $ j < $ b + 1 ; $ j + + ) { for ( $ k = 0 ; $ k < $ c + 1 ; $ k + + ) { if ( 500 * $ i + 100 * $ j + 50 * $ k = = $ x ) { $ ans + + ; } } } } echo $ ans ; ? > < ? php while ( true ) { fscanf ( STDIN , " % d " , $ n ) ; if ( $ n = = 0 ) break ; fscanf ( STDIN , " % d " , $ m ) ; $ input = array ( array ( ) , array ( ) , array ( ) , array ( ) , ) ; for ( $ i = 0 ; $ m > $ i ; $ i + + ) { fscanf ( STDIN , " % d , % d , % d " , $ a , $ b , $ d ) ; $ input [ $ a ] [ $ b ] = $ d ; $ input [ $ b ] [ $ a ] = $ d ; } $ already = array _ pad ( array ( ) , $ n , false ) ; $ already [ 0 ] = true ; $ result = 0 ; while ( true ) { $ f = false ; foreach ( $ already as $ k = > $ flg ) { if ( ! $ flg ) { $ f = true ; } } if ( ! $ f ) break ; $ index = 0 ; $ tmp = PHP _ INT _ MAX ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { if ( ! $ already [ $ i ] ) continue ; foreach ( $ input [ $ i ] as $ key = > $ val ) { if ( $ tmp > $ val & & ! $ already [ $ key ] ) { $ index = $ key ; $ tmp = $ val ; } } } $ already [ $ index ] = true ; $ result + = $ tmp ; } echo ( ( $ result - ( ( $ n - 1 ) * 100 ) ) / 100 ) . " \ n " ; } < ? php fscanf ( STDIN , " % d " , $ n ) ; $ s = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ r = array ( ) ; foreach ( $ s as $ col ) { $ r [ $ col ] + + ; } if ( count ( $ r ) = = 3 ) { echo " Three \ n " ; } else { echo " Four \ n " ; } < ? php $ s = trim ( fgets ( STDIN ) ) ; echo ( $ s [ 2 ] = = $ s [ 3 ] and $ s [ 4 ] = = $ s [ 5 ] ) ? " Yes " : " No " ; < ? php list ( $ N , $ D ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; for ( $ i = 0 ; $ i < $ N ; $ i + + ) { $ x [ ] = explode ( " " , trim ( fgets ( STDIN ) ) ) ; } $ ans = 0 ; for ( $ i = 0 ; $ i < $ N - 1 ; $ i + + ) { for ( $ j = $ i + 1 ; $ j < $ N ; $ j + + ) { $ diff = 0 ; foreach ( $ x [ $ i ] as $ k = > $ v ) { $ diff + = pow ( $ x [ $ i ] [ $ k ] - $ x [ $ j ] [ $ k ] , 2 ) ; } $ diff _ int = sqrt ( $ diff ) ; if ( $ diff _ int = = intval ( $ diff _ int ) ) { $ ans + + ; } } } printf ( " % d \ n " , $ ans ) ; < ? php $ input = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ n = ( int ) $ input [ 0 ] ; $ m = ( int ) $ input [ 1 ] ; $ args = [ ] ; $ count = 0 ; while ( true ) { $ input = trim ( fgets ( STDIN ) ) ; $ input = explode ( " " , $ input ) ; $ args [ ( int ) $ input [ 0 ] ] [ $ count ] = ( int ) $ input [ 1 ] ; + + $ count ; if ( $ count > = $ m ) { break ; } } $ result = [ ] ; for ( $ i = 1 ; $ i < = $ n ; $ i + + ) { if ( ! empty ( $ args [ $ i ] ) ) { $ p = $ args [ $ i ] ; asort ( $ p ) ; $ city = 1 ; foreach ( $ p as $ idx = > $ year ) { $ result [ $ idx ] = str _ pad ( ( string ) $ i , 6 , " 0 " , STR _ PAD _ LEFT ) . str _ pad ( ( string ) $ city , 6 , " 0 " , STR _ PAD _ LEFT ) ; + + $ city ; } } } for ( $ k = 0 ; $ k < $ m ; $ k + + ) { echo $ result [ $ k ] . " \ n " ; } < ? php fscanf ( STDIN , " % d % d % d " , $ a , $ b , $ c ) ; $ checkList = array ( 7 , 5 , 5 ) ; $ numList = array ( $ a , $ b , $ c ) ; rsort ( $ numList ) ; $ result = " YES " ; foreach ( $ checkList as $ check ) { $ tmp = array _ shift ( $ numList ) ; if ( $ check ! = $ tmp ) { $ result = " NO " ; break ; } } echo $ result ; < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; $ ave = ( $ a + $ b ) / 2 ; $ dec = ( $ a + $ b ) / 2 ; $ n = 0 ; while ( $ dec > = 1 ) { $ dec = $ dec - 1 ; } if ( $ dec > 0 ) { $ n = $ ave - $ dec + 1 ; echo $ n . " \ n " ; } else { $ n = $ ave - $ dec ; echo $ n . " \ n " ; } ? > < ? php $ single _ line _ input = fgets ( STDIN ) ; $ input = explode ( " " , $ single _ line _ input ) ; $ a _ = $ input [ 0 ] * $ input [ 1 ] ; $ b _ = $ input [ 2 ] * $ input [ 3 ] ; if ( $ a _ > $ b _ ) { echo $ a _ ; } else if ( $ b _ > $ a _ ) { echo $ b _ ; } else { echo $ a _ ; } < ? php fscanf ( STDIN , " % d % d " , $ n , $ w ) ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { fscanf ( STDIN , " % d % d " , $ W [ ] , $ V [ ] ) ; } $ offset = $ W [ 0 ] ; array _ unshift ( $ V , null ) ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ W [ $ i ] - = $ offset ; } array _ unshift ( $ W , null ) ; $ dp [ 0 ] [ 0 ] = array _ fill ( 0 , 301 , 0 ) ; for ( $ i = 1 ; $ i < = $ n ; $ i + + ) { $ dp [ $ i ] = $ dp [ $ i - 1 ] ; $ dp [ $ i ] [ $ i ] = $ dp [ $ i ] [ $ i - 1 ] ; for ( $ j = 1 ; $ j < = $ i ; $ j + + ) { for ( $ k = 0 ; $ k < = 3 * $ n ; $ k + + ) { if ( $ k - $ W [ $ i ] > = 0 ) $ dp [ $ i ] [ $ j ] [ $ k ] = max ( $ dp [ $ i ] [ $ j ] [ $ k ] , $ dp [ $ i - 1 ] [ $ j - 1 ] [ $ k - $ W [ $ i ] ] + $ V [ $ i ] ) ; } } } $ max = 0 ; for ( $ i = 0 ; $ i < = $ n ; $ i + + ) { if ( $ w - $ i * $ offset > = 0 ) { $ max = max ( $ max , $ dp [ $ n ] [ $ i ] [ min ( $ w - $ i * $ offset , 3 * $ n ) ] ) ; } } echo $ max ; < ? php fscanf ( STDIN , " % d % d % d % d " , $ a , $ b , $ c , $ d ) ; $ rec1 = $ a * $ b ; $ rec2 = $ c * $ d ; if ( $ rec1 = = = $ rec2 ) { echo $ rec1 ; } elseif ( $ rec1 > $ rec2 ) { echo $ rec1 ; } else { echo $ rec2 ; } ? > < ? php fscanf ( STDIN , " % d " , $ n ) ; $ p _ arr = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ count = 0 ; $ min = $ n + 1 ; for ( $ i = 0 ; $ i < $ n ; + + $ i ) { if ( $ p _ arr [ $ i ] < = $ min ) { + + $ count ; } $ min = min ( $ min , $ p _ arr [ $ i ] ) ; } echo $ count ; < ? php $ input = fgets ( STDIN ) ; $ ans = pow ( $ input , 3 ) ; echo $ ans . " \ n " ; ? > < ? php declare ( strict _ types = 1 ) ; fscanf ( STDIN , " % i " , $ n ) ; $ xs = explode ( " " , fgets ( STDIN ) ) ; $ start = min ( $ xs ) ; $ end = max ( $ xs ) ; echo $ end - $ start , PHP _ EOL ; < ? php $ s = str _ split ( trim ( fgets ( STDIN ) ) ) ; $ count = count ( $ s ) ; $ a = array ( " a " = > 1 , " b " = > 2 , " c " = > 3 , " d " = > 4 , " e " = > 5 , " f " = > 6 , " g " = > 7 , " h " = > 8 , " i " = > 9 , " j " = > 10 , " k " = > 11 , " l " = > 12 , " m " = > 13 , " n " = > 14 , " o " = > 15 , " p " = > 16 , " q " = > 17 , " r " = > 18 , " s " = > 19 , " t " = > 20 , " u " = > 21 , " v " = > 22 , " w " = > 23 , " x " = > 24 , " y " = > 25 , " z " = > 26 ) ; $ i = 0 ; while ( $ i < $ count ) { $ num [ $ i ] = strtr ( $ s [ $ i ] , $ a ) ; $ d [ $ i ] = 27 - $ num [ $ i ] ; + + $ i ; } $ i = 0 ; $ K = trim ( fgets ( STDIN ) ) ; $ n = 0 ; while ( $ i < $ count ) { if ( $ d [ $ i ] ! = 26 & & $ d [ $ i ] < = $ K - $ n ) { $ num [ $ i ] = 1 ; $ n + = $ d [ $ i ] ; } + + $ i ; } if ( $ n ! = $ K ) { $ num [ $ count - 1 ] + = $ K - $ n ; $ num [ $ count - 1 ] % = 26 ; if ( $ num [ $ count - 1 ] = = 0 ) { $ num [ $ count - 1 ] = 26 ; } } $ i = 0 ; while ( $ i < $ count ) { echo array _ search ( $ num [ $ i ] , $ a ) ; + + $ i ; } echo PHP _ EOL ; ? > < ? php $ input = fgets ( STDIN ) ; $ input _ array = explode ( " " , $ input ) ; $ int _ array = array _ map ( function ( $ value ) { return ( int ) $ value ; } , $ input _ array ) ; $ ans = $ int _ array [ 2 ] * 60 + $ int _ array [ 3 ] - $ int _ array [ 0 ] * 60 - $ int _ array [ 1 ] - $ int _ array [ 4 ] ; echo $ ans ; < ? php $ n = intval ( trim ( fgets ( STDIN ) ) ) ; $ a = array _ map ( " intval " , explode ( " " , trim ( fgets ( STDIN ) ) ) ) ; $ sum = 0 ; $ mod = 10 * * 9 + 7 ; for ( $ i = 0 ; $ i < = 60 ; $ i + + ) { $ c = 0 ; foreach ( $ a as $ b ) { $ c + = ( $ b > > $ i ) & 1 ; } $ c % = $ mod ; $ c * = $ n - $ c ; $ c % = $ mod ; $ c * = ( 1 < < $ i ) % $ mod ; $ c % = $ mod ; $ sum + = $ c ; $ sum % = $ mod ; } echo $ sum ; < ? php # 入力部 fscanf ( STDIN , " % d " , $ r ) ; # 処理部 # 出力部 echo $ r * * 2 . " \ n " ; < ? php for ( $ i = 0 ; $ i < 5 ; $ i + + ) { $ array [ $ i ] = trim ( fgets ( STDIN ) ) ; } $ k = trim ( fgets ( STDIN ) ) ; $ cnt = 0 ; for ( $ i = 0 ; $ i < 5 ; $ i + + ) { for ( $ j = $ i + 1 ; $ j < 5 ; $ j + + ) { $ sub = $ array [ $ j ] - $ array [ $ i ] ; if ( $ sub > $ k ) { $ cnt = 1 ; } } } if ( $ cnt = = 1 ) { echo " : ( " ; } else { echo " Yay ! " ; } ? > < ? php $ input = trim ( fgets ( STDIN ) ) ; $ ans = pow ( $ input , 3 ) ; print $ ans ; ? > < ? php $ n = intval ( trim ( fgets ( STDIN ) ) ) ; $ a = array _ map ( " intval " , explode ( " " , trim ( fgets ( STDIN ) ) ) ) ; $ sum = 0 ; $ mod = 10 * * 9 + 7 ; for ( $ i = 0 ; $ i < 60 ; $ i + + ) { $ c = 0 ; foreach ( $ a as $ b ) { $ c + = ( $ b > > $ i ) & 1 ; } $ d = $ c * ( $ n - $ c ) % $ mod ; $ d * = ( 1 < < $ i ) % $ mod ; $ sum + = $ d % $ mod ; $ sum % = $ mod ; } echo $ sum ; < ? php $ input = preg _ split ( ' / [ \ s , ] + / ' , trim ( fgets ( STDIN ) ) ) ; $ a = $ input [ 0 ] ; $ b = $ input [ 1 ] ; if ( $ a = = $ b ) { echo " Draw \ n " ; } else if ( $ b = = 1 ) { echo " Bob \ n " ; } else if ( $ a > $ b | | $ a = = 1 ) { echo " Alice \ n " ; } else echo " Bob \ n " ; ? > < ? php define ( ' MOD ' , pow ( 10 , 9 ) + 7 ) ; define ( ' BIT ' , 60 ) ; $ x [ 0 ] = 1 ; for ( $ i = 1 ; $ i < BIT ; $ i + + ) { $ x [ $ i ] = $ x [ $ i - 1 ] * 2 ; $ x [ $ i ] % = MOD ; } fscanf ( STDIN , " % d " , $ N ) ; $ a = array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; $ k [ 0 ] = array _ pad ( array ( ) , BIT , 0 ) ; $ k [ 1 ] = array _ pad ( array ( ) , BIT , 0 ) ; $ ans = 0 ; for ( $ i = 0 ; $ i < $ N ; $ i + + ) { $ s = strrev ( str _ pad ( decbin ( $ a [ $ i ] ) , BIT , ' 0 ' , STR _ PAD _ LEFT ) ) ; for ( $ j = 0 ; $ j < BIT ; $ j + + ) { $ k [ $ s [ $ j ] ] [ $ j ] + + ; } } for ( $ i = 0 ; $ i < BIT ; $ i + + ) { $ tmp = $ k [ 0 ] [ $ i ] * $ k [ 1 ] [ $ i ] ; $ tmp % = MOD ; $ tmp * = $ x [ $ i ] ; $ tmp % = MOD ; $ ans + = $ tmp ; } $ ans % = MOD ; printf ( " % d " , $ ans ) ; < ? php $ input = trim ( fgets ( STDIN ) ) ; echo $ input * $ input * $ input ; ? > < ? php list ( $ A , $ B , $ H , $ M ) = array _ map ( ' intval ' , explode ( " " , trim ( fgets ( STDIN ) ) ) ) ; $ hh = ( $ H % 12 ) * 30 ; $ mm = $ M * 6 ; $ hh + = $ M * 0.5 ; $ k = abs ( $ hh - $ mm ) ; if ( $ k > 180 ) $ k = 360 - $ k ; echo sqrt ( $ A * * 2 + $ B * * 2 - ( 2 * $ A * $ B * cos ( deg2rad ( $ k ) ) ) ) ; < ? php $ line = fgets ( STDIN ) ; $ data = explode ( ' ' , $ line ) ; $ a = $ data [ 0 ] ; $ b = $ data [ 1 ] ; $ result = round ( ( $ a + $ b ) / 2 ) ; print $ result ; < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; if ( $ a = = 1 ) { $ a = 14 ; } if ( $ b = = 1 ) { $ b = 14 ; } if ( $ a > $ b ) { echo ( " Alice " ) ; } elseif ( $ a < $ b ) { echo ( " Bob " ) ; } else { echo ( " Draw " ) ; } < ? php fscanf ( STDIN , " % d % d % d " , $ a , $ b , $ c ) ; if ( $ a + $ b + $ c = = 17 ) { echo ' YES ' ; } else { echo ' NO ' ; } < ? php while ( $ line = fgets ( STDIN ) ) { $ stdin [ ] = trim ( $ line ) ; } # $ v2 = str _ split ( $ stdin [ 0 ] ) ; # $ v2 = explode ( " " , $ stdin [ 0 ] ) ; $ ans = $ stdin [ 0 ] * $ stdin [ 0 ] ; echo $ ans . PHP _ EOL ; < ? php $ A = trim ( fgets ( STDIN ) ) ; $ B = trim ( fgets ( STDIN ) ) ; $ C = trim ( fgets ( STDIN ) ) ; $ X = trim ( fgets ( STDIN ) ) ; $ cnt = 0 ; for ( $ i = 0 ; $ i < $ A + 1 ; $ i + + ) { for ( $ j = 0 ; $ j < $ B + 1 ; $ j + + ) { for ( $ k = 0 ; $ k < $ C + 1 ; $ k + + ) { if ( ( 500 * $ i + 100 * $ j + 50 * $ k ) = = $ X ) { $ cnt + + ; } } } } print $ cnt ; < ? php $ arr = [ ] ; for ( $ i = 0 ; $ i < 5 ; $ i + + ) { fscanf ( STDIN , ' % d ' , $ d ) ; $ arr [ ] = $ d ; } rsort ( $ arr ) ; fscanf ( STDIN , ' % d ' , $ k ) ; for ( $ j = 0 ; $ j < 5 ; $ j + + ) { for ( $ h = 1 ; $ h < 5 ; $ h + + ) { if ( $ arr [ $ j ] - $ arr [ $ h ] > $ k ) { echo ' : ( ' , PHP _ EOL ; exit ; } } } echo ' Yay ! ' , PHP _ EOL ; < ? php fscanf ( STDIN , " % d % d % d " , $ a , $ b , $ c ) ; if ( $ a + $ b + $ c = = 17 & & $ a * $ b * $ c = = 175 ) { echo " YES " ; } else { echo " NO " ; } ? > < ? php fscanf ( STDIN , " % d " , $ n ) ; $ inputs = array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; $ max = max ( $ inputs ) ; $ decs = [ ] ; for ( $ i = 1 ; $ max > = $ i ; $ i + + ) { $ tmp = 0 ; foreach ( $ inputs as $ input ) { $ x = $ input - $ i ; $ y = pow ( $ x , 2 ) ; # echo join ( " , " , [ $ input , $ i , $ n , $ x , $ y ] ) . " \ n " ; $ tmp + = $ y ; } # echo " = " . $ tmp . " \ n " ; $ decs [ ] = $ tmp ; } # echo join ( " , " , $ decs ) . " \ n " ; echo min ( $ decs ) ; < ? php [ $ H1 , $ M1 , $ H2 , $ M2 , $ K ] = array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; printf ( " % d " , $ H2 * 60 + $ M2 - ( $ H1 * 60 + $ M1 ) - $ K ) ; < ? php for ( $ i = 0 ; $ i < 5 ; $ i + + ) { $ X [ ] = intval ( trim ( fgets ( STDIN ) ) ) ; } $ ans = 10 ; for ( $ i = 0 ; $ i < 5 ; $ i + + ) { $ amari = $ X [ $ i ] % 10 ; if ( ( $ amari < $ ans ) & & ( $ amari ! = 0 ) ) { $ ans = $ amari ; $ i _ memory = $ i ; } } $ sum = 0 ; for ( $ i = 0 ; $ i < 5 ; $ i + + ) { if ( $ i = = $ i _ memory ) { $ sum + = $ X [ $ i ] ; } else { if ( $ X [ $ i ] % 10 = = 0 ) { $ sum + = $ X [ $ i ] ; } else { $ sum + = ( intdiv ( $ X [ $ i ] + 10 , 10 ) * 10 ) ; } } } echo $ sum ; ? > < ? php $ input = trim ( fgets ( STDIN ) ) ; $ total = $ input * 800 ; $ option = 200 * floor ( $ input / 15 ) ; echo ( $ total - $ option . " \ n " ) ; < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; if ( $ a < = 5 ) { $ result = 0 ; } elseif ( $ a < = 12 ) { $ result = $ b / 2 ; } else { $ result = $ b ; } echo $ result , PHP _ EOL ; < ? php fscanf ( STDIN , " % d " , $ N ) ; $ S = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ flag = 0 ; for ( $ i = 0 ; $ i < $ N ; $ i + + ) { if ( $ S [ $ i ] = = ' Y ' ) { $ flag = 1 ; } } if ( $ flag = = 1 ) { out : : println ( ' Four ' ) ; } else { out : : println ( ' Three ' ) ; } class out { public static function println ( $ str = " " ) { echo $ str . PHP _ EOL ; } } ? > < ? php $ r = ( int ) trim ( fgets ( STDIN ) ) ; echo $ r * $ r ; < ? php list ( $ a , $ b , $ c , $ d ) = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ A = $ a * $ b ; $ B = $ c * $ d ; echo $ A > $ B ? $ A : $ B ; ? > < ? php $ min = 124 ; $ max = 0 ; for ( $ i = 0 ; $ i < 5 ; $ i + + ) { fscanf ( STDIN , " % d " , $ now ) ; if ( $ max < $ now ) { $ max = $ now ; } if ( $ min > $ now ) { $ min = $ now ; } } fscanf ( STDIN , " % d " , $ k ) ; echo ( $ max - $ min < = $ k ) ? " Yay ! " : " : ( " ; < ? php $ map [ ] = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ map [ ] = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ map [ ] = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ flag = true ; for ( $ i = 0 ; $ i < 2 ; $ i + + ) { if ( $ map [ $ i ] [ 1 ] - $ map [ $ i ] [ 0 ] ! = $ map [ $ i + 1 ] [ 1 ] - $ map [ $ i + 1 ] [ 0 ] ) $ flag = false ; if ( $ map [ $ i ] [ 2 ] - $ map [ $ i ] [ 1 ] ! = $ map [ $ i + 1 ] [ 2 ] - $ map [ $ i + 1 ] [ 1 ] ) $ flag = false ; if ( $ map [ 1 ] [ $ i ] - $ map [ 0 ] [ $ i ] ! = $ map [ 1 ] [ $ i + 1 ] - $ map [ 0 ] [ $ i + 1 ] ) $ flag = false ; if ( $ map [ 2 ] [ $ i ] - $ map [ 1 ] [ $ i ] ! = $ map [ 2 ] [ $ i + 1 ] - $ map [ 1 ] [ $ i + 1 ] ) $ flag = false ; } echo $ flag ? " Yes " : " No " ; < ? php list ( $ a , $ b ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; if ( $ a = = 1 ) $ a = 100 ; if ( $ b = = 1 ) $ b = 100 ; if ( $ a > $ b ) { echo " Alice " ; } elseif ( $ a < $ b ) { echo " Bob " ; } else { echo " Draw " ; } < ? php fscanf ( STDIN , ' % d % d ' , $ a , $ b ) ; echo ( $ a < = 8 & & $ b < = 8 ) ? ' Yay ! ' : ' : ( ' ; echo " \ n " ; < ? php $ input = trim ( fgets ( STDIN ) ) ; echo $ input * $ input * $ input ; ? > < ? php list ( $ n , $ m ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ tree = [ ] ; $ tree2 = [ ] ; for ( $ i = 1 ; $ i < = $ n ; $ i + + ) { $ tree2 [ $ i ] = [ ] ; for ( $ j = 1 ; $ j < = $ n ; $ j + + ) { if ( $ i = = $ j ) { $ tree2 [ $ i ] [ $ j ] = 0 ; } else { $ tree2 [ $ i ] [ $ j ] = PHP _ INT _ MAX ; } } } for ( $ i = 0 ; $ i < $ m ; $ i + + ) { list ( $ a , $ b , $ c ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; if ( ! isset ( $ tree [ $ a ] ) ) $ tree [ $ a ] = [ ] ; $ tree [ $ a ] [ $ b ] = $ c ; $ tree2 [ $ a ] [ $ b ] = $ c ; $ tree2 [ $ b ] [ $ a ] = $ c ; } for ( $ k = 1 ; $ k < = $ n ; $ k + + ) { for ( $ i = 1 ; $ i < = $ n ; $ i + + ) { for ( $ j = 1 ; $ j < = $ n ; $ j + + ) { $ tree2 [ $ i ] [ $ j ] = min ( $ tree2 [ $ i ] [ $ j ] , $ tree2 [ $ i ] [ $ k ] + $ tree2 [ $ k ] [ $ j ] ) ; } } } $ ans = 0 ; foreach ( $ tree as $ i = > $ t ) { foreach ( $ t as $ j = > $ v ) { if ( $ v ! = $ tree2 [ $ i ] [ $ j ] ) { $ ans + + ; } } } echo $ ans ; < ? php $ a = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; echo max ( $ a ) - min ( $ a ) ; < ? php error _ reporting ( 0 ) ; list ( $ A , $ B , $ C ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; if ( $ A + $ B > = $ C ) { printf ( " Yes \ n " ) ; } else { printf ( " No \ n " ) ; } < ? php while ( true ) { fscanf ( STDIN , ' % s ' , $ x ) ; if ( $ x = = 0 ) { break ; } echo array _ sum ( str _ split ( $ x ) ) , PHP _ EOL ; } < ? php fscanf ( STDIN , ' % d ' , $ r ) ; echo $ r * * 2 ; < ? php fscanf ( STDIN , " % d % d % d " , $ a , $ b , $ c ) ; $ array = [ $ a , $ b , $ c ] ; $ seven = 0 ; $ five = 0 ; for ( $ i = 0 ; $ i < 3 ; $ i + + ) { if ( $ array [ $ i ] = = 7 ) { $ seven + + ; } elseif ( $ array [ $ i ] = = 5 ) { $ five + + ; } } if ( $ seven = = = 1 & & $ five = = = 2 ) { echo ' YES ' ; } else { echo ' NO ' ; } ? > < ? php fscanf ( STDIN , " % d " , $ N ) ; $ x _ list = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ flag = true ; $ sum _ distance _ list = array ( ) ; $ sum _ distance = 0 ; for ( $ i = 1 ; $ i < = 100 ; $ i + + ) { for ( $ j = 0 ; $ j < $ N ; $ j + + ) { $ sum _ distance + = ( $ x _ list [ $ j ] - $ i ) * * 2 ; } $ sum _ distance _ list [ ] = $ sum _ distance ; $ sum _ distance = 0 ; } echo min ( $ sum _ distance _ list ) . " \ n " ; < ? php $ nm = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ n = $ nm [ 0 ] ; $ m = $ nm [ 1 ] ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ a [ $ i ] = str _ split ( trim ( fgets ( STDIN ) ) ) ; } for ( $ i = 0 ; $ i < $ m ; $ i + + ) { $ b [ $ i ] = str _ split ( trim ( fgets ( STDIN ) ) ) ; } $ ans = ' No ' ; for ( $ i = 0 ; $ i < = $ n - $ m ; $ i + + ) { for ( $ j = 0 ; $ j < = $ n - $ m ; $ j + + ) { $ c = 0 ; for ( $ k = 0 ; $ k < $ m ; $ k + + ) { for ( $ l = 0 ; $ l < $ m ; $ l + + ) { if ( $ a [ $ i + $ k ] [ $ j + $ l ] = = $ b [ $ k ] [ $ l ] ) { $ c + + ; } } } if ( $ c = = $ m * $ m ) $ ans = ' Yes ' ; } } echo $ ans ; ? > < ? php fscanf ( STDIN , " % d % d % d % d " , $ A , $ B , $ C , $ D ) ; $ AB = $ A * $ B ; $ CD = $ C * $ D ; $ ans = max ( $ AB , $ CD ) ; echo $ ans . PHP _ EOL ; < ? php $ x = trim ( fgets ( STDIN ) ) ; echo $ x * $ x * $ x ; ? > < ? php fscanf ( STDIN , " % d % d % d " , $ Ayen , $ Byen , $ Cyen ) ; if ( $ Cyen - ( $ Ayen + $ Byen ) < = 0 ) { echo " Yes " ; } else { echo " No " ; } < ? php $ min = 0 ; for ( $ i = 0 ; $ i < 5 ; $ i + + ) { $ times [ ] = nextInt ( ) ; } $ a = array _ map ( function ( $ time ) { return ceil ( $ time / 10 ) * 10 ; } , $ times ) ; $ b = array _ sum ( $ a ) ; $ c = array _ map ( function ( $ time ) { return $ time % 10 ; } , $ times ) ; $ d = array _ filter ( $ c , function ( $ i ) { return $ i ! = 0 ; } ) ; $ e = $ d ? min ( $ d ) : 10 ; echo $ b - ( 10 - $ e ) , PHP _ EOL ; function nextInt ( ) { return ( int ) trim ( fgets ( STDIN ) ) ; } < ? php fscanf ( STDIN , " % d % d " , $ K , $ S ) ; $ from = max ( 0 , $ S - $ K - $ K ) ; $ to = min ( $ K , $ S ) ; for ( $ i = $ from ; $ i < = $ to ; $ i + + ) { $ rest = $ S - $ i ; if ( 0 < = $ rest & & $ rest < = $ K + $ K ) { $ ans + = min ( $ rest , $ K + $ K - $ rest ) + 1 ; } } echo $ ans . PHP _ EOL ; < ? php fscanf ( STDIN , " % d " , $ N ) ; $ input _ org = $ input _ changed = explode ( " " , trim ( fgets ( STDIN ) ) ) ; asort ( $ input _ changed ) ; for ( $ i = 0 ; $ i < $ N / 2 ; $ i + + ) { $ n = current ( $ input _ changed ) ; next ( $ input _ changed ) ; } $ n _ 1 = current ( $ input _ changed ) ; foreach ( $ input _ org as $ elem ) { if ( $ elem < = $ n ) { echo " $ n _ 1 \ n " ; } else { echo " $ n \ n " ; } } < ? php $ r = trim ( fgets ( STDIN ) ) ; echo $ r * $ r ; < ? php [ $ H1 , $ M1 , $ H2 , $ M2 , $ K ] = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; printf ( " % d " , $ H2 * 60 + $ M2 - ( $ H1 * 60 + $ M1 ) - $ K ) ; < ? php $ a [ ] = trim ( fgets ( STDIN ) ) ; $ a [ ] = trim ( fgets ( STDIN ) ) ; $ a [ ] = trim ( fgets ( STDIN ) ) ; $ a [ ] = trim ( fgets ( STDIN ) ) ; $ a [ ] = trim ( fgets ( STDIN ) ) ; $ sum = 0 ; $ maxLeft = 0 ; for ( $ i = 0 ; $ i < 5 ; $ i + + ) { $ sum + = ceil ( $ a [ $ i ] / 10 ) * 10 ; $ maxLeft = max ( ceil ( $ a [ $ i ] / 10 ) * 10 - $ a [ $ i ] , $ maxLeft ) ; } echo $ sum - $ maxLeft ; < ? php list ( $ A , $ B , $ C ) = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; echo ( ( int ) $ A + ( int ) $ B > = ( int ) $ C ) ? ' Yes ' : ' No ' ; < ? php $ output = array ( ) ; while ( true ) { $ data = trim ( fgets ( STDIN ) ) ; if ( " 0 " = = $ data ) { break ; } $ nums = str _ split ( $ data ) ; array _ push ( $ output , array _ sum ( $ nums ) ) ; } print implode ( " \ n " , $ output ) ; ? > < ? php fscanf ( STDIN , " % d " , $ x ) ; echo pow ( $ x , 3 ) , PHP _ EOL ; < ? php fscanf ( STDIN , " % d % d " , $ k , $ s ) ; $ c = 0 ; for ( $ i = 0 ; $ i < = $ k ; $ i + + ) { for ( $ j = 0 ; $ j < = $ k ; $ j + + ) { if ( ( $ s - ( $ i + $ j ) ) < = $ k & & ( $ i + $ j ) < = $ s ) { $ c + + ; } } } echo $ c ; < ? php $ c [ ] = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ c [ ] = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ c [ ] = explode ( " " , trim ( fgets ( STDIN ) ) ) ; for ( $ i = 0 ; $ i < 3 ; $ i + + ) { if ( $ i = = 0 ) { $ p = $ c [ $ i ] [ $ i ] ; for ( $ j = 1 ; $ j < 3 ; $ j + + ) { $ w [ $ j ] = $ c [ $ i ] [ $ j ] - $ p ; $ h [ $ j ] = $ c [ $ j ] [ $ i ] - $ p ; } continue ; } foreach ( $ h as $ j = > $ s ) { if ( $ s ! = $ c [ $ j ] [ $ i ] - $ c [ 0 ] [ $ i ] ) { echo " No " ; exit ; } } } echo " Yes " ; < ? php $ arg1 = fscanf ( STDIN , " % d % d % d " ) ; $ flag5 = 0 ; $ flag7 = 0 ; for ( $ i = 0 ; $ i < count ( $ arg1 ) ; $ i + + ) { if ( $ arg1 [ $ i ] = = 5 ) $ flag5 + + ; else if ( $ arg1 [ $ i ] = = 7 ) $ flag7 + + ; } if ( $ flag5 = = 2 & & $ flag7 = = 1 ) echo " YES \ n " ; else echo " NO \ n " ; ? > < ? php $ x = trim ( fgets ( STDIN ) ) ; echo $ x * $ x * $ x , " \ n " ; < ? php $ num = trim ( fgets ( STDIN ) ) ; echo $ num * * 3 , PHP _ EOL ; < ? php fscanf ( STDIN , ' % d % d ' , $ a , $ b ) ; if ( $ a > = 9 | | $ b > = 9 ) { echo ' : ( ' . PHP _ EOL ; } else { echo ' Yay ! ' . PHP _ EOL ; } < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; if ( $ a < = 8 and $ b < = 8 ) { print ( " Yay ! \ n " ) ; } else { print ( " : ( \ n " ) ; } ? > < ? php do { $ input = preg _ split ( ' if ( 0 = = $ input [ 0 ] ) { break ; } $ cnt = count ( $ input ) ; $ sum = 0 ; for ( $ loop _ cnt = 0 ; $ loop _ cnt < $ cnt ; $ loop _ cnt + + ) { $ sum + = $ input [ $ loop _ cnt ] ; } echo $ sum . " \ n " ; } while ( 1 ) ; ? > < ? php list ( $ a , $ b , $ c ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; if ( $ a = = ' 7 ' & & $ b = = ' 5 ' & & $ c = = ' 5 ' ) { echo " YES " ; } else if ( $ a = = ' 5 ' & & $ b = = ' 7 ' & & $ c = = ' 5 ' ) { echo " YES " ; } else if ( $ a = = ' 5 ' & & $ b = = ' 5 ' & & $ c = = ' 7 ' ) { echo " YES " ; } else { echo " NO " ; } < ? php class out { public static function println ( $ str = " " ) { echo ( $ str ) . PHP _ EOL ; } } $ num = fgets ( STDIN ) ; $ ans = pow ( $ num , 3 ) ; echo out : : println ( $ ans ) ; ? > < ? php declare ( strict _ types = 1 ) ; fscanf ( STDIN , " % i % i " , $ a , $ b ) ; $ eval = function ( $ x ) { return ( $ x + 11 ) % 13 ; } ; $ a = $ eval ( $ a ) ; $ b = $ eval ( $ b ) ; if ( $ a > $ b ) { echo " Alice " . PHP _ EOL ; } else if ( $ a < $ b ) { echo " Bob " . PHP _ EOL ; } else { echo " Draw " . PHP _ EOL ; } < ? php $ A = [ ] ; fscanf ( STDIN , " % d % d % d " , $ A [ 0 ] , $ A [ 1 ] , $ A [ 2 ] ) ; sort ( $ A ) ; echo abs ( $ A [ 1 ] - $ A [ 0 ] ) + abs ( $ A [ 2 ] - $ A [ 1 ] ) ; ? > < ? php $ x [ ] = trim ( fgets ( STDIN ) ) ; $ x [ ] = trim ( fgets ( STDIN ) ) ; $ x [ ] = trim ( fgets ( STDIN ) ) ; $ x [ ] = trim ( fgets ( STDIN ) ) ; $ x [ ] = trim ( fgets ( STDIN ) ) ; $ sum = 0 ; usort ( $ x , ' cmp ' ) ; foreach ( $ x as $ v ) { $ amari = $ sum % 10 ; if ( $ amari > 0 ) { $ sum + = 10 - $ amari ; } $ sum + = $ v ; } printf ( " % d \ n " , $ sum ) ; function cmp ( $ a , $ b ) { $ aa = $ a % 10 ; $ bb = $ b % 10 ; if ( $ aa = = 0 ) $ aa = 10 ; if ( $ bb = = 0 ) $ bb = 10 ; return $ bb - $ aa ; } < ? php $ line = str _ split ( trim ( fgets ( STDIN ) ) ) ; if ( ( $ line [ 2 ] = = $ line [ 3 ] ) & & ( $ line [ 4 ] = = $ line [ 5 ] ) ) { echo " Yes " ; } else { echo " No " ; } ? > < ? php $ input = fgets ( STDIN ) ; echo $ output = pow ( $ input , 3 ) ; ? > < ? php $ input = array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; $ Ki = $ input [ 0 ] ; $ S = $ input [ 1 ] ; $ cnt = 0 ; for ( $ i = 0 ; $ i < = $ Ki ; $ i + + ) { for ( $ j = 0 ; $ j < = $ Ki ; $ j + + ) { if ( ( $ i + $ j ) > $ S ) { $ k = 0 ; } else { $ k = $ S - $ i - $ j ; if ( $ k > $ Ki ) { $ k = $ Ki ; } } if ( ( $ i + $ j + $ k ) = = = $ S ) { $ cnt + + ; } } } print $ cnt ; < ? php error _ reporting ( 0 ) ; $ stdin = file _ get _ contents ( ' php : $ line = explode ( " \ n " , $ stdin ) ; $ fi = 0 ; $ cnt = 0 ; $ list = array ( ) ; $ key = new stdclass ( ) ; foreach ( $ line as $ l ) { if ( strlen ( $ l ) = = 0 ) continue ; if ( $ fi = = 0 ) { $ a = explode ( " " , $ l ) ; $ key- > A = $ a ; $ fi + + ; continue ; } if ( $ fi > 0 ) { $ a = explode ( " " , $ l ) ; $ key- > X [ ] = $ a ; } } $ A = $ key- > A [ 0 ] ; $ x = array ( ) ; foreach ( $ key- > X [ 0 ] as $ k = > $ a ) { $ x [ ] = $ a ; } if ( $ A = = 1 ) { printf ( " % s \ n " , $ A ) ; exit ; } $ n = 2 ; while ( 1 ) { if ( ( $ n > = $ A ) | | ( $ n * 2 > $ A ) ) break ; $ n = $ n * 2 ; } printf ( " % s \ n " , $ n ) ; < ? php $ a = fgets ( STDIN ) ; $ aaa = $ a * $ a * $ a ; echo $ aaa ; ? > < ? php $ a = trim ( fgets ( STDIN ) ) ; $ b = trim ( fgets ( STDIN ) ) ; $ c = trim ( fgets ( STDIN ) ) ; $ d = trim ( fgets ( STDIN ) ) ; $ e = trim ( fgets ( STDIN ) ) ; $ a1 = ceil ( $ a / 10 ) * 10 ; $ b1 = ceil ( $ b / 10 ) * 10 ; $ c1 = ceil ( $ c / 10 ) * 10 ; $ d1 = ceil ( $ d / 10 ) * 10 ; $ e1 = ceil ( $ e / 10 ) * 10 ; $ a2 = $ a % 10 + ( $ a % 10 = = 0 ? 10 : 0 ) ; $ b2 = $ b % 10 + ( $ b % 10 = = 0 ? 10 : 0 ) ; $ c2 = $ c % 10 + ( $ c % 10 = = 0 ? 10 : 0 ) ; $ d2 = $ d % 10 + ( $ d % 10 = = 0 ? 10 : 0 ) ; $ e2 = $ e % 10 + ( $ e % 10 = = 0 ? 10 : 0 ) ; $ min = min ( $ a2 , $ b2 , $ c2 , $ d2 , $ e2 ) ; $ temp = $ a1 + $ b1 + $ c1 + $ d1 + $ e1 ; if ( $ min = = $ a2 ) { $ temp = $ temp - $ a1 + $ a ; } else if ( $ min = = $ b2 ) { $ temp = $ temp - $ b1 + $ b ; } else if ( $ min = = $ c2 ) { $ temp = $ temp - $ c1 + $ c ; } else if ( $ min = = $ d2 ) { $ temp = $ temp - $ d1 + $ d ; } else if ( $ min = = $ e2 ) { $ temp = $ temp - $ e1 + $ e ; } else { $ temp = $ temp - $ a1 + $ a ; } echo $ temp ; < ? php fscanf ( STDIN , " % d " , $ n ) ; $ s = fgets ( STDIN ) ; if ( strchr ( $ s , ' Y ' ) = = = false ) { echo " Three " ; return ; } echo " Four " ; < ? php $ coin _ 500 = trim ( fgets ( STDIN ) ) ; $ coin _ 100 = trim ( fgets ( STDIN ) ) ; $ coin _ 50 = trim ( fgets ( STDIN ) ) ; $ price = trim ( fgets ( STDIN ) ) ; $ count = 0 ; for ( $ i = 0 ; $ i < = $ coin _ 500 ; $ i + + ) { for ( $ j = 0 ; $ j < = $ coin _ 100 ; $ j + + ) { for ( $ k = 0 ; $ k < = $ coin _ 50 ; $ k + + ) { $ sum = $ i * 500 + $ j * 100 + $ k * 50 ; if ( $ sum = = $ price ) { $ count + + ; } } } } echo $ count ; < ? php function getKyori ( $ a , $ b , $ d ) { $ sum = 0 ; for ( $ i = 0 ; $ i < $ d ; $ i + + ) { $ sum + = ( $ a [ $ i ] - $ b [ $ i ] ) * * 2 ; } return sqrt ( $ sum ) ; } $ tmp = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ n = $ tmp [ 0 ] ; $ d = $ tmp [ 1 ] ; $ data = [ ] ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ data [ ] = explode ( " " , trim ( fgets ( STDIN ) ) ) ; } $ count = 0 ; for ( $ i = 0 ; $ i < $ n - 1 ; $ i + + ) { for ( $ j = $ i + 1 ; $ j < $ n ; $ j + + ) { $ kyori = getKyori ( $ data [ $ i ] , $ data [ $ j ] , $ d ) ; if ( ceil ( $ kyori ) ! = = $ kyori ) { } else { $ count + + ; } } } echo $ count . " \ n " ; < ? php $ a = fgets ( STDIN ) ; echo $ a * $ a ; < ? php fscanf ( STDIN , ' % d ' , $ arr [ ] ) ; fscanf ( STDIN , ' % d ' , $ arr [ ] ) ; fscanf ( STDIN , ' % d ' , $ arr [ ] ) ; fscanf ( STDIN , ' % d ' , $ arr [ ] ) ; fscanf ( STDIN , ' % d ' , $ arr [ ] ) ; $ min = $ arr [ 0 ] % 10 ; $ min _ i = 0 ; foreach ( $ arr as $ i = > $ v ) { $ d1 = $ v % 10 ; $ _ arr [ ] = ( int ) ( ceil ( $ v / 10 ) * 10 ) ; if ( $ d1 > 0 & & $ d1 < $ min ) { $ min = $ d1 ; $ min _ i = $ i ; } } $ _ arr [ $ min _ i ] = $ arr [ $ min _ i ] ; $ ans = array _ sum ( $ _ arr ) ; echo $ ans . PHP _ EOL ; < ? php fscanf ( STDIN , " % d " , $ r ) ; echo ( $ r * * 2 ) . " \ n " ; < ? php fscanf ( STDIN , " % d % d " , $ A , $ V ) ; fscanf ( STDIN , " % d % d " , $ B , $ W ) ; fscanf ( STDIN , " % d " , $ T ) ; $ D = abs ( $ A - $ B ) ; $ S = $ V - $ W ; if ( $ D < = $ S * $ T ) { echo ' YES ' ; } else { echo ' NO ' ; } < ? php $ x = trim ( fgets ( STDIN ) ) ; print ( $ x * $ x * $ x . " \ n " ) ; < ? php $ cake = explode ( " " , fgets ( STDIN ) ) ; if ( $ cake [ 0 ] < = 8 & & $ cake [ 1 ] < = 8 ) { echo ' Yay ! ' ; } else { echo ' : ( ' ; } < ? php $ sum = 0 ; $ amax = 0 ; for ( $ i = 1 ; $ i < = 5 ; $ i + + ) { $ s [ $ i ] = trim ( fgets ( STDIN ) ) ; $ sum + = ( int ) ( ( $ s [ $ i ] + 9 ) / 10 ) * 10 ; if ( $ s [ $ i ] % 10 ! = 0 ) { $ amax = max ( $ amax , 10 - ( $ s [ $ i ] % 10 ) ) ; } } echo $ sum - $ amax ; < ? php # 入力部 fscanf ( STDIN , " % s " , $ s ) ; # 処理部 $ arr = str _ split ( $ s ) ; $ r = " No " ; if ( $ arr [ 2 ] = = $ arr [ 3 ] & & $ arr [ 4 ] = = $ arr [ 5 ] ) { $ r = " Yes " ; } # 出力部 echo $ r . " \ n " ; < ? php $ input = trim ( fgets ( STDIN ) ) ; $ array = explode ( " " , $ input ) ; list ( $ a , $ b , $ c , $ d ) = $ array ; $ s1 = $ a * $ b ; $ s2 = $ c * $ d ; if ( $ s1 = = $ s2 ) { echo $ s1 . " \ n " ; } else if ( $ s1 < $ s2 ) { echo $ s2 . " \ n " ; } else if ( $ s1 > $ s2 ) { echo $ s1 . " \ n " ; } < ? php fscanf ( STDIN , ' % d ' , $ x ) ; $ a = 0 ; while ( true ) { $ a5 = $ a * * 5 ; $ arr [ $ a ] = $ a5 ; foreach ( $ arr as $ i = > $ v ) { if ( $ a5 + $ v = = = $ x ) { $ b = - $ i ; break 2 ; } elseif ( $ a5 - $ v = = = $ x ) { $ b = $ i ; break 2 ; } } $ a + + ; } echo $ a . ' ' . $ b ; < ? php $ in = fgets ( STDIN ) ; echo pow ( $ in , 2 ) ; ? > < ? php fscanf ( STDIN , " % d " , $ N ) ; $ n _ arr = array ( ) ; $ n _ arr = explode ( " " , fgets ( STDIN ) ) ; $ ans = 0 ; $ CurMin = INF ; for ( $ i = 0 ; $ i < $ N ; $ i + + ) { $ CurMin = min ( $ CurMin , $ n _ arr [ $ i ] ) ; if ( $ CurMin = = $ n _ arr [ $ i ] ) { $ ans + + ; } } echo $ ans ; ? > < ? php if ( basename ( _ _ FILE _ _ ) = = basename ( $ _ SERVER [ ' PHP _ SELF ' ] ) ) { while ( $ line = fgets ( STDIN ) ) { echo $ line * $ line * $ line ; } } ? > < ? php fscanf ( STDIN , " % d % d % d % d " , $ a , $ b , $ h , $ m ) ; $ rad = ( $ h + $ m / 60 ) / 6 * pi ( ) - $ m / 30 * pi ( ) ; $ c2 = $ a * $ a + $ b * $ b - 2 * $ a * $ b * cos ( $ rad ) ; echo sqrt ( $ c2 ) ; < ? php fscanf ( STDIN , " % d " , $ r ) ; $ area = $ r * $ r ; $ answer = $ area / 1 ; echo ( int ) $ answer ; ? > < ? php fgets ( STDIN ) ; $ array = explode ( " " , trim ( fgets ( STDIN ) ) ) ; foreach ( $ array as $ c ) { $ map [ $ c ] = true ; } echo count ( $ map ) = = 3 ? " Three " : " Four " ; < ? php fscanf ( STDIN , " % d % d % d " , $ a , $ b , $ c ) ; $ hoge = sprintf ( " % d % d % d " , $ a , $ b , $ c ) ; if ( str _ replace ( " 5 " , " " , $ hoge ) = = 7 ) { echo " YES " ; } else { echo " NO " ; } < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; if ( $ a > = 13 ) { echo $ b ; } else if ( $ a < = 5 ) { echo 0 ; } else { echo $ b / 2 ; } < ? php while ( true ) { $ stdin = preg _ split ( ' if ( $ stdin [ 1 ] = = 0 ) return ; print ( array _ sum ( $ stdin ) . " \ n " ) ; } < ? php $ cnt = 0 ; $ arr = explode ( " " , trim ( fgets ( STDIN ) ) ) ; foreach ( $ arr as $ val ) { if ( $ val = = 5 ) { $ cnt + + ; } } if ( $ cnt = = 2 ) echo " YES " ; else echo " NO " ; ? > < ? php fscanf ( STDIN , " % d % d " , $ n , $ d ) ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ arr [ ] = explode ( " " , trim ( fgets ( STDIN ) ) ) ; } $ arr _ 2 = [ ] ; $ result = [ ] ; $ count = 0 ; $ sum = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { for ( $ s = $ i + 1 ; $ s < $ n ; $ s + + ) { for ( $ j = 0 ; $ j < $ d ; $ j + + ) { $ arr _ 2 [ ] = ( abs ( ( $ arr [ $ i ] [ $ j ] ) - ( $ arr [ $ s ] [ $ j ] ) ) ) * * 2 ; } } } for ( $ l = 0 ; $ l < ( count ( $ arr _ 2 ) / $ d ) ; $ l + + ) { $ k = $ l * $ d ; $ sum = 0 ; for ( $ i = 0 ; $ i < $ d ; $ i + + ) { $ sum = $ sum + $ arr _ 2 [ $ k + $ i ] ; $ result [ $ l ] = sqrt ( $ sum ) ; } } for ( $ i = 0 ; $ i < count ( $ result ) ; $ i + + ) { if ( preg _ match ( ' / ^ [ 0-9 ] + $ / ' , $ result [ $ i ] ) ) { $ count + + ; } } echo $ count ; ? > < ? php fscanf ( STDIN , " % d % d % d % d " , $ a , $ b , $ h , $ m ) ; $ arg1 = 6 * $ m ; $ arg2 = ( 30 * $ h ) + ( 0.5 * $ m ) ; if ( $ arg1 ! = $ arg2 ) { $ arg = abs ( $ arg1 - $ arg2 ) ; if ( $ arg > 180 ) { $ arg = 360 - $ arg ; ; } else if ( $ arg = = 180 ) { echo $ a + $ b ; exit ; } $ dis2 = ( $ a * $ a ) + ( $ b * $ b ) - ( 2 * $ a * $ b * cos ( deg2rad ( $ arg ) ) ) ; echo sqrt ( $ dis2 ) ; } else { echo abs ( $ a - $ b ) ; } < ? php $ at = new Atcoder ( ) ; $ at - > main ( ) ; unset ( $ at ) ; class Atcoder { private function arrayIn ( ) { $ buf = explode ( " " , fgets ( STDIN ) ) ; return $ this - > killNewLine ( $ buf ) ; } private function killNewLine ( $ buf = null ) { $ buf = str _ replace ( " \ r \ n " , " " , $ buf ) ; $ buf = str _ replace ( " \ n " , " " , $ buf ) ; $ buf = str _ replace ( " \ r " , " " , $ buf ) ; return $ buf ; } public function main ( ) { $ n = $ this - > arrayIn ( ) ; sort ( $ n ) ; if ( 1 = = $ n [ 0 ] & & 4 = = $ n [ 1 ] & & 7 = = $ n [ 2 ] & & 9 = = $ n [ 3 ] ) { echo " YES \ n " ; } else { echo " NO \ n " ; } } } ? > < ? php $ x = trim ( fgets ( STDIN ) ) ; echo $ x * $ x * $ x . " \ n " ; < ? php fscanf ( STDIN , " % s " , $ n ) ; $ len = strlen ( $ n ) ; $ fx = 0 ; for ( $ i = 0 ; $ i < $ len ; $ i + + ) { $ fx + = $ n [ $ i ] ; } echo ( $ n % $ fx = = 0 ) ? ' Yes ' . " \ n " : ' No ' . " \ n " ; < ? php fscanf ( STDIN , ' % d % d ' , $ A , $ B ) ; echo round ( ( $ A + $ B ) / 2 ) ; echo PHP _ EOL ; < ? php fscanf ( STDIN , " % d % d " , $ n , $ d ) ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) $ x [ $ i ] = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ ans = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) for ( $ j = 0 ; $ j < $ n ; $ j + + ) { if ( $ i < $ j ) { $ tmp = 0 ; for ( $ k = 0 ; $ k < $ d ; $ k + + ) $ tmp + = pow ( $ x [ $ i ] [ $ k ] - $ x [ $ j ] [ $ k ] , 2 ) ; if ( sqrt ( $ tmp ) = = ( int ) sqrt ( $ tmp ) ) $ ans + + ; } } echo $ ans ; ? > < ? php $ N = explode ( " " , trim ( fgets ( STDIN ) ) ) ; sort ( $ N ) ; $ S = implode ( " " , $ N ) ; echo $ S = = = ' 1479 ' ? ' YES ' : ' NO ' ; < ? php fscanf ( STDIN , ' % d ' , $ num ) ; echo pow ( $ num , 3 ) ; ? > < ? php $ stdin = fgets ( STDIN ) ; $ x = ( int ) trim ( $ stdin ) ; echo pow ( $ x , 3 ) . PHP _ EOL ; < ? php $ n = intval ( trim ( fgets ( STDIN ) ) ) ; $ ans = 800 * $ n - 200 * floor ( $ n / 15 ) ; print ( " $ ans \ n " ) ; ? > < ? php fscanf ( STDIN , ' % d ' , $ a ) ; fscanf ( STDIN , ' % d ' , $ b ) ; fscanf ( STDIN , ' % d ' , $ c ) ; fscanf ( STDIN , ' % d ' , $ d ) ; fscanf ( STDIN , ' % d ' , $ e ) ; fscanf ( STDIN , ' % d ' , $ k ) ; if ( $ e - $ a > $ k ) $ ans = ' : ( ' ; else $ ans = ' Yay ! ' ; echo $ ans . PHP _ EOL ; < ? php fscanf ( STDIN , " % d " , $ x ) ; for ( $ i = - 1000 ; $ i < = 1000 ; + + $ i ) { for ( $ j = - 1000 ; $ j < = 1000 ; + + $ j ) { if ( $ x = = pow ( $ i , 5 ) - pow ( $ j , 5 ) ) { break 2 ; } } } echo " $ i $ j " ; < ? php fscanf ( STDIN , " % d % d " , $ N , $ K ) ; if ( $ K = = = 1 ) { echo 0 ; } else { echo $ N - $ K ; } < ? php $ n = intval ( trim ( fgets ( STDIN ) ) ) ; $ listA = [ ] ; $ listB = [ ] ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ var = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ listA [ $ i ] = intval ( $ var [ 0 ] ) ; $ listB [ $ i ] = intval ( $ var [ 1 ] ) ; } $ sum = 0 ; $ min = null ; foreach ( $ listA as $ i = > $ a ) { if ( $ a > $ listB [ $ i ] ) { if ( is _ null ( $ min ) ) { $ min = $ listB [ $ i ] ; } else { $ min = min ( $ min , $ listB [ $ i ] ) ; } } $ sum + = $ listB [ $ i ] ; } if ( is _ null ( $ min ) ) { echo 0 ; } else { echo $ sum - $ min ; } < ? php $ n = intval ( trim ( fgets ( STDIN ) ) ) ; for ( $ a = 1 ; $ a < = 3500 ; $ a + + ) { for ( $ b = 1 ; $ b < = 3500 ; $ b + + ) { $ c1 = $ n * $ a * $ b ; $ c2 = 4 * $ a * $ b - $ n * ( $ a + $ b ) ; if ( $ c2 > 0 & & $ c1 % $ c2 = = 0 ) { printf ( " % d % d % d \ n " , $ a , $ b , $ c1 / $ c2 ) ; exit ; } } } < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; echo ( $ a < = 8 & & $ b < = 8 ) ? " Yay ! " : " : ( " ? > < ? php fscanf ( STDIN , " % d % d % d % d " , $ a , $ b , $ h , $ m ) ; $ dH = ( $ h * 30 ) + ( $ m * 0.5 ) ; $ dM = $ m * 6 ; $ d = abs ( $ dH - $ dM ) ; if ( $ d > 180 ) { $ d = 360 - $ d ; } $ c2 = ( $ a * * 2 ) + ( $ b * * 2 ) - ( 2 * $ a * $ b * cos ( deg2rad ( $ d ) ) ) ; $ c = sqrt ( $ c2 ) ; echo " { $ c } \ n " ; < ? php $ t = trim ( fgets ( STDIN ) ) ; $ i = 0 ; $ c = strlen ( $ t ) ; while ( $ i < $ c ) { echo ( $ t [ $ i ] = = " ? " ) ? " D " : $ t [ $ i ] ; + + $ i ; } < ? php fscanf ( STDIN , " % d % d " , $ A , $ B ) ; if ( $ A > = 13 ) { echo $ B ; } elseif ( $ A > = 6 & & $ A < = 12 ) { echo $ B / 2 ; } elseif ( $ A < = 5 ) { echo 0 ; } ? > < ? php $ input = fgets ( STDIN ) ; $ age _ price = explode ( " " , $ input ) ; if ( $ age _ price [ 0 ] > = 13 ) { echo $ age _ price [ 1 ] ; } elseif ( $ age _ price [ 0 ] < = 12 & & $ age _ price [ 0 ] > = 6 ) { echo $ age _ price [ 1 ] / 2 ; } else { echo 0 ; } < ? php $ input = intval ( fgets ( STDIN ) ) ; echo $ input * $ input * $ input . " \ n " ; ? > < ? php $ input = fgets ( STDIN ) ; print ( pow ( $ input , 3 ) ) ; ? > < ? php fscanf ( STDIN , " % d % d " , $ N , $ D ) ; $ row = array ( ) ; $ cnt = 0 ; for ( $ n = 1 ; $ n < = $ N ; $ n + + ) { $ row [ $ n ] = explode ( " " , fgets ( STDIN ) ) ; if ( $ n = = 1 ) continue ; for ( $ m = $ n - 1 ; 0 < $ m ; $ m -- ) { $ dst = 0 ; $ stp = $ n - $ m ; for ( $ d = 0 ; $ d < $ D ; $ d + + ) { $ x = intval ( $ row [ $ n ] [ $ d ] ) ; $ y = intval ( $ row [ $ n - $ stp ] [ $ d ] ) ; $ dst + = pow ( $ y - $ x , 2 ) ; } $ sqt = sqrt ( $ dst ) ; $ cnt + = ( $ sqt - intval ( sqrt ( $ dst ) ) = = 0 ) ? 1 : 0 ; } } echo $ cnt ; < ? php list ( $ n ) = ints ( ) ; $ a = ints ( ) ; $ b = ints ( ) ; $ suma = array _ sum ( $ a ) ; $ sumb = array _ sum ( $ b ) ; if ( $ sumb > $ suma ) exit ( ' -1 ' ) ; $ md = $ pd = [ ] ; for ( $ i = 0 ; $ i < $ n ; + + $ i ) { $ d = $ a [ $ i ] - $ b [ $ i ] ; if ( $ d < 0 ) $ md [ ] = $ d ; elseif ( $ d > 0 ) $ pd [ ] = $ d ; } if ( count ( $ md ) = = = 0 ) exit ( ' 0 ' ) ; $ ans = count ( $ md ) ; $ sum _ md = array _ sum ( $ md ) ; $ i = 0 ; rsort ( $ pd ) ; while ( $ sum _ md < 0 ) { $ sum _ md + = $ pd [ $ i ] ; + + $ i ; } $ ans + = $ i ; echo $ ans ; function ints ( ) { return array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; } < ? php error _ reporting ( 0 ) ; $ stdin = file _ get _ contents ( ' php : $ line = explode ( " \ n " , $ stdin ) ; $ fi = 0 ; $ cnt = 0 ; $ list = array ( ) ; $ key = new stdclass ( ) ; foreach ( $ line as $ l ) { if ( strlen ( $ l ) = = 0 ) continue ; if ( $ fi = = 0 ) { $ a = explode ( " " , $ l ) ; $ key- > A = $ a ; $ fi + + ; continue ; } if ( $ fi > 0 ) { $ a = explode ( " " , $ l ) ; $ key- > X [ ] = $ a ; } } $ a = ( int ) ( $ key- > A [ 0 ] / 15 ) ; printf ( " % d \ n " , $ key- > A [ 0 ] * 800- ( $ a * 200 ) ) ; < ? php fscanf ( STDIN , " % d " , $ r ) ; echo ( int ) pow ( $ r , " 2 " ) ; ? > < ? php fscanf ( STDIN , " % s " , $ s ) ; fscanf ( STDIN , " % d " , $ K ) ; $ arr = str _ split ( $ s ) ; $ len = strlen ( $ s ) ; $ num = array ( ) ; foreach ( $ arr as $ key = > $ val ) { $ num [ $ key ] = 123 - ord ( $ val ) ; if ( $ num [ $ key ] = = 26 ) $ num [ $ key ] = 0 ; } $ allA = true ; for ( $ i = 0 ; $ i < $ len ; $ i + + ) { if ( $ num [ $ i ] < = $ K ) { $ arr [ $ i ] = ' a ' ; $ K - = $ num [ $ i ] ; } else { $ allA = false ; } } if ( $ allA = = = true ) { $ K % = 26 ; } $ arr [ $ len - 1 ] = chr ( ord ( $ arr [ $ len - 1 ] ) + $ K ) ; $ K - = $ K ; if ( ord ( $ arr [ $ len - 1 ] ) > = 123 ) { $ arr [ $ len - 1 ] = chr ( ord ( $ arr [ $ len - 1 ] ) - 26 ) ; } ; echo implode ( " " , $ arr ) . PHP _ EOL ; < ? php fscanf ( STDIN , " % s " , $ s ) ; echo ( $ s [ 2 ] = = $ s [ 3 ] & & $ s [ 4 ] = = $ s [ 5 ] ) ? ' Yes ' : ' No ' ; < ? php $ n = trim ( fgets ( STDIN ) ) ; $ P = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ min = $ P [ 0 ] ; $ ans = 1 ; for ( $ i = 1 ; $ i < $ n ; $ i + + ) { if ( $ P [ $ i ] < $ min ) { $ ans + + ; $ min = $ P [ $ i ] ; } } echo $ ans ; < ? php $ a = fgets ( STDIN ) ; if ( $ a [ 2 ] = = $ a [ 3 ] & & $ a [ 4 ] = = $ a [ 5 ] ) { echo " Yes " ; } else { echo " No " ; } < ? php fscanf ( STDIN , ' % d ' , $ x ) ; $ b = 0 ; while ( true ) { if ( preg _ match ( ' / ^ [ 0-9 ] + $ / ' , $ a = pow ( $ x + pow ( $ b , 5 ) , 1 / 5 ) ) ) { echo $ a . ' ' . $ b . PHP _ EOL ; break ; } if ( preg _ match ( ' / ^ [ 0-9 ] + $ / ' , $ a = pow ( $ x - pow ( $ b , 5 ) , 1 / 5 ) ) ) { echo $ a . ' - ' . $ b . PHP _ EOL ; break ; } + + $ b ; } ? > < ? php $ x = fgets ( STDIN ) ; $ cubic = $ x * $ x * $ x ; echo $ cubic . " \ n " ; ? > < ? php function f ( $ x ) { if ( $ x < 10 ) return $ x ; return $ x % 10 + f ( floor ( $ x / 10 ) ) ; } $ n ; fscanf ( STDIN , " % d " , $ n ) ; $ m = f ( $ n ) ; if ( $ n % $ m = = 0 ) { echo " Yes \ n " ; } else { echo " No \ n " ; } ? > < ? php $ a = ( int ) trim ( fgets ( STDIN ) ) ; $ b = ( int ) trim ( fgets ( STDIN ) ) ; $ c = ( int ) trim ( fgets ( STDIN ) ) ; $ d = ( int ) trim ( fgets ( STDIN ) ) ; $ e = ( int ) trim ( fgets ( STDIN ) ) ; $ ary = [ $ a , $ b , $ c , $ d , $ e ] ; $ cand = [ ] ; $ sum = 0 ; foreach ( $ ary as $ k = > $ v ) { if ( $ v % 10 = = = 0 ) { $ sum + = $ v ; } else { $ cand [ $ k ] = $ v % 10 ; } } asort ( $ cand ) ; $ first = true ; foreach ( $ cand as $ k = > $ v ) { if ( $ first ) { $ first = false ; $ sum + = $ ary [ $ k ] ; } else { $ sum + = ( int ) ( ceil ( $ ary [ $ k ] / 10 ) * 10 ) ; } } echo $ sum ; < ? php function convNum ( $ i ) { if ( $ i = = 1 ) { return 14 ; } else { return $ i ; } } fscanf ( STDIN , " % d % d " , $ a , $ b ) ; $ a = convNum ( $ a ) ; $ b = convNum ( $ b ) ; if ( $ a > $ b ) { print " Alice " ; } elseif ( $ a = = $ b ) { print " Draw " ; } else { print " Bob " ; } ? > < ? php list ( $ n ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ a = array _ map ( ' intval ' , explode ( " " , trim ( fgets ( STDIN ) ) ) ) ; sort ( $ a ) ; echo $ a [ $ n - 1 ] - $ a [ 0 ] ; < ? php $ base _ num = explode ( " " , fgets ( STDIN ) ) ; if ( ( int ) $ base _ num [ 0 ] < = 8 & & ( int ) $ base _ num [ 1 ] < = 8 ) { echo " Yay ! " ; } else { echo " : ( " ; } < ? php ini _ set ( ' error _ reporting ' , E _ ALL & ~ E _ NOTICE ) ; fscanf ( STDIN , " % d % d " , $ n , $ m ) ; define ( ' MOD ' , pow ( 10 , 9 ) + 7 ) ; $ ans = 0 ; $ xx = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ yy = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ bx = array ( ) ; $ by = array ( ) ; for ( $ i = 0 ; $ i < $ n - 1 ; $ i + + ) { $ bx [ $ i ] = ( $ i + 1 ) * ( $ n - $ i - 1 ) ; } for ( $ i = 0 ; $ i < $ m - 1 ; $ i + + ) { $ by [ $ i ] = ( $ i + 1 ) * ( $ m - $ i - 1 ) ; } for ( $ x = 0 ; $ x < $ n - 1 ; $ x + + ) { $ dx = $ xx [ $ x + 1 ] - $ xx [ $ x ] ; $ total _ x + = $ bx [ $ x ] * $ dx ; $ total _ x % = MOD ; } for ( $ y = 0 ; $ y < $ m - 1 ; $ y + + ) { $ dy = $ yy [ $ y + 1 ] - $ yy [ $ y ] ; $ total _ y + = $ by [ $ y ] * $ dy ; $ total _ y % = MOD ; } $ ans = $ total _ x * $ total _ y % MOD ; echo $ ans . PHP _ EOL ; < ? php $ x = trim ( fgets ( STDIN ) ) ; $ x3 = pow ( $ x , 3 ) ; echo $ x3 ; ? > < ? php $ N = explode ( " " , trim ( fgets ( STDIN ) ) ) ; sort ( $ N ) ; if ( $ N = = [ 5 , 5 , 7 ] ) { echo ' YES ' ; } else { echo ' NO ' ; } < ? php fscanf ( STDIN , " % s " , $ a ) ; if ( $ a < = ' 2019 / 04 / 30 ' ) { echo ' Heisei ' ; } else { echo ' TBD ' ; } < ? php fscanf ( STDIN , ' % d ' , $ x ) ; echo pow ( $ x , 3 ) , PHP _ EOL ; < ? php class main { var $ arr = array ( ) ; var $ img1 = array ( ) ; var $ img2 = array ( ) ; function run ( ) { $ line = trim ( fgets ( STDIN ) ) ; $ this - > arr = explode ( " " , $ line ) ; for ( $ i = 0 ; $ i < $ this - > arr [ 0 ] ; $ i + + ) { fscanf ( STDIN , " % s " , $ s ) ; $ this - > img1 [ $ i ] = str _ split ( $ s ) ; } for ( $ j = 0 ; $ j < $ this - > arr [ 1 ] ; $ j + + ) { fscanf ( STDIN , " % s " , $ s ) ; $ this - > img2 [ $ j ] = str _ split ( $ s ) ; } for ( $ h = 0 ; $ h < = ( $ this - > arr [ 0 ] - $ this - > arr [ 1 ] ) ; $ h + + ) { for ( $ w = 0 ; $ w < = ( $ this - > arr [ 0 ] - $ this - > arr [ 1 ] ) ; $ w + + ) { if ( $ this - > img1 [ $ h ] [ $ w ] = = $ this - > img2 [ 0 ] [ 0 ] ) { $ this - > check ( $ h , $ w ) ; } } } echo " No " ; } function check ( $ h , $ w ) { for ( $ n = 0 ; $ n < $ this - > arr [ 1 ] ; $ n + + ) { for ( $ m = 0 ; $ m < $ this - > arr [ 1 ] ; $ m + + ) { if ( $ this - > img1 [ $ h + $ n ] [ $ w + $ m ] ! = $ this - > img2 [ $ n ] [ $ m ] ) { return false ; } } } echo " Yes " ; exit ; } } $ object = new main ( ) ; $ object - > run ( ) ; < ? php function getq ( $ get _ word = null ) { if ( $ get _ word = = = null ) { return str _ replace ( " \ n " , " " , fgets ( STDIN ) ) ; } else if ( $ get _ word = = = 1 ) { return explode ( " " , str _ replace ( " \ n " , " " , fgets ( STDIN ) ) ) ; } } $ a = getq ( 1 ) ; if ( $ a [ 0 ] + $ a [ 1 ] > = $ a [ 2 ] ) { echo " Yes \ n " ; } else { echo " No \ n " ; } ? > < ? php fscanf ( STDIN , " % d " , $ n ) ; $ x = 800 * $ n ; $ y = floor ( $ n / 15 ) * 200 ; echo $ x - $ y ; ? > < ? php fscanf ( STDIN , " % d " , $ N ) ; echo ( $ N * 800 - floor ( $ N / 15 ) * 200 ) . PHP _ EOL ; < ? php $ a = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; echo $ a [ 0 ] + $ a [ 1 ] > = $ a [ 2 ] ? ' Yes ' : ' No ' ; < ? php $ n = fgets ( STDIN ) ; for ( $ i = 1 ; $ i * 2 < = $ n ; $ i * = 2 ) ; echo $ i ; < ? php $ S = trim ( fgets ( STDIN ) ) ; if ( $ S [ 2 ] = = = $ S [ 3 ] & & $ S [ 4 ] = = = $ S [ 5 ] ) { echo ' Yes ' ; return ; } echo ' No ' ; < ? php while ( false ! = = ( $ line = fgets ( STDIN ) ) ) { $ line = trim ( $ line ) ; if ( ' 0 ' = = = $ line ) { break ; } $ nums = preg _ split ( ' $ sum = array _ reduce ( $ nums , function ( $ carry , $ item ) { return $ carry + intval ( $ item ) ; } , 0 ) ; echo " $ sum \ n " ; } < ? php for ( $ i = 0 ; $ i < 6 ; $ i + + ) { $ arr [ ] = trim ( fgets ( STDIN ) ) ; } for ( $ i = 0 ; $ i < count ( $ arr ) - 1 ; $ i + + ) { for ( $ s = $ i + 1 ; $ s < count ( $ arr ) - 1 ; $ s + + ) { if ( $ arr [ 5 ] < abs ( $ arr [ $ i ] - $ arr [ $ s ] ) ) { echo " : ( " ; exit ; } } } echo " Yay ! " ; ? > < ? php $ n = fgets ( STDIN ) ; if ( $ n > = 64 ) { echo 64 ; } elseif ( $ n > = 32 ) { echo 32 ; } elseif ( $ n > = 16 ) { echo 16 ; } elseif ( $ n > = 8 ) { echo 8 ; } elseif ( $ n > = 4 ) { echo 4 ; } elseif ( $ n > = 2 ) { echo 2 ; } else { echo 1 ; } < ? php $ array = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ five _ count = 0 ; $ seven _ count = 0 ; for ( $ i = 0 ; $ i < count ( $ array ) ; $ i + + ) { if ( ( int ) $ array [ $ i ] = = = 5 ) { $ five _ count + + ; } elseif ( ( int ) $ array [ $ i ] = = = 7 ) { $ seven _ count + + ; } } if ( $ five _ count = = = 2 & & $ seven _ count = = = 1 ) { echo ' YES ' ; } else { echo ' NO ' ; } < ? php fscanf ( STDIN , " % d % d " , $ A , $ B ) ; echo max ( $ A , $ B ) < = 8 ? " Yay ! " : " : ( " , " \ n " ; < ? php for ( $ i = 0 ; $ i < 5 ; $ i + + ) { $ arr [ ] = trim ( fgets ( STDIN ) ) ; } $ array = [ ] ; for ( $ i = 0 ; $ i < 5 ; $ i + + ) { $ a = strlen ( $ arr [ 0 ] ) ; if ( $ a = = 2 ) { if ( $ arr [ $ i ] % 10 ! = 0 ) { $ array [ ] = 10 - ( $ arr [ $ i ] % 10 ) ; } else { $ array [ ] = 0 ; } } else { if ( $ arr [ $ i ] % 10 ! = 0 ) { $ array [ ] = 10 - ( $ arr [ $ i ] % 10 ) ; } else { $ array [ ] = 0 ; } } } $ end = array _ keys ( $ array , max ( $ array ) ) ; $ count = 0 ; for ( $ i = 0 ; $ i < 5 ; $ i + + ) { if ( $ i ! = $ end [ 0 ] ) { $ count + = $ array [ $ i ] + $ arr [ $ i ] ; } } echo $ count + $ arr [ $ end [ 0 ] ] ; ? > < ? php fscanf ( STDIN , ' % d % d ' , $ n , $ m ) ; $ a = array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; $ lcm = $ a [ 0 ] ; for ( $ i = 0 ; $ i < $ n ; + + $ i ) { $ lcm = lcm ( $ lcm , $ a [ $ i ] ) ; if ( $ lcm / $ a [ $ i ] % 2 = = = 0 ) { echo ( 0 ) . PHP _ EOL ; exit ; } } $ ans = floor ( ( 2 * $ m + $ lcm ) / ( 2 * $ lcm ) ) ; echo $ ans . PHP _ EOL ; function gcd ( $ m , $ n ) { if ( ! $ n ) return $ m ; return gcd ( $ n , $ m % $ n ) ; } function gcdAll ( $ arr ) { $ gcd = $ arr [ 0 ] ; for ( $ i = 0 ; $ i < count ( $ arr ) ; $ i + + ) { $ gcd = gcd ( $ gcd , $ arr [ $ i ] ) ; } return $ gcd ; } function lcm ( $ m , $ n ) { return $ m * $ n / gcd ( $ m , $ n ) ; } function lcmAll ( $ arr ) { $ lcm = $ arr [ 0 ] ; for ( $ i = 0 ; $ i < count ( $ arr ) ; $ i + + ) { $ lcm = lcm ( $ lcm , $ arr [ $ i ] ) ; } return $ lcm ; } < ? php fscanf ( STDIN , " % d % d % d % d % d " , $ h1 , $ m1 , $ h2 , $ m2 , $ k ) ; $ sm = $ h1 * 60 + $ m1 ; $ em = $ h2 * 60 + $ m2 ; $ ans = $ em - $ sm - $ k ; echo $ ans . PHP _ EOL ; < ? php fscanf ( STDIN , " % d " , $ a ) ; fscanf ( STDIN , " % d " , $ b ) ; fscanf ( STDIN , " % d " , $ c ) ; fscanf ( STDIN , " % d " , $ x ) ; $ ans = 0 ; $ ma = min ( $ a , floor ( $ x / 500 ) ) ; for ( $ i = 0 ; $ i < = $ ma ; $ i + + ) { $ ra = $ x - $ i * 500 ; $ mb = min ( $ b , floor ( $ ra / 100 ) ) ; for ( $ j = 0 ; $ j < = $ mb ; $ j + + ) { $ rb = $ ra - $ j * 100 ; if ( $ rb / 50 < = $ c ) $ ans + + ; } } echo $ ans ; < ? php $ list = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ five = 0 ; $ seven = 0 ; for ( $ i = 0 ; $ i < 3 ; $ i + + ) { if ( $ list [ $ i ] = = 5 ) { $ five + + ; } else if ( $ list [ $ i ] = = 7 ) { $ seven + + ; } } if ( $ five = = 2 & & $ seven = = 1 ) { echo ' YES ' ; } else { echo ' NO ' ; } ? > < ? php list ( $ n ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ a = array _ map ( ' intval ' , explode ( " " , trim ( fgets ( STDIN ) ) ) ) ; $ mod = 1000000007 ; $ ans = 0 ; for ( $ i = 0 ; $ i < = 60 ; $ i + + ) { $ zero = 0 ; $ one = 0 ; $ bit = pow ( 2 , $ i ) ; for ( $ j = 0 ; $ j < count ( $ a ) ; $ j + + ) { $ xor = $ a [ $ j ] & $ bit ; if ( $ xor = = 0 ) { $ zero + + ; } else { $ one + + ; } } $ bit = $ bit % $ mod ; $ bit = $ bit * $ zero % $ mod ; $ bit = $ bit * $ one % $ mod ; $ ans = $ ans + $ bit % $ mod ; } echo $ ans % $ mod ; < ? php class Scanner { private $ arr = [ ] ; private $ count = 0 ; private $ pointer = 0 ; public function next ( ) { if ( $ this - > pointer > = $ this - > count ) { $ str = trim ( fgets ( STDIN ) ) ; $ this - > arr = explode ( " " , $ str ) ; $ this - > count = count ( $ this - > arr ) ; $ this - > pointer = 0 ; } $ result = $ this - > arr [ $ this - > pointer ] ; $ this - > pointer + + ; return $ result ; } public function hasNext ( ) { return $ this - > pointer < $ this - > count ; } public function nextInt ( ) { return ( int ) $ this - > next ( ) ; } public function nextDouble ( ) { return ( double ) $ this - > next ( ) ; } } class out { public static function printIn ( $ str = " " ) { echo $ str . PHP _ EOL ; } } $ sc = new Scanner ; $ a = $ sc - > nextInt ( ) ; $ b = $ sc - > nextInt ( ) ; $ c = $ sc - > nextInt ( ) ; $ x = $ sc - > nextInt ( ) ; $ d = 0 ; for ( $ i = 0 ; $ i < = $ a ; $ i + + ) { for ( $ j = 0 ; $ j < = $ b ; $ j + + ) { for ( $ k = 0 ; $ k < = $ c ; $ k + + ) { $ total = 500 * $ i + 100 * $ j + 50 * $ k ; if ( $ total = = $ x ) { $ d + + ; } } } } echo $ d ; < ? php fscanf ( STDIN , " % d " , $ N ) ; $ waribiki = ( int ) ( $ N / 15 ) ; $ sum = $ N * 800 ; $ sum _ discon = $ sum - $ waribiki * 200 ; echo $ sum _ discon . " \ n " ; < ? php $ N = fgets ( STDIN ) ; $ A = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ max = max ( $ A ) ; $ min = min ( $ A ) ; echo $ max - $ min ; ? > < ? php fscanf ( STDIN , " % d % d % d " , $ a , $ b , $ c ) ; $ abs _ a = abs ( $ a - $ b ) ; $ abs _ b = abs ( $ a - $ c ) ; $ abs _ c = abs ( $ b - $ c ) ; $ arr = [ $ abs _ a , $ abs _ b , $ abs _ c , ] ; sort ( $ arr ) ; $ answer = $ arr [ 0 ] + $ arr [ 1 ] ; echo $ answer ; ? > < ? php $ in = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ h1 = $ in [ 0 ] ; $ m1 = $ in [ 1 ] ; $ h2 = $ in [ 2 ] ; $ m2 = $ in [ 3 ] ; $ k = $ in [ 4 ] ; $ h = $ h2 - $ h1 ; $ m = $ m2 - $ m1 ; $ wakemin = $ h * 60 + $ m ; echo $ wakemin - $ k ; ? > < ? php $ input = fgets ( STDIN ) ; $ array = str _ split ( $ input ) ; if ( $ array [ 2 ] = = = $ array [ 3 ] & & $ array [ 4 ] = = = $ array [ 5 ] ) { echo ' Yes ' ; } else { echo ' No ' ; } < ? php $ max = trim ( fgets ( STDIN ) ) ; if ( $ max = = 1 ) { echo $ max . " \ n " ; } else { for ( $ i = $ max ; $ i > = 2 ; $ i -- ) { if ( ( $ i & ( $ i - 1 ) ) = = 0 ) { echo $ i . " \ n " ; break ; } } } < ? php $ stdin = trim ( fgets ( STDIN ) ) ; $ num = intval ( $ stdin ) ; $ ans = $ num * $ num * $ num ; print ( " { $ ans } \ n " ) ; < ? php # 整数の入力 fscanf ( STDIN , " % d % d % d " , $ a , $ b , $ c ) ; $ arrat = [ 5 = > 0,7 = > 0 ] ; if ( $ a = = = 5 | | $ a = = = 7 ) { $ arrat [ $ a ] = $ arrat [ $ a ] + 1 ; } if ( $ b = = = 5 | | $ b = = = 7 ) { $ arrat [ $ b ] = $ arrat [ $ b ] + 1 ; } if ( $ a = = = 5 | | $ a = = = 7 ) { $ arrat [ $ c ] = $ arrat [ $ c ] + 1 ; } if ( $ arrat [ 5 ] = = = 2 & & $ arrat [ 7 ] = = = 1 ) { echo ' YES ' ; } else { echo ' NO ' ; } < ? php $ A = fgets ( STDIN , 4096 ) ; $ array = explode ( " " , $ A ) ; $ check1 = false ; $ check2 = false ; $ check3 = false ; foreach ( $ array as $ x ) { if ( $ x = = 5 & & $ check1 = = false ) { $ check1 = true ; } elseif ( $ x = = 7 ) { $ check2 = true ; } elseif ( $ x = = 5 ) { $ check3 = true ; } } if ( $ check1 = = true & & $ check2 = = true & & $ check3 = = true ) { echo ' YES ' ; } else { echo ' NO ' ; } < ? php $ n = intval ( trim ( fgets ( STDIN ) ) ) ; print ( $ n * $ n * $ n ) ; ? > < ? php fscanf ( STDIN , " % d % d % d % d % d " , $ ho , $ mo , $ he , $ me , $ k ) ; $ o = $ ho * 60 + $ mo ; $ e = $ he * 60 + $ me ; $ ans = $ e - $ o - $ k ; if ( $ ans > 0 ) { echo $ ans ; } else { echo 0 ; } < ? php $ a = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ f = 0 ; $ s = 0 ; foreach ( $ a as $ value ) { if ( $ value = = 5 ) { $ f + = 1 ; } elseif ( $ value = = 7 ) { $ s + = 1 ; } } if ( $ f = = 2 & & $ s = = 1 ) { echo ' YES ' ; } else { echo ' NO ' ; } < ? php fscanf ( STDIN , ' % d ' , $ cnt ) ; $ people = array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; $ limit = max ( $ people ) ; $ ans = 1000000 ; for ( $ i = 1 ; $ i < = $ limit ; $ i + + ) { $ tmp = 0 ; foreach ( $ people as $ key = > $ person ) { $ tmp + = ( ( $ person - $ i ) * * 2 ) ; } $ ans = min ( $ ans , $ tmp ) ; } echo $ ans ; < ? php fscanf ( STDIN , " % d % d % d " , $ a , $ b , $ c ) ; if ( $ a = = 5 & & $ b = = 5 & & $ c = = 7 | | $ a = = 5 & & $ b = = 7 & & $ c = = 5 | | $ a = = 7 & & $ b = = 5 & & $ c = = 5 ) { echo " YES \ n " ; } else { echo " NO \ n " ; } < ? php list ( $ a [ 0 ] ) = fscanf ( STDIN , ' % d ' ) ; list ( $ a [ 1 ] ) = fscanf ( STDIN , ' % d ' ) ; list ( $ a [ 2 ] ) = fscanf ( STDIN , ' % d ' ) ; list ( $ a [ 3 ] ) = fscanf ( STDIN , ' % d ' ) ; list ( $ a [ 4 ] ) = fscanf ( STDIN , ' % d ' ) ; list ( $ k ) = fscanf ( STDIN , ' % d ' ) ; $ flg = true ; for ( $ i = 0 ; $ i < 5 ; $ i + + ) { for ( $ j = $ i + 1 ; $ j < 5 ; $ j + + ) { if ( $ a [ $ j ] - $ a [ $ i ] > $ k ) { $ flg = false ; break ; } } } echo $ flg ? " Yay ! " : " : ( " ? > < ? php list ( $ a , $ b ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; echo ceil ( ( $ a + $ b ) / 2 ) ; ? > < ? php $ n = trim ( fgets ( STDIN ) ) ; for ( $ i = 0 ; pow ( 2 , $ i ) < = $ n ; $ i + + ) { } echo pow ( 2 , $ i - 1 ) ; ? > < ? php $ in = [ ] ; fscanf ( STDIN , " % d " , $ in [ ] ) ; fscanf ( STDIN , " % d " , $ in [ ] ) ; fscanf ( STDIN , " % d " , $ in [ ] ) ; fscanf ( STDIN , " % d " , $ in [ ] ) ; fscanf ( STDIN , " % d " , $ in [ ] ) ; fscanf ( STDIN , " % d " , $ k ) ; $ ans = " Yay ! " ; for ( $ i = 0 ; $ i < count ( $ in ) - 1 ; $ i + + ) { for ( $ j = $ i + 1 ; $ j < count ( $ in ) ; $ j + + ) { if ( $ in [ $ j ] - $ in [ $ i ] > $ k ) { $ ans = " : ( " ; break ; } } } echo $ ans ; < ? php fscanf ( STDIN , " % d " , $ n ) ; $ array = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ dummy = array ( ) ; $ count = 0 ; $ min = null ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { if ( $ min = = null | | $ min > $ array [ $ i ] ) { $ min = $ array [ $ i ] ; } if ( $ array [ $ i ] < = $ min ) { $ count + + ; } } echo $ count ; < ? php $ a = trim ( fgets ( STDIN ) ) ; $ b = trim ( fgets ( STDIN ) ) ; $ c = trim ( fgets ( STDIN ) ) ; $ d = trim ( fgets ( STDIN ) ) ; $ e = trim ( fgets ( STDIN ) ) ; $ data [ " a " ] = $ a ; $ data [ " b " ] = $ b ; $ data [ " c " ] = $ c ; $ data [ " d " ] = $ d ; $ data [ " e " ] = $ e ; $ sort [ " a " ] = $ a % 10 ; $ sort [ " b " ] = $ b % 10 ; $ sort [ " c " ] = $ c % 10 ; $ sort [ " d " ] = $ d % 10 ; $ sort [ " e " ] = $ e % 10 ; asort ( $ sort ) ; foreach ( $ sort as $ key = > $ val ) { if ( $ val ! = 0 ) { $ min = $ data [ $ key ] ; unset ( $ data [ $ key ] ) ; break ; } } $ sum = 0 ; foreach ( $ data as $ key = > $ val ) { $ add = 0 ; if ( $ sort [ $ key ] ! = 0 ) { $ add = 10 - $ sort [ $ key ] ; } $ sum + = $ val + $ add ; } $ sum + = $ min ; echo $ sum ; ? > < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; echo ceil ( ( $ a + $ b ) / 2 ) . " \ n " ; < ? php fscanf ( STDIN , " % d % d " , $ K , $ S ) ; for ( $ i = 0 ; $ i < = $ K ; $ i + + ) { $ rest = $ S - $ i ; if ( 0 < = $ rest & & $ rest < = $ K + $ K ) { $ ans + = min ( $ rest , $ K + $ K - $ rest ) + 1 ; } } echo $ ans . PHP _ EOL ; < ? php $ n = trim ( fgets ( STDIN ) ) * 2 ; $ h = floor ( $ n / 60 ) ; $ m = $ n % 60 ; echo $ h . " " . $ m . PHP _ EOL ; ? > < ? php $ n = trim ( fgets ( STDIN ) ) ; $ count _ list = [ ] ; for ( $ i = 1 ; $ i < = $ n ; $ i + + ) { $ count = 0 ; $ q = $ i ; while ( $ q > 0 & & $ q % 2 = = 0 ) { $ p = $ q / 2 ; $ count + + ; $ q = $ p ; } $ count _ list [ $ i ] = $ count ; } arsort ( $ count _ list ) ; echo key ( $ count _ list ) . " \ n " ; < ? php $ ks = explode ( ' ' , fgets ( STDIN ) ) ; $ k = $ ks [ 0 ] ; $ s = $ ks [ 1 ] ; $ count = 0 ; for ( $ i = 0 ; $ i < = $ k ; $ i + + ) { for ( $ j = 0 ; $ j < = $ k ; $ j + + ) { $ l = $ s - $ i - $ j ; if ( 0 < = $ l & & $ l < = $ k ) $ count + + ; } } echo $ count ; ? > < ? php define ( ' MAX ' , pow ( 10 , 9 ) ) ; $ x = 0 ; $ a [ 0 ] = 0 ; for ( $ i = 1 ; $ i < PHP _ INT _ MAX ; $ i + + ) { $ tmp = pow ( $ i , 5 ) ; if ( $ tmp - $ a [ $ i - 1 ] > MAX ) { break ; } $ a [ $ i ] = $ tmp ; $ a [ - $ i ] = - $ tmp ; } fscanf ( STDIN , " % d " , $ N ) ; $ cnt = count ( $ a ) ; foreach ( $ a as $ k1 = > $ v1 ) { foreach ( $ a as $ k2 = > $ v2 ) { if ( $ v1 - $ v2 = = = $ N ) { printf ( " % d % d " , $ k1 , $ k2 ) ; break 2 ; } } } < ? php $ n = trim ( fgets ( STDIN ) ) ; $ a = explode ( ' ' , fgets ( STDIN ) ) ; while ( $ n > 0 ) { -- $ n ; if ( $ a [ $ n ] = = ' Y ' ) { echo ' Four ' ; exit ; } } echo ' Three ' ; < ? php while ( true ) { $ number = str _ split ( trim ( fgets ( STDIN ) ) ) ; if ( $ number [ 0 ] = = 0 ) exit ; echo array _ sum ( $ number ) . " \ n " ; } < ? php fscanf ( STDIN , " % d " , $ n ) ; $ q = [ 64 , 32 , 16 , 8 , 4 , 2 , 1 ] ; foreach ( $ q as $ p ) { if ( $ n > = $ p ) exit ( " $ p " ) ; } < ? php $ in = trim ( fgets ( STDIN ) ) ; echo $ in * $ in * $ in . " \ n " ; < ? php fscanf ( STDIN , " % d % d " , $ K , $ S ) ; for ( $ i = 0 ; $ i < = $ K ; $ i + + ) { for ( $ j = 0 ; $ j < = $ K ; $ j + + ) { $ rest = $ S - $ i - $ j ; if ( 0 < = $ rest & & $ rest < = $ K ) { $ ans + + ; } } } echo $ ans . PHP _ EOL ; < ? php fscanf ( STDIN , ' % s ' , $ str ) ; $ arr = str _ split ( $ str ) ; if ( $ arr [ 2 ] = = $ arr [ 3 ] & & $ arr [ 4 ] = = $ arr [ 5 ] ) { echo " Yes " ; } else { echo " No " ; } echo " \ n " ; < ? php fscanf ( STDIN , " % d " , $ N ) ; $ X = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ Y = $ X ; sort ( $ Y ) ; $ n1 = $ Y [ $ N / 2 - 1 ] ; $ n2 = $ Y [ $ N / 2 ] ; for ( $ i = 0 ; $ i < $ N ; $ i + + ) { if ( $ n2 < = $ X [ $ i ] ) { echo $ n1 ; } else { echo $ n2 ; } echo PHP _ EOL ; } < ? php fscanf ( STDIN , " % d " , $ n ) ; $ line = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ cnt = 1 ; $ min = $ line [ 0 ] ; for ( $ i = 1 ; $ i < $ n ; $ i + + ) { if ( $ line [ $ i ] < $ min ) { $ cnt + + ; $ min = $ line [ $ i ] ; } } echo $ cnt ; < ? php fscanf ( STDIN , " % d " , $ n ) ; $ a = explode ( " " , rtrim ( fgets ( STDIN ) ) ) ; $ b = explode ( " " , rtrim ( fgets ( STDIN ) ) ) ; $ over = 0 ; $ under = 0 ; $ result = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { if ( $ a [ $ i ] > = $ b [ $ i ] ) $ over + = $ a [ $ i ] - $ b [ $ i ] ; else { $ under + = $ b [ $ i ] - $ a [ $ i ] ; $ result + + ; } $ err [ $ i ] = $ a [ $ i ] - $ b [ $ i ] ; } $ i = 0 ; rsort ( $ err ) ; while ( $ under > 0 ) { $ under - = $ err [ $ i ] ; $ result + + ; $ i + + ; if ( $ i = = $ n ) { $ result = - 1 ; break ; } } printf ( " % d \ n " , $ result ) ; < ? php $ line = trim ( fgets ( STDIN ) ) ; if ( in _ array ( $ line , [ ' 5 5 7 ' , ' 5 7 5 ' , ' 7 5 5 ' , ] , true , ) ) { echo " YES " ; } else { echo " NO " ; } < ? php $ N = trim ( fgets ( STDIN ) ) ; $ I = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ r = null ; $ min = min ( $ I ) ; $ max = max ( $ I ) + 1 ; for ( ; $ min < $ max ; + + $ min ) { $ c = 0 ; for ( $ i = 0 ; $ i < $ N ; + + $ i ) { $ c + = pow ( $ I [ $ i ] - $ min , 2 ) ; } if ( $ r = = null | | $ r > $ c ) $ r = $ c ; } echo $ r ; < ? php fscanf ( STDIN , " % d " , $ n ) ; $ x _ arr = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ min = PHP _ INT _ MAX ; for ( $ i = 1 ; $ i < = 100 ; + + $ i ) { $ sum = 0 ; foreach ( $ x _ arr as $ x ) { $ sum + = pow ( $ x - $ i , 2 ) ; } if ( $ sum < $ min ) { $ min = $ sum ; } } echo $ min ; < ? php list ( $ n , $ m ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ i = 0 ; while ( $ i < $ n ) { $ a [ ] = trim ( fgets ( STDIN ) ) ; + + $ i ; } $ i = 0 ; while ( $ i < $ m ) { $ b [ ] = trim ( fgets ( STDIN ) ) ; + + $ i ; } $ i = 0 ; while ( $ i < = $ n - $ m ) { $ j = 0 ; while ( $ j < = $ n - $ m ) { if ( substr ( $ a [ $ i ] , $ j , $ m ) = = $ b [ 0 ] ) { $ flag = 1 ; $ k = $ i + 1 ; while ( $ k < $ i + $ m ) { if ( substr ( $ a [ $ k ] , $ j , $ m ) ! = $ b [ $ k - $ i ] ) { $ flag = 0 ; break ; } + + $ k ; } if ( $ flag ) { echo " Yes " ; exit ; } } + + $ j ; } + + $ i ; } echo " No " ; < ? php $ a = intval ( trim ( fgets ( STDIN ) ) ) ; preg _ match _ all ( " ( [ 0-9 ] ) " , $ a , $ m ) ; if ( $ a % array _ sum ( $ m [ 0 ] ) = = = 0 ) { echo " Yes " . " \ n " ; } else { echo " No " . " \ n " ; } < ? php $ line = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ limit = $ line [ 0 ] ; $ sum = $ line [ 1 ] ; $ count = 0 ; for ( $ x = 0 ; $ x < = $ limit ; $ x + + ) { for ( $ y = 0 ; $ y < = $ limit ; $ y + + ) { if ( $ x + $ y < = $ sum & & $ sum - $ x - $ y < = $ limit ) { $ count + + ; } } } print $ count ; < ? php for ( $ i = 0 ; $ i < = 5 ; $ i + + ) { $ a [ ] = trim ( fgets ( STDIN ) ) ; } if ( $ a [ 4 ] - $ a [ 0 ] > $ a [ 5 ] ) { echo ' : ( ' ; } else { echo ' Yay ! ' ; } < ? php $ vars = explode ( " " , trim ( fgets ( STDIN ) ) ) ; sort ( $ vars ) ; if ( $ vars = = array ( ' 5 ' , ' 5 ' , ' 7 ' ) ) { echo " YES " ; } else { echo " NO " ; } < ? php $ a = fgets ( STDIN ) ; echo $ a * $ a * $ a ; ? > < ? php fscanf ( STDIN , ' % d % d ' , $ n , $ m ) ; $ a = array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; $ lcm = lcmAll ( $ a ) ; for ( $ i = 0 ; $ i < $ n ; + + $ i ) { if ( $ lcm / $ a [ $ i ] % 2 = = = 0 ) { echo ( 0 ) . PHP _ EOL ; exit ; } } $ ans = floor ( ( 2 * $ m + $ lcm ) / ( 2 * $ lcm ) ) ; echo $ ans . PHP _ EOL ; function gcd ( $ m , $ n ) { if ( ! $ n ) return $ m ; return gcd ( $ n , $ m % $ n ) ; } function gcdAll ( $ arr ) { $ gcd = $ arr [ 0 ] ; for ( $ i = 0 ; $ i < count ( $ arr ) ; $ i + + ) { $ gcd = gcd ( $ gcd , $ arr [ $ i ] ) ; } return $ gcd ; } function lcm ( $ m , $ n ) { return $ m * $ n / gcd ( $ m , $ n ) ; } function lcmAll ( $ arr ) { $ lcm = $ arr [ 0 ] ; for ( $ i = 0 ; $ i < count ( $ arr ) ; $ i + + ) { $ lcm = lcm ( $ lcm , $ arr [ $ i ] ) ; } return $ lcm ; } < ? php class STD { static function input ( ) { $ line = trim ( fgets ( STDIN ) ) ; return $ line ; } static function output ( $ text ) { echo $ text . " \ n " ; } } function cost ( $ str ) { return - intval ( $ str , 36 ) + 36 ; } $ s = STD : : input ( ) ; $ n = intval ( STD : : input ( ) ) ; $ len = strlen ( $ s ) ; for ( $ i = 0 ; $ i < $ len ; $ i + + ) { if ( cost ( $ s [ $ i ] ) < = $ n & & $ s [ $ i ] ! = ' a ' ) { $ n - = cost ( $ s [ $ i ] ) ; $ s [ $ i ] = ' a ' ; } } if ( $ n > 0 ) { $ diff = $ n % 26 ; for ( $ g = 0 ; $ g < $ diff ; $ g + + ) { $ str = $ s [ $ len - 1 ] ; $ s [ $ len - 1 ] = + + $ str ; } } STD : : output ( $ s ) ; ? > < ? php fscanf ( STDIN , " % d % d % d % d " , $ A , $ B , $ H , $ M ) ; $ L _ KAKUDO = 90 - $ H * 30 - $ M / 2 ; $ S _ KAKUDO = 90 - $ M * 6 ; define ( ' RAD ' , 180 / M _ PI ) ; $ L _ X = cos ( $ L _ KAKUDO / RAD ) * $ A ; $ L _ Y = sin ( $ L _ KAKUDO / RAD ) * $ A ; $ S _ X = cos ( $ S _ KAKUDO / RAD ) * $ B ; $ S _ Y = sin ( $ S _ KAKUDO / RAD ) * $ B ; $ ans = sqrt ( pow ( $ L _ X - $ S _ X , 2 ) + pow ( $ L _ Y - $ S _ Y , 2 ) ) ; printf ( " % 0.53f " , $ ans ) ; < ? php $ f = fopen ( ' php : $ line = fgets ( $ f ) ; $ date _ array = explode ( ' / ' , $ line ) ; if ( $ date _ array [ 0 ] < ' 2019 ' ) { echo ( ' Heisei ' ) ; } elseif ( $ date _ array [ 0 ] = = = ' 2019 ' & & $ date _ array [ 1 ] < = 4 ) { echo ( ' Heisei ' ) ; } else { echo ( ' TBD ' ) ; } < ? php fscanf ( STDIN , ' % d ' , $ i ) ; echo $ i * $ i * $ i . PHP _ EOL ; < ? PHP fscanf ( STDIN , ' % d / % d / % d ' , $ a , $ b , $ c ) ; echo $ b < 5 ? Heisei : TBD ; < ? php $ r = fgets ( STDIN ) ; $ s1 = pow ( 2 * 3.14 * 1 , 2 ) ; $ sr = pow ( 2 * 3.14 * $ r , 2 ) ; print ( $ sr / $ s1 ) ; < ? php fscanf ( STDIN , " % d % d " , $ H , $ W ) ; $ loadmap = [ ] ; for ( $ i = 0 ; $ i < $ H ; + + $ i ) { $ loadmap [ ] = array _ map ( " intval " , explode ( " " , trim ( fgets ( STDIN ) ) ) ) ; } $ answer = 2000000000000000 ; for ( $ i = 0 ; $ i < $ H ; + + $ i ) { for ( $ j = 0 ; $ j < $ W ; + + $ j ) { $ tmp _ sum = 0 ; for ( $ row = 0 ; $ row < $ H ; + + $ row ) { for ( $ col = 0 ; $ col < $ W ; + + $ col ) { $ tmp _ sum + = $ loadmap [ $ row ] [ $ col ] * min ( abs ( $ row - $ i ) , abs ( $ col - $ j ) ) ; } } $ answer = min ( $ answer , $ tmp _ sum ) ; } } echo $ answer , " \ n " ; < ? php $ N = trim ( fgets ( STDIN ) ) ; $ a = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ b = explode ( " " , trim ( fgets ( STDIN ) ) ) ; for ( $ i = 0 ; $ i < $ N ; $ i + + ) { $ c [ $ i ] = $ a [ $ i ] - $ b [ $ i ] ; } $ A = array _ sum ( $ a ) ; $ B = array _ sum ( $ b ) ; $ k = 0 ; foreach ( $ c as $ value ) { if ( $ value < 0 ) { $ k = 1 ; } } if ( $ A < $ B ) { echo ' -1 ' ; exit ; } elseif ( $ k = = 0 ) { echo ' 0 ' ; exit ; } sort ( $ c ) ; $ point = 0 ; $ ans = 0 ; $ j = 0 ; while ( true ) { if ( $ c [ $ j ] < 0 ) { $ ans + + ; $ point + = $ c [ $ j ] ; $ j + + ; } else { break ; } } rsort ( $ c ) ; $ k = 0 ; while ( true ) { $ point + = $ c [ $ k ] ; $ ans + + ; if ( $ point > 0 ) { echo $ ans ; exit ; } $ k + + ; } < ? php $ n = intval ( fgets ( STDIN ) ) ; $ A = array _ map ( " intval " , explode ( " " , trim ( fgets ( STDIN ) ) ) ) ; $ low = 10 * * 10 ; $ count = 0 ; foreach ( $ A as $ a ) { if ( $ a < $ low ) { $ count + + ; $ low = $ a ; } } echo $ count ; < ? php fscanf ( STDIN , " % d " , $ n ) ; echo ( 800 * $ n - floor ( $ n / 15 ) * 200 ) . " \ n " ; < ? php $ stdin = file _ get _ contents ( ' php : print ( $ stdin * $ stdin * $ stdin ) ; ? > < ? php fscanf ( STDIN , " % d % d " , $ n , $ k ) ; if ( $ k = = 1 ) { echo 0 ; exit ; } else { $ zan = $ n - $ k ; $ max = $ zan + 1 ; $ min = 1 ; echo $ max - $ min ; } ? > < ? php $ line = readline ( ) ; readline _ add _ history ( $ line ) ; $ x = intval ( $ line ) ; $ x = $ x * $ x * $ x ; echo $ x ; ? > < ? php $ a = array _ map ( ' intval ' , explode ( " " , trim ( fgets ( STDIN ) ) ) ) ; sort ( $ a ) ; echo $ a [ 2 ] - $ a [ 0 ] ; < ? php $ t = trim ( fgets ( STDIN ) ) ; $ len = strlen ( $ t ) ; for ( $ i = 0 ; $ i < $ len ; $ i + + ) { if ( $ t [ $ i ] = = " ? " ) $ t [ $ i ] = " D " ; } echo $ t ; < ? php $ c [ ] = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ c [ ] = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ c [ ] = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ j1 = $ c [ 0 ] [ 1 ] - $ c [ 0 ] [ 0 ] ; $ j2 = $ c [ 0 ] [ 2 ] - $ c [ 0 ] [ 0 ] ; $ i1 = $ c [ 1 ] [ 0 ] - $ c [ 0 ] [ 0 ] ; $ i2 = $ c [ 2 ] [ 0 ] - $ c [ 0 ] [ 0 ] ; for ( $ i = 1 ; $ i < 3 ; $ i + + ) { if ( $ j1 ! = $ c [ $ i ] [ 1 ] - $ c [ $ i ] [ 0 ] ) { echo " No " ; exit ; } if ( $ j2 ! = $ c [ $ i ] [ 2 ] - $ c [ $ i ] [ 0 ] ) { echo " No " ; exit ; } if ( $ i1 ! = $ c [ 1 ] [ $ i ] - $ c [ 0 ] [ $ i ] ) { echo " No " ; exit ; } if ( $ i2 ! = $ c [ 2 ] [ $ i ] - $ c [ 0 ] [ $ i ] ) { echo " No " ; exit ; } } echo " Yes " ; < ? php $ a = fgets ( STDIN ) ; echo $ a * $ a ; ? > < ? php fscanf ( STDIN , " % d " , $ N ) ; $ map = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ ans = PHP _ INT _ MAX ; for ( $ i = 1 ; $ i < = 100 ; $ i + + ) { $ temp = 0 ; foreach ( $ map as $ item ) { $ temp + = pow ( $ item - $ i , 2 ) ; } $ ans = min ( $ ans , $ temp ) ; } echo $ ans ; < ? php fscanf ( STDIN , " % d / % d / % d " , $ yyyy , $ mm , $ dd ) ; $ num = $ yyyy * 10000 + $ mm * 100 + $ dd ; echo $ num < = 20190430 ? " Heisei " : " TBD " ; < ? php $ s = preg _ split ( ' print ( $ s [ 2 ] = = $ s [ 3 ] & & $ s [ 4 ] = = $ s [ 5 ] ) ? " Yes " : " No " ; < ? php $ s = trim ( fgets ( STDIN ) ) ; $ s = str _ replace ( array ( " \ r \ n " , " \ r " , " \ n " ) , ' ' , $ s ) ; $ s = explode ( " " , $ s ) ; $ count = $ s [ 0 ] ; $ n = $ s [ 1 ] ; $ ponints = array ( ) ; for ( $ i = 0 ; $ i < $ count ; $ i + + ) { $ s = trim ( fgets ( STDIN ) ) ; $ s = str _ replace ( array ( " \ r \ n " , " \ r " , " \ n " ) , ' ' , $ s ) ; $ s = explode ( " " , $ s ) ; $ ponints [ ] = $ s ; } function kyori ( $ a , $ b , $ n ) { $ sum = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ sum + = ( $ a [ $ i ] - $ b [ $ i ] ) * ( $ a [ $ i ] - $ b [ $ i ] ) ; } return sqrt ( ( int ) $ sum ) ; } function is _ decimal ( $ value ) { return filter _ var ( $ value , FILTER _ VALIDATE _ INT ) ! = = false ; } $ seisuu _ num = 0 ; for ( $ i = 0 ; $ i < $ count ; $ i + + ) { for ( $ j = $ i + 1 ; $ j < $ count ; $ j + + ) { $ kyori = kyori ( $ ponints [ $ i ] , $ ponints [ $ j ] , $ n ) ; if ( is _ decimal ( $ kyori ) ) { $ seisuu _ num + + ; } } } echo $ seisuu _ num ; ? > < ? php fscanf ( STDIN , " % d % d " , $ N , $ M ) ; $ N _ img = " " ; $ M _ img = " " ; $ ans = " No " ; for ( $ i = 0 ; $ i < $ N ; $ i + + ) { $ N _ img [ $ i ] = str _ split ( trim ( fgets ( STDIN ) ) ) ; } for ( $ j = 0 ; $ j < $ M ; $ j + + ) { $ M _ img [ $ j ] = str _ split ( trim ( fgets ( STDIN ) ) ) ; } for ( $ i = 0 ; $ i < = $ N - $ M ; $ i + + ) { for ( $ j = 0 ; $ j < = $ N - $ M ; $ j + + ) { $ count = 0 ; for ( $ k = 0 ; $ k < $ M ; $ k + + ) { for ( $ l = 0 ; $ l < $ M ; $ l + + ) { if ( $ N _ img [ $ i + $ k ] [ $ j + $ l ] = = $ M _ img [ $ k ] [ $ l ] ) { $ count + + ; } } } if ( $ count = = $ M * $ M ) $ ans = " Yes " ; } } echo $ ans ; ? > < ? php fscanf ( STDIN , " % d % d " , $ posa , $ speeda ) ; fscanf ( STDIN , " % d % d " , $ posb , $ speedb ) ; fscanf ( STDIN , " % d " , $ timelimit ) ; if ( $ posa = = = $ posb ) { echo " YES " ; exit ( 0 ) ; } if ( $ speeda < = $ speedb ) { echo " NO " ; } else { $ distance = abs ( $ posa - $ posb ) ; $ speed = abs ( $ speeda - $ speedb ) ; $ time = $ distance / $ speed ; if ( $ time < = $ timelimit ) { echo " YES " ; } else { echo " NO " ; } } < ? php fscanf ( STDIN , " % d " , $ n ) ; $ li = array ( ) ; $ count = 0 ; $ max = 0 ; $ max _ i = 1 ; for ( $ i = 1 ; $ i < = $ n ; $ i + + ) { $ i _ update = $ i ; for ( $ j = 0 ; $ j < $ i ; $ j + + ) { if ( $ i _ update % 2 = = 0 ) { $ i _ update / = 2 ; $ count + + ; } } if ( $ max < $ count ) { $ max = $ count ; $ max _ i = $ i ; } $ count = 0 ; } echo $ max _ i . " \ n " ; < ? php while ( true ) { $ input = trim ( fgets ( STDIN ) ) ; $ input = explode ( " " , $ input ) ; foreach ( $ input as $ value ) { $ args [ ] = $ value ; if ( count ( $ args ) > = 3 ) { break ; } } if ( count ( $ args ) > = 3 ) { break ; } } $ t1 = $ args [ 0 ] ; $ t2 = $ args [ 1 ] ; $ t3 = $ args [ 2 ] ; $ cost12 = abs ( $ t1 - $ t2 ) ; $ cost23 = abs ( $ t2 - $ t3 ) ; $ cost31 = abs ( $ t3 - $ t1 ) ; $ cost1 = 0 + $ cost12 + $ cost23 ; $ cost2 = 0 + $ cost23 + $ cost31 ; $ cost3 = 0 + $ cost31 + $ cost12 ; if ( $ cost1 < $ cost2 ) { if ( $ cost1 < $ cost3 ) { $ result = $ cost1 ; } else { $ result = $ cost3 ; } } else { if ( $ cost2 < $ cost3 ) { $ result = $ cost2 ; } else { $ result = $ cost3 ; } } out ( $ result ) ; function out ( $ var ) { echo $ var , PHP _ EOL ; } < ? php fscanf ( STDIN , " % d % d " , $ n , $ d ) ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ x _ li [ ] = explode ( " " , trim ( fgets ( STDIN ) ) ) ; } $ sum = 0 ; $ count = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { for ( $ j = 0 ; $ j < $ n ; $ j + + ) { if ( $ i < $ j ) { for ( $ k = 0 ; $ k < $ d ; $ k + + ) { $ sum + = ( $ x _ li [ $ j ] [ $ k ] - $ x _ li [ $ i ] [ $ k ] ) * * 2 ; } if ( sqrt ( $ sum ) - ( int ) sqrt ( $ sum ) = = 0 ) { $ count + + ; } } $ sum = 0 ; } } echo $ count . " \ n " ; < ? php fscanf ( STDIN , " % d % d % d % d " , $ a , $ b , $ c , $ d ) ; $ factor = $ a * $ b ; $ factor2 = $ c * $ d ; if ( $ factor > = $ factor2 ) { print ( " $ factor \ n " ) ; } else { print ( " $ factor2 \ n " ) ; } ? > < ? php fscanf ( STDIN , " % d % d " , $ N , $ M ) ; for ( $ i = 1 ; $ i < = $ M ; $ i + + ) { fscanf ( STDIN , " % d % d % d " , $ a [ $ i ] , $ b [ $ i ] , $ c [ $ i ] ) ; } for ( $ i = 1 ; $ i < = $ N ; $ i + + ) { for ( $ j = 1 ; $ j < = $ N ; $ j + + ) { if ( $ i = = $ j ) { $ dist [ $ i ] [ $ j ] = 0 ; } else { $ dist [ $ i ] [ $ j ] = INF ; } } } for ( $ i = 1 ; $ i < = $ M ; $ i + + ) { $ dist [ $ a [ $ i ] ] [ $ b [ $ i ] ] = $ c [ $ i ] ; $ dist [ $ b [ $ i ] ] [ $ a [ $ i ] ] = $ c [ $ i ] ; } for ( $ k = 1 ; $ k < = $ N ; $ k + + ) { for ( $ i = 1 ; $ i < = $ N ; $ i + + ) { for ( $ j = 1 ; $ j < = $ N ; $ j + + ) { if ( $ dist [ $ i ] [ $ k ] + $ dist [ $ k ] [ $ j ] < $ dist [ $ i ] [ $ j ] ) { $ dist [ $ i ] [ $ j ] = $ dist [ $ i ] [ $ k ] + $ dist [ $ k ] [ $ j ] ; $ dist [ $ j ] [ $ i ] = $ dist [ $ i ] [ $ k ] + $ dist [ $ k ] [ $ j ] ; } } } } $ ans = 0 ; for ( $ i = 1 ; $ i < = $ M ; $ i + + ) { if ( $ dist [ $ a [ $ i ] ] [ $ b [ $ i ] ] < $ c [ $ i ] ) { $ ans + + ; } } echo $ ans ; < ? php fscanf ( STDIN , " % d " , $ r ) ; printf ( " % d \ n " , $ r * $ r ) ; ? > < ? php $ x = trim ( fgets ( STDIN ) ) ; for ( $ i = - 118 ; $ i < = 119 ; $ i + + ) { for ( $ j = - 118 ; $ j < = 119 ; $ j + + ) { if ( pow ( $ i , 5 ) - pow ( $ j , 5 ) = = $ x ) { $ ans = " $ i $ j " . " \ n " ; break ; } } } echo $ ans ; < ? php $ x = fgets ( STDIN ) ; $ y = $ x * $ x * $ x ; echo " $ y \ n " ; return 0 ; ? > < ? php fscanf ( STDIN , " % d % d " , $ alice , $ bob ) ; if ( $ alice = = 1 & & $ bob ! = = 1 ) { echo " Alice " ; } elseif ( $ alice ! = = 1 & & $ bob = = 1 ) { echo " Bob " ; } elseif ( $ alice = = $ bob ) { echo " Draw " ; } elseif ( $ alice > $ bob ) { echo ' Alice ' ; } else { echo ' Bob ' ; } < ? php fscanf ( STDIN , " % d " , $ n ) ; $ max _ cnt = 0 ; $ ans = $ n ; for ( $ i = $ n ; $ i > 1 ; $ i -- ) { $ cnt = 0 ; $ m = $ i ; while ( true ) { if ( $ m % 2 = = 0 ) { $ m = $ m / 2 ; $ cnt + + ; } else { if ( $ max _ cnt < $ cnt ) { $ ans = $ i ; $ max _ cnt = $ cnt ; } break ; } } } echo $ ans ; < ? php fscanf ( STDIN , " % d % d % d % d % d " , $ hs , $ ms , $ he , $ me , $ long ) ; $ dist = ( $ he * 60 + $ me ) - ( $ hs * 60 + $ ms ) ; if ( $ dist > $ long ) { echo $ dist - $ long ; } else { echo 0 ; } < ? php fscanf ( STDIN , " % d " , $ r ) ; echo $ r * $ r ; ? > < ? php $ input = trim ( fgets ( STDIN ) ) ; while ( 0 ! = $ input ) { $ list = str _ split ( $ input ) ; $ sum = 0 ; foreach ( $ list as $ i ) { $ sum + = ( int ) $ i ; } echo $ sum . " \ n " ; $ input = trim ( fgets ( STDIN ) ) ; } < ? php $ n = trim ( fgets ( STDIN ) ) ; $ ca = [ ] ; for ( $ i = 1 ; $ i < = $ n ; $ i + + ) { $ c = 0 ; $ t = $ i ; while ( $ t > 0 ) { if ( $ t % 2 ! = = 0 ) { break ; } else if ( $ t % 2 = = 0 ) { $ c + + ; $ t = $ t / 2 ; } } $ ca = $ ca + array ( $ i = > $ c ) ; } $ max = max ( $ ca ) ; echo array _ keys ( $ ca , $ max ) [ 0 ] ; ? > < ? php fscanf ( STDIN , " % d " , $ num ) ; for ( $ i = - 6208 ; $ i < 6209 ; $ i + + ) { $ array [ $ i ] = ( int ) pow ( $ i , 5 ) ; } foreach ( $ array as $ key = > $ value ) { $ target = binarySearch ( $ value , $ num , - 6208 , 6208 ) ; if ( $ target ! = = false ) { echo $ key . " " . $ target ; exit ; } } function binarySearch ( $ n , $ target , $ min , $ max ) { global $ array ; $ pivot = $ min + intdiv ( $ max - $ min , 2 ) ; if ( $ n - $ array [ $ pivot ] < $ target ) { if ( $ pivot = = $ min ) { return false ; } if ( $ n - $ array [ $ pivot - 1 ] > $ target ) { return false ; } elseif ( $ n - $ array [ $ pivot - 1 ] = = $ target ) { return $ pivot - 1 ; } else { if ( $ pivot - 1 = = $ min ) { return false ; } return ( binarySearch ( $ n , $ target , $ min , $ pivot ) ) ; } } elseif ( $ n - $ array [ $ pivot ] > $ target ) { if ( $ pivot = = $ max ) { return false ; } if ( $ n - $ array [ $ pivot + 1 ] < $ target ) { return false ; } elseif ( $ n - $ array [ $ pivot + 1 ] = = $ target ) { return $ pivot + 1 ; } else { if ( $ pivot + 1 = = $ max ) { return false ; } return ( binarySearch ( $ n , $ target , $ pivot , $ max ) ) ; } } else { return $ pivot ; } } function array _ last ( array $ array ) { return end ( $ array ) ; } < ? php $ cnt = 0 ; $ arr = explode ( " " , trim ( fgets ( STDIN ) ) ) ; foreach ( $ arr as $ val ) { if ( $ val = = 5 ) { $ cnt + + ; } } if ( $ cnt = = 2 ) echo " YES " ; else echo " NO " ; ? > < ? php fscanf ( STDIN , " % s " , $ a ) ; $ num = str _ replace ( ' / ' , ' ' , $ a ) ; echo $ num < = 20190430 ? ' Heisei ' : ' TBD ' ; < ? php list ( $ a , $ b ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; if ( $ a < = 8 & & $ b < = 8 ) { echo " Yay ! " ; } else { echo " : ( " ; } ? > < ? php $ x = ( int ) trim ( fgets ( STDIN ) ) ; echo $ x * $ x * $ x ; ? > < ? php list ( $ coinA , $ coinB , $ price ) = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; echo ( ( $ coinA + $ coinB ) > = $ price ) ? ' Yes ' : ' No ' ; < ? php fscanf ( STDIN , ' % d % d ' , $ k , $ s ) ; for ( $ i = 0 ; $ i < = $ k ; $ i + + ) { $ c = $ s - $ i ; if ( $ c > $ k ) $ a + = max ( 0 , 2 * $ k - $ c + 1 ) ; elseif ( $ c > = 0 ) $ a + = $ c + 1 ; } echo $ a ; < ? php $ antennas = array ( ) ; for ( $ i = 0 ; $ i < = 5 ; $ i + + ) { $ antennas [ $ i ] = trim ( fgets ( STDIN ) ) ; } $ k = $ antennas [ 5 ] ; if ( delta ( $ antennas [ 0 ] , $ antennas [ 1 ] ) > $ k ) { echo " : ( " ; exit ( ) ; } if ( delta ( $ antennas [ 0 ] , $ antennas [ 2 ] ) > $ k ) { echo " : ( " ; exit ( ) ; } if ( delta ( $ antennas [ 0 ] , $ antennas [ 3 ] ) > $ k ) { echo " : ( " ; exit ( ) ; } if ( delta ( $ antennas [ 0 ] , $ antennas [ 4 ] ) > $ k ) { echo " : ( " ; exit ( ) ; } if ( delta ( $ antennas [ 1 ] , $ antennas [ 2 ] ) > $ k ) { echo " : ( " ; exit ( ) ; } if ( delta ( $ antennas [ 1 ] , $ antennas [ 3 ] ) > $ k ) { echo " : ( " ; exit ( ) ; } if ( delta ( $ antennas [ 1 ] , $ antennas [ 4 ] ) > $ k ) { echo " : ( " ; exit ( ) ; } if ( delta ( $ antennas [ 2 ] , $ antennas [ 3 ] ) > $ k ) { echo " : ( " ; exit ( ) ; } if ( delta ( $ antennas [ 2 ] , $ antennas [ 4 ] ) > $ k ) { echo " : ( " ; exit ( ) ; } if ( delta ( $ antennas [ 3 ] , $ antennas [ 4 ] ) > $ k ) { echo " : ( " ; exit ( ) ; } echo " Yay ! " ; exit ( ) ; function delta ( $ a , $ b ) { if ( $ a > $ b ) { return $ a - $ b ; } else if ( $ a < $ b ) { return $ b - $ a ; } } < ? php $ arr = explode ( ' ' , fgets ( STDIN ) ) ; $ age = ( int ) $ arr [ 0 ] ; $ price = ( int ) $ arr [ 1 ] ; if ( $ age < = 5 ) { echo 0 . PHP _ EOL ; exit ; } elseif ( 6 < = $ age & & $ age < = 12 ) { echo ( $ price / 2 ) . PHP _ EOL ; exit ; } else { echo $ price . PHP _ EOL ; exit ; } < ? php $ line = fgets ( STDIN ) ; $ arr = str _ split ( $ line ) ; if ( $ arr [ 2 ] = = $ arr [ 3 ] & & $ arr [ 4 ] = = $ arr [ 5 ] ) { echo " Yes \ n " ; } else { echo " No \ n " ; } ? > < ? php $ number = trim ( fgets ( STDIN ) ) ; $ log = log ( $ number , 2 ) ; $ log = ( int ) $ log ; echo pow ( 2 , $ log ) ; echo " \ n " ; < ? php while ( fscanf ( STDIN , " % d % d " , $ a , $ b ) > 0 ) { print ( $ a + $ b ) . " \ n " ; } ? > < ? php print ( strval ( cubic ( read _ num ( ) ) ) . " \ n " ) ; function read _ num ( ) { if ( fscanf ( STDIN , " % d " , $ num ) ! = 1 ) { exit ( " invalid input " ) ; } return $ num ; } function cubic ( $ num ) { return $ num * $ num * $ num ; } < ? php $ n = trim ( fgets ( STDIN ) ) ; $ i = 0 ; while ( $ i < $ n ) { list ( $ x [ ] , $ y [ ] ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; + + $ i ; } $ ans = 0 ; $ i = 0 ; while ( $ i < $ n ) { $ j = $ i + 1 ; while ( $ j < $ n ) { $ ans + = 2 * ( sqrt ( pow ( $ x [ $ j ] - $ x [ $ i ] , 2 ) + pow ( $ y [ $ j ] - $ y [ $ i ] , 2 ) ) ) ; + + $ j ; } + + $ i ; } echo sprintf ( ' % .7f ' , $ ans / $ n ) , PHP _ EOL ; < ? php $ a = fgets ( STDIN ) ; $ b = fgets ( STDIN ) ; $ c = fgets ( STDIN ) ; $ x = fgets ( STDIN ) ; $ result = 0 ; for ( $ fiveH = 0 ; $ fiveH < = $ a ; $ fiveH + + ) { for ( $ hund = 0 ; $ hund < = $ b ; $ hund + + ) { for ( $ fifty = 0 ; $ fifty < = $ c ; $ fifty + + ) { if ( 500 * $ fiveH + 100 * $ hund + 50 * $ fifty = = $ x ) { $ result + + ; } } } } echo ( $ result ) ; < ? php list ( $ n ) = ints ( ) ; echo isHarshad ( $ n ) ? ' Yes ' : ' No ' ; function ints ( ) { return array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; } function isHarshad ( $ n ) { return $ n % array _ sum ( array _ map ( ' intval ' , str _ split ( ( string ) $ n ) ) ) = = = 0 ; } < ? php $ x = trim ( fgets ( STDIN ) ) ; $ res = $ x * $ x * $ x ; echo $ res ; ? > < ? php $ stdin = trim ( fgets ( STDIN ) ) ; $ circle = $ stdin * $ stdin ; echo $ circle ; ? > < ? php $ calcAnswer = trim ( fgets ( STDIN ) ) ; echo calc ( $ calcAnswer ) ; echo " \ n " ; function calc ( $ x ) { $ answer = $ x * $ x * $ x ; return $ answer ; } ? > < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; $ average = ( $ a + $ b ) / 2 ; echo ceil ( $ average ) ; echo " \ n " ; ? > < ? php list ( $ n , $ k ) = ints ( ) ; echo $ k > 1 ? $ n - $ k : 0 ; function ints ( ) { return array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; } < ? php $ a = [ ] ; list ( $ a [ ] ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; list ( $ a [ ] ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; list ( $ a [ ] ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; list ( $ a [ ] ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; list ( $ a [ ] ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; list ( $ k ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; for ( $ i = 0 ; $ i < count ( $ a ) - 1 ; $ i + + ) { for ( $ j = $ i + 1 ; $ j < count ( $ a ) ; $ j + + ) { if ( abs ( $ a [ $ i ] - $ a [ $ j ] ) > $ k ) { echo " : ( " ; exit ; } } } echo " Yay ! " ; < ? php list ( $ A , $ B ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; if ( $ A > 8 | | $ B > 8 ) { printf ( " : ( \ n " ) ; } else { printf ( " Yay ! \ n " ) ; } < ? php fscanf ( STDIN , " % d % d " , $ N , $ D ) ; $ ans = 0 ; for ( $ i = 0 ; $ i < $ N ; $ i + + ) { $ X [ $ i ] = explode ( " " , trim ( fgets ( STDIN ) ) ) ; } for ( $ i = 0 ; $ i < $ N - 1 ; $ i + + ) { for ( $ j = $ i + 1 ; $ j < $ N ; $ j + + ) { $ diff = 0 ; foreach ( $ X [ $ i ] as $ k = > $ z ) { $ diff + = pow ( $ X [ $ i ] [ $ k ] - $ X [ $ j ] [ $ k ] , 2 ) ; } $ diff _ int = sqrt ( $ diff ) ; if ( $ diff _ int = = intval ( $ diff _ int ) ) { $ ans + + ; } } } echo $ ans ; < ? php $ str = fgets ( STDIN ) ; $ arr = str _ split ( $ str ) ; if ( $ arr [ 2 ] = = $ arr [ 3 ] & & $ arr [ 4 ] = = $ arr [ 5 ] ) { echo " Yes " ; } else { echo " No " ; } ? > < ? php while ( ! feof ( STDIN ) ) { $ stdin [ ] = trim ( fgets ( STDIN ) ) ; } $ a = ( int ) $ stdin [ 0 ] ; $ b = ( int ) $ stdin [ 1 ] ; $ c = ( int ) $ stdin [ 2 ] ; $ x = ( int ) $ stdin [ 3 ] ; $ answer = 0 ; if ( ! is _ ok1 ( $ a ) | | ! is _ ok1 ( $ b ) | | ! is _ ok1 ( $ c ) ) { echo $ answer ; } if ( ! is _ ok2 ( $ a + $ b + $ c ) ) { echo $ answer ; } if ( ! is _ ok3 ( $ x ) ) { echo $ answer ; } for ( $ i = 0 ; $ i < = $ a ; $ i + + ) { for ( $ j = 0 ; $ j < = $ b ; $ j + + ) { for ( $ k = 0 ; $ k < = $ c ; $ k + + ) { $ total = ( 500 * $ i ) + ( 100 * $ j ) + ( 50 * $ k ) ; if ( is _ ok4 ( $ x , $ total ) ) { $ answer + + ; } } } } echo $ answer ; function is _ ok1 ( $ num ) { if ( ( ! is _ int ( $ num ) ) | | ( $ num < 0 | | 50 < $ num ) ) { return false ; } return true ; } function is _ ok2 ( $ total ) { if ( ( $ total ) < 0 ) { return false ; } return true ; } function is _ ok3 ( $ stdin _ total ) { if ( ( $ stdin _ total < 50 ) | | ( 20000 < $ stdin _ total ) | | ( $ stdin _ total % 50 ! = 0 ) ) { return false ; } return true ; } function is _ ok4 ( $ stdin _ total , $ total ) { if ( $ total ! = $ stdin _ total ) { return false ; } return true ; } ? > < ? php $ a = trim ( fgets ( STDIN ) ) ; $ b = trim ( fgets ( STDIN ) ) ; $ c = trim ( fgets ( STDIN ) ) ; $ d = trim ( fgets ( STDIN ) ) ; $ e = trim ( fgets ( STDIN ) ) ; $ r = 0 ; $ ans = 0 ; $ ans + = ceil ( $ a / 10 ) * 10 ; $ r = max ( $ r , ceil ( $ a / 10 ) * 10 - $ a ) ; $ ans + = ceil ( $ b / 10 ) * 10 ; $ r = max ( $ r , ceil ( $ b / 10 ) * 10 - $ b ) ; $ ans + = ceil ( $ c / 10 ) * 10 ; $ r = max ( $ r , ceil ( $ c / 10 ) * 10 - $ c ) ; $ ans + = ceil ( $ d / 10 ) * 10 ; $ r = max ( $ r , ceil ( $ d / 10 ) * 10 - $ d ) ; $ ans + = ceil ( $ e / 10 ) * 10 ; $ r = max ( $ r , ceil ( $ e / 10 ) * 10 - $ e ) ; echo $ ans - $ r ; < ? php list ( $ n ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ ans = 1 ; $ max = 0 ; for ( $ i = 0 ; $ i < = $ n ; $ i + + ) { $ div2 = 0 ; $ x = $ i ; while ( $ x % 2 = = 0 & & $ x > 1 ) { $ div2 + + ; $ x = $ x / 2 ; } if ( $ max < $ div2 ) { $ ans = $ i ; $ max = $ div2 ; } } echo $ ans ; < ? php list ( $ N , $ M ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; for ( $ i = 0 ; $ i < $ M ; $ i + + ) { list ( $ P [ ] , $ Y [ ] ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ PY [ $ P [ $ i ] ] [ $ Y [ $ i ] ] = $ i ; } foreach ( $ PY as $ k = > $ y ) { ksort ( $ y ) ; $ seq = 1 ; foreach ( $ y as $ kk = > $ v ) { $ a [ $ v ] = sprintf ( " % 06d % 06d " , $ k , $ seq ) ; $ seq + + ; } } ksort ( $ a ) ; foreach ( $ a as $ v ) { printf ( " % s \ n " , $ v ) ; } < ? php list ( $ a , $ v ) = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; list ( $ b , $ w ) = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ t = trim ( fgets ( STDIN ) ) ; if ( $ v < = $ w ) { echo " NO \ n " ; exit ; } echo ( abs ( $ a - $ b ) / ( $ v - $ w ) ) < = $ t ? " YES \ n " : " NO \ n " ; < ? php $ n = trim ( fgets ( STDIN ) ) ; $ x = $ n * 800 ; $ count = - 1 ; while ( $ n > = 0 ) { $ count + + ; $ n - = 15 ; } echo ( $ x - ( 200 * $ count ) ) . " \ n " ; < ? php for ( $ i = 0 ; $ i < 5 ; $ i + + ) { $ input [ ] = trim ( fgets ( STDIN ) ) ; } $ q = trim ( fgets ( STDIN ) ) ; $ bool = false ; $ n = 1 ; for ( $ i = 0 ; $ i < 4 ; $ i + + ) { for ( $ j = $ n ; $ j < 5 ; $ j + + ) { $ dis = $ input [ $ j ] - $ input [ $ i ] ; if ( $ dis > $ q ) { $ bool = true ; } } $ n + + ; } if ( $ bool ) echo " : ( " ; else echo " Yay ! " ; ? > < ? php fscanf ( STDIN , " % d % d " , $ A , $ B ) ; if ( $ A < = 8 & & $ B < = 8 ) { echo " Yay ! " . " \ n " ; } else { echo " : ( " . " \ n " ; } < ? php $ n = fscanf ( STDIN , str _ repeat ( " % d " , 3 ) ) ; $ cnt5 = 0 ; $ cnt7 = 0 ; foreach ( $ n as $ k = > $ v ) { if ( $ v = = = 5 ) { $ cnt5 + + ; } else { $ cnt7 + + ; } } if ( $ cnt5 = = = 2 & & $ cnt7 = = = 1 ) { echo ' YES ' ; } else { echo ' NO ' ; } ? > < ? php list ( $ n , $ m ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; for ( $ i = 0 ; $ i < $ m ; $ i + + ) { list ( $ p , $ y ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ data [ ] = [ $ p , $ y ] ; $ map [ $ p ] [ $ i ] = $ y ; } foreach ( $ map as $ p = > & $ m ) { sort ( $ m ) ; $ map2 [ $ p ] = array _ flip ( $ m ) ; } foreach ( $ data as $ row ) { printf ( " % 06d % 06d \ n " , $ row [ 0 ] , 1 + $ map2 [ $ row [ 0 ] ] [ $ row [ 1 ] ] ) ; } < ? php while ( true ) { $ stdin = trim ( fgets ( STDIN ) ) ; if ( $ stdin = = = ' ' ) { break ; } $ val = explode ( ' , ' , $ stdin ) ; $ number = $ val [ 0 ] ; $ weight = $ val [ 1 ] ; $ height = $ val [ 2 ] ; $ bmi = $ weight / ( $ height * $ height ) ; if ( $ bmi > = 25 ) { printf ( " % d \ n " , $ number ) ; } } < ? php function mygets ( ) { return array _ map ( intval , split ( ' ' , fgets ( STDIN ) ) ) ; } list ( $ n , $ x ) = mygets ( ) ; $ a = mygets ( ) ; $ b1 = $ a ; $ b2 = $ a ; $ ans = array _ sum ( $ a ) ; for ( $ i = 1 ; $ i < $ n ; $ i + + ) { for ( $ j = 0 ; $ j < $ n ; $ j + + ) { $ b2 [ $ j ] = min ( $ b1 [ ( $ j + $ n - 1 ) % $ n ] , $ a [ $ j ] ) ; } $ ans = min ( $ ans , $ i * $ x + array _ sum ( $ b2 ) ) ; $ sw = & $ b1 ; $ b1 = & $ b2 ; $ b2 = & $ sw ; } echo $ ans , PHP _ EOL ; < ? php while ( $ stdin = fgets ( STDIN ) ) { $ line [ ] = trim ( $ stdin ) ; } foreach ( $ line as $ key = > $ value ) { $ data [ ] = explode ( ' ' , $ value ) ; } foreach ( $ data as & $ line ) { $ line = array _ map ( function ( $ val ) { return ( int ) $ val ; } , $ line ) ; } $ A = $ data [ 0 ] [ 0 ] ; $ B = $ data [ 0 ] [ 1 ] ; $ H = $ data [ 0 ] [ 2 ] ; $ M = $ data [ 0 ] [ 3 ] ; $ short = ( $ H * 60 + $ M ) * 0.5 ; $ long = $ M * 6 ; $ sin = sin ( deg2rad ( $ long - $ short ) ) ; $ cos = cos ( deg2rad ( $ long - $ short ) ) ; $ tan = tan ( deg2rad ( $ long - $ short ) ) ; $ alpha = $ A * $ cos ; $ height = sqrt ( $ A * $ A - $ alpha * $ alpha ) ; $ beta = $ B - $ alpha ; $ ans = sqrt ( $ height * $ height + $ beta * $ beta ) ; echo $ ans ; < ? php $ num = trim ( fgets ( STDIN ) ) ; $ input = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; foreach ( $ input as $ letter ) { if ( $ letter = = = " Y " ) { echo ( " Four " ) ; exit ( ) ; } } echo ( " Three " ) ; ? > < ? php const INPUT _ DELIMITER = " " ; $ input = fgets ( STDIN ) ; list ( $ N , $ D ) = array _ map ( ' intval ' , explode ( INPUT _ DELIMITER , $ input ) ) ; $ points = [ ] ; for ( $ i = 0 ; $ i < $ N ; $ i + + ) { $ input = fgets ( STDIN ) ; $ points [ ] = array _ map ( ' intval ' , explode ( INPUT _ DELIMITER , $ input ) ) ; } $ count = 0 ; foreach ( $ points as $ index = > $ point ) { if ( $ index + 1 = = count ( $ points ) ) { break ; } for ( $ i = $ index + 1 ; $ i < count ( $ points ) ; $ i + + ) { $ powSum = 0 ; for ( $ j = 0 ; $ j < $ D ; $ j + + ) { $ powSum + = pow ( $ point [ $ j ] - $ points [ $ i ] [ $ j ] , 2 ) ; } $ diff = sqrt ( $ powSum ) - floor ( sqrt ( $ powSum ) ) ; if ( $ diff = = 0 ) { $ count + + ; } } } echo $ count ; < ? php $ inp = fgets ( STDIN ) ; $ n = ( int ) $ inp ; $ inp = fgets ( STDIN ) ; $ t = explode ( " " , $ inp ) ; $ t = array _ map ( function ( $ a ) { return ( int ) $ a ; } , $ t ) ; $ ans = 1e20 ; for ( $ int = 0 ; $ int < = 100 ; $ int + + ) { $ score = 0 ; foreach ( $ t as $ x ) { $ score + = pow ( ( $ int - $ x ) , 2 ) ; } $ ans = min ( $ score , $ ans ) ; } echo ( $ ans ) ; ? > < ? php list ( $ n ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; list ( $ tc , $ ac ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; for ( $ i = 1 ; $ i < $ n ; $ i + + ) { list ( $ t , $ a ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ b1 = intdiv ( $ tc + $ t - 1 , $ t ) ; $ b2 = intdiv ( $ ac + $ a - 1 , $ a ) ; $ tc = $ t * max ( $ b1 , $ b2 ) ; $ ac = $ a * max ( $ b1 , $ b2 ) ; } echo $ tc + $ ac ; < ? php $ n = trim ( fgets ( STDIN ) ) ; $ x = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ mean = round ( array _ sum ( $ x ) / $ n ) ; $ total = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ dis = $ x [ $ i ] - $ mean ; $ total + = $ dis * $ dis ; } echo $ total . " \ n " ; < ? php fscanf ( STDIN , " % d % d " , $ A , $ B ) ; if ( $ A = = $ B ) { echo " Draw " ; die ( ) ; } if ( $ A = = 1 ) { echo " Alice " ; die ( ) ; } if ( $ B = = 1 ) { echo " Bob " ; die ( ) ; } if ( $ A > $ B ) { echo " Alice " ; die ( ) ; } else { echo " Bob " ; die ( ) ; } < ? php $ data = fgets ( STDIN ) ; if ( strpos ( $ data , ' 5 ' ) = = = false | | strpos ( $ data , ' 7 ' ) = = = false ) { echo " NO " ; return ; } $ data = count _ chars ( $ data , 1 ) ; if ( $ data [ ' 53 ' ] = = 2 & & $ data [ ' 55 ' ] = = 1 ) echo " YES " ; else echo " NO " ; ? > < ? php $ x = trim ( fgets ( STDIN ) ) ; $ res = $ x * $ x * $ x ; echo $ res ; ? > < ? php $ array = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; echo ceil ( array _ sum ( $ array ) / count ( $ array ) ) ? > < ? php fscanf ( STDIN , ' % s ' , $ s ) ; $ date1 = date ( $ s ) ; $ date2 = date ( ' 2019 / 4 / 30 ' ) ; if ( strtotime ( $ date1 ) < = strtotime ( $ date2 ) ) $ ans = ' Heisei ' ; else $ ans = ' TBD ' ; echo $ ans . PHP _ EOL ; < ? php $ stdin = trim ( fgets ( STDIN ) ) ; $ result = pow ( $ stdin , 3 ) ; echo $ result ; ? > < ? php $ s = fgets ( STDIN ) ; if ( $ s [ 2 ] = = $ s [ 3 ] & & $ s [ 4 ] = = $ s [ 5 ] ) { echo " Yes " ; } else { echo " No " ; } ? > < ? php while ( ! feof ( STDIN ) ) { $ stdin = trim ( fgets ( STDIN ) ) ; $ values = explode ( ' , ' , $ stdin ) ; if ( count ( $ values ) ! = 3 ) { } else { list ( $ no , $ weight , $ height ) = $ values ; $ bmi = $ weight / pow ( $ height , 2 ) ; if ( $ bmi > = 25 ) { echo $ no . " \ n " ; } } } < ? php fscanf ( STDIN , ' % d % d ' , $ a , $ b ) ; echo max ( $ a , $ b ) > 8 ? ' : ( ' : ' Yay ! ' ; < ? php fscanf ( STDIN , " % d % d % d " , $ a _ coin , $ b _ coin , $ item ) ; $ cash = ( $ a _ coin + $ b _ coin ) - $ item ; echo $ cash > = 0 ? ' Yes ' : ' No ' ; ? > < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; $ alice = [ ' alice ' = > $ a ] ; $ bob = [ ' bob ' = > $ b ] ; if ( $ alice [ ' alice ' ] = = = $ bob [ ' bob ' ] ) { echo ' Draw ' ; } elseif ( $ bob [ ' bob ' ] = = 1 ) { echo ' Bob ' ; } elseif ( $ alice [ ' alice ' ] = = 1 ) { echo ' Alice ' ; } elseif ( $ alice [ ' alice ' ] < $ bob [ ' bob ' ] ) { echo ' Bob ' ; } elseif ( $ alice [ ' alice ' ] > $ bob [ ' bob ' ] ) { echo ' Alice ' ; } < ? php $ res = 0 ; $ min = 10 ; for ( $ i = 0 ; $ i < 5 ; $ i + + ) { $ input = rtrim ( fgets ( STDIN ) ) ; $ last = intval ( substr ( $ input , - 1 ) ) ; if ( $ last = = = 0 ) { $ res + = intval ( $ input ) / 10 ; } else { $ min = intval ( $ last ) < $ min ? $ last : $ min ; $ res + = ceil ( intval ( $ input ) / 10 ) ; } } $ res = ( $ res * 10 ) + $ min - 10 ; echo $ res ; ? > < ? php fscanf ( STDIN , " % d " , $ number ) ; $ len = strlen ( $ number ) ; $ total = 0 ; for ( $ i = 0 ; $ i < $ len ; $ i + + ) { $ total + = substr ( $ number , $ i , 1 ) ; } echo ( $ number % $ total = = 0 ) ? ' Yes ' : ' No ' ; < ? php $ i = fgets ( STDIN ) ; print pow ( $ i , 3 ) ; print " \ n " ; < ? php $ a = explode ( " " , trim ( fgets ( STDIN ) ) ) ; sort ( $ a ) ; echo implode ( " " , $ a ) = = " 557 " ? " YES " : " NO " ; < ? php $ n = ( int ) ( fgets ( STDIN ) ) ; $ towns = [ ] ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ towns [ $ i ] = explode ( " " , trim ( fgets ( STDIN ) ) ) ; } $ sum = [ ] ; for ( $ mask = 0 ; $ mask < ( 1 < < $ n ) ; $ mask + + ) { if ( substr _ count ( decbin ( $ mask ) , " 1 " ) ! = = 2 ) continue ; $ tmp = [ ] ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { if ( ( $ mask > > $ i ) & 1 ) { $ tmp [ ] = $ i ; } } $ sum [ ] = sqrt ( pow ( ( $ towns [ $ tmp [ 0 ] ] [ 0 ] - $ towns [ $ tmp [ 1 ] ] [ 0 ] ) , 2 ) + pow ( ( $ towns [ $ tmp [ 0 ] ] [ 1 ] - $ towns [ $ tmp [ 1 ] ] [ 1 ] ) , 2 ) ) ; } $ average = array _ sum ( $ sum ) / count ( $ sum ) ; echo $ average * ( $ n - 1 ) ; < ? php class Scanner { private $ arr = [ ] ; private $ count = 0 ; private $ pointer = 0 ; public function next ( ) { if ( $ this - > pointer > = $ this - > count ) { $ str = trim ( fgets ( STDIN ) ) ; $ this - > arr = explode ( " " , $ str ) ; $ this - > count = count ( $ this - > arr ) ; $ this - > pointer = 0 ; } $ result = $ this - > arr [ $ this - > pointer ] ; $ this - > pointer + + ; return $ result ; } public function hasNext ( ) { return $ this - > pointer < $ this - > count ; } public function nextInt ( ) { return ( int ) $ this - > next ( ) ; } public function nextDouble ( ) { return ( double ) $ this - > next ( ) ; } } class out { public static function printIn ( $ str = " " ) { echo $ str . PHP _ EOL ; } } $ sc = new Scanner ; $ n = $ sc - > nextInt ( ) ; $ ref = [ 1 , 2 , 4 , 8 , 16 , 32 , 64 ] ; arsort ( $ ref ) ; $ res = 0 ; for ( $ i = 0 ; $ i < count ( $ ref ) ; $ i + + ) { if ( $ n > = $ ref [ $ i ] ) { $ res = $ ref [ $ i ] ; } } echo $ res ; < ? php $ line = trim ( fgets ( STDIN ) ) ; if ( in _ array ( $ line , [ ' 5 5 7 ' , ' 5 7 5 ' , ' 7 5 5 ' ] , true , ) ) { echo " YES " ; } else { echo " NO " ; } ? > < ? php $ a = fgets ( STDIN ) ; echo $ a * $ a * $ a ; ? > < ? php fscanf ( STDIN , ' % d ' , $ x [ ' a ' ] ) ; fscanf ( STDIN , ' % d ' , $ x [ ' b ' ] ) ; fscanf ( STDIN , ' % d ' , $ x [ ' c ' ] ) ; fscanf ( STDIN , ' % d ' , $ x [ ' d ' ] ) ; fscanf ( STDIN , ' % d ' , $ x [ ' e ' ] ) ; $ min _ x = 0 ; $ min _ mod = 10 ; foreach ( $ x as $ v ) { if ( 0 < $ v % 10 & & $ min _ mod > $ v % 10 ) { $ min _ x = $ v ; $ min _ mod = $ v % 10 ; } } $ sum = 0 ; $ cnt = 0 ; foreach ( $ x as $ v ) { if ( $ cnt = = 0 & & $ min _ x = = $ v ) { $ cnt = 1 ; continue ; } $ sum + = ceil ( $ v / 10 ) * 10 ; } $ sum + = $ min _ x ; echo $ sum . PHP _ EOL ; < ? php $ s = explode ( ' / ' , trim ( fgets ( STDIN ) ) ) ; if ( $ s [ 0 ] < = 2018 ) { echo " Heisei " ; } else if ( $ s [ 0 ] = = 2019 & & $ s [ 1 ] < = 4 ) { echo " Heisei " ; } else { echo " TBD " ; } ? > < ? php fscanf ( STDIN , " % d " , $ x ) ; print pow ( $ x , 3 ) ; ? > < ? php fscanf ( STDIN , ' % s % s % s ' , $ s [ 0 ] , $ s [ 1 ] , $ s [ 2 ] ) ; $ five _ flag = 0 ; $ seven _ flag = 0 ; foreach ( $ s as $ value ) { if ( $ value = = = " 5 " ) $ five _ flag + + ; if ( $ value = = = " 7 " ) $ seven _ flag + + ; } if ( $ seven _ flag = = = 1 & & $ five _ flag = = = 2 ) echo ' YES ' ; else echo ' NO ' ; ? > < ? php fscanf ( STDIN , " % d % d " , $ k , $ s ) ; $ result = 0 ; for ( $ i = 0 ; $ i < = $ k ; $ i + + ) { for ( $ j = 0 ; $ j < = $ k ; $ j + + ) { if ( $ s - $ i - $ j < = $ k & & $ s - $ i - $ j > = 0 ) $ result + + ; } } printf ( " % d \ n " , $ result ) ; < ? php $ n = trim ( fgets ( STDIN ) ) ; $ a = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ b = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ sumA = 0 ; foreach ( $ a as $ val ) { $ sumA + = $ val ; } $ sumB = 0 ; foreach ( $ b as $ val ) { $ sumB + = $ val ; } if ( $ sumA < $ sumB ) { echo " -1 " ; exit ; } $ lessThanNum = 0 ; $ differenceMinusSum = 0 ; $ differencePlusArr = [ ] ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { if ( $ a [ $ i ] < $ b [ $ i ] ) { $ lessThanNum + + ; $ differenceMinusSum + = ( $ b [ $ i ] - $ a [ $ i ] ) ; } else { $ differencePlusArr [ $ i ] = $ a [ $ i ] - $ b [ $ i ] ; } } $ echoNum = $ lessThanNum ; if ( $ echoNum = = 0 ) { echo $ echoNum ; exit ; } rsort ( $ differencePlusArr ) ; foreach ( $ differencePlusArr as $ val ) { $ echoNum + + ; if ( $ val > = $ differenceMinusSum ) { break ; } else { $ differenceMinusSum - = $ val ; } } echo $ echoNum ; exit ; < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; if ( $ a > = 9 | | $ b > = 9 ) { echo ' : ( ' ; } else { echo ' Yay ! ' ; } ? > < ? php fscanf ( STDIN , " % d % d " , $ A , $ B ) ; if ( max ( $ A , $ B ) < = 8 ) { echo ' Yay ! ' ; } else { echo ' : ( ' ; } < ? php fscanf ( STDIN , " % s " , $ A ) ; if ( $ A < = " 2019 / 04 / 30 " ) { echo " Heisei " ; } else { echo " TBD " ; } < ? php fscanf ( STDIN , ' % s ' , $ s ) ; if ( $ s [ 2 ] = = $ s [ 3 ] & & $ s [ 4 ] = = $ s [ 5 ] ) { echo " Yes " ; } else { echo " No " ; } < ? php fscanf ( STDIN , ' % d % d % d ' , $ a , $ b , $ c ) ; echo max ( $ a , $ b , $ c ) - min ( $ a , $ b , $ c ) ; < ? php fscanf ( STDIN , " % d % d % d % d " , $ a , $ b , $ c , $ d ) ; echo max ( $ a * $ b , $ c * $ d ) ; < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; if ( $ a < = 5 ) { echo 0 ; } else if ( $ a < = 12 ) { echo $ b / 2 ; } else { echo $ b ; } < ? php $ stdin = trim ( fgets ( STDIN ) ) ; $ nums = explode ( " " , $ stdin ) ; $ count _ 5 = 0 ; $ count _ 7 = 0 ; foreach ( $ nums as $ num ) { if ( $ num = = 5 ) { $ count _ 5 + = 1 ; } elseif ( $ num = = 7 ) { $ count _ 7 + = 1 ; } } if ( $ count _ 5 = = 2 & & $ count _ 7 = = 1 ) { echo " YES " . PHP _ EOL ; } else { echo " NO " . PHP _ EOL ; } < ? php while ( fscanf ( STDIN , " % d " , $ n ) & & $ n ) { $ riso _ bmi = 10000 ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { fscanf ( STDIN , " % d % d % d " , $ bango , $ height , $ weight ) ; $ height / = 100.0 ; $ bmi = $ weight * 1.0 / $ height / $ height ; if ( abs ( $ bmi - 22 ) < abs ( $ riso _ bmi - 22 ) ) { $ riso _ bmi = $ bmi ; $ riso _ no = $ bango ; } } fprintf ( STDOUT , " % d \ n " , $ riso _ no ) ; } return ( 0 ) ; ? > < ? php $ line = trim ( fgets ( STDIN ) ) ; echo $ line * $ line ? > < ? php fscanf ( STDIN , " % d " , $ a ) ; fscanf ( STDIN , " % d " , $ b ) ; fscanf ( STDIN , " % d " , $ c ) ; fscanf ( STDIN , " % d " , $ x ) ; $ total = 0 ; $ count = 0 ; for ( $ ai = 0 ; $ ai < = $ a ; $ ai + + ) { for ( $ bi = 0 ; $ bi < = $ b ; $ bi + + ) { for ( $ ci = 0 ; $ ci < = $ c ; $ ci + + ) { $ total = ( 500 * $ ai ) + ( 100 * $ bi ) + ( 50 * $ ci ) ; if ( $ x = = $ total ) { $ count + + ; } } } } echo $ count ; < ? php fscanf ( STDIN , ' % d ' , $ r ) ; echo $ r * $ r ; echo PHP _ EOL ; < ? php for ( $ i = 0 ; $ i < = 4 ; $ i + + ) { $ a [ ] = trim ( fgets ( STDIN ) ) ; } $ ans = 0 ; foreach ( $ a as $ value ) { if ( $ value % 10 = = 0 ) { $ b [ ] = 0 ; } else { $ b [ ] = 10 - $ value % 10 ; } $ ans + = $ value ; } sort ( $ b ) ; $ b [ 4 ] = 0 ; foreach ( $ b as $ value ) { $ ans + = $ value ; } echo $ ans ; < ? php fscanf ( STDIN , " % d " , $ n ) ; echo $ n * $ n ; < ? php fscanf ( STDIN , " % d " , $ N ) ; $ xList = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ min = min ( $ xList ) ; $ max = max ( $ xList ) ; $ ans = 0x1 < < 31 ; for ( $ i = $ min ; $ i < = $ max ; $ i + + ) { $ wk = 0 ; foreach ( $ xList as $ v ) { $ wk + = pow ( $ i - $ v , 2 ) ; } $ ans = min ( $ ans , $ wk ) ; } echo " { $ ans } \ n " ; < ? php $ input = trim ( fgets ( STDIN ) ) ; echo $ input * * 3 . " \ n " ; ? > < ? php fscanf ( STDIN , " % s " , $ s ) ; if ( strtotime ( $ s ) < = strtotime ( ' 2019 / 04 / 30 ' ) ) { echo ' Heisei ' ; } else { echo ' TBD ' ; } ? > < ? php $ input = trim ( fgets ( STDIN ) ) ; if ( $ input [ 2 ] = = = $ input [ 3 ] & & $ input [ 4 ] = = = $ input [ 5 ] ) { echo ' Yes ' ; } else { echo ' No ' ; } < ? php fscanf ( STDIN , ' % s ' , $ S ) ; $ arr = str _ split ( $ S ) ; if ( $ arr [ 5 ] = = 0 & & $ arr [ 6 ] < = 4 ) { echo ' Heisei ' ; } else { echo ' TBD ' ; } ? > < ? php $ input = trim ( fgets ( STDIN ) ) ; echo pow ( $ input , 3 ) , PHP _ EOL ; < ? php define ( ' DEBUG ' , false ) ; ini _ set ( ' error _ reporting ' , E _ ALL & ~ E _ NOTICE ) ; fscanf ( STDIN , " % d " , $ N ) ; $ a = explode ( " " , trim ( fgets ( STDIN ) ) ) ; echo ( max ( $ a ) - min ( $ a ) ) . PHP _ EOL ; < ? php $ n = trim ( fgets ( STDIN ) ) ; $ parr = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ cnt = 0 ; $ min = $ n + 1 ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ min = min ( $ min , $ parr [ $ i ] ) ; if ( $ min = = $ parr [ $ i ] ) { $ cnt + + ; } } echo " $ cnt \ n " ; < ? php $ input = explode ( " " , fgets ( STDIN ) ) ; $ K = intval ( $ input [ 0 ] ) ; $ S = intval ( $ input [ 1 ] ) ; $ count = 0 ; for ( $ x = 0 ; $ x < = $ K ; $ x + + ) { for ( $ y = 0 ; $ y < = $ K ; $ y + + ) { $ z = $ S - ( $ x + $ y ) ; if ( $ z < = $ K & & 0 < = $ z ) { if ( $ x + $ y + $ z = = $ S ) { $ count + + ; } } } } echo $ count ; < ? php fscanf ( STDIN , ' % d % d ' , $ a [ ] , $ a [ ] ) ; echo ceil ( array _ sum ( $ a ) / count ( $ a ) ) ; < ? php fscanf ( STDIN , " % d " , $ r ) ; $ d = ( int ) ( $ r * $ r ) ; echo $ d ; < ? php fscanf ( STDIN , " % i % i % i % i " , $ a , $ b , $ c , $ d ) ; $ ab = $ a * $ b ; $ cd = $ c * $ d ; echo max ( [ $ ab , $ cd ] ) . PHP _ EOL ; ? > < ? php function dfs ( $ first , $ last ) { if ( count ( $ last ) = = = 0 ) { return [ $ first ] ; } $ res = [ ] ; foreach ( $ last as $ key = > $ val ) { $ next _ f = $ first ; $ next _ l = $ last ; $ next _ f [ ] = $ val ; array _ splice ( $ next _ l , $ key , 1 ) ; $ res = array _ merge ( $ res , dfs ( $ next _ f , $ next _ l ) ) ; } return $ res ; } function next _ permutation ( $ start , $ end ) { return dfs ( [ ] , range ( $ start , $ end ) ) ; } fscanf ( STDIN , " % d " , $ n ) ; $ x _ arr = [ ] ; $ y _ arr = [ ] ; for ( $ i = 0 ; $ i < $ n ; + + $ i ) { fscanf ( STDIN , " % d % d " , $ x , $ y ) ; $ x _ arr [ ] = $ x ; $ y _ arr [ ] = $ y ; } $ routes = next _ permutation ( 1 , $ n ) ; $ sum = 0 ; foreach ( $ routes as $ route ) { for ( $ i = 0 ; $ i < $ n - 1 ; + + $ i ) { $ sum + = sqrt ( pow ( $ x _ arr [ $ route [ $ i ] - 1 ] - $ x _ arr [ $ route [ $ i + 1 ] - 1 ] , 2 ) + pow ( $ y _ arr [ $ route [ $ i ] - 1 ] - $ y _ arr [ $ route [ $ i + 1 ] - 1 ] , 2 ) ) ; } } $ tmp = 1 ; for ( $ i = 1 ; $ i < = $ n ; + + $ i ) { $ tmp * = $ i ; } echo $ sum / $ tmp ; < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; if ( $ a > 12 ) { echo $ b ; } elseif ( $ a < 6 ) { echo 0 ; } else { echo $ b / 2 ; } < ? php $ array = [ ] ; fscanf ( STDIN , " % d % d % d % d " , $ array [ ' A ' ] , $ array [ ' B ' ] , $ array [ ' C ' ] , $ array [ ' D ' ] ) ; $ ab = $ array [ ' A ' ] * $ array [ ' B ' ] ; $ cd = $ array [ ' C ' ] * $ array [ ' D ' ] ; echo max ( $ ab , $ cd ) ; ? > < ? php list ( $ n ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ len = strlen ( $ n ) ; $ x = $ n ; $ p = 0 ; for ( $ i = $ len - 1 ; $ i > = 0 ; $ i -- ) { $ p + = intdiv ( $ x , pow ( 10 , $ i ) ) ; $ x % = pow ( 10 , $ i ) ; } if ( $ n % $ p = = 0 ) echo " Yes " ; else echo " No " ; < ? php while ( true ) { $ x = fgets ( STDIN ) ; if ( $ x = = 0 ) break ; $ x = str _ split ( $ x ) ; $ sum = 0 ; foreach ( $ x as $ num ) { $ sum + = $ num ; } print " $ sum \ n " ; } < ? php fscanf ( STDIN , " % d % d " , $ k , $ s ) ; $ c = 0 ; for ( $ x = 0 ; $ x < = $ k ; $ x + + ) { for ( $ y = 0 ; $ y < = $ k ; $ y + + ) { $ z = $ s - $ x - $ y ; if ( $ z > = 0 & & $ z < = $ k ) { $ c + + ; } } } echo $ c . " \ n " ; < ? php $ r = fgets ( STDIN ) ; echo $ r * $ r ; ? > < ? php $ input = trim ( fgets ( STDIN ) ) ; $ As = explode ( ' ' , $ input ) ; rsort ( $ As ) ; $ cost1 = abs ( $ As [ 1 ] - $ As [ 0 ] ) ; $ cost1 + = abs ( $ As [ 2 ] - $ As [ 1 ] ) ; $ cost2 = abs ( $ As [ 2 ] - $ As [ 0 ] ) ; $ cost2 + = abs ( $ As [ 1 ] - $ As [ 2 ] ) ; echo min ( $ cost1 , $ cost2 ) ; < ? php # include < stdio.h > # 整数の入力 fscanf ( STDIN , " % d " , $ a ) ; fscanf ( STDIN , " % d " , $ b ) ; fscanf ( STDIN , " % d " , $ c ) ; fscanf ( STDIN , " % d " , $ x ) ; $ ways = 0 ; for ( $ i = 0 ; $ i < $ a + 1 ; $ i + + ) { for ( $ j = 0 ; $ j < $ b + 1 ; $ j + + ) { for ( $ k = 0 ; $ k < $ c + 1 ; $ k + + ) { $ sum = $ i * 500 + $ j * 100 + $ k * 50 ; if ( $ sum = = $ x ) { $ ways + + ; } } } } echo $ ways . " \ n " ; < ? php fscanf ( STDIN , " % d % d % d % d " , $ a , $ b , $ h , $ m ) ; $ hangle = $ h = = 0 ? 360 : 360 / 12 * $ h ; if ( $ m ! = = 0 ) { $ mangle = $ m = = 0 ? 360 : 360 / 60 * $ m ; $ hangle + = 360 / 12 / 60 * $ m ; } if ( $ hangle = = $ mangle ) { echo " 0 " . PHP _ EOL ; exit ; } else if ( $ hangle > $ mangle ) { $ angle = $ hangle - $ mangle ; } else { $ angle = $ mangle - $ hangle ; } if ( $ angle = = 90 ) { echo sqrt ( ( $ a * * 2 ) + ( $ b * * 2 ) ) . PHP _ EOL ; } else { echo sqrt ( ( $ a * * 2 ) + ( $ b * * 2 ) - ( 2 * $ a * $ b * cos ( deg2rad ( $ angle ) ) ) ) ; } < ? php fscanf ( STDIN , ' % d % d % d ' , $ a , $ b , $ c ) ; echo $ a + $ b > = $ c ? ' Yes ' : ' No ' ; < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; print ( ( $ a + $ b + 1 ) > > 1 ) ; < ? php fscanf ( STDIN , ' % d ' , $ N ) ; echo $ N * 800 - floor ( $ N / 15 ) * 200 ; ? > < ? php fscanf ( STDIN , ' % d % d % d % d % d ' , $ h1 , $ m1 , $ h2 , $ m2 , $ k ) ; echo ( $ h2 * 60 + $ m2 ) - $ k - ( $ h1 * 60 + $ m1 ) ; < ? php fscanf ( STDIN , " % d % d " , $ n , $ m ) ; $ citys = array ( ) ; for ( $ i = 0 ; $ i < $ m ; $ i + + ) { $ p _ y = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ pref [ $ p _ y [ 0 ] ] [ ] = $ p _ y [ 1 ] ; $ py _ li [ ] = $ p _ y ; } $ p _ y _ key _ li = array _ keys ( $ pref ) ; for ( $ i = 0 ; $ i < count ( $ p _ y _ key _ li ) ; $ i + + ) { sort ( $ pref [ $ p _ y _ key _ li [ $ i ] ] ) ; } $ memo = array ( ) ; foreach ( $ pref as $ c ) { foreach ( $ c as $ x = > $ year ) { $ memo [ $ year ] = $ x + 1 ; } } foreach ( $ py _ li as $ py ) { $ x = $ memo [ $ py [ 1 ] ] ; for ( $ i = 0 ; $ i < 6 - strlen ( $ py [ 0 ] ) ; $ i + + ) { echo " 0 " ; } echo $ py [ 0 ] ; for ( $ i = 0 ; $ i < 6 - strlen ( $ x ) ; $ i + + ) { echo " 0 " ; } echo ( $ x ) . " \ n " ; } < ? php for ( $ i = 0 ; $ i < 5 ; $ i + + ) { $ array [ $ i ] = trim ( fgets ( STDIN ) ) ; } $ time = 0 ; $ min = 10 ; $ num = 0 ; $ x = 0 ; for ( $ i = 0 ; $ i < 5 ; $ i + + ) { $ x = $ array [ $ i ] % 10 ; if ( $ x < $ min & & $ x ! = 0 ) { $ min = $ x ; $ num = $ i ; } } $ tmp = $ array [ 4 ] ; $ array [ 4 ] = $ array [ $ num ] ; $ array [ $ num ] = $ tmp ; for ( $ i = 0 ; $ i < 4 ; $ i + + ) { $ time + = $ array [ $ i ] ; while ( $ time % 10 ! = 0 ) { $ time + + ; } } $ time + = $ array [ 4 ] ; echo $ time ; ? > < ? php $ number = trim ( fgets ( STDIN ) ) ; $ maxNumber = 1 ; while ( $ number > $ maxNumber ) { $ maxNumber * = 2 ; } if ( $ number < $ maxNumber ) { $ maxNumber / = 2 ; } echo $ maxNumber ; ? > < ? php $ max = 150 ; fscanf ( STDIN , " % d " , $ in _ n ) ; for ( $ i = 0 ; $ i < $ max ; $ i + + ) { $ gojo [ $ i ] = $ i * $ i * $ i * $ i * $ i ; } $ flag = false ; for ( $ i = 0 ; $ i < $ max ; $ i + + ) { for ( $ j = 0 ; $ j < $ max ; $ j + + ) { if ( ( $ gojo [ $ i ] - $ gojo [ $ j ] ) = = $ in _ n ) { print " $ i $ j " ; $ flag = true ; break ; } elseif ( ( $ gojo [ $ i ] + $ gojo [ $ j ] ) = = $ in _ n ) { print " $ i - $ j " ; $ flag = true ; break ; } elseif ( ( - $ gojo [ $ i ] + $ gojo [ $ j ] ) = = $ in _ n ) { print " - $ i - $ j " ; $ flag = true ; break ; } } if ( $ flag = = true ) { break ; } } < ? php while ( true ) { $ received _ num = str _ split ( trim ( fgets ( STDIN ) ) ) ; if ( $ received _ num [ 0 ] = = 0 ) { break ; } echo array _ sum ( $ received _ num ) . PHP _ EOL ; } < ? php declare ( strict _ types = 1 ) ; fscanf ( STDIN , " % i " , $ n ) ; echo ( $ n * 800 - ( int ) ( $ n / 15 ) * 200 ) , PHP _ EOL ; < ? php list ( $ a , $ b , $ h , $ m ) = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ angle = abs ( ( 30 * $ h + 1 / 2 * $ m ) - 6 * $ m ) ; if ( $ angle > 180 ) { $ angle = 360 - $ angle ; } $ ans = sqrt ( pow ( $ a , 2 ) + pow ( $ b , 2 ) - 2 * $ a * $ b * cos ( $ angle * pi ( ) / 180 ) ) ; printf ( " % .20f " , $ ans ) ; < ? php class cal { private $ integer ; public function _ _ construct ( $ integer ) { $ this - > integer = $ integer ; } public function check ( ) { $ integer = $ this - > integer ; $ total = $ this - > _ check ( $ integer , 0 ) ; return ( $ integer % $ total ) = = = 0 ; } private function _ check ( $ integer , $ total ) { $ ceil = $ this - > _ getCeil ( $ integer ) ; $ total = $ total + $ ceil ; $ quotient = $ this - > _ getQuotient ( $ integer ) ; if ( $ quotient = = 0 ) { return $ total ; } return $ this - > _ check ( $ quotient , $ total ) ; } private function _ getCeil ( $ integer ) { return $ integer % 10 ; } private function _ getQuotient ( $ integer ) { return floor ( $ integer / 10 ) ; } } fscanf ( STDIN , " % d " , $ integer ) ; $ cal = new cal ( $ integer ) ; $ bool = $ cal - > check ( ) ; echo $ bool ? ' Yes ' : ' No ' ; ? > < ? php fscanf ( STDIN , " % d % d " , $ N , $ M ) ; for ( $ i = 0 ; $ i < $ M ; $ i + + ) { fscanf ( STDIN , " % d % d " , $ P , $ Y ) ; $ X = sprintf ( " Z % 06d % 010d " , $ P , $ Y ) ; $ arr [ ] = $ X ; } asort ( $ arr ) ; $ prev = ' Z000000000000 ' ; $ cnt = 0 ; $ ans = [ ] ; foreach ( $ arr as $ k = > $ v ) { $ p1 = substr ( $ v , 1 , 6 ) ; $ prev _ p1 = substr ( $ prev , 1 , 6 ) ; if ( $ p1 ! = = $ prev _ p1 ) { $ cnt = 1 ; } else { $ cnt + + ; } $ ans [ $ k ] = sprintf ( " % 06d % 06d " , $ p1 , $ cnt ) ; $ prev = $ v ; } ksort ( $ ans ) ; echo implode ( PHP _ EOL , $ ans ) ; < ? php $ x = trim ( fgets ( STDIN ) ) ; echo $ x * * 3 ; ? > < ? php fscanf ( STDIN , ' % s ' , $ s ) ; if ( strtotime ( $ s ) > strtotime ( ' 2019 / 04 / 30 ' ) ) { echo ' TBD ' ; } else { echo ' Heisei ' ; } echo PHP _ EOL ; < ? php fscanf ( STDIN , ' % d % d % d % d ' , $ A , $ B , $ C , $ D ) ; echo max ( $ A * $ B , $ C * $ D ) ; ? > < ? php fscanf ( STDIN , " % d % d " , $ N , $ D ) ; for ( $ i = 0 ; $ i < $ N ; $ i + + ) { $ X [ ] = array _ map ( ' intval ' , explode ( " " , trim ( fgets ( STDIN ) ) ) ) ; } $ count = 0 ; for ( $ j = 0 ; $ j < $ N - 1 ; $ j + + ) { for ( $ k = $ j + 1 ; $ k < $ N ; $ k + + ) { $ ans = 0 ; for ( $ d = 0 ; $ d < $ D ; $ d + + ) { $ dis = ( abs ( $ X [ $ j ] [ $ d ] - $ X [ $ k ] [ $ d ] ) ) * * 2 ; $ ans + = $ dis ; } if ( ( sqrt ( $ ans ) ) = = intval ( sqrt ( $ ans ) ) ) { $ count + + ; } } } echo $ count ; ? > < ? php fscanf ( STDIN , " % d " , $ n ) ; $ a = strlen ( $ n ) ; $ array = str _ split ( $ n ) ; $ count = 0 ; for ( $ i = 1 ; $ i < = $ a + 1 ; $ i + + ) { $ count + = $ array [ $ i - 1 ] ; } if ( $ n % $ count = = 0 ) { echo " Yes " ; } else { echo " No " ; } < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; if ( $ a < = 5 ) { echo 0 ; } else if ( $ a < = 12 ) { echo $ b / 2 ; } else { echo $ b ; } < ? php fscanf ( STDIN , " % s " , $ hinaArareNum ) ; $ HinaArares = trim ( fgets ( STDIN ) ) ; $ oneHinaArare = explode ( " " , $ HinaArares ) ; $ result = array _ unique ( $ oneHinaArare ) ; if ( count ( $ result ) = = 3 ) { echo ' Three ' ; } else { echo ' Four ' ; } < ? php class Scanner { private $ arr = [ ] ; private $ count = 0 ; private $ pointer = 0 ; public function next ( ) { if ( $ this - > pointer > = $ this - > count ) { $ str = trim ( fgets ( STDIN ) ) ; $ this - > arr = explode ( " " , $ str ) ; $ this - > count = count ( $ this - > arr ) ; $ this - > pointer = 0 ; } $ result = $ this - > arr [ $ this - > pointer ] ; $ this - > pointer + + ; return $ result ; } public function hasNext ( ) { return $ this - > pointer < $ this - > count ; } public function nextInt ( ) { return ( int ) $ this - > next ( ) ; } public function nextDouble ( ) { return ( double ) $ this - > next ( ) ; } } class out { public static function printIn ( $ str = " " ) { echo $ str . PHP _ EOL ; } } $ sc = new Scanner ; $ K = $ sc - > nextInt ( ) ; $ S = $ sc - > nextInt ( ) ; $ count = 0 ; for ( $ x = 0 ; $ x < = $ K ; $ x + + ) { for ( $ y = 0 ; $ y < = $ K ; $ y + + ) { $ z = $ S - $ x - $ y ; if ( 0 < = $ z & & $ z < = $ K ) { $ count + + ; } } } echo $ count ; < ? php $ x = ( int ) fgets ( STDIN ) ; echo $ x * $ x * $ x ; ? > < ? php $ n = trim ( fgets ( STDIN ) ) ; $ p = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ i = 1 ; $ ans = 1 ; $ min = $ p [ 0 ] ; while ( $ i < $ n ) { if ( $ p [ $ i ] < $ min ) { + + $ ans ; $ min = $ p [ $ i ] ; } + + $ i ; } echo $ ans ; < ? php fscanf ( STDIN , " % d " , $ n ) ; $ step = trim ( fgets ( STDIN ) ) ; $ rows = [ ] ; while ( ( $ row = trim ( fgets ( STDIN ) ) ) ! = = ' ' ) { $ rows [ ] = explode ( ' ' , $ row ) ; } for ( $ i = 0 ; $ i < $ n * 4 ; $ i + + ) { if ( $ step [ $ i ] = = " Y " ) { $ ans = " Four " ; break ; } else { $ ans = " Three " ; } } echo $ ans ; < ? php while ( TRUE ) { $ c = fscanf ( STDIN , ' % d , % d , % d , % d , % d ' ) ; if ( feof ( STDIN ) ) { break ; } sort ( $ c ) ; $ hash = array ( ) ; $ max = 0 ; foreach ( $ c as $ v ) { if ( ! isset ( $ hash [ $ v ] ) ) { $ hash [ $ v ] = 0 ; } $ hash [ $ v ] + + ; $ max = $ hash [ $ v ] > $ max ? $ hash [ $ v ] : $ max ; } arsort ( $ hash ) ; $ combo = ' null ' ; if ( $ max > = 2 ) { $ combo = ' one pair ' ; } if ( $ max > = 2 & & count ( $ hash ) < = 3 ) { $ combo = ' two pair ' ; } if ( $ max > = 3 ) { $ combo = ' three card ' ; } if ( count ( $ hash ) = = = 5 & & isStraight ( $ c ) ) { $ combo = ' straight ' ; } if ( $ max > = 3 & & count ( $ hash ) < = 2 ) { $ combo = ' full house ' ; } if ( $ max > = 4 ) { $ combo = ' four card ' ; } echo $ combo . PHP _ EOL ; } function isStraight ( $ cards ) { if ( max ( $ cards ) - min ( $ cards ) = = = 4 ) { return true ; } if ( $ cards [ 0 ] = = = 1 & & $ cards [ 1 ] = = = 10 & & $ cards [ 4 ] = = = 13 ) { return true ; } return false ; } < ? php $ A = trim ( fgets ( STDIN ) ) ; $ B = trim ( fgets ( STDIN ) ) ; $ C = trim ( fgets ( STDIN ) ) ; $ X = trim ( fgets ( STDIN ) ) ; $ cnt = 0 ; for ( $ a = min ( $ A , floor ( $ X / 500 ) ) ; $ a > = 0 ; $ a -- ) { for ( $ b = min ( $ B , floor ( ( $ X - 500 * $ a ) / 100 ) ) ; $ b > = 0 ; $ b -- ) { $ c = min ( $ C , floor ( ( $ X - 500 * $ a - 100 * $ b ) / 50 ) ) ; if ( $ X = = 500 * $ a + 100 * $ b + 50 * $ c ) { $ cnt + + ; } } } print " { $ cnt } \ n " ; < ? php $ array = explode ( " " , trim ( fgets ( STDIN ) ) ) ; echo max ( $ array ) - min ( $ array ) ; < ? php $ a = fgets ( STDIN ) ; $ b = fgets ( STDIN ) ; $ c = fgets ( STDIN ) ; $ x = fgets ( STDIN ) ; for ( $ i = 0 ; $ i < = $ a ; $ i + + ) for ( $ j = 0 ; $ j < = $ b ; $ j + + ) for ( $ k = 0 ; $ k < = $ c ; $ k + + ) $ cnt + = $ i * 500 + $ j * 100 + $ k * 50 = = $ x ; echo $ cnt ; < ? php list ( $ a , $ b , $ c , $ d ) = ints ( ) ; echo max ( $ a * $ b , $ c * $ d ) ; function ints ( ) { return array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; } < ? php $ a = trim ( fgets ( STDIN ) ) ; $ b = trim ( fgets ( STDIN ) ) ; $ c = trim ( fgets ( STDIN ) ) ; $ x = trim ( fgets ( STDIN ) ) ; $ cnt = 0 ; for ( $ i = $ a ; $ i > = 0 ; $ i -- ) { if ( $ x - 500 * $ i < = 0 ) { if ( $ x - 500 * $ i = = 0 ) { $ cnt + + ; } continue ; } $ tmp1 = $ x - 500 * $ i ; for ( $ j = $ b ; $ j > = 0 ; $ j -- ) { if ( $ tmp1 - 100 * $ j < = 0 ) { if ( $ tmp1 - 100 * $ j = = 0 ) { $ cnt + + ; } continue ; } $ tmp2 = $ tmp1 - 100 * $ j ; if ( $ tmp2 % 50 = = 0 & & $ tmp2 / 50 < = $ c ) { $ cnt + + ; } } } echo $ cnt . PHP _ EOL ; < ? php fscanf ( STDIN , ' % d ' , $ n ) ; $ p = array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; $ min = 10 * * 9 + 7 ; $ ans = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ min = min ( $ p [ $ i ] , $ min ) ; if ( $ p [ $ i ] = = = $ min ) $ ans + + ; } echo $ ans . PHP _ EOL ; < ? php fscanf ( STDIN , " % d " , $ N ) ; $ paid = $ N * 800 ; if ( $ N > 15 ) { $ get = 200 * ( floor ( $ N / 15 ) ) ; } echo $ paid - $ get ; ? > < ? php $ n = trim ( fgets ( STDIN ) ) ; $ res = $ n % sumEachDigit ( $ n ) = = = 0 ? ' Yes ' : ' No ' ; print " $ res \ n " ; function sumEachDigit ( int $ number ) { $ sum = 0 ; while ( $ number ! = = 0 ) { $ sum + = $ number % 10 ; $ number = intdiv ( $ number , 10 ) ; } return $ sum ; } < ? php list ( $ H1 , $ M1 , $ H2 , $ M2 , $ K ) = array _ map ( ' intval ' , explode ( " " , trim ( fgets ( STDIN ) ) ) ) ; $ h1 = $ H1 * 60 + $ M1 ; $ h2 = $ H2 * 60 + $ M2 ; printf ( " % d \ n " , max ( $ h2 - $ h1 - $ K , 0 ) ) ; < ? php fscanf ( STDIN , " % d % d % d % d " , $ a , $ b , $ h , $ m ) ; $ minx = $ b * sin ( $ m / 60 * 2 * pi ( ) ) ; $ miny = $ b * cos ( $ m / 60 * 2 * pi ( ) ) ; $ hourx = $ a * sin ( ( $ h + $ m / 60 ) / 12 * 2 * pi ( ) ) ; $ houry = $ a * cos ( ( $ h + $ m / 60 ) / 12 * 2 * pi ( ) ) ; echo sqrt ( pow ( $ houry - $ miny , 2 ) + pow ( $ hourx - $ minx , 2 ) ) ; < ? php fscanf ( STDIN , " % d % d " , $ n , $ k ) ; if ( $ k = = 1 ) { echo ( 0 ) ; } else { echo ( $ n - $ k ) ; } < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; echo ( $ a < = 8 & & $ b < = 8 ) ? ' Yay ! ' : ' : ( ' ; < ? php fscanf ( STDIN , " % d " , $ r ) ; echo ( $ r * * 2 ) ; ? > < ? php fscanf ( STDIN , " % d % d % d " , $ a1 , $ a2 , $ a3 ) ; $ max = max ( $ a1 , $ a2 , $ a3 ) ; $ min = min ( $ a1 , $ a2 , $ a3 ) ; echo $ max - $ min ; < ? php fscanf ( STDIN , " % d % d % d " , $ a , $ b , $ c ) ; $ point1 = abs ( $ a - $ b ) + abs ( $ b - $ c ) ; $ point2 = abs ( $ a - $ c ) + abs ( $ b - $ c ) ; $ point3 = abs ( $ a - $ b ) + abs ( $ a - $ c ) ; echo min ( $ point1 , $ point2 , $ point3 ) . PHP _ EOL ; < ? php function getCost ( $ p , $ x ) { return ( $ p - $ x ) * * 2 ; } $ n = intval ( fgets ( STDIN ) ) ; $ tmp = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ min = min ( $ tmp ) ; $ max = max ( $ tmp ) ; $ minCost = - 1 ; for ( $ i = $ min ; $ i < = $ max ; $ i + + ) { $ cost = 0 ; for ( $ j = 0 ; $ j < $ n ; $ j + + ) { $ cost + = getCost ( $ i , $ tmp [ $ j ] ) ; } if ( $ minCost = = - 1 | | $ cost < $ minCost ) { $ minCost = $ cost ; } } echo $ minCost . " \ n " ; < ? php fscanf ( STDIN , ' % d % d % d ' , $ A1 , $ A2 , $ A3 ) ; $ min = min ( $ A1 , $ A2 , $ A3 ) ; $ max = max ( $ A1 , $ A2 , $ A3 ) ; echo $ max - $ min ; ? > < ? php $ s = trim ( fgets ( STDIN ) ) ; $ target _ day = " 2019 / 04 / 30 " ; if ( strtotime ( $ s ) < = strtotime ( $ target _ day ) ) { echo " Heisei " ; } else { echo " TBD " ; } ? > < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; echo $ a > = 13 ? $ b : ( $ a > = 6 ? $ b / 2 : 0 ) ; ? > < ? php $ n = trim ( fgets ( STDIN ) ) ; echo ( $ n * 800 - floor ( $ n / 15 ) * 200 ) . PHP _ EOL ; < ? php $ r = trim ( fgets ( STDIN ) ) ; echo $ r * $ r ; < ? php fscanf ( STDIN , " % d " , $ n ) ; if ( $ n > = 64 ) { $ res = 64 ; } else if ( $ n > = 32 ) { $ res = 32 ; } else if ( $ n > = 16 ) { $ res = 16 ; } else if ( $ n > = 8 ) { $ res = 8 ; } else if ( $ n > = 4 ) { $ res = 4 ; } else if ( $ n > = 2 ) { $ res = 2 ; } else if ( $ n > = 1 ) { $ res = 1 ; } echo $ res ; < ? php fscanf ( STDIN , ' % d % d ' , $ a , $ b ) ; if ( $ a > = 13 ) $ ans = $ b ; elseif ( $ a > = 6 ) $ ans = $ b / 2 ; else $ ans = 0 ; echo $ ans . PHP _ EOL ; < ? php list ( $ A , $ B , $ H , $ M ) = array _ map ( ' intval ' , explode ( " " , ( trim ( fgets ( STDIN ) ) ) ) ) ; $ angle _ a = 360 / 12 * $ H + 30 / 60 * $ M ; $ angle _ b = 360 / 60 * $ M ; $ diff = abs ( $ angle _ b - $ angle _ a ) ; if ( $ diff > 180 ) { $ diff = 360 - $ diff ; } $ C = sqrt ( $ A * * 2 + $ B * * 2 - 2 * $ A * $ B * cos ( deg2rad ( $ diff ) ) ) ; echo $ C . " \ n " ; ? > < ? php $ x = ( int ) trim ( fgets ( STDIN ) ) ; echo $ x * $ x * $ x . " \ n " ; ? > < ? php $ input = trim ( fgets ( STDIN ) ) ; if ( $ input [ 2 ] = = = $ input [ 3 ] & & $ input [ 4 ] = = = $ input [ 5 ] ) { echo ' Yes ' ; } else { echo ' No ' ; } < ? php function createPermutation ( $ n , $ r ) { if ( ! $ r | | $ n < $ r ) { return array ( ) ; } $ return = array ( ) ; $ n2 = $ n - 1 ; if ( $ r = = 1 ) { for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ return [ ] = array ( $ i ) ; } return $ return ; } foreach ( createPermutation ( $ n2 , $ r ) as $ row ) { $ return [ ] = $ row ; } foreach ( createPermutation ( $ n2 , $ r - 1 ) as $ row ) { for ( $ i = 0 ; $ i < $ r ; $ i + + ) { $ return [ ] = array _ merge ( array _ slice ( $ row , 0 , $ i ) , array ( $ n2 ) , array _ slice ( $ row , $ i ) ) ; } } return $ return ; } fscanf ( STDIN , " % d " , $ in _ n ) ; for ( $ i = 0 ; $ i < $ in _ n ; $ i + + ) { fscanf ( STDIN , " % d % d " , $ in _ x [ $ i ] , $ in _ y [ $ i ] ) ; } $ kyori _ goukei = 0 ; $ arr _ junban = createPermutation ( $ in _ n , $ in _ n ) ; foreach ( $ arr _ junban as $ junban ) { for ( $ i = 0 ; $ i < ( $ in _ n - 1 ) ; $ i + + ) { $ kyori _ goukei = $ kyori _ goukei + ( sqrt ( pow ( abs ( $ in _ x [ $ junban [ $ i ] ] - $ in _ x [ $ junban [ $ i + 1 ] ] ) , 2 ) + pow ( abs ( $ in _ y [ $ junban [ $ i ] ] - $ in _ y [ $ junban [ $ i + 1 ] ] ) , 2 ) ) ) ; } } $ ans = $ kyori _ goukei / ( count ( $ arr _ junban ) ) ; echo " $ ans \ n " ; ? > < ? php $ l = [ ] ; while ( $ r = trim ( fgets ( STDIN ) ) ) $ l [ ] = $ r ; $ l [ 1 ] = explode ( " " , $ l [ 1 ] ) ; echo max ( $ l [ 1 ] ) - min ( $ l [ 1 ] ) ; < ? php $ x ; $ y ; fscanf ( STDIN , " % d " , $ N ) ; $ x = $ N * 800 ; $ y = 200 * ( int ) ( $ N / 15 ) ; echo $ x - $ y ; < ? php fscanf ( STDIN , " % d % d " , $ A , $ V ) ; fscanf ( STDIN , " % d % d " , $ B , $ W ) ; fscanf ( STDIN , " % d " , $ T ) ; $ d = abs ( $ A - $ B ) ; $ dv = $ V - $ W ; if ( $ dv < = 0 ) { echo " NO " ; } else { echo $ d < = $ T * $ dv ? " YES " : " NO " ; } < ? php $ time = trim ( fgets ( STDIN ) ) ; $ discount = 200 * intval ( $ time / 15 ) ; echo 800 * $ time - $ discount ; ? > < ? php fscanf ( STDIN , " % d " , $ n ) ; $ s = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ rsl = in _ array ( " Y " , $ s ) ; if ( $ rsl = = = true ) { echo " Four " ; } else { echo " Three " ; } < ? php $ T = trim ( fgets ( STDIN ) ) ; $ len = strlen ( $ T ) ; $ S = " " ; for ( $ i = 0 ; $ i < $ len ; $ i + + ) { if ( $ T [ $ i ] = = ' ? ' ) { $ S [ $ i ] = ' D ' ; } else { $ S [ $ i ] = $ T [ $ i ] ; } } printf ( " % s \ n " , $ S ) ; < ? php fscanf ( STDIN , " % d " , $ a ) ; fscanf ( STDIN , " % d " , $ b ) ; fscanf ( STDIN , " % d " , $ c ) ; fscanf ( STDIN , " % d " , $ d ) ; fscanf ( STDIN , " % d " , $ e ) ; fscanf ( STDIN , " % d " , $ k ) ; if ( $ e - $ a > $ k ) { print ( " : ( \ n " ) ; } else { print ( " Yay ! \ n " ) ; } ? > < ? php $ N = intval ( trim ( fgets ( STDIN ) ) ) ; $ P _ array = array _ map ( ' intval ' , explode ( " " , trim ( fgets ( STDIN ) ) ) ) ; if ( $ N = = 1 ) { echo $ P _ array [ 0 ] ; exit ; } $ count = 0 ; $ min = $ P _ array [ 0 ] ; for ( $ i = 1 ; $ i < $ N ; $ i + + ) { if ( $ P _ array [ $ i ] < $ min ) { $ count + + ; $ min = $ P _ array [ $ i ] ; } } echo $ count + 1 ; ? > < ? php $ x = trim ( fgets ( STDIN ) ) ; echo pow ( $ x , 3 ) ; ? > < ? php $ five _ hundred = trim ( fgets ( STDIN ) ) ; $ one _ hundred = trim ( fgets ( STDIN ) ) ; $ fifty = trim ( fgets ( STDIN ) ) ; $ target = trim ( fgets ( STDIN ) ) ; $ cnt = 0 ; for ( $ i = 0 ; $ i < = $ five _ hundred ; $ i + + ) { for ( $ j = 0 ; $ j < = $ one _ hundred ; $ j + + ) { $ k = $ target - ( $ i * 500 + $ j * 100 ) ; if ( $ k > = 0 & & $ k / 50 < = $ fifty ) { $ cnt + + ; } } } echo $ cnt ; ? > < ? php fscanf ( STDIN , " % d " , $ N ) ; echo $ N * $ N ; < ? php $ x = trim ( fgets ( STDIN ) ) ; echo pow ( $ x , 3 ) ; ? > < ? php $ input _ line = fgets ( STDIN ) ; $ array = explode ( " " , $ input _ line ) ; $ age = $ array [ 0 ] ; $ price = $ array [ 1 ] ; if ( $ age > = 13 ) { echo $ price ; } else if ( $ age < = 12 & & $ age > = 6 ) { echo $ price / 2 ; } else { echo 0 ; } < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; echo ceil ( ( $ a + $ b ) / 2 ) ; < ? php fscanf ( STDIN , " % d " , $ n ) ; $ xList = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ ave = round ( array _ sum ( $ xList ) / $ n ) ; $ totalHp = 0 ; foreach ( $ xList as $ x ) { $ totalHp + = pow ( ( $ x - $ ave ) , 2 ) ; } echo $ totalHp ; echo PHP _ EOL ; ? > < ? php $ input = fgets ( STDIN ) ; print ( pow ( $ input , 3 ) . " \ n " ) ; < ? php $ s = trim ( fgets ( STDIN ) ) ; $ i = intVal ( $ s ) ; echo pow ( $ i , 3 ) . PHP _ EOL ; exit ; ? > < ? php list ( $ n ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ x = [ ] ; $ y = [ ] ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { list ( $ x [ ] , $ y [ ] ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; } $ distance = 0 ; $ o = 0 ; for ( $ i = 0 ; $ i < $ n - 1 ; $ i + + ) { for ( $ j = $ i + 1 ; $ j < $ n ; $ j + + ) { $ o + + ; $ distance + = sqrt ( ( $ x [ $ i ] - $ x [ $ j ] ) * ( $ x [ $ i ] - $ x [ $ j ] ) + ( $ y [ $ i ] - $ y [ $ j ] ) * ( $ y [ $ i ] - $ y [ $ j ] ) ) ; } } echo $ distance * ( $ n - 1 ) / $ o ; < ? php fscanf ( STDIN , " % d " , $ n ) ; $ x = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ sum = array _ sum ( $ x ) ; $ p = round ( $ sum / $ n ) ; $ ans = 0 ; foreach ( $ x as $ v ) { $ ans + = ( $ v - $ p ) * * 2 ; } echo $ ans ; < ? php fscanf ( STDIN , " % d % d % d " , $ A , $ B , $ C ) ; if ( $ A = = 7 and $ B = = 5 and $ C = = 5 ) { echo " YES " ; } elseif ( $ A = = 5 and $ B = = 7 and $ C = = 5 ) { echo " YES " ; } elseif ( $ A = = 5 and $ B = = 5 and $ C = = 7 ) { echo " YES " ; } else { echo " NO " ; } < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; if ( $ a < 9 & & $ b < 9 ) { echo " Yay ! \ n " ; } else { echo " : ( \ n " ; } ? > < ? php fscanf ( STDIN , " % d " , $ r ) ; echo $ r * $ r ; ? > < ? php $ x = trim ( fgets ( STDIN ) ) ; $ x = pow ( $ x , 3 ) ; echo $ x ; ? > < ? php fscanf ( STDIN , " % d " , $ a ) ; echo $ a * * 3 , " \ n " ; < ? php fscanf ( STDIN , " % d " , $ N ) ; $ p _ list = array ( ) ; $ p _ list = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ max = $ p _ list [ 0 ] ; $ count = 1 ; for ( $ i = 1 ; $ i < $ N ; $ i + + ) { if ( $ max > = $ p _ list [ $ i ] ) { $ count + + ; $ max = $ p _ list [ $ i ] ; } } echo $ count . " \ n " ; < ? php fscanf ( STDIN , ' % d % d % d % d ' , $ a , $ b , $ h , $ m ) ; $ y = $ m / 60 ; $ x = ( $ h + $ y ) / 12 ; $ rad = deg2rad ( ( $ x - $ y ) * 360 ) ; $ ans = sqrt ( $ a * * 2 + $ b * * 2 - 2 * $ a * $ b * cos ( $ rad ) ) ; echo $ ans ; < ? php fscanf ( STDIN , ' % d % d % d ' , $ a , $ b , $ c ) ; if ( $ a + $ b > = $ c ) { echo ' Yes ' ; } else { echo ' No ' ; } ? > < ? php $ num = intval ( trim ( fgets ( STDIN ) ) ) ; echo $ num * $ num * $ num ; echo " \ n " ; ? > < ? php $ input = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ n = ( int ) $ input [ 0 ] ; $ k = ( int ) $ input [ 1 ] ; if ( $ k = = = 1 ) { echo 0 ; } else { echo $ n - $ k ; } < ? php fscanf ( STDIN , " % d % d % d % d " , $ a , $ b , $ h , $ m ) ; if ( $ m = = = 0 ) { $ mc = 360 ; } else { $ mc = $ m * 360 / 60 ; } $ hc = ( $ h * 60 + $ m ) * 360 / ( 12 * 60 ) ; $ cos = abs ( $ hc - $ mc ) ; $ ans = $ a * $ a + $ b * $ b - ( 2 * $ a * $ b * cos ( deg2rad ( $ cos ) ) ) ; echo sqrt ( $ ans ) ; ? > < ? php $ x = ( int ) fgets ( STDIN ) ; echo $ x * * 3 ; echo PHP _ EOL ; < ? php $ n = explode ( " " , trim ( fgets ( STDIN ) ) ) ; asort ( $ n ) ; $ nn = array _ values ( $ n ) ; if ( $ nn [ 0 ] = = 1 & & $ nn [ 1 ] = = 4 & & $ nn [ 2 ] = = 7 & & $ nn [ 3 ] = = 9 ) { echo " YES \ n " ; } else { echo " NO \ n " ; } < ? php $ T = trim ( fgets ( STDIN ) ) ; while ( true ) { $ sp _ q = strpos ( $ T , ' ? ' ) ; if ( $ sp _ q = = = FALSE ) { break ; } $ T = substr _ replace ( $ T , ' D ' , $ sp _ q , 1 ) ; } echo $ T ; ? > < ? php $ x = trim ( fgets ( STDIN ) ) ; echo pow ( $ x , 3 ) ; ? > < ? php fscanf ( STDIN , " % d % d % d % d " , $ s [ 1 ] , $ s [ 2 ] , $ s [ 3 ] , $ s [ 4 ] ) ; if ( in _ array ( 1 , $ s ) & & in _ array ( 9 , $ s ) & & in _ array ( 7 , $ s ) & & in _ array ( 4 , $ s ) ) echo " YES " ; else echo " NO " ; < ? php error _ reporting ( 0 ) ; $ stdin = file _ get _ contents ( ' php : $ line = explode ( " \ n " , $ stdin ) ; $ fi = 0 ; $ cnt = 0 ; $ list = array ( ) ; $ key = new stdclass ( ) ; foreach ( $ line as $ l ) { if ( strlen ( $ l ) = = 0 ) continue ; if ( $ fi = = 0 ) { $ a = explode ( " " , $ l ) ; $ key- > A = $ a ; $ fi + + ; continue ; } if ( $ fi > 0 ) { $ a = explode ( " " , $ l ) ; $ key- > X [ ] = $ a ; } } $ N = $ key- > A [ 0 ] ; $ A = $ key- > X [ 0 ] ; $ mx = max ( $ A ) ; $ mi = min ( $ A ) ; printf ( " % d \ n " , $ mx- $ mi ) ; < ? php list ( $ A , $ B ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; if ( $ A < = 5 ) { $ B = 0 ; } else if ( $ A < = 12 ) { $ B = $ B / 2 ; } printf ( " % d \ n " , $ B ) ; < ? php $ input = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ n = ( int ) $ input [ 0 ] ; $ p = ( int ) $ input [ 1 ] ; $ max = floor ( sqrt ( $ p ) ) ; $ as = [ ] ; if ( $ n = = = 1 ) { echo $ p ; exit ( ) ; } for ( $ i = 2 ; $ i < = $ max ; $ i + + ) { while ( $ p % $ i = = = 0 ) { if ( empty ( $ as [ $ i ] ) ) { $ as [ $ i ] = 1 ; } else { $ as [ $ i ] + = 1 ; } $ p = floor ( $ p / $ i ) ; } } $ min = 1 ; foreach ( $ as as $ key = > $ value ) { if ( $ value > = $ n ) { $ jo = floor ( $ value / $ n ) ; $ min * = pow ( $ key , $ jo ) ; } } echo $ min ; < ? php list ( $ a , $ b , $ h , $ m ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ hr = $ h * 30 + $ m * 0.5 ; $ mr = $ m * 6 ; $ r = abs ( $ hr - $ mr ) ; $ r = min ( 360 - $ r , $ r ) ; $ ans = $ a * $ a + $ b * $ b - 2 * $ a * $ b * cos ( deg2rad ( $ r ) ) ; echo sprintf ( " % .12f " , sqrt ( $ ans ) ) ; < ? php $ num = trim ( fgets ( STDIN ) ) ; $ num = $ num * $ num * $ num ; echo $ num ; ? > < ? php $ number = trim ( fgets ( STDIN ) ) ; $ times = $ number * $ number * $ number ; print $ times ; ? > < ? php list ( $ A , $ B ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; if ( $ A = = $ B ) { echo " Draw " ; } elseif ( $ A = = 1 ) { echo " Alice " ; } elseif ( $ B = = 1 ) { echo " Bob " ; } elseif ( $ A < $ B ) { echo " Bob " ; } else { echo " Alice " ; } ? > < ? php $ min = 10 ; for ( $ i = 0 ; $ i < 5 ; $ i + + ) { fscanf ( STDIN , " % d " , $ N [ $ i ] ) ; $ nowmin = $ N [ $ i ] % 10 ; if ( $ min > $ nowmin & & $ nowmin ! = 0 ) { $ min = $ nowmin ; } if ( $ nowmin = = 0 ) { $ result + = $ N [ $ i ] ; } else { $ result + = $ N [ $ i ] + 10 - $ nowmin ; } } $ result = $ result - 10 + $ min ; echo $ result ; < ? php fscanf ( STDIN , ' % s % s ' , $ a , $ b ) ; if ( $ a > = 13 ) { echo $ b ; } elseif ( $ a < = 12 & & $ a > = 6 ) { echo $ b / 2 ; } else { echo 0 ; } ? > < ? php list ( $ a , $ b , $ h , $ m ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; if ( $ h = = 6 & & $ m = = 0 ) { echo $ a + $ b ; exit ; } if ( $ h = = 0 & & $ m = = 0 ) { echo abs ( $ a - $ b ) ; exit ; } $ h _ degree = ( 30 * $ h ) + ( 30 * $ m / 60 ) ; $ m _ degree = 6 * $ m ; $ degree = abs ( $ h _ degree - $ m _ degree ) ; $ ans = $ a * $ a + $ b * $ b - 2 * $ a * $ b * cos ( deg2rad ( $ degree ) ) ; echo sqrt ( $ ans ) ; < ? php $ array = [ ] ; for ( $ i = 0 ; $ i < 5 ; $ i + + ) { $ array [ ] = trim ( fgets ( STDIN ) ) ; } $ k = trim ( fgets ( STDIN ) ) ; for ( $ i = 0 ; $ i < 5 ; $ i + + ) { for ( $ j = $ i + 1 ; $ j < 5 ; $ j + + ) { if ( $ array [ $ i ] = = = $ array [ $ j ] ) { continue ; } else if ( $ array [ $ j ] - $ array [ $ i ] > $ k ) { echo ' : ( ' , PHP _ EOL ; exit ( ) ; } } } echo ' Yay ! ' , PHP _ EOL ; < ? php $ a = fgets ( STDIN ) ; $ b = fgets ( STDIN ) ; $ c = fgets ( STDIN ) ; $ total = fgets ( STDIN ) ; $ num = 0 ; for ( $ i = 0 ; $ i < = $ a ; $ i + + ) { for ( $ j = 0 ; $ j < = $ b ; $ j + + ) { for ( $ k = 0 ; $ k < = $ c ; $ k + + ) { $ sum = 500 * $ i + 100 * $ j + 50 * $ k ; if ( $ sum = = $ total ) { $ num + + ; } } } } echo $ num ; < ? php $ args = [ ] ; while ( true ) { $ input = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; foreach ( $ input as $ value ) { if ( ! empty ( $ value ) ) { $ args [ ] = $ value ; } if ( count ( $ args ) > = 3 ) { break ; } } if ( count ( $ args ) > = 3 ) { break ; } } sort ( $ args ) ; $ check = [ 5 , 5 , 7 ] ; for ( $ i = 0 ; $ i < 3 ; $ i + + ) { if ( $ args [ $ i ] = = $ check [ $ i ] ) { continue ; } else { echo ' NO ' ; exit ( 0 ) ; } } echo ' YES ' ; < ? php list ( $ a , $ b , $ c ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; echo min ( abs ( $ b - $ a ) + abs ( $ c - $ b ) , abs ( $ c - $ a ) + abs ( $ b - $ c ) , abs ( $ a - $ b ) + abs ( $ c - $ a ) , abs ( $ c - $ b ) + abs ( $ a - $ c ) , abs ( $ b - $ c ) + abs ( $ a - $ b ) , abs ( $ a - $ c ) + abs ( $ b - $ a ) ) ; < ? php fscanf ( STDIN , ' % d ' , $ max500 ) ; fscanf ( STDIN , ' % d ' , $ max100 ) ; fscanf ( STDIN , ' % d ' , $ max50 ) ; fscanf ( STDIN , ' % d ' , $ total ) ; $ cnt = 0 ; for ( $ i = 0 ; $ i < = $ max500 ; $ i + + ) { $ money = $ i * 500 ; if ( $ money = = $ total ) { + + $ cnt ; echo $ cnt ; exit ; } if ( $ money > $ total ) { echo $ cnt ; exit ; } for ( $ j = 0 ; $ j < = $ max100 ; $ j + + ) { $ money = $ i * 500 + $ j * 100 ; if ( $ money = = $ total ) { + + $ cnt ; break ; } if ( $ money > $ total ) { break ; } for ( $ k = 0 ; $ k < = $ max50 ; $ k + + ) { $ money = $ i * 500 + $ j * 100 + $ k * 50 ; if ( $ money = = $ total ) { + + $ cnt ; break ; } } } } echo $ cnt ; < ? php function input ( string $ func = null ) { if ( $ func = = = null ) { return trim ( fgets ( STDIN ) ) ; } else { return $ func ( trim ( fgets ( STDIN ) ) ) ; } } function input _ array ( string $ func = null ) { if ( $ func = = = null ) { return explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; } else { return array _ map ( function ( $ v ) use ( $ func ) { return $ func ( $ v ) ; } , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; } } $ n = input ( ' intval ' ) ; $ as = input _ array ( ' intval ' ) ; $ bs = input _ array ( ' intval ' ) ; $ overs = [ ] ; $ count = 0 ; $ to _ be _ added = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { if ( $ as [ $ i ] > $ bs [ $ i ] ) { $ overs [ ] = $ as [ $ i ] - $ bs [ $ i ] ; } else if ( $ as [ $ i ] < $ bs [ $ i ] ) { $ count + + ; $ to _ be _ added + = $ bs [ $ i ] - $ as [ $ i ] ; } } rsort ( $ overs ) ; for ( $ i = 0 , $ c = count ( $ overs ) ; $ i < $ c ; $ i + + ) { if ( $ to _ be _ added < = 0 ) { break ; } $ to _ be _ added - = $ overs [ $ i ] ; $ count + + ; } if ( array _ sum ( $ as ) < array _ sum ( $ bs ) ) { echo " -1 \ n " ; } else { echo " { $ count } \ n " ; } < ? php while ( true ) { $ x = trim ( fgets ( STDIN ) ) ; if ( $ x = = 0 ) break ; $ sum = 0 ; for ( $ i = 0 ; $ i < strlen ( $ x ) ; $ i + + ) { $ sum + = $ x [ $ i ] ; } echo $ sum . " \ n " ; } < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; if ( $ a > = 13 ) { echo $ b . PHP _ EOL ; } elseif ( $ a > = 6 & & $ a < = 12 ) { echo ( $ b / 2 ) . PHP _ EOL ; } else { echo ( 0 ) . PHP _ EOL ; } < ? php $ line = fgets ( STDIN ) ; $ data = explode ( ' ' , $ line ) ; $ a = $ data [ 0 ] ; $ b = $ data [ 1 ] ; print ceil ( ( $ a + $ b ) / 2 ) ; < ? php fscanf ( STDIN , " % d % d " , $ pref _ max , $ city _ max ) ; for ( $ i = 0 ; $ i < $ city _ max ; $ i + + ) { fscanf ( STDIN , " % d % d " , $ pref , $ city ) ; $ dispList [ ] = array ( " pref " = > $ pref , " city " = > $ city ) ; $ list [ $ pref ] [ $ i ] = $ city ; } foreach ( $ list as $ pref = > $ cities ) { sort ( $ cities ) ; $ num = 1 ; foreach ( $ cities as $ city ) { $ idList [ $ pref ] [ $ city ] = $ num ; $ num + + ; } } foreach ( $ dispList as $ disp ) { $ pref _ id = sprintf ( " % 06d " , $ disp [ ' pref ' ] ) ; $ city _ id = sprintf ( " % 06d " , $ idList [ $ disp [ ' pref ' ] ] [ $ disp [ ' city ' ] ] ) ; echo $ pref _ id . $ city _ id . " \ n " ; } < ? php fscanf ( STDIN , " % d % d " , $ k , $ s ) ; $ exists = 0 ; for ( $ x = 0 ; $ x < = $ k ; $ x + + ) { for ( $ y = 0 ; $ y < = $ k ; $ y + + ) { $ z = $ s - $ x - $ y ; if ( $ z > = 0 & & $ z < = $ k ) { $ exists + + ; } } } printf ( " % d \ n " , $ exists ) ; ? > < ? php list ( $ n , $ m ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; echo intdiv ( $ n + $ m + 1 , 2 ) ; < ? php list ( $ a ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; list ( $ b ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; list ( $ c ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; list ( $ x ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ ans = 0 ; for ( $ i = 0 ; $ i < = $ a ; $ i + + ) { for ( $ j = 0 ; $ j < = $ b ; $ j + + ) { for ( $ k = 0 ; $ k < = $ c ; $ k + + ) { if ( $ i * 500 + $ j * 100 + $ k * 50 = = $ x ) $ ans + + ; } } } echo $ ans ; < ? php $ array = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ tri = $ array [ 0 ] * $ array [ 0 ] * $ array [ 0 ] ; echo $ tri ; ? > < ? php $ r = fgets ( STDIN ) ; echo $ r * $ r . " \ n " ; ? > < ? php fscanf ( STDIN , " % d " , $ a ) ; fscanf ( STDIN , " % d " , $ b ) ; fscanf ( STDIN , " % d " , $ c ) ; fscanf ( STDIN , " % d " , $ x ) ; $ ret = 0 ; for ( $ i = 0 ; $ i < = $ a ; $ i + + ) { for ( $ j = 0 ; $ j < = $ b ; $ j + + ) { for ( $ k = 0 ; $ k < = $ c ; $ k + + ) { $ sum = 500 * $ i + 100 * $ j + 50 * $ k ; if ( $ x - $ sum = = 0 ) { $ ret + + ; } } } } echo $ ret . " \ n " ; < ? php $ arr = explode ( ' ' , fgets ( STDIN ) ) ; $ five = 0 ; $ seven = 0 ; foreach ( $ arr as $ key = > $ value ) { $ arr [ $ key ] = intval ( $ value ) ; if ( $ arr [ $ key ] = = = 5 ) { $ five + + ; continue ; } if ( $ arr [ $ key ] = = = 7 ) { $ seven + + ; continue ; } } if ( $ five = = = 2 & & $ seven = = = 1 ) { echo ' YES ' ; return ; } echo ' NO ' ; ? > < ? php fscanf ( STDIN , " % d " , $ N ) ; $ map = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ ans = 0 ; $ min = PHP _ INT _ MAX ; foreach ( $ map as $ value ) { if ( $ value < $ min ) { $ ans + + ; $ min = $ value ; } } echo $ ans ; < ? php fscanf ( STDIN , " % d % d % d " , $ a , $ b , $ c ) ; echo ( $ a + $ b + $ c = = 17 ) ? ' YES ' : ' NO ' , PHP _ EOL ; < ? php $ num = trim ( fgets ( STDIN ) ) ; echo pow ( $ num , 3 ) . " \ n " ; ? > < ? php $ N = fgets ( STDIN ) ; $ line = fgets ( STDIN ) ; $ X = explode ( " " , $ line ) ; $ syu = round ( array _ sum ( $ X ) / $ N ) ; $ tai = 0 ; for ( $ i = 0 ; $ i < $ N ; $ i + + ) { $ tai + = ( $ X [ $ i ] - $ syu ) * ( $ X [ $ i ] - $ syu ) ; } echo $ tai . " \ n " ; ? > < ? php fscanf ( STDIN , ' % d % d ' , $ a , $ b ) ; if ( $ a = = = 1 ) { $ a = 14 ; } if ( $ b = = = 1 ) { $ b = 14 ; } if ( $ a > $ b ) { echo ' Alice ' ; } elseif ( $ a < $ b ) { echo ' Bob ' ; } else { echo ' Draw ' ; } echo PHP _ EOL ; < ? php $ r = trim ( fgets ( STDIN ) ) ; echo $ r * * 2 ; < ? php $ n = trim ( fgets ( STDIN ) ) ; if ( $ n [ 6 ] > = 5 ) { echo " TBD " ; } elseif ( $ n [ 5 ] = = 1 ) { echo " TBD " ; } else { echo " Heisei " ; } < ? php $ input = array _ map ( ' intval ' , explode ( ' ' , fgets ( STDIN ) ) ) ; $ a = $ input [ 0 ] ; $ b = $ input [ 1 ] ; $ c = $ input [ 2 ] ; $ d = $ input [ 3 ] ; if ( ( $ a * $ b ) > = ( $ c * $ d ) ) { print $ a * $ b ; } else { print $ c * $ d ; } < ? php fscanf ( STDIN , " % d % d " , $ in _ k , $ in _ s ) ; $ ans _ kumi = 0 ; for ( $ x = 0 ; $ x < = $ in _ k ; $ x + + ) { for ( $ y = 0 ; $ y < = $ in _ k ; $ y + + ) { if ( ( $ in _ s - $ x - $ y > = 0 ) & & ( $ in _ s - $ x - $ y < = $ in _ k ) ) { $ ans _ kumi + + ; } } } echo " $ ans _ kumi \ n " ; ? > < ? php fscanf ( STDIN , " % d % d " , $ n , $ d ) ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ input = fgets ( STDIN ) ; $ list [ $ i ] = explode ( " " , $ input ) ; } $ cnt = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { for ( $ j = $ i + 1 ; $ j < $ n ; $ j + + ) { $ sum = 0 ; for ( $ k = 0 ; $ k < $ d ; $ k + + ) { $ sum + = ( $ list [ $ i ] [ $ k ] - $ list [ $ j ] [ $ k ] ) * * 2 ; } if ( floor ( sqrt ( $ sum ) ) = = sqrt ( $ sum ) ) $ cnt + + ; } } echo $ cnt ; < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; echo ceil ( ( $ a + $ b ) / 2 ) ; < ? php function checkSimilar ( $ words ) { $ a = str _ split ( $ words ) ; if ( $ a [ 2 ] = = = $ a [ 3 ] & & $ a [ 4 ] = = = $ a [ 5 ] ) { return ' Yes ' ; } else { return ' No ' ; } } $ stdin = ( string ) trim ( fgets ( STDIN ) ) ; echo checkSimilar ( $ stdin ) ; < ? php $ a = explode ( " " , trim ( fgets ( STDIN ) ) ) ; sort ( $ a ) ; echo implode ( " " , $ a ) = = 1479 ? " YES " : " NO " ; < ? php for ( $ i = 0 ; $ i < 5 ; $ i + + ) { $ a = fgets ( STDIN ) ; $ s + = $ t = floor ( ( $ a + 9 ) / 10 ) * 10 ; if ( $ m < $ t - $ a ) $ m = $ t - $ a ; } echo $ s - $ m ; < ? php while ( true ) { $ x = trim ( fgets ( STDIN ) ) ; if ( $ x = = 0 ) break ; echo array _ sum ( str _ split ( $ x ) ) . " \ n " ; } < ? php $ input = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ five = 0 ; $ seven = 0 ; foreach ( $ input as $ i ) { if ( $ i = = = " 5 " ) { $ five + = 1 ; } elseif ( $ i = = = " 7 " ) { $ seven + = 1 ; } } if ( $ five = = = 2 & & $ seven = = = 1 ) { echo " YES " . " \ n " ; } else { echo " NO " . " \ n " ; } ? > < ? php function getInput ( ) : array { return array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; } function calculate ( int $ K , int $ S ) : int { $ numberOfTriples = 0 ; for ( $ X = 0 ; $ X < = $ K & & $ X < = $ S ; $ X + + ) { for ( $ Y = 0 ; $ Y < = $ K & & $ Y < = $ S - $ X ; $ Y + + ) { $ Z = $ S - $ X - $ Y ; if ( 0 < = $ Z & & $ Z < = $ K ) { $ numberOfTriples + + ; } } } return $ numberOfTriples ; } list ( $ K , $ S ) = getInput ( ) ; $ result = calculate ( $ K , $ S ) ; echo $ result . PHP _ EOL ; < ? php fscanf ( STDIN , " % d % d % d " , $ a , $ b , $ c ) ; if ( $ a + $ b > = $ c ) { print ( " Yes \ n " ) ; } else { print ( " No \ n " ) ; } ? > < ? php fscanf ( STDIN , ' % s ' , $ t ) ; echo str _ replace ( ' ? ' , ' D ' , $ t ) ; < ? php $ x = trim ( fgets ( STDIN ) ) ; echo $ x * $ x * $ x . PHP _ EOL ; < ? php $ input = file _ get _ contents ( ' php : echo $ input * $ input * $ input , PHP _ EOL ; < ? php fscanf ( STDIN , " % d " , $ n ) ; $ numbers = fgets ( STDIN ) ; $ exploded _ numbers = explode ( ' ' , trim ( $ numbers ) ) ; $ p = ( int ) round ( array _ sum ( $ exploded _ numbers ) / $ n ) ; $ sum = 0 ; foreach ( $ exploded _ numbers as $ num ) { $ sum + = pow ( $ num - $ p , 2 ) ; } echo $ sum ; < ? php list ( $ n , $ p ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; if ( $ n = = 1 ) { echo $ p ; } elseif ( $ p = = 1 ) { echo 1 ; } else { $ ans = 1 ; $ i = 2 ; while ( pow ( $ i , $ n ) < = $ p ) { $ c = pow ( $ i , $ n ) ; if ( $ p % $ c = = 0 ) { $ p / = ( int ) $ c ; $ ans * = $ i ; -- $ i ; } + + $ i ; } echo $ ans ; } < ? php $ s = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ m = [ ] ; array _ push ( $ m , abs ( $ s [ 0 ] - $ s [ 1 ] ) , abs ( $ s [ 0 ] - $ s [ 2 ] ) , abs ( $ s [ 1 ] - $ s [ 2 ] ) ) ; rsort ( $ m ) ; echo 0 + $ m [ 1 ] + $ m [ 2 ] ; ? > < ? php fscanf ( STDIN , " % s " , $ n ) ; $ n _ array = str _ split ( $ n ) ; $ sum = 0 ; foreach ( $ n _ array as $ value ) { $ sum + = $ value ; } if ( intval ( $ n ) % $ sum = = 0 ) { echo ' Yes ' ; } else { echo ' No ' ; } < ? php list ( $ K , $ S ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ c = 0 ; for ( $ i = 0 ; $ i < = $ K ; $ i + + ) { for ( $ j = 0 ; $ j < = $ K ; $ j + + ) { if ( $ S - $ i - $ j > = 0 & & $ S - $ i - $ j < = $ K ) { $ c + + ; } } } echo $ c ; < ? php class Scanner { private $ arr = [ ] ; private $ count = 0 ; private $ pointer = 0 ; public function next ( ) { if ( $ this - > pointer > = $ this - > count ) { $ str = trim ( fgets ( STDIN ) ) ; $ this - > arr = explode ( ' ' , $ str ) ; $ this - > count = count ( $ this - > arr ) ; $ this - > pointer = 0 ; } $ result = $ this - > arr [ $ this - > pointer ] ; $ this - > pointer + + ; return $ result ; } public function hasNext ( ) { return $ this - > pointer < $ this - > count ; } public function nextInt ( ) { return ( int ) $ this - > next ( ) ; } public function nextDouble ( ) { return ( double ) $ this - > next ( ) ; } } function be _ able _ to _ reach ( $ from , $ to ) { $ time = $ to [ 0 ] - $ from [ 0 ] ; $ distance = abs ( $ to [ 1 ] - $ from [ 1 ] ) + abs ( $ to [ 2 ] - $ from [ 2 ] ) ; # var _ dump ( $ time , $ distance ) ; if ( $ distance > $ time ) return false ; if ( $ distance % 2 = = 0 & & $ time % 2 = = 0 ) return true ; if ( $ distance % 2 = = 1 & & $ time % 2 = = 1 ) return true ; return false ; } $ scan = new Scanner ( ) ; $ A = $ scan- > nextInt ( ) ; $ B = $ scan- > nextInt ( ) ; $ cost = 0 ; if ( $ A > = 13 ) $ cost = $ B ; elseif ( $ A > = 6 ) $ cost = $ B / 2 ; else $ cost = 0 ; print ( $ cost ) ; < ? php function getNext ( ) { return trim ( isset ( $ GLOBALS [ ' _ input ' ] ) ? array _ shift ( $ GLOBALS [ ' _ input ' ] ) : fgets ( STDIN ) ) ; } $ nCoinA = ( int ) getNext ( ) ; $ nCoinB = ( int ) getNext ( ) ; $ nCoinC = ( int ) getNext ( ) ; $ amount = ( ( int ) getNext ( ) ) ; $ count = 0 ; for ( $ a = 0 ; $ a < = $ nCoinA ; $ a + + ) { for ( $ b = 0 ; $ b < = $ nCoinB ; $ b + + ) { $ temp = $ a * 500 + $ b * 100 ; if ( $ temp < = $ amount & & ( ( $ amount - $ temp ) / 50 ) < = $ nCoinC ) { + + $ count ; } } } printf ( " % d \ n " , $ count ) ; < ? php fscanf ( STDIN , " % d % d % d " , $ a , $ b , $ c ) ; $ array _ string = array ( $ a , $ b , $ c ) ; $ dem _ 5 = 0 ; $ dem _ 7 = 0 ; foreach ( $ array _ string as $ string ) { if ( $ string = = 5 ) { $ dem _ 5 + + ; } if ( $ string = = 7 ) { $ dem _ 7 + + ; } } # output if ( $ dem _ 5 = = 2 & & $ dem _ 7 = = 1 ) { echo " YES \ n " ; } else { echo " NO \ n " ; } ? > < ? php $ input = trim ( fgets ( STDIN ) ) ; echo pow ( $ input , 3 ) , PHP _ EOL ; < ? php fscanf ( STDIN , ' % d ' , $ n ) ; for ( $ i = 1 ; $ i < = $ n ; $ i + + ) { fscanf ( STDIN , ' % d % d ' , $ x , $ y ) ; $ chart _ points [ $ i ] = [ ' x ' = > $ x , ' y ' = > $ y ] ; } function dfs ( $ ranged _ n , $ array = " " ) { $ result = [ ] ; if ( count ( $ ranged _ n ) = = 0 ) { $ result [ ] = $ array ; } else { foreach ( $ ranged _ n as $ key = > $ val ) { $ _ array = $ array . $ val ; $ _ ranged _ n = $ ranged _ n ; unset ( $ _ ranged _ n [ $ key ] ) ; $ pre _ result = dfs ( $ _ ranged _ n , $ _ array ) ; $ result = array _ merge ( $ result , $ pre _ result ) ; } } return $ result ; } $ ranged _ n = range ( 1 , $ n ) ; $ pattern _ s = dfs ( $ ranged _ n ) ; $ distance = 0 ; foreach ( $ pattern _ s as $ pattern ) { $ splited _ pattern = str _ split ( $ pattern ) ; $ i = 0 ; while ( $ i < $ n - 1 ) { $ flg = $ splited _ pattern [ $ i ] ; $ flg2 = $ splited _ pattern [ $ i + 1 ] ; $ distance + = sqrt ( pow ( ( $ chart _ points [ $ flg ] [ ' x ' ] - $ chart _ points [ $ flg2 ] [ ' x ' ] ) , 2 ) + pow ( ( $ chart _ points [ $ flg ] [ ' y ' ] - $ chart _ points [ $ flg2 ] [ ' y ' ] ) , 2 ) ) ; $ i + + ; } } echo $ distance / count ( $ pattern _ s ) ; < ? php $ a = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ i = 0 ; $ ans = 0 ; while ( $ i < 3 ) { if ( $ a [ $ i ] = = 5 | | $ a [ $ i ] = = 7 ) { $ ans + = $ a [ $ i ] ; } else { break ; } + + $ i ; } echo ( $ ans = = 17 ) ? " YES " : " NO " ; < ? php $ x = ( int ) trim ( fgets ( STDIN ) ) ; echo $ x * $ x * $ x . " \ n " ; ? > < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; if ( $ a > = 13 ) { echo $ b . " \ n " ; } elseif ( $ a < = 12 & & $ a > = 6 ) { echo ( $ b / 2 ) . " \ n " ; } else { echo ( 0 ) . " \ n " ; } ? > < ? php $ input = fgets ( STDIN ) ; print ( pow ( $ input , 3 ) ) ; ? > < ? php $ A = fgets ( STDIN ) ; $ B = fgets ( STDIN ) ; $ C = fgets ( STDIN ) ; $ X = fgets ( STDIN ) ; $ cnt = 0 ; $ i = 0 ; $ j = 0 ; $ k = 0 ; while ( $ i < = $ A ) { $ en = 500 * $ i ; if ( $ en = = $ X ) $ cnt + + ; if ( $ en > = $ X ) { break ; } else { while ( $ j < = $ B ) { $ en = 500 * $ i + 100 * $ j ; if ( $ en = = $ X ) $ cnt + + ; if ( $ en > = $ X ) { break ; } else { while ( $ k < = $ C ) { $ en = 500 * $ i + 100 * $ j + 50 * $ k ; if ( $ en = = $ X ) $ cnt + + ; if ( $ en > = $ X ) { break ; } $ k + + ; } } $ k = 0 ; $ j + + ; } $ j = 0 ; $ i + + ; } } echo $ cnt ; ? > < ? php fscanf ( STDIN , " % d " , $ n ) ; $ a = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ b = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ arg = [ ] ; $ minuscount ; $ minus = 0 ; $ plus = 0 ; foreach ( $ a as $ key = > $ value ) { $ arg [ $ key ] = $ a [ $ key ] - $ b [ $ key ] ; if ( $ arg [ $ key ] < 0 ) { $ minus + = $ arg [ $ key ] ; $ minuscount + + ; } else { $ plus + = $ arg [ $ key ] ; } } if ( $ plus + $ minus < 0 ) { echo " -1 " ; exit ; } rsort ( $ arg ) ; for ( $ i = 0 ; $ minus < 0 ; $ i + + ) { $ minus + = $ arg [ $ i ] ; } echo $ i + $ minuscount ; < ? php fscanf ( STDIN , ' % d ' , $ N ) ; $ X = array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; $ min = min ( $ X ) ; $ max = max ( $ X ) ; $ ans = PHP _ INT _ MAX ; for ( $ i = $ min ; $ i < = $ max ; $ i + + ) { $ diff = array _ sum ( array _ map ( function ( $ t ) use ( $ i ) { return ( $ t - $ i ) * ( $ t - $ i ) ; } , $ X ) ) ; $ ans = min ( $ ans , $ diff ) ; } echo $ ans ; < ? php $ n = trim ( fgets ( STDIN ) ) ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ xy = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ x [ $ i ] = $ xy [ 0 ] ; $ y [ $ i ] = $ xy [ 1 ] ; } $ d = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { for ( $ j = 1 ; $ j < $ n ; $ j + + ) { $ jj = ( $ i + $ j ) % $ n ; $ d + = sqrt ( ( $ x [ $ i ] - $ x [ $ jj ] ) * * 2 + ( $ y [ $ i ] - $ y [ $ jj ] ) * * 2 ) ; } } echo $ d / $ n ; ? > < ? php $ a = ints ( ) ; echo array _ sum ( $ a ) = = = 17 & & max ( $ a ) = = = 7 & & min ( $ a ) = = = 5 ? ' YES ' : ' NO ' ; function ints ( ) { return array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; } < ? php $ s = trim ( fgets ( STDIN ) ) ; echo $ s * * 2 ; ? > < ? php fscanf ( STDIN , " % d " , $ a ) ; fscanf ( STDIN , " % d " , $ b ) ; fscanf ( STDIN , " % d " , $ c ) ; fscanf ( STDIN , " % d " , $ d ) ; fscanf ( STDIN , " % d " , $ e ) ; $ minutes = [ ' A ' = > $ a , ' B ' = > $ b , ' C ' = > $ c , ' D ' = > $ d , ' E ' = > $ e ] ; $ minKey = null ; $ minVal = null ; foreach ( $ minutes as $ key = > $ minute ) { $ mod = $ minute % 10 ; if ( $ mod = = = 0 ) { $ mod = 10 ; } if ( $ minKey = = = null | | $ minVal > $ mod ) { $ minKey = $ key ; $ minVal = $ mod ; } } $ sum = 0 ; foreach ( $ minutes as $ key = > $ minute ) { $ orderTime = toOrderTime ( $ minute ) ; if ( $ key = = = $ minKey ) { $ sum + = $ minute ; } else { $ sum + = $ orderTime ; } } echo $ sum ; function toOrderTime ( $ minute ) { $ mod = $ minute % 10 ; if ( $ mod = = = 0 ) { return $ minute ; } else { return $ minute + 10 - $ mod ; ; } } ? > < ? php $ a = fgets ( STDIN ) ; $ b = fgets ( STDIN ) ; $ c = fgets ( STDIN ) ; $ t = fgets ( STDIN ) ; $ ans = 0 ; for ( $ i = 0 ; $ i < = $ a ; + + $ i ) { for ( $ j = 0 ; $ j < = $ b ; + + $ j ) { for ( $ k = 0 ; $ k < = $ c ; + + $ k ) { if ( ( 500 * $ i ) + ( 100 * $ j ) + ( 50 * $ k ) = = $ t ) { $ ans + + ; } } } } echo $ ans ; ? > < ? php fscanf ( STDIN , ' % d % d ' , $ a , $ b ) ; if ( $ a > = 13 ) { echo $ b , PHP _ EOL ; } elseif ( $ a > = 6 & & $ a < = 12 ) { echo $ b / 2 , PHP _ EOL ; } else { echo 0 , PHP _ EOL ; } < ? php $ s = fgets ( STDIN ) ; if ( $ s [ 2 ] = = = $ s [ 3 ] & $ s [ 4 ] = = = $ s [ 5 ] ) { echo " Yes " ; } else { echo " No " ; } ? > < ? php $ line = fgets ( STDIN ) ; echo $ line * $ line * $ line ; ? > < ? php fscanf ( STDIN , " % d " , $ a ) ; fscanf ( STDIN , " % d " , $ b ) ; fscanf ( STDIN , " % d " , $ c ) ; fscanf ( STDIN , " % d " , $ d ) ; fscanf ( STDIN , " % d " , $ e ) ; fscanf ( STDIN , " % d " , $ k ) ; $ cities = [ $ a , $ b , $ c , $ d , $ e ] ; asort ( $ cities ) ; if ( ( $ cities [ 4 ] - $ cities [ 0 ] ) > $ k ) { echo " : ( \ n " ; } else { echo " Yay ! \ n " ; } < ? php $ grid = array ( 0 = > array ( 0 , 0 , 0 ) , 1 = > array ( 0 , 0 , 0 ) , 2 = > array ( 0 , 0 , 0 ) , ) ; for ( $ i = 0 ; $ i < 3 ; $ i + + ) { $ cins = trim ( fgets ( STDIN ) ) ; $ cin = explode ( " " , $ cins ) ; for ( $ j = 0 ; $ j < 3 ; $ j + + ) { $ grid [ $ i ] [ $ j ] = $ cin [ $ j ] ; } } for ( $ i = 0 ; $ i < 2 ; $ i + + ) { for ( $ j = 0 ; $ j < 2 ; $ j + + ) { if ( $ grid [ $ i + 1 ] [ $ j + 1 ] - $ grid [ 0 ] [ $ j + 1 ] ! = $ grid [ $ i + 1 ] [ 0 ] - $ grid [ 0 ] [ 0 ] ) { $ wrong + + ; } } } for ( $ i = 0 ; $ i < 2 ; $ i + + ) { for ( $ j = 0 ; $ j < 2 ; $ j + + ) { if ( $ grid [ $ i + 1 ] [ $ j + 1 ] - $ grid [ $ i + 1 ] [ 0 ] ! = $ grid [ 0 ] [ $ j + 1 ] - $ grid [ 0 ] [ 0 ] ) { $ wrong + + ; } } } if ( $ wrong ! = 0 ) { echo ( " No " ) ; } else { echo ( " Yes " ) ; } ? > < ? php list ( $ h1 , $ m1 , $ h2 , $ m2 , $ k ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ t1 = $ h1 * 60 + $ m1 ; $ t2 = $ h2 * 60 + $ m2 ; echo ( $ t2 - $ t1 - $ k ) ; < ? php fscanf ( STDIN , " % d " , $ a ) ; fscanf ( STDIN , " % d " , $ b ) ; fscanf ( STDIN , " % d " , $ c ) ; fscanf ( STDIN , " % d " , $ x ) ; $ result = 0 ; for ( $ i1 = 0 ; $ i1 < = $ a ; $ i1 + + ) { for ( $ i2 = 0 ; $ i2 < = $ b ; $ i2 + + ) { for ( $ i3 = 0 ; $ i3 < = $ c ; $ i3 + + ) { if ( ( $ i1 * 500 ) + ( $ i2 * 100 ) + ( $ i3 * 50 ) = = $ x ) { $ result = $ result + 1 ; } } } } echo $ result , " \ n " ; < ? php fscanf ( STDIN , " % d % d " , $ A , $ B ) ; if ( $ A < = 8 & & $ B < = 8 ) { echo " Yay ! " ; } else { echo " : ( " ; } ? > < ? php $ a = trim ( fgets ( STDIN ) ) ; trim ( fgets ( STDIN ) ) ; trim ( fgets ( STDIN ) ) ; trim ( fgets ( STDIN ) ) ; $ e = trim ( fgets ( STDIN ) ) ; $ k = trim ( fgets ( STDIN ) ) ; echo ( $ e - $ a < = $ k ) ? " Yay ! " : " : ( " ; < ? php $ t = new temp ( ) ; $ t - > main ( ) ; unset ( $ t ) ; class temp { private function arrayIn ( ) { return explode ( " " , fgets ( STDIN ) ) ; } public function main ( ) { $ in = $ this - > arrayIn ( ) ; if ( ( $ in [ 0 ] + $ in [ 1 ] ) < $ in [ 2 ] ) { echo " No " ; } else { echo " Yes " ; } } } ? > < ? php $ input = trim ( fgets ( STDIN ) ) ; echo $ input * * 3 ; ? > < ? php $ n = fgets ( STDIN ) ; $ ans = 0 ; for ( $ i = 0 ; pow ( 2 , $ i ) < = $ n ; $ i + + ) { $ ans = max ( pow ( 2 , $ i ) , $ ans ) ; } echo ( $ ans ) ? > < ? php fscanf ( STDIN , ' % d % d ' , $ a , $ b ) ; if ( $ a > = 13 ) { $ result = $ b ; } else if ( $ a > = 6 | | 12 < = $ a ) { $ result = $ b / 2 ; } else { $ result = 0 ; } echo $ result ; ? > < ? php list ( $ A , $ V ) = array _ map ( ' intval ' , explode ( " " , trim ( fgets ( STDIN ) ) ) ) ; list ( $ B , $ W ) = array _ map ( ' intval ' , explode ( " " , trim ( fgets ( STDIN ) ) ) ) ; $ T = ( int ) trim ( fgets ( STDIN ) ) ; $ p = abs ( $ B - $ A ) ; $ d = $ V - $ W ; if ( $ T * $ d > = $ p ) { printf ( " YES \ n " ) ; } else { printf ( " NO \ n " ) ; } < ? php function dfs ( $ first , $ last ) { if ( count ( $ last ) = = = 0 ) { return [ $ first ] ; } $ res = [ ] ; foreach ( $ last as $ key = > $ val ) { $ next _ f = $ first ; $ next _ l = $ last ; $ next _ f [ ] = $ val ; array _ splice ( $ next _ l , $ key , 1 ) ; $ res = array _ merge ( $ res , dfs ( $ next _ f , $ next _ l ) ) ; } return $ res ; } function next _ permutation ( $ start , $ end ) { return dfs ( [ ] , range ( $ start , $ end ) ) ; } fscanf ( STDIN , " % d " , $ n ) ; $ x _ arr = [ ] ; $ y _ arr = [ ] ; for ( $ i = 0 ; $ i < $ n ; + + $ i ) { $ inputs = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ x _ arr [ ] = $ inputs [ 0 ] ; $ y _ arr [ ] = $ inputs [ 1 ] ; } $ perms = next _ permutation ( 1 , $ n ) ; $ sum = 0 ; foreach ( $ perms as $ perm ) { for ( $ i = 0 ; $ i < $ n - 1 ; + + $ i ) { $ a = $ perm [ $ i ] - 1 ; $ b = $ perm [ $ i + 1 ] - 1 ; $ sum + = sqrt ( pow ( $ x _ arr [ $ a ] - $ x _ arr [ $ b ] , 2 ) + pow ( $ y _ arr [ $ a ] - $ y _ arr [ $ b ] , 2 ) ) ; } } function factorial ( $ n ) { if ( $ n = = = 1 ) { return 1 ; } return $ n * factorial ( $ n - 1 ) ; } echo $ sum / factorial ( $ n ) ; < ? php $ x = fgets ( STDIN ) ; echo pow ( $ x , 3 ) , PHP _ EOL ; < ? php $ stdin = trim ( fgets ( STDIN ) ) ; $ arr = explode ( ' ' , $ stdin ) ; $ rslt = ' NO ' ; $ five _ cnt = 0 ; $ sevn _ cnt = 0 ; foreach ( $ arr as $ val ) { if ( $ val = = = ' 5 ' ) { $ five _ cnt + + ; } if ( $ val = = = ' 7 ' ) { $ sevn _ cnt + + ; } } if ( $ five _ cnt = = = 2 & & $ sevn _ cnt = = = 1 ) { $ rslt = ' YES ' ; } echo $ rslt ; ? > < ? php list ( $ a , $ b ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; if ( $ a > = 13 ) { echo $ b ; } else if ( $ a > = 6 ) { echo $ b / 2 ; } else { echo 0 ; } < ? php $ x = trim ( fgets ( STDIN ) ) ; $ x = $ x * $ x * $ x ; echo $ x ; ? > < ? php $ s = trim ( fgets ( STDIN ) ) ; if ( substr ( $ s , 0 , 4 ) < 2019 ) { echo " Heisei " ; } else if ( substr ( $ s , 0 , 4 ) = = 2019 & & intval ( substr ( $ s , 5 , 2 ) ) < = 4 & & intval ( substr ( $ s , 8 , 2 ) ) < = 30 ) { echo " Heisei " ; } else { echo " TBD " ; } < ? php while ( true ) { fscanf ( STDIN , ' % s ' , $ num ) ; if ( $ num = = 0 ) { break ; } $ result [ ] = array _ sum ( str _ split ( $ num ) ) ; } echo implode ( PHP _ EOL , $ result ) , PHP _ EOL ; < ? php while ( fscanf ( STDIN , " % d % d " , $ a , $ b ) > 0 ) { print ( $ a + $ b . " \ n " ) ; } ? > < ? php $ s = trim ( fgets ( STDIN ) ) ; echo $ s * * 2 ; < ? php define ( ' N ' , 3 ) ; $ x = trim ( fgets ( STDIN ) ) ; echo pow ( $ x , N ) . " \ n " ; < ? php echo str _ replace ( ' ? ' , ' D ' , trim ( fgets ( STDIN ) ) ) . " \ n " ; ? > < ? php list ( $ hs , $ ms , $ he , $ me , $ k ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; echo ( $ he - $ hs ) * 60 + $ me - $ ms - $ k ; < ? php list ( $ k , $ s ) = explode ( " " , fgets ( STDIN ) ) ; $ cnt = 0 ; for ( $ x = 0 ; $ x < = $ k ; $ x + + ) { for ( $ y = 0 ; $ y < = $ k ; $ y + + ) { $ z = $ s - $ x - $ y ; if ( 0 < = $ z & & $ z < = $ k ) { $ cnt + + ; } } } echo $ cnt ; ? > < ? php function cubic ( $ x ) { echo $ x * $ x * $ x , PHP _ EOL ; } $ input = trim ( fgets ( STDIN ) ) ; $ x = intval ( $ input ) ; cubic ( $ x ) ; < ? php $ sc = new Scanner ( ) ; $ a = [ ] ; $ b = [ ] ; $ d = [ ] ; $ N = $ sc - > nextInt ( ) ; for ( $ i = 0 ; $ i < $ N ; $ i + + ) { $ a [ ] = $ sc - > nextInt ( ) ; } $ all _ plus = true ; for ( $ i = 0 ; $ i < $ N ; $ i + + ) { $ b [ ] = $ sc - > nextInt ( ) ; $ d [ ] = $ a [ $ i ] - $ b [ $ i ] ; if ( $ d [ $ i ] < 0 ) { $ all _ plus = false ; } } if ( array _ sum ( $ a ) < array _ sum ( $ b ) ) { echo ' -1 ' . PHP _ EOL ; exit ; } if ( $ all _ plus ) { echo 0 . PHP _ EOL ; exit ; } sort ( $ d ) ; $ cnt = 0 ; $ total = 0 ; foreach ( $ d as $ v ) { if ( $ v < 0 ) { $ cnt + + ; $ total + = $ v ; } else { break ; } } for ( $ i = $ N - 1 ; $ i > 0 ; $ i -- ) { $ total + = $ d [ $ i ] ; $ cnt + + ; if ( $ total > = 0 ) { break ; } } echo $ cnt . PHP _ EOL ; class Scanner { private $ arr = [ ] ; private $ count = 0 ; private $ pointer = 0 ; public function next ( ) { if ( $ this - > pointer > = $ this - > count ) { $ str = trim ( fgets ( STDIN ) ) ; $ this - > arr = explode ( ' ' , $ str ) ; $ this - > count = count ( $ this - > arr ) ; $ this - > pointer = 0 ; } $ result = $ this - > arr [ $ this - > pointer ] ; $ this - > pointer + + ; return $ result ; } public function hasNext ( ) { return $ this - > pointer < $ this - > count ; } public function nextInt ( ) { return ( int ) $ this - > next ( ) ; } public function nextDouble ( ) { return ( double ) $ this - > next ( ) ; } } < ? php $ at = new Atcoder ( ) ; $ at - > main ( ) ; unset ( $ at ) ; class Atcoder { private function arrayIn ( ) { $ buf = explode ( " " , fgets ( STDIN ) ) ; return $ this - > killNewLine ( $ buf ) ; } private function killNewLine ( $ buf = null ) { $ buf = str _ replace ( " \ r \ n " , " " , $ buf ) ; $ buf = str _ replace ( " \ n " , " " , $ buf ) ; $ buf = str _ replace ( " \ r " , " " , $ buf ) ; return $ buf ; } public function main ( ) { $ t = $ this - > arrayIn ( ) ; sort ( $ t ) ; $ ans = 0 ; $ ans = $ t [ 2 ] - $ t [ 1 ] ; $ ans + = $ t [ 1 ] - $ t [ 0 ] ; echo $ ans . " \ n " ; } } ? > < ? php $ a = trim ( fgets ( STDIN ) ) ; print ( pow ( $ a , 3 ) ) ; ? > < ? php for ( $ i = 0 ; $ i < 5 ; $ i + + ) { fscanf ( STDIN , " % d " , $ tmp ) ; $ array [ ] = $ tmp ; } fscanf ( STDIN , " % d " , $ K ) ; if ( max ( $ array ) - min ( $ array ) > $ K ) { echo " : ( " ; } else { echo " Yay ! " ; } < ? php $ string = trim ( fgets ( STDIN ) ) ; $ parts = explode ( " " , $ string ) ; $ dogs = $ parts [ 0 ] ; $ monkeys = $ parts [ 1 ] ; if ( abs ( $ dogs - $ monkeys ) > 1 ) { echo " 0 \ n " ; die ( ) ; } if ( $ dogs = = $ monkeys ) { $ result = ( ( mod _ fact ( $ dogs ) * mod _ fact ( $ monkeys ) ) * 2 ) % 1000000007 ; } else { $ result = ( ( mod _ fact ( $ dogs ) * mod _ fact ( $ monkeys ) ) ) % 1000000007 ; } function mod _ fact ( $ num ) { $ ans = 1 ; $ mod = 1000000007 ; for ( $ i = 1 ; $ i < = $ num ; $ i + + ) { $ ans = ( $ ans * $ i ) % $ mod ; } return $ ans ; } echo $ result . " \ n " ; < ? php fscanf ( STDIN , " % d " , $ a ) ; fscanf ( STDIN , " % d " , $ b ) ; fscanf ( STDIN , " % d " , $ c ) ; fscanf ( STDIN , " % d " , $ d ) ; fscanf ( STDIN , " % d " , $ e ) ; fscanf ( STDIN , " % d " , $ k ) ; if ( $ e - $ a > $ k ) { echo ' : ( ' ; } else { echo ' Yay ! ' ; } ? > < ? php fscanf ( STDIN , ' % s ' , $ s ) ; $ a = str _ split ( $ s ) ; if ( $ a [ 2 ] = = $ a [ 3 ] & & $ a [ 4 ] = = $ a [ 5 ] ) { echo " Yes " ; } else { echo " No " ; } < ? php fscanf ( STDIN , " % d " , $ n ) ; $ a = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ au = array _ unique ( $ a ) ; echo ( max ( $ au ) - min ( $ au ) ) . " \ n " ; < ? php fscanf ( STDIN , " % s " , $ S ) ; echo ( $ S [ 2 ] = = = $ S [ 3 ] & & $ S [ 4 ] = = = $ S [ 5 ] ) ? ' Yes ' : ' No ' ; < ? php list ( $ a , $ v ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; list ( $ b , $ w ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ t = trim ( fgets ( STDIN ) ) ; if ( $ a < $ b ) { echo ( $ a + ( $ v * $ t ) > = $ b + ( $ w * $ t ) ) ? " YES " : " NO " ; } else { echo ( $ a - ( $ v * $ t ) < = $ b - ( $ w * $ t ) ) ? " YES " : " NO " ; } < ? php $ input = fgets ( STDIN ) ; print ( pow ( $ input , 3 ) ) ; ? > < ? php $ r = intval ( trim ( fgets ( STDIN ) ) ) ; $ ans = $ r * $ r ; echo $ ans ; ? > < ? php fscanf ( STDIN , " % d % d % d % d " , $ A , $ B , $ H , $ M ) ; $ argH = ( $ H / 12 + $ M / 12 / 60 ) * 2 * pi ( ) ; $ argM = $ M / 60 * 2 * pi ( ) ; $ dx = $ A * cos ( $ argH ) - $ B * cos ( $ argM ) ; $ dy = $ A * sin ( $ argH ) - $ B * sin ( $ argM ) ; printf ( " % .18f " , ( $ dx * * 2 + $ dy * * 2 ) * * 0.5 ) ; < ? php $ a = fgets ( STDIN ) ; $ a = explode ( " " , $ a ) ; $ k = intval ( $ a [ 0 ] ) ; $ s = intval ( $ a [ 1 ] ) ; $ count = 0 ; $ z = 0 ; for ( $ x = 0 ; $ x < = $ k ; $ x + + ) { for ( $ y = 0 ; $ y < = $ k ; $ y + + ) { $ z = $ s - ( $ x + $ y ) ; if ( $ z > = 0 & & $ z < = $ k ) { $ count + + ; } } } echo $ count ; ? > < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; if ( $ a > = 13 ) { echo $ b ; } elseif ( $ a < 13 & & $ a > = 6 ) { echo 0.5 * $ b ; } else { echo 0 ; } < ? php $ s = trim ( fgets ( STDIN ) ) ; echo str _ replace ( ' ? ' , ' D ' , $ s ) ; < ? php fscanf ( STDIN , " % d " , $ N ) ; $ X = explode ( " " , fgets ( STDIN ) ) ; $ X = array _ map ( ' intval ' , $ X ) ; $ mean _ ceil = ceil ( array _ sum ( $ X ) / count ( $ X ) ) ; $ mean _ floor = floor ( array _ sum ( $ X ) / count ( $ X ) ) ; $ ans _ 1 = 0 ; $ ans _ 2 = 0 ; for ( $ i = 0 ; $ i < count ( $ X ) ; $ i + + ) { $ ans _ 1 + = pow ( $ X [ $ i ] - $ mean _ ceil , 2 ) ; $ ans _ 2 + = pow ( $ X [ $ i ] - $ mean _ floor , 2 ) ; } echo min ( $ ans _ 1 , $ ans _ 2 ) ; < ? php $ r = fgets ( STDIN ) ; echo ( int ) ( $ r * $ r ) . " \ n " ; < ? php list ( $ s ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; echo str _ replace ( " ? " , " D " , $ s ) ; < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; if ( 12 < $ a ) { echo $ b ; } else if ( 6 < = $ a | | $ a > = 12 ) { echo $ b / 2 ; } else if ( $ a < = 5 ) { echo 0 ; } < ? php fscanf ( STDIN , " % d " , $ a ) ; fscanf ( STDIN , " % d " , $ b ) ; fscanf ( STDIN , " % d " , $ c ) ; fscanf ( STDIN , " % d " , $ d ) ; fscanf ( STDIN , " % d " , $ e ) ; fscanf ( STDIN , " % d " , $ k ) ; if ( $ b - $ a > $ k ) { echo " : ( \ n " ; } elseif ( $ c - $ a > $ k ) { echo " : ( \ n " ; } elseif ( $ d - $ a > $ k ) { echo " : ( \ n " ; } elseif ( $ e - $ a > $ k ) { echo " : ( \ n " ; } elseif ( $ c - $ b > $ k ) { echo " : ( \ n " ; } elseif ( $ d - $ b > $ k ) { echo " : ( \ n " ; } elseif ( $ e - $ b > $ k ) { echo " : ( \ n " ; } elseif ( $ d - $ c > $ k ) { echo " : ( \ n " ; } elseif ( $ e - $ c > $ k ) { echo " : ( \ n " ; } elseif ( $ e - $ d > $ k ) { echo " : ( \ n " ; } else { echo " Yay ! \ n " ; } ? > < ? php while ( $ stdin = fgets ( STDIN ) ) { $ line [ ] = trim ( $ stdin ) ; } foreach ( $ line as $ key = > $ value ) { $ data [ ] = explode ( ' ' , $ value ) ; } foreach ( $ data as & $ line ) { $ line = array _ map ( function ( $ val ) { return ( int ) $ val ; } , $ line ) ; } $ A = $ data [ 0 ] [ 0 ] ; $ B = $ data [ 0 ] [ 1 ] ; $ C = $ data [ 0 ] [ 2 ] ; $ arr = [ $ A , $ B , $ C ] ; sort ( $ arr ) ; $ is = $ arr [ 0 ] = = = 5 & & $ arr [ 1 ] = = = 5 & & $ arr [ 2 ] = = = 7 ; $ ans = $ is ? ' YES ' : ' NO ' ; printf ( ' % s ' , $ ans ) ; < ? php $ x = trim ( fgets ( STDIN ) ) ; $ a = - 200 ; while ( $ a < 200 ) { $ b = - 200 ; while ( $ b < 200 ) { $ n = ( int ) ( pow ( $ a , 5 ) - pow ( $ b , 5 ) ) ; if ( $ n = = $ x ) { echo " $ a $ b " ; exit ; } + + $ b ; } + + $ a ; } < ? php $ x = ( int ) fgets ( STDIN ) ; echo ( $ x * $ x * $ x ) ; echo ( " \ n " ) ; < ? php $ n = fgets ( STDIN ) ; $ s = 1 ; while ( true ) { if ( $ n < $ s ) { $ s = $ s / 2 ; break ; } elseif ( $ n = = $ s ) { break ; } $ s = $ s * 2 ; } echo $ s ; ? > < ? php fscanf ( STDIN , ' % d ' , $ n ) ; $ in = explode ( ' ' , fgets ( STDIN ) ) ; $ ans ; for ( $ i = 0 ; $ i < 100 ; $ i + + ) { $ sum = 0 ; foreach ( $ in as $ v ) { $ sum + = ( $ v - $ i ) * * 2 ; } $ ans [ ] = $ sum ; } echo min ( $ ans ) , PHP _ EOL ; < ? php fscanf ( STDIN , " % s " , $ s ) ; $ str = str _ replace ( " ? " , " D " , $ s ) ; echo $ str ; < ? php $ n = trim ( fgets ( STDIN ) ) ; $ s = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; echo in _ array ( ' Y ' , $ s ) ? ' Four ' : ' Three ' ; ? > < ? php for ( $ i = 0 ; $ i < 5 ; $ i + + ) { $ s [ $ i ] = trim ( fgets ( STDIN ) ) ; } $ ans = ' Yay ! ' ; $ k = trim ( fgets ( STDIN ) ) ; for ( $ i = 0 ; $ i < 4 ; $ i + + ) { for ( $ j = $ i ; $ j < 5 ; $ j + + ) { $ n = abs ( $ s [ $ i ] - $ s [ $ j ] ) ; if ( $ n > $ k ) { $ ans = ' : ( ' ; break ; } } } echo $ ans ; ? > < ? php fscanf ( STDIN , " % d " , $ fiveHundred ) ; fscanf ( STDIN , " % d " , $ oneHundred ) ; fscanf ( STDIN , " % d " , $ fifty ) ; fscanf ( STDIN , " % d " , $ allMoney ) ; $ ans = 0 ; for ( $ i = 0 ; $ i < = $ fiveHundred ; $ i + + ) { for ( $ j = 0 ; $ j < = $ oneHundred ; $ j + + ) { for ( $ k = 0 ; $ k < = $ fifty ; $ k + + ) { if ( ( $ allMoney - ( 500 * $ i + 100 * $ j + 50 * $ k ) ) = = 0 ) { $ ans + + ; } ; } } } echo $ ans ; < ? php fscanf ( STDIN , " % d " , $ a ) ; echo $ a * $ a ; < ? php echo str _ replace ( ' ? ' , ' D ' , trim ( fgets ( STDIN ) ) ) ; ? > < ? php $ result = array ( ) ; while ( ( $ line = trim ( fgets ( STDIN ) ) ) ! = = ' ' ) { sscanf ( $ line , ' % d , % f , % f ' , $ n , $ kg , $ m ) ; if ( $ kg / pow ( $ m , 2 ) > = 25.0 ) { $ result [ ] = $ n ; } } echo count ( $ result ) > 0 ? implode ( PHP _ EOL , $ result ) : ' 該当なし ' , PHP _ E O L < ? php $ stdin = file _ get _ contents ( ' php : $ line = explode ( " \ n " , $ stdin ) ; $ fi = 0 ; $ cnt = 0 ; $ list = array ( ) ; $ key = new stdclass ( ) ; foreach ( $ line as $ l ) { if ( empty ( $ l ) ) continue ; if ( $ fi = = 0 ) { $ a = explode ( " " , $ l ) ; $ key- > A = $ a [ 0 ] ; $ key- > B = $ a [ 1 ] ; $ key- > C = $ a [ 2 ] ; $ fi + + ; continue ; } if ( $ fi > 0 ) { $ a = explode ( " " , $ l ) ; } } $ a = array ( ) ; $ a [ 5 ] = 0 ; $ a [ 7 ] = 0 ; $ a [ $ key- > A ] = $ a [ $ key- > A ] + 1 ; $ a [ $ key- > B ] = $ a [ $ key- > B ] + 1 ; $ a [ $ key- > C ] = $ a [ $ key- > C ] + 1 ; if ( ( $ a [ 5 ] = = 2 ) & & ( $ a [ 7 ] = = 1 ) ) { printf ( " YES \ n " ) ; } else { printf ( " NO \ n " ) ; } < ? php $ num = fgets ( STDIN ) ; echo pow ( $ num , 3 ) . " \ n " ; < ? PHP $ num = trim ( fgets ( STDIN ) ) ; echo pow ( $ num , 3 ) ; ? > < ? php $ x = trim ( fgets ( STDIN ) ) ; echo $ x * * 3 . PHP _ EOL ; < ? php while ( ( $ line = trim ( fgets ( STDIN ) ) ) ! = = ' ' ) { if ( $ line = = = ' 0 ' ) { break ; } $ arr = str _ split ( $ line ) ; echo array _ sum ( $ arr ) , PHP _ EOL ; } < ? php $ a = trim ( fgets ( STDIN ) ) ; $ b = trim ( fgets ( STDIN ) ) ; $ c = trim ( fgets ( STDIN ) ) ; $ d = trim ( fgets ( STDIN ) ) ; $ e = trim ( fgets ( STDIN ) ) ; $ order = [ $ a , $ b , $ c , $ d , $ e ] ; $ wait = [ ] ; for ( $ i = 0 ; $ i < count ( $ order ) ; $ i + + ) { $ wait [ $ i ] = ceil ( $ order [ $ i ] / 10 ) * 10 - $ order [ $ i ] ; } arsort ( $ wait ) ; $ last = key ( $ wait ) ; asort ( $ wait ) ; $ time = 0 ; foreach ( $ wait as $ w = > $ t ) { if ( $ w ! = $ last ) { $ time + = ceil ( $ order [ $ w ] / 10 ) * 10 ; } else { $ time + = $ order [ $ w ] ; } } echo $ time . " \ n " ; < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; if ( $ a > 12 ) { echo $ b ; } elseif ( 6 < = $ a & & $ a < = 12 ) { echo $ b / 2 ; } else { echo 0 ; } ? > < ? php fscanf ( STDIN , " % d " , $ a ) ; $ search = " % d " ; for ( $ i = 1 ; $ i < $ a ; $ i + + ) { $ search . = " % d " ; } $ list = fscanf ( STDIN , $ search ) ; $ num = 1 ; $ limit = 0 ; foreach ( $ list as $ key = > $ val ) { if ( $ key = = 0 ) { $ limit = $ val ; continue ; } if ( $ limit > $ val ) { $ num + = 1 ; $ limit = $ val ; } } echo $ num ; < ? php fscanf ( STDIN , " % d % d " , $ A , $ B ) ; if ( $ A + $ B < = 16 & & $ A < = 8 & & $ B < = 8 ) { $ ans = " Yay ! " ; } else { $ ans = " : ( " ; } echo $ ans ; ? > < ? php $ a = trim ( fgets ( STDIN ) ) ; $ b = trim ( fgets ( STDIN ) ) ; $ c = trim ( fgets ( STDIN ) ) ; $ d = trim ( fgets ( STDIN ) ) ; $ e = trim ( fgets ( STDIN ) ) ; $ k = trim ( fgets ( STDIN ) ) ; echo $ k > = ( $ e - $ a ) ? " Yay ! " : " : ( " ; ? > < ? php $ mod7 = ( pow ( 10 , 9 ) + 7 ) ; $ N = trim ( fgets ( STDIN ) ) ; $ A = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ cnt = [ ] ; for ( $ i = 0 ; $ i < 60 ; $ i + + ) { $ cnt [ $ i ] = 0 ; } foreach ( $ A as $ outerKey = > $ item ) { for ( $ i = 0 ; $ i < 60 ; $ i + + ) { $ cnt [ $ i ] + = $ item > > $ i & 1 ; } } $ res = 0 ; for ( $ i = 0 ; $ i < 60 ; $ i + + ) { $ tmp = ( $ cnt [ $ i ] * ( $ N - $ cnt [ $ i ] ) ) % $ mod7 ; $ tmp2 = ( 1 < < $ i ) % $ mod7 ; $ tmp = ( $ tmp * $ tmp2 ) % $ mod7 ; $ res = ( $ res + $ tmp ) % $ mod7 ; } echo $ res . PHP _ EOL ; < ? php fscanf ( STDIN , " % d " , $ n ) ; $ floor = floor ( $ n / 15 ) ; $ y = 200 * $ floor ; $ x = 800 * $ n ; echo $ x - $ y ; < ? php fscanf ( STDIN , " % d " , $ n ) ; $ p = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ max = $ n ; $ cnt = 0 ; for ( $ i = 0 ; $ i < count ( $ p ) ; $ i + + ) { if ( $ max > = $ p [ $ i ] ) { $ max = $ p [ $ i ] ; $ cnt + + ; } } echo $ cnt ; ? > < ? php fscanf ( STDIN , " % d % d % d " , $ a [ 0 ] , $ a [ 1 ] , $ a [ 2 ] ) ; sort ( $ a ) ; if ( $ a [ 0 ] = = 5 & & $ a [ 1 ] = = 5 & & $ a [ 2 ] = = 7 ) { echo " YES \ n " ; } else { echo " NO \ n " ; } < ? php fscanf ( STDIN , " % d " , $ A ) ; fscanf ( STDIN , " % d " , $ B ) ; fscanf ( STDIN , " % d " , $ C ) ; fscanf ( STDIN , " % d " , $ X ) ; $ ans = 0 ; $ c500 = min ( $ A , floor ( $ X / 500 ) ) ; for ( $ i = $ c500 ; $ i > = 0 ; $ i -- ) { $ rest1 = $ X - $ i * 500 ; $ c100 = min ( $ B , floor ( $ rest1 / 100 ) ) ; for ( $ j = $ c100 ; $ j > = 0 ; $ j -- ) { $ rest2 = $ rest1 - $ j * 100 ; $ c50 = $ rest2 / 50 ; if ( $ c50 < = $ C ) { $ ans + + ; } } } echo $ ans . " \ n " ; < ? php $ a = fgets ( STDIN ) ; $ b = fgets ( STDIN ) ; $ c = fgets ( STDIN ) ; $ x = fgets ( STDIN ) ; $ r = 0 ; $ tmp = 0 ; for ( $ ia = 0 ; $ ia < = $ a ; $ ia + + ) { for ( $ ib = 0 ; $ ib < = $ b ; $ ib + + ) { for ( $ ic = 0 ; $ ic < = $ c ; $ ic + + ) { $ tmp = $ ia * 500 + $ ib * 100 + $ ic * 50 ; if ( $ tmp = = $ x ) { $ r + + ; continue 2 ; } elseif ( $ tmp > $ x ) { continue 2 ; } } } } echo $ r ; ? > < ? php list ( $ age , $ fee ) = explode ( " " , fgets ( STDIN ) ) ; echo $ fee * check _ discount _ fee ( $ age ) ; echo " \ n " ; function check _ discount _ fee ( $ age ) { if ( $ age > = 13 ) { return 1 ; } elseif ( $ age > = 6 ) { return 0.5 ; } else { return 0 ; } } ? > < ? php $ stdin = trim ( fgets ( STDIN ) ) ; define ( " n " , 3 ) ; echo pow ( $ stdin , n ) ; ? > < ? php for ( $ i = 0 ; $ i < 5 ; $ i + + ) { $ xs [ ] = trim ( fgets ( STDIN ) ) ; } fscanf ( STDIN , ' % d ' , $ k ) ; echo max ( $ xs ) - min ( $ xs ) > $ k ? ' : ( ' : ' Yay ! ' , PHP _ EOL ; < ? php $ s = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; if ( $ s [ 0 ] < = 5 ) { echo 0 ; } else if ( $ s [ 0 ] > = 6 & & $ s [ 0 ] < = 12 ) { echo $ s [ 1 ] / 2 ; } else { echo $ s [ 1 ] ; } ? > < ? php fscanf ( STDIN , " % d " , $ N ) ; $ P = trim ( fgets ( STDIN ) ) ; $ PArray = explode ( ' ' , $ P ) ; $ count = 0 ; $ min = $ PArray [ 0 ] ; for ( $ i = 0 ; $ i < $ N - 1 ; $ i + + ) { if ( $ PArray [ $ i ] > = $ PArray [ $ i + 1 ] & & $ min > $ PArray [ $ i + 1 ] ) { $ count + + ; $ min = $ PArray [ $ i + 1 ] ; } } echo ( $ count + 1 ) ; ? > < ? php $ num500 = trim ( fgets ( STDIN ) ) ; for ( $ i = 0 ; $ i < 3 ; $ i + + ) { $ s = trim ( fgets ( STDIN ) ) ; $ s = str _ replace ( array ( " \ r \ n " , " \ r " , " \ n " ) , ' ' , $ s ) ; $ s = explode ( " " , $ s ) ; if ( $ i = = 0 ) { $ num100 = $ s [ 0 ] ; } else if ( $ i = = 1 ) { $ num50 = $ s [ 0 ] ; } else if ( $ i = = 2 ) { $ sum = $ s [ 0 ] ; } } $ result = 0 ; for ( $ a = 0 ; $ a < = $ num500 ; $ a + + ) { for ( $ b = 0 ; $ b < = $ num100 ; $ b + + ) { for ( $ c = 0 ; $ c < = $ num50 ; $ c + + ) { $ total = ( 500 * $ a ) + ( 100 * $ b ) + ( 50 * $ c ) ; if ( $ sum = = $ total ) { $ result + + ; } } } } echo $ result ; ? > < ? php list ( $ a _ point , $ a _ move ) = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; list ( $ b _ point , $ b _ move ) = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ time = trim ( fgets ( STDIN ) ) ; if ( $ a _ move < = $ b _ move ) { echo ' NO ' ; exit ; } if ( abs ( $ a _ point - $ b _ point ) < = abs ( $ a _ move - $ b _ move ) * $ time ) { echo ' YES ' ; exit ; } echo ' NO ' ; exit ; ? > < ? php fscanf ( STDIN , " % s " , $ date ) ; $ date = str _ replace ( ' / ' , ' ' , $ date ) ; if ( $ date < = 20190430 ) { echo " Heisei " ; } else { echo " TBD " ; } ? > < ? php while ( 1 ) { $ a = trim ( fgets ( STDIN ) ) ; if ( $ a = = 0 ) break ; $ num = str _ split ( $ a ) ; echo array _ sum ( $ num ) , PHP _ EOL ; } < ? php fscanf ( STDIN , " % d % d " , $ K , $ S ) ; $ res = 0 ; for ( $ i = 0 ; $ i < = $ K ; $ i + + ) { for ( $ j = 0 ; $ j < = $ K ; $ j + + ) { $ k = $ S - $ i - $ j ; if ( $ k < 0 | | $ k > $ K ) { continue ; } $ res + + ; } } print " $ res \ n " ; < ? php fscanf ( STDIN , " % d % d " , $ k , $ s ) ; $ c = 0 ; $ min = max ( 0 , $ s - $ k * 2 ) ; for ( $ x = $ min ; $ x < = $ k ; $ x + + ) { $ s1 = $ s - $ x ; if ( $ s1 < 0 ) break ; $ c + = $ s1 - max ( 0 , $ s1 - $ k ) * 2 + 1 ; } echo $ c ; < ? php $ input = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ a = $ input [ 0 ] ; $ b = $ input [ 1 ] ; $ h = $ input [ 2 ] ; $ m = $ input [ 3 ] ; $ long = 6 * $ m ; $ short = 30 * $ h + $ m / 2 ; $ alpha = 0 ; if ( $ long > $ short ) { $ alpha = $ long - $ short ; } else { $ alpha = $ short - $ long ; } if ( $ alpha > 180 ) { $ alpha = 360 - $ alpha ; } $ powc = pow ( $ a , 2 ) + pow ( $ b , 2 ) - 2 * $ a * $ b * cos ( deg2rad ( $ alpha ) ) ; $ c = sqrt ( $ powc ) ; echo $ c ; ? > < ? php $ a = trim ( fgets ( STDIN ) ) ; $ b = trim ( fgets ( STDIN ) ) ; $ c = trim ( fgets ( STDIN ) ) ; $ x = trim ( fgets ( STDIN ) ) ; $ cnt = 0 ; for ( $ i = 0 ; $ i < = $ a ; $ i + + ) { for ( $ j = 0 ; $ j < = $ b ; $ j + + ) { for ( $ k = 0 ; $ k < = $ c ; $ k + + ) { if ( 500 * $ i + 100 * $ j + 50 * $ k = = $ x ) { $ cnt + + ; } } } } echo $ cnt ; < ? php $ a = [ ] ; fscanf ( STDIN , " % d % d % d " , $ a [ 0 ] , $ a [ 1 ] , $ a [ 2 ] ) ; sort ( $ a ) ; if ( $ a [ 0 ] = = 5 & & $ a [ 1 ] = = 5 & & $ a [ 2 ] = = 7 ) { echo " YES \ n " ; } else { echo " NO \ n " ; } < ? php $ inputs = explode ( " " , file _ get _ contents ( " php : $ inputs = array _ map ( intval , $ inputs ) ; list ( $ a , $ b ) = $ inputs ; if ( $ a = = = $ b ) { echo " Draw " ; } else if ( ( $ a ! = = 1 & & $ a < $ b ) | | $ b = = 1 ) { echo " Bob " ; } else { echo " Alice " ; } < ? php $ N = fgets ( STDIN ) ; $ Xs = fgets ( STDIN ) ; $ X = array ( ) ; $ format = " % d " ; $ formated = " " ; for ( $ i = 0 ; $ i < $ N ; $ i + + ) { $ formated = $ formated . ' ' . $ format ; } $ X = sscanf ( $ Xs , $ formated ) ; $ min = 50000000000 ; $ sum = 0 ; for ( $ p = 0 ; $ p < = 100 ; $ p + + ) { for ( $ i = 0 ; $ i < $ N ; $ i + + ) { $ sum + = ( ( ( int ) $ X [ $ i ] - $ p ) * * 2 ) ; } if ( ( $ min > $ sum ) & & ( $ sum > = 0 ) ) { $ min = $ sum ; } $ sum = 0 ; } echo $ min ; < ? php fscanf ( STDIN , " % d " , $ a ) ; fscanf ( STDIN , " % d " , $ b ) ; fscanf ( STDIN , " % d " , $ c ) ; fscanf ( STDIN , " % d " , $ x ) ; $ ans = 0 ; for ( $ i = 0 ; $ i < = $ a ; $ i + + ) { for ( $ j = 0 ; $ j < = $ b ; $ j + + ) { for ( $ k = 0 ; $ k < = $ c ; $ k + + ) { $ selectCoin = $ i * 500 + $ j * 100 + $ k * 50 ; if ( $ selectCoin = = = $ x ) { $ ans + + ; } } } } echo $ ans ; < ? php $ t = new temp ( ) ; $ t - > stdin ( fgets ( STDIN ) ) ; $ t - > run ( ) ; unset ( $ t ) ; class temp { private $ stdin = array ( ) ; public function _ _ construct ( ) { } public function stdin ( $ data = null ) { $ this - > stdin = explode ( " " , $ data ) ; } public function run ( ) { $ num = ( $ this - > stdin [ 0 ] + $ this - > stdin [ 1 ] ) / 2 ; $ num = ceil ( $ num ) ; echo $ num ; } } ? > < ? php $ inputs = [ ] ; for ( $ i = 0 ; $ i < 5 ; + + $ i ) { $ inputs [ ] = trim ( fgets ( STDIN ) ) ; } $ min1 = substr ( $ inputs [ 0 ] , - 1 ) ; $ min _ index = 0 ; for ( $ i = 1 ; $ i < 5 ; + + $ i ) { $ last = substr ( $ inputs [ $ i ] , - 1 ) ; if ( $ last ! = 0 & & $ last < $ min1 ) { $ min1 = $ last ; $ min _ index = $ i ; } } $ result = 0 ; for ( $ i = 0 ; $ i < 5 ; + + $ i ) { if ( $ i = = = $ min _ index ) { continue ; } $ result + = ceil ( $ inputs [ $ i ] / 10 ) * 10 ; } $ result + = $ inputs [ $ min _ index ] ; echo $ result ; < ? php list ( $ max , $ sum ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ x = 0 ; $ y = 0 ; $ z = 0 ; $ count = 0 ; $ rest = 0 ; for ( $ x = 0 ; $ x < = $ max ; $ x + + ) { $ rest = $ sum - $ x ; if ( $ rest < = 2 * $ max & & $ rest > = 0 ) { $ makkusu = min ( $ rest , $ max ) ; $ min = $ rest - $ makkusu ; $ tasu = $ makkusu - $ min + 1 ; $ count + = $ tasu ; } } echo $ count ; ? > < ? php $ N = intval ( trim ( fgets ( STDIN ) ) ) ; $ X _ array = array _ map ( ' intval ' , explode ( " " , trim ( fgets ( STDIN ) ) ) ) ; $ sum = INF ; for ( $ X = 1 ; $ X < = 100 ; $ X + + ) { $ ans = 0 ; for ( $ i = 0 ; $ i < count ( $ X _ array ) ; $ i + + ) { $ ans = $ ans + ( $ X _ array [ $ i ] - $ X ) * * 2 ; } if ( $ sum > $ ans ) { $ sum = $ ans ; } } echo $ sum . " \ n " ; ? > < ? php fscanf ( STDIN , " % d % d " , $ N , $ D ) ; for ( $ i = 0 ; $ i < $ N ; $ i + + ) { $ X [ $ i ] = array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; } $ count = 0 ; for ( $ i = 0 ; $ i < $ N - 1 ; $ i + + ) { for ( $ j = $ i + 1 ; $ j < $ N ; $ j + + ) { $ distance = 0 ; for ( $ k = 0 ; $ k < $ D ; $ k + + ) { $ distance + = pow ( abs ( $ X [ $ i ] [ $ k ] - $ X [ $ j ] [ $ k ] ) , 2 ) ; } if ( is _ pythagoras ( $ distance ) ) $ count + + ; } } echo $ count , PHP _ EOL ; function is _ pythagoras ( $ number ) { for ( $ i = 0 ; pow ( $ i , 2 ) < = $ number ; $ i + + ) { if ( pow ( $ i , 2 ) = = = $ number ) return true ; } return false ; } < ? php fscanf ( STDIN , " % d " , $ a ) ; fscanf ( STDIN , " % d " , $ b ) ; fscanf ( STDIN , " % d " , $ c ) ; fscanf ( STDIN , " % d " , $ d ) ; fscanf ( STDIN , " % d " , $ e ) ; fscanf ( STDIN , " % d " , $ k ) ; if ( ( $ e - $ a ) > $ k ) { echo ' : ( ' ; } else { echo ' Yay ! ' ; } < ? php list ( $ A , $ B , $ C ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; if ( $ A + $ B > = $ C ) { echo ' Yes ' ; } else { echo ' No ' ; } < ? php list ( $ S ) = sscanf ( trim ( fgets ( STDIN ) ) , " % d " ) ; printf ( $ S * * 2 ) ; < ? php while ( $ a = array _ sum ( str _ split ( trim ( fgets ( STDIN ) ) ) ) ) echo $ a . PHP _ EOL ; < ? php $ ns = explode ( ' ' , fgets ( STDIN ) ) ; echo $ ns [ 0 ] + $ ns [ 1 ] > = $ ns [ 2 ] ? ' Yes ' : ' No ' ; ? > < ? php $ input = fgets ( STDIN ) ; echo $ output = $ input * $ input * $ input ; ? > < ? php fscanf ( STDIN , " % d " , $ n ) ; $ s = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; echo count ( array _ unique ( $ s ) ) = = 3 ? ' Three ' : ' Four ' ; < ? php fscanf ( STDIN , ' % d % d ' , $ a , $ b ) ; echo $ a < 9 & & $ b < 9 ? ' Yay ! ' : ' : ( ' ; < ? php fscanf ( STDIN , " % d % d " , $ b , $ c ) ; if ( $ b > = 13 ) { echo $ c ; } elseif ( $ b > = 6 & & $ b < = 12 ) { echo $ c / 2 ; } elseif ( $ b < = 5 ) { echo 0 ; } ? > < ? php $ x = trim ( fgets ( STDIN ) ) ; echo $ x * $ x * $ x . " \ n " ; ? > < ? php $ s = trim ( fgets ( STDIN ) ) ; if ( $ s [ 2 ] = = $ s [ 3 ] & & $ s [ 4 ] = = $ s [ 5 ] ) { print ( ' Yes ' ) ; } else { print ( " No " ) ; } < ? php fscanf ( STDIN , " % d % d " , $ a , $ v ) ; fscanf ( STDIN , " % d % d " , $ b , $ w ) ; fscanf ( STDIN , " % d " , $ t ) ; if ( $ v > $ w & & abs ( $ a - $ b ) < = ( $ v - $ w ) * $ t ) { echo " YES " ; } else { echo " NO " ; } < ? php $ n = int ( ) ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { list ( $ a [ ] , $ b [ ] ) = ints ( ) ; } $ sum = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { for ( $ j = 0 ; $ j < $ n ; $ j + + ) { if ( $ i ! = $ j ) { $ sum + = $ l [ $ i ] [ $ j ] = sqrt ( ( $ a [ $ i ] - $ a [ $ j ] ) * * 2 + ( $ b [ $ i ] - $ b [ $ j ] ) * * 2 ) ; } } } echo $ sum / $ n ; function str ( ) { return trim ( fgets ( STDIN ) ) ; } function ints ( ) { return array _ map ( " intval " , explode ( " " , trim ( fgets ( STDIN ) ) ) ) ; } function int ( ) { return intval ( trim ( fgets ( STDIN ) ) ) ; } function o ( ... $ val ) { if ( count ( $ val ) = = 1 ) $ val = array _ shift ( $ val ) ; $ trace = debug _ backtrace ( ) ; echo $ trace [ 0 ] [ ' line ' ] . " ) " ; if ( is _ array ( $ val ) ) { if ( count ( $ val ) = = 0 ) { echo " empty array " ; } elseif ( ! is _ array ( current ( $ val ) ) ) { echo " array : " ; echo implode ( " " , $ val ) . " \ n " ; } else { echo " array : array \ n " ; foreach ( $ val as $ row ) { echo implode ( " " , $ row ) . " \ n " ; } } } else { echo $ val . " \ n " ; } } < ? php fscanf ( STDIN , " % d " , $ N ) ; $ num = array _ sum ( str _ split ( $ N ) ) ; echo $ N % $ num ? ' No ' : ' Yes ' ; ? > < ? php $ X = ( int ) fgets ( STDIN ) ; for ( $ b = - 100 ; $ b < 1000 ; $ b + + ) { $ pow _ b = - pow ( $ b , 5 ) ; if ( $ pow _ b = = = $ X ) { echo 0 . ' ' . $ b ; exit ; } if ( $ pow _ b > $ X ) { continue ; } for ( $ a = 0 ; $ a < 1000 ; $ a + + ) { $ pow _ a = pow ( $ a , 5 ) ; $ sum = $ pow _ a + $ pow _ b ; if ( $ sum = = = $ X ) { echo $ a . ' ' . $ b ; exit ; } if ( $ sum > $ X ) { break ; } } } < ? php fscanf ( STDIN , ' % s ' , $ s ) ; $ ans = ' No ' ; if ( ( substr ( $ s , 2 , 1 ) = = = substr ( $ s , 3 , 1 ) ) & & ( substr ( $ s , 4 , 1 ) = = = substr ( $ s , 5 , 1 ) ) ) { $ ans = ' Yes ' ; } echo $ ans . PHP _ EOL ; ? > < ? php $ s = trim ( fgets ( STDIN ) ) ; if ( strtotime ( $ s ) < = strtotime ( ' 2019 / 04 / 30 ' ) ) { echo ' Heisei ' , PHP _ EOL ; } else { echo ' TBD ' , PHP _ EOL ; } < ? php $ l = trim ( fgets ( STDIN ) ) ; list ( $ a , $ v ) = explode ( " " , $ l ) ; $ l = trim ( fgets ( STDIN ) ) ; list ( $ b , $ w ) = explode ( " " , $ l ) ; $ t = trim ( fgets ( STDIN ) ) ; $ d = $ a < $ b ? 1 : - 1 ; $ oni = $ a + $ v * $ t * $ d ; $ ko = $ b + $ w * $ t * $ d ; if ( ( $ a < $ b & & $ oni > = $ ko ) | | ( $ a > $ b & & $ oni < = $ ko ) ) { echo " YES \ n " ; } else { echo " NO \ n " ; } < ? php $ arr = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; $ a = $ arr [ 0 ] ; $ b = $ arr [ 1 ] ; $ H = $ arr [ 2 ] ; $ M = $ arr [ 3 ] ; $ hk = ( ( $ H * 60 + $ M ) / 720 ) * 360 ; $ mk = ( $ M / 60 ) * 360 ; $ k = deg2rad ( abs ( $ hk - $ mk ) ) ; $ ret = sqrt ( ( $ a * $ a ) + ( $ b * $ b ) - ( 2 * $ a * $ b * cos ( $ k ) ) ) ; echo $ ret ; return ; ? > < ? php fscanf ( STDIN , " % d " , $ x ) ; echo pow ( $ x , 3 ) ; echo " \ n " ; < ? php fscanf ( STDIN , ' % d % d % d % d ' , $ a , $ b , $ c , $ d ) ; echo max ( $ a * $ b , $ c * $ d ) ; echo PHP _ EOL ; < ? php while ( true ) { $ val = str _ split ( trim ( fgets ( STDIN ) ) ) ; if ( $ val [ 0 ] = = 0 ) { break ; } echo array _ sum ( $ val ) . PHP _ EOL ; } < ? php list ( $ a , $ b , $ c , $ d ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ ab = $ a * $ b ; $ cd = $ c * $ d ; if ( $ ab > = $ cd ) { echo $ ab ; } else { echo $ cd ; } ? > < ? php $ input = explode ( " " , fgets ( STDIN ) ) ; $ sumA = $ input [ 0 ] * $ input [ 1 ] ; $ sumB = $ input [ 2 ] * $ input [ 3 ] ; if ( $ sumA > = $ sumB ) { echo $ sumA ; } else { echo $ sumB ; } ? > < ? php $ n = trim ( fgets ( STDIN ) ) ; $ arr = explode ( " " , trim ( fgets ( STDIN ) ) ) ; sort ( $ arr ) ; $ min = 0 ; $ total = 0 ; for ( $ i = $ arr [ 0 ] ; $ i < = $ arr [ $ n - 1 ] ; $ i + + ) { for ( $ j = 0 ; $ j < $ n ; $ j + + ) { $ total + = ( $ arr [ $ j ] - $ i ) * ( $ arr [ $ j ] - $ i ) ; } if ( $ i = = $ arr [ 0 ] ) { $ min = $ total ; } elseif ( $ min > $ total ) { $ min = $ total ; } $ total = 0 ; } echo $ min ; ? > < ? php $ n = trim ( fgets ( STDIN ) ) ; $ max = 0 ; $ max _ i = 0 ; for ( $ i = 1 ; $ i < = $ n ; $ i + + ) { $ j = $ i ; $ count = 0 ; while ( $ j % 2 = = = 0 ) { $ j = $ j / 2 ; $ count + + ; } if ( $ count > = $ max ) { $ max = $ count ; $ max _ i = $ i ; } } print $ max _ i ; < ? php fscanf ( STDIN , " % d " , $ a ) ; fscanf ( STDIN , " % d " , $ b ) ; fscanf ( STDIN , " % d " , $ c ) ; fscanf ( STDIN , " % d " , $ d ) ; fscanf ( STDIN , " % d " , $ e ) ; fscanf ( STDIN , " % d " , $ k ) ; $ arr = [ $ a , $ b , $ c , $ d , $ e ] ; for ( $ i = 0 ; $ i < = 3 ; $ i + + ) { for ( $ j = $ i + 1 ; $ j < = 4 ; $ j + + ) { if ( $ arr [ $ j ] - $ arr [ $ i ] > $ k ) { echo " : ( " ; exit ; } } } echo " Yay ! " ; ? > < ? php $ sc = new Scanner ( ) ; $ f = [ ' 1 ' = > false , ' 9 ' = > false , ' 7 ' = > false , ' 4 ' = > false , ] ; for ( $ i = 0 ; $ i < 4 ; $ i + + ) { $ t = $ sc - > nextInt ( ) ; if ( $ f [ $ t ] ) { echo ' NO ' . PHP _ EOL ; exit ; } $ f [ $ t ] = true ; } foreach ( $ f as $ v ) { if ( ! $ v ) { echo ' NO ' . PHP _ EOL ; exit ; } } echo ' YES ' . PHP _ EOL ; exit ; class Scanner { private $ arr = [ ] ; private $ count = 0 ; private $ pointer = 0 ; public function next ( ) { if ( $ this - > pointer > = $ this - > count ) { $ str = trim ( fgets ( STDIN ) ) ; $ this - > arr = explode ( ' ' , $ str ) ; $ this - > count = count ( $ this - > arr ) ; $ this - > pointer = 0 ; } $ result = $ this - > arr [ $ this - > pointer ] ; $ this - > pointer + + ; return $ result ; } public function hasNext ( ) { return $ this - > pointer < $ this - > count ; } public function nextInt ( ) { return ( int ) $ this - > next ( ) ; } public function nextDouble ( ) { return ( double ) $ this - > next ( ) ; } } < ? php fscanf ( STDIN , " % d " , $ N ) ; $ numbers = array _ sum ( str _ split ( $ N ) ) ; if ( $ N % $ numbers = = = 0 ) { echo ' Yes ' ; } else { echo ' No ' ; } < ? php fscanf ( STDIN , " % d " , $ n ) ; $ y = floor ( $ n / 15 ) * 200 ; $ x = $ n * 800 ; echo $ x - $ y ; < ? php $ input = explode ( ' ' , trim ( fgets ( ( STDIN ) ) ) ) ; $ counted = array _ count _ values ( $ input ) ; print ( $ counted [ 5 ] = = 2 ) & & ( $ counted [ 7 ] = = 1 ) ? ' YES ' : ' NO ' ; < ? php echo pow ( trim ( fgets ( STDIN ) ) , 3 ) ; ? > < ? php $ n = readline ( ) ; $ sor = readline ( ) ; $ ex = explode ( " " , $ sor ) ; $ avg = 0 ; $ sum = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ sum = $ sum + $ ex [ $ i ] ; } $ avg = $ sum / $ n ; $ fel = ceil ( $ avg ) ; $ le = floor ( $ avg ) ; $ pFel = 0 ; $ pLe = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ pFel = $ pFel + ( ( $ ex [ $ i ] - $ fel ) * ( $ ex [ $ i ] - $ fel ) ) ; $ pLe = $ pLe + ( ( $ ex [ $ i ] - $ le ) * ( $ ex [ $ i ] - $ le ) ) ; } if ( $ pLe < $ pFel ) { echo $ pLe ; } else { echo $ pFel ; } < ? php $ input = fgets ( STDIN ) ; $ array = explode ( " " , $ input ) ; $ ans = " " ; foreach ( $ array as $ value ) { if ( $ value = = 5 | | $ value = = 7 ) { $ ans + = $ value ; } } echo ( $ ans = = 17 ? " YES " : " NO " ) ; < ? php $ x = intval ( fgets ( STDIN ) ) ; echo $ x * $ x * $ x ; ? > < ? php $ menu = [ ] ; for ( $ i = 0 ; $ i < 5 ; $ i + + ) { fscanf ( STDIN , " % d " , $ input ) ; $ key = ( $ input % 10 = = 0 ) ? 10 : ( $ input % 10 ) ; $ menu [ ] = [ ' key ' = > $ key , ' value ' = > $ input , ] ; } usort ( $ menu , function ( $ a , $ b ) { return $ a [ ' key ' ] - $ b [ ' key ' ] ; } ) ; $ t = 0 ; foreach ( array _ slice ( $ menu , 1 , 4 ) as $ m ) { $ t = $ t + ( ( int ) ( ( $ m [ ' value ' ] + 9 ) / 10 ) ) * 10 ; } $ t = $ t + $ menu [ 0 ] [ ' value ' ] ; echo $ t . " \ n " ; < ? php define ( ' N ' , 3 ) ; $ x = trim ( fgets ( STDIN ) ) ; echo pow ( $ x , N ) . " \ n " ; < ? php $ x = trim ( fgets ( STDIN ) ) ; echo $ x * $ x * $ x ; ? > < ? php fscanf ( STDIN , " % d % d " , $ n , $ m ) ; $ d = $ n - $ m + 1 ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { fscanf ( STDIN , " % s " , $ a [ ] ) ; } for ( $ i = 0 ; $ i < $ m ; $ i + + ) { fscanf ( STDIN , " % s " , $ s ) ; $ b [ ] = str _ replace ( ' . ' , ' \ . ' , $ s ) ; } $ a = implode ( ' / ' , $ a ) ; $ b = implode ( ' . { ' . $ d . ' } ' , $ b ) ; echo preg _ match ( " / $ b / " , $ a ) ? ' Yes ' : ' No ' ; < ? php list ( $ s ) = strs ( ) ; list ( $ k ) = ints ( ) ; for ( $ i = 0 ; $ i < 26 ; + + $ i ) $ a2n [ chr ( 97 + $ i ) ] = $ i ; $ n = strlen ( $ s ) ; for ( $ i = 0 ; $ i < $ n ; + + $ i ) { $ x = $ a2n [ $ s [ $ i ] ] ; if ( $ x = = = 0 ) continue ; if ( $ k > = 26 - $ x ) { $ s [ $ i ] = ' a ' ; $ k - = 26 - $ x ; } } if ( $ k > 0 ) $ s [ $ n - 1 ] = chr ( 97 + ( $ a2n [ $ s [ $ n - 1 ] ] + $ k ) % 26 ) ; echo $ s . PHP _ EOL ; function ints ( ) { return array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; } function strs ( ) { return explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; } < ? php $ n = trim ( fgets ( STDIN ) ) ; $ s = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ kind = [ ] ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ kind [ ] = $ s [ $ i ] ; } $ k = count ( array _ unique ( $ kind ) ) ; if ( $ k = = 3 ) { echo " Three \ n " ; } else { echo " Four \ n " ; } < ? php do { $ input = preg _ split ( ' if ( 0 = = $ input [ 0 ] ) { break ; } $ cnt = count ( $ input ) ; $ sum = 0 ; for ( $ loop _ cnt = 0 ; $ loop _ cnt < $ cnt ; $ loop _ cnt + + ) { $ sum + = $ input [ $ loop _ cnt ] ; } echo $ sum . " \ n " ; } while ( 1 ) ; ? > < ? php $ s = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; echo $ s [ 0 ] < = 8 & & $ s [ 1 ] < = 8 ? ' Yay ! ' : ' : ( ' ; ? > < ? php $ is _ honban = true ; if ( $ is _ honban ) { $ sc = new Scanner ( ) ; $ a = $ sc - > nextInt ( ) ; $ b = $ sc - > nextInt ( ) ; $ c = $ sc - > nextInt ( ) ; $ x = $ sc - > nextInt ( ) ; } else { error _ reporting ( E _ ERROR | E _ WARNING | E _ PARSE ) ; $ a = 30 ; $ b = 40 ; $ c = 50 ; $ x = 6000 ; } $ ans = 0 ; for ( $ i = 0 ; $ i < = $ a ; $ i + + ) { for ( $ j = 0 ; $ j < = $ b ; $ j + + ) { for ( $ k = 0 ; $ k < = $ c ; $ k + + ) { if ( $ i * 500 + $ j * 100 + $ k * 50 = = $ x ) { $ ans + + ; } } } } out : : println ( $ ans ) ; class Scanner { private $ arr = array ( ) ; private $ count = 0 ; private $ pointer = 0 ; public function next ( ) { if ( $ this - > pointer > = $ this - > count ) { $ str = trim ( fgets ( STDIN ) ) ; $ this - > arr = explode ( ' ' , $ str ) ; $ this - > count = count ( $ this - > arr ) ; $ this - > pointer = 0 ; } $ result = $ this - > arr [ $ this - > pointer ] ; $ this - > pointer + + ; return $ result ; } public function hasNext ( ) { return $ this - > pointer < $ this - > count ; } public function nextInt ( ) { return ( int ) $ this - > next ( ) ; } public function nextDouble ( ) { return ( double ) $ this - > next ( ) ; } } class out { public static function println ( $ str = " " ) { echo $ str . PHP _ EOL ; } } ? > < ? php fscanf ( STDIN , " % d % d % d " , $ a , $ b , $ c ) ; echo $ a + $ b > = $ c ? ' Yes ' : ' No ' ; < ? php $ n = trim ( fgets ( STDIN ) ) ; $ a = explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; sort ( $ a ) ; echo $ a [ $ n - 1 ] - $ a [ 0 ] ; ? > < ? php $ line = fgets ( STDIN ) ; if ( in _ array ( $ line , [ " 5 5 7 \ n " , " 5 7 5 \ n " , " 7 5 5 \ n " , ] , true , ) ) { echo " YES " ; } else { echo " NO " ; } < ? php $ input = trim ( fgets ( STDIN ) ) ; list ( $ n , $ m ) = explode ( ' ' , $ input ) ; $ inputs = [ ] ; $ count = 0 ; while ( $ count < $ m ) { $ input = trim ( fgets ( STDIN ) ) ; list ( $ p , $ y ) = explode ( ' ' , $ input ) ; $ inputs [ $ p ] [ $ y ] = $ count ; $ count + + ; } $ results = [ ] ; foreach ( $ inputs as $ p = > $ input ) { ksort ( $ input ) ; $ cities = array _ values ( $ input ) ; $ id = 1 ; foreach ( $ cities as $ i = > $ count ) { $ results [ $ count ] [ ' p ' ] = $ p ; $ results [ $ count ] [ ' c ' ] = $ id ; $ id + + ; } } ksort ( $ results ) ; foreach ( $ results as $ result ) { echo str _ pad ( ( string ) $ result [ ' p ' ] , 6 , " 0 " , STR _ PAD _ LEFT ) . str _ pad ( ( string ) $ result [ ' c ' ] , 6 , " 0 " , STR _ PAD _ LEFT ) . " \ n " ; } < ? php $ antennas = [ ] ; for ( $ i = 0 ; $ i < 5 ; + + $ i ) { $ antennas [ ] = trim ( fgets ( STDIN ) ) ; } fscanf ( STDIN , " % d " , $ k ) ; $ result = true ; for ( $ i = 0 ; $ i < 4 ; + + $ i ) { for ( $ j = $ i + 1 ; $ j < 5 ; + + $ j ) { if ( $ antennas [ $ j ] - $ antennas [ $ i ] > $ k ) { $ result = false ; break ; } } } echo $ result ? ' Yay ! ' : ' : ( ' ; < ? php fscanf ( STDIN , " % d % d % d " , $ a , $ b , $ c ) ; $ p1 = abs ( $ b - $ a ) + abs ( $ c - $ b ) ; $ p2 = abs ( $ c - $ a ) + abs ( $ b - $ c ) ; $ p3 = abs ( $ a - $ b ) + abs ( $ c - $ a ) ; $ p4 = abs ( $ c - $ b ) + abs ( $ a - $ c ) ; $ p5 = abs ( $ a - $ c ) + abs ( $ b - $ a ) ; $ p6 = abs ( $ b - $ c ) + abs ( $ a - $ b ) ; echo min ( $ p1 , $ p2 , $ p3 , $ p4 , $ p5 , $ p6 ) . PHP _ EOL ; < ? php # B - Good Distance fscanf ( STDIN , " % d % d " , $ N , $ D ) ; $ array = [ ] ; for ( $ i = 0 ; $ i < $ N ; $ i + + ) { $ array [ ] = explode ( ' ' , fgets ( STDIN ) ) ; } $ count = 0 ; for ( $ i = 0 ; $ i < $ N-1 ; $ i + + ) { for ( $ j = $ i + 1 ; $ j < $ N ; $ j + + ) { $ sum = 0 ; for ( $ k = 0 ; $ k < $ D ; $ k + + ) { $ sum + = abs ( intval ( $ array [ $ i ] [ $ k ] ) - intval ( $ array [ $ j ] [ $ k ] ) ) * abs ( intval ( $ array [ $ i ] [ $ k ] ) - intval ( $ array [ $ j ] [ $ k ] ) ) ; } if ( is _ decimal ( sqrt ( $ sum ) ) & & $ sum ! = 0 ) { $ count + + ; } } } echo $ count . PHP _ EOL ; function is _ decimal ( $ value ) { return filter _ var ( $ value , FILTER _ VALIDATE _ INT ) ! = = false ; } < ? php # 入力 list ( $ n , $ d ) = array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ x [ ] = array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; } $ cnt = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { for ( $ j = $ i + 1 ; $ j < $ n ; $ j + + ) { if ( is _ decimal ( distance ( $ x [ $ i ] , $ x [ $ j ] ) ) ) { $ cnt + + ; } } } echo $ cnt.PHP _ EOL ; function distance ( $ yi , $ zi ) { $ sum = 0 ; foreach ( $ yi as $ j = > $ v ) { $ sum + = ( $ yi [ $ j ] - $ zi [ $ j ] ) * * 2 ; } return sqrt ( $ sum ) ; } function is _ decimal ( $ v ) { return ( string ) ( int ) $ v = = = ( string ) $ v ; } ? > < ? php list ( $ n , $ m ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ s = [ ] ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { list ( $ s [ ] ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; } $ t = [ ] ; for ( $ i = 0 ; $ i < $ m ; $ i + + ) { list ( $ t [ ] ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; } $ sa = $ n - $ m ; for ( $ i = 0 ; $ i < = $ sa ; $ i + + ) { for ( $ j = 0 ; $ j < = $ sa ; $ j + + ) { $ icchi = true ; for ( $ k = 0 ; $ k < $ m ; $ k + + ) { for ( $ l = 0 ; $ l < $ m ; $ l + + ) { if ( $ t [ $ k ] [ $ l ] ! = $ s [ $ k + $ i ] [ $ l + $ j ] ) { $ icchi = false ; } } } if ( $ icchi ) { echo " Yes " ; exit ; } } } echo " No " ; < ? php fscanf ( STDIN , ' % s ' , $ a ) ; if ( strcmp ( $ a [ 2 ] , $ a [ 3 ] ) = = 0 & & strcmp ( $ a [ 4 ] , $ a [ 5 ] ) = = 0 ) { echo ( " Yes " ) ; } else { echo ( " No " ) ; } ? > < ? php fscanf ( STDIN , " % d " , $ in _ r ) ; $ menseki = $ in _ r * $ in _ r ; echo " $ menseki \ n " ; ? > < ? php $ a = fgets ( STDIN ) ; $ b = fgets ( STDIN ) ; $ c = fgets ( STDIN ) ; $ x = fgets ( STDIN ) ; $ result = 0 ; for ( $ i = 0 ; $ i < = $ a ; $ i + + ) { for ( $ j = 0 ; $ j < = $ b ; $ j + + ) { for ( $ k = 0 ; $ k < = $ c ; $ k + + ) { if ( 500 * $ i + 100 * $ j + 50 * $ k = = $ x ) { $ result + + ; } } } } echo $ result ; ? > < ? php $ data = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ H = $ data [ 0 ] ; $ W = $ data [ 1 ] ; $ h = $ data [ 2 ] ; $ w = $ data [ 3 ] ; $ ans = true ; if ( $ W % $ w = = 0 & & $ H % $ h = = 0 ) $ ans = false ; $ x = floor ( 10 * ( $ W * $ H ) / ( $ w * $ h ) ) ; $ y = ( 1 - $ w * $ h ) * $ x - 1 ; for ( $ i = 1 ; $ i < = $ H ; $ i + + ) { $ z [ $ i ] = array _ fill ( 0 , $ W + 1 , 0 ) ; for ( $ j = 1 ; $ j < = $ W ; $ j + + ) { $ z [ $ i ] [ $ j ] = $ x ; if ( $ i % $ h = = 0 & & $ j % $ w = = 0 ) $ z [ $ i ] [ $ j ] = $ y ; } } if ( $ ans ) { echo " Yes \ n " ; for ( $ i = 1 ; $ i < = $ H ; $ i + + ) { for ( $ j = 1 ; $ j < = $ W ; $ j + + ) { echo $ z [ $ i ] [ $ j ] . " " ; } echo " \ n " ; } } else echo " No " ; ? > < ? php $ a = trim ( fgets ( STDIN ) ) ; $ b = trim ( fgets ( STDIN ) ) ; $ c = trim ( fgets ( STDIN ) ) ; $ x = trim ( fgets ( STDIN ) ) ; $ count = 0 ; for ( $ i = 0 ; $ i < = $ a ; $ i + + ) { for ( $ j = 0 ; $ j < = $ b ; $ j + + ) { for ( $ k = 0 ; $ k < = $ c ; $ k + + ) { if ( 500 * $ i + 100 * $ j + 50 * $ k = = $ x ) $ count + + ; } } } echo $ count ; ? > < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; echo $ a > = 13 ? $ b : ( $ a > = 6 ? $ b / 2 : 0 ) ; < ? php fscanf ( STDIN , " % d % d " , $ K , $ S ) ; $ sum = 0 ; for ( $ i = 0 ; $ i < = $ K & & $ i < = $ S ; + + $ i ) { $ d = $ S - $ i ; if ( $ d > 2 * $ K ) { continue ; } $ sum + = min ( $ K , $ d ) - max ( $ d - $ K , 0 ) + 1 ; } print " $ sum \ n " ; < ? php while ( 1 ) { $ N = trim ( fgets ( STDIN ) ) ; if ( $ N = = ' 0 ' ) break ; $ s = 0 ; foreach ( str _ split ( $ N ) as $ n ) $ s + = $ n ; echo $ s , PHP _ EOL ; } < ? php list ( $ n , $ m ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ city = [ ] ; $ p = [ ] ; $ y = [ ] ; for ( $ i = 0 ; $ i < $ m ; $ i + + ) { list ( $ p [ $ i ] , $ y [ $ i ] ) = explode ( " " , trim ( fgets ( STDIN ) ) ) ; $ city [ $ y [ $ i ] ] = $ p [ $ i ] ; } ksort ( $ city ) ; $ pref = [ ] ; $ prefcnt = [ ] ; foreach ( $ city as $ key = > $ val ) { if ( ! isset ( $ pref [ $ val ] ) ) { $ pref [ $ val ] = [ ] ; $ prefcnt [ $ val ] = 0 ; } $ prefcnt [ $ val ] + + ; $ pref [ $ val ] [ $ key ] = $ prefcnt [ $ val ] ; } for ( $ i = 0 ; $ i < $ m ; $ i + + ) { echo str _ pad ( $ p [ $ i ] , 6 , " 0 " , STR _ PAD _ LEFT ) ; echo str _ pad ( $ pref [ $ p [ $ i ] ] [ $ y [ $ i ] ] , 6 , " 0 " , STR _ PAD _ LEFT ) ; echo PHP _ EOL ; } < ? php $ n = trim ( fgets ( STDIN ) ) ; if ( $ n > = 64 ) { echo 64 ; } elseif ( $ n > = 32 ) { echo 32 ; } elseif ( $ n > = 16 ) { echo 16 ; } elseif ( $ n > = 8 ) { echo 8 ; } elseif ( $ n > = 4 ) { echo 4 ; } elseif ( $ n > = 2 ) { echo 2 ; } else { echo 1 ; } < ? php fscanf ( STDIN , " % d % d % d " , $ a , $ b , $ c ) ; $ numbers = array ( ) ; $ numbers [ ] = $ a ; $ numbers [ ] = $ b ; $ numbers [ ] = $ c ; sort ( $ numbers ) ; if ( $ numbers [ 0 ] = = 5 and $ numbers [ 1 ] = = 5 and $ numbers [ 2 ] = = 7 ) { echo " YES " ; } else { echo " NO " ; } ? > < ? php $ in = ( fgets ( STDIN ) ) ; echo ( $ in * $ in * $ in ) ; ? > < ? php fscanf ( STDIN , " % d % d " , $ n , $ k ) ; echo $ k > 1 ? $ n - $ k : 0 ; ? > < ? php $ a = trim ( fgets ( STDIN ) ) ; $ b = trim ( fgets ( STDIN ) ) ; $ c = trim ( fgets ( STDIN ) ) ; $ x = trim ( fgets ( STDIN ) ) ; $ ans = 0 ; $ a _ s = $ x / 500 ; for ( $ i = 0 ; $ i < = $ a _ s ; $ i + + ) { $ x _ 1 = $ x - 500 * $ i ; $ b _ s = $ x _ 1 / 100 ; for ( $ j = 0 ; $ j < = $ b _ s ; $ j + + ) { $ x _ 2 = $ x _ 1 - 100 * $ j ; $ c _ 3 = $ x _ 2 / 50 ; if ( $ c _ 3 < = $ c & & $ j < = $ b & & $ i < = $ a ) { $ ans + = 1 ; } } } echo $ ans . " \ n " ; ? > < ? php fscanf ( STDIN , " % d % d " , $ a , $ b ) ; echo max ( $ a , $ b ) < 9 ? ' Yay ! ' : ' : ( ' ; < ? php list ( $ s ) = strs ( ) ; list ( $ k ) = ints ( ) ; for ( $ i = 0 ; $ i < 26 ; + + $ i ) $ a2n [ chr ( 97 + $ i ) ] = $ i ; $ n = strlen ( $ s ) ; for ( $ i = 0 ; $ i < $ n ; + + $ i ) { $ x = $ a2n [ $ s [ $ i ] ] ; if ( $ x = = = 0 ) continue ; if ( $ k > = 26 - $ x ) { $ s [ $ i ] = ' a ' ; $ k - = 26 - $ x ; } } if ( $ k > 0 ) $ s [ $ n - 1 ] = chr ( 97 + ( $ a2n [ $ s [ $ n - 1 ] ] + $ k ) % 26 ) ; echo $ s . PHP _ EOL ; function ints ( ) { return array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; } function strs ( ) { return explode ( ' ' , trim ( fgets ( STDIN ) ) ) ; } < ? php fgets ( STDIN ) ; $ data = [ ] ; while ( $ line = fgets ( STDIN ) ) { $ data [ ] = explode ( " " , trim ( $ line ) ) ; } $ ans = 0 ; $ cnt = count ( $ data ) ; for ( $ i = 0 ; $ i < $ cnt - 1 ; $ i + + ) { for ( $ j = $ i + 1 ; $ j < $ cnt ; $ j + + ) { $ tmp = 0 ; foreach ( $ data [ $ i ] as $ k = > $ v ) { $ tmp + = pow ( $ v - $ data [ $ j ] [ $ k ] , 2 ) ; } if ( sqrt ( $ tmp ) = = intdiv ( sqrt ( $ tmp ) , 1 ) ) { $ ans + + ; } } } echo $ ans ; < ? php fscanf ( STDIN , " % s " , $ n ) ; for ( $ i = 0 ; $ i < strlen ( $ n ) ; $ i + + ) { $ sum + = $ n [ $ i ] ; } if ( $ n % $ sum = = 0 ) { echo " Yes " ; } else { echo " No " ; } < ? php fgets ( STDIN ) ; echo strpos ( fgets ( STDIN ) , " Y " ) = = = false ? " Three " : " Four " ; < ? php $ x = ( int ) trim ( fgets ( STDIN ) ) ; echo $ x * $ x * $ x ; ? > < ? php list ( $ S ) = sscanf ( trim ( fgets ( STDIN ) ) , " % s " ) ; if ( ( $ S [ 2 ] = = $ S [ 3 ] ) & & ( $ S [ 4 ] = = $ S [ 5 ] ) ) { printf ( " Yes " ) ; } else { printf ( " No " ) ; } < ? php $ x = fgets ( STDIN ) ; print ( $ x * $ x * $ x ) ; ? > < ? php fscanf ( STDIN , " % d % d " , $ N , $ K ) ; $ sa = ( $ N - $ K ) ; if ( $ K = = 1 ) { $ sa = 0 ; } echo ( $ sa ) . " \ n " ; ? > < ? php $ radius = fgets ( STDIN ) ; echo $ radius * $ radius ; ? > < ? php $ N = trim ( fgets ( STDIN ) ) ; printf ( " % d \ n " , $ N * $ N ) ; < ? php $ line = fgets ( STDIN ) ; $ line = str _ replace ( array ( " " , " " ) , " " , $ line ) ; if ( $ line = = 557 | | $ line = = 575 | | $ line = = 755 ) { echo ' YES ' ; } else { echo ' NO ' ; } ? > < ? php fscanf ( STDIN , " % d % d % d " , $ a , $ b , $ c ) ; $ array = [ $ a , $ b , $ c ] ; $ five = 0 ; $ seven = 0 ; for ( $ tmp = 0 ; $ tmp < 3 ; $ tmp + + ) { if ( $ array [ $ tmp ] = = 5 ) { $ five + = 1 ; } if ( $ array [ $ tmp ] = = 7 ) { $ seven + = 1 ; } } if ( $ five = = 2 and $ seven = = 1 ) { print ( " YES \ n " ) ; } else { print ( " NO \ n " ) ; } ? > < ? php fscanf ( STDIN , " % d % d % d % d " , $ a , $ b , $ c , $ d ) ; echo ( $ a * $ b > = $ c * $ d ) ? $ a * $ b : $ c * $ d , PHP _ EOL ; < ? php $ line = trim ( fgets ( STDIN ) ) ; $ arr = explode ( " " , $ line ) ; if ( $ arr [ 0 ] = = $ arr [ 1 ] ) { echo " Draw " ; } elseif ( ( $ arr [ 0 ] = = 1 ) | | ( $ arr [ 0 ] > $ arr [ 1 ] & & $ arr [ 1 ] ! = 1 ) ) { echo " Alice " ; } else { echo " Bob " ; } < ? php fscanf ( STDIN , " % d " , $ n ) ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { fscanf ( STDIN , " % d % d " , $ x [ ] , $ y [ ] ) ; } $ route = 1 ; for ( $ i = 1 ; $ i < = $ n ; $ i + + ) { $ route = $ route * $ i ; } $ pair = 0 ; for ( $ i = 1 ; $ i < = $ n - 1 ; $ i + + ) { $ pair = $ pair + $ i ; } $ move = $ route * ( $ n - 1 ) / $ pair ; $ totalLength = 0 ; for ( $ i = 0 ; $ i < $ n - 1 ; $ i + + ) { for ( $ j = $ i + 1 ; $ j < $ n ; $ j + + ) { $ totalLength + = $ pairLength = sqrt ( pow ( $ x [ $ i ] - $ x [ $ j ] , 2 ) + ( pow ( $ y [ $ i ] - $ y [ $ j ] , 2 ) ) ) ; } } $ totalLength = $ totalLength * $ move ; $ averageLength = $ totalLength / $ route ; echo $ averageLength ; ? > < ? php fscanf ( STDIN , " % d % d % d " , $ a , $ b , $ c ) ; echo $ a + $ b > = $ c ? ' Yes ' : ' No ' ; < ? php $ line = trim ( fgets ( STDIN ) ) ; if ( $ line [ 2 ] = = $ line [ 3 ] & & $ line [ 4 ] = = $ line [ 5 ] ) { echo " Yes \ n " ; } else { echo " No \ n " ; } < ? php define ( ' DEBUG _ FILENAME ' , ' input.txt ' ) ; if ( file _ exists ( DEBUG _ FILENAME ) ) { $ inputs = explode ( " \ n --- \ n " , file _ get _ contents ( DEBUG _ FILENAME ) ) ; define ( ' DEBUG ' , TRUE ) ; } else { $ inputs = array ( file _ get _ contents ( ' php : define ( ' DEBUG ' , FALSE ) ; } foreach ( $ inputs as $ i = > $ input ) { if ( DEBUG ) { echo " \ n ----- { $ i } ----- \ n " ; $ time _ start = microtime ( true ) ; } solve ( $ input ) ; if ( DEBUG ) { $ time _ end = microtime ( true ) ; $ time = $ time _ end - $ time _ start ; echo sprintf ( " \ n [ % .5fms ] " , $ time * 1000 ) ; } } function solve ( $ input ) { echo ( $ input * $ input * $ input ) . PHP _ EOL ; } < ? php # -a + k = b-k # -a-b = -2k # k = ( a + b ) / 2 # 入力部 fscanf ( STDIN , " % d % d " , $ a , $ b ) ; # 処理部 if ( $ a < = 5 ) { $ r = 0 ; } elseif ( $ a < = 12 ) { $ r = $ b / 2 ; } else { $ r = $ b ; } # 出力部 echo $ r . " \ n " ; < ? php fscanf ( STDIN , " % d % d " , $ n , $ d ) ; $ x = [ ] ; $ c = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i + + ) { $ x [ ] = array _ map ( ' intval ' , explode ( ' ' , trim ( fgets ( STDIN ) ) ) ) ; } for ( $ i = 0 ; $ i < $ n - 1 ; $ i + + ) { for ( $ j = $ i + 1 ; $ j < $ n ; $ j + + ) { if ( isSquare ( calcDist ( $ x [ $ i ] , $ x [ $ j ] ) ) ) $ c + + ; } } echo $ c ; function isSquare ( $ v ) { return pow ( floor ( sqrt ( $ v ) ) , 2 ) = = $ v ; } function calcDist ( $ a , $ b ) { global $ d ; $ ret = 0 ; for ( $ i = 0 ; $ i < $ d ; $ i + + ) { $ ret + = pow ( $ a [ $ i ] - $ b [ $ i ] , 2 ) ; } return $ ret ; } ? > package main import " " func main ( ) { var a , b , c , d , e , k int fmt . Scan ( & a , & b , & c , & d , & e , & k ) if e - a > k { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " ) func main ( ) { var n int fmt . Scan ( & n ) ans : = 1 for ans * 2 < = n { ans * = 2 } fmt . Println ( ans ) } package main import ( " " " fmt " " math " " os " " strconv " " % d " package main import ( " " ) func main ( ) { c : = make ( [ ] int , 9 ) for i : = 0 ; i < 9 ; i + + { fmt . Scan ( & c [ i ] ) } for a1 : = - 1000 ; a1 < = 1000 ; a1 + + { invalid : = false b1 : = c [ 0 ] - a1 b2 : = c [ 1 ] - a1 b3 : = c [ 2 ] - a1 a2 : = c [ 3 ] - b1 if c [ 4 ] - b2 ! = a2 { invalid = true } if c [ 5 ] - b3 ! = a2 { invalid = true } a3 : = c [ 6 ] - b1 if c [ 7 ] - a3 ! = b2 { invalid = true } if c [ 8 ] - a3 ! = b3 { invalid = true } if ! invalid { fmt . Println ( " " ) return } } fmt . Println ( " " ) return } package main import ( " " ) func main ( ) { var N int fmt . Scan ( & N ) X : = make ( [ ] int , N ) for i : = 0 ; i < N ; i + + { fmt . Scan ( & X [ i ] ) } min : = exec ( X ) fmt . Println ( min ) } func exec ( X [ ] int ) int { var sum , min int min = 1000000000000 for p : = 1 ; p < = 100 ; p + + { sum = 0 for _ , v : = range X { sum + = ( v - p ) * ( v - p ) } if sum < min { min = sum } } return min } package main import ( " " " fmt " " os " " strconv " " strings " " " " YES " " NO " package main import ( " " " math " " % d % d % d % d " package main import ( " " ) func main ( ) { var k , s int fmt . Scanf ( " % d % d " package main import ( " " " bytes " " fmt " " os " " strconv " " strings " " io . nextToken < len ( io . tokens ) " " % v " " " " \ n " , a . . . ) } func Max ( numbers ... int ) int { max : = numbers [ 0 ] for i , number : = range numbers { if i = = 0 { continue } if number > max { max = number } } return max } func Min ( numbers ... int ) int { max : = numbers [ 0 ] for i , number : = range numbers { if i = = 0 { continue } if max > number { max = number } } return max } func DigitSum ( n int ) int { if n < 0 { return - 1 } res : = 0 for n > 0 { res + = n % 10 n / = 10 } return res } func Sum ( numbers ... int ) int { sum : = 0 for _ , number : = range numbers { sum + = number } return sum } package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " strconv " package main import ( " " ) func main ( ) { var a , b , c , d , e , k int var ans string fmt . Scan ( & a , & b , & c , & d , & e , & k ) if e - a < = k { ans = " " } else { ans = " " } fmt . Println ( ans ) } package main import ( " " " fmt " " os " " strconv " " % d \ n " , ABC051B ( K , S ) ) } func ABC051B ( K , S int ) ( res int ) { for x : = 0 ; x < = K ; x + + { for y : = 0 ; y < = K ; y + + { z : = S - x - y if 0 < = z & & z < = K { res + + } } } return } package main import " " func main ( ) { var n , k int fmt . Scan ( & n , & k ) if k = = 1 { fmt . Println ( 0 ) } else { fmt . Println ( n - k ) } } package main import ( " " " " ) func main ( ) { N : = read ( ) X : = readArray ( N ) Min , Max , Result : = min ( X ... ) , max ( X ... ) , 200000000 for p : = Min ; p < = Max ; p + + { lResult : = 0 for _ , r : = range X { lResult + = ( r - p ) * ( r - p ) } if lResult < Result { Result = lResult } } fmt . Println ( Result ) } func read ( ) int { var v int fmt . Scan ( & v ) return v } func readArray ( length int ) [ ] int { result : = make ( [ ] int , length ) for i : = 0 ; i < length ; i + + { result [ i ] = read ( ) } return result } func min ( a ... int ) int { result : = float64 ( a [ 0 ] ) for _ , i : = range a { result = math . Min ( float64 ( i ) , result ) } return int ( result ) } func max ( a ... int ) int { result : = float64 ( a [ 0 ] ) for _ , i : = range a { result = math . Max ( float64 ( i ) , result ) } return int ( result ) } package main import " " func main ( ) { var n int fmt . Scan ( & n ) a : = [ ] int { 64 , 32 , 16 , 8 , 4 , 2 , 1 } for _ , v : = range a { if n > = v { fmt . Println ( v ) return } } } package main import ( " " ) func main ( ) { var n , k int fmt . Scan ( & n , & k ) if k = = 1 { fmt . Println ( 0 ) } else { fmt . Println ( n - k ) } } package main import " " import " " import " " func main ( ) { var a , b , c int fmt . Scanf ( " % d % d % d " " 5 " ) ) = = 2 { if ( strings . Count ( sabc , " " ) ) = = 1 { fmt . Println ( " " ) } } else { fmt . Println ( " " ) } } package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var N int fmt . Scanf ( " % d " " % s " " Four " ) } else { fmt . Println ( " " ) } } package main import " " func main ( ) { arr : = make ( [ ] [ ] int , 3 ) for i : = 0 ; i < 3 ; i + + { arr [ i ] = make ( [ ] int , 3 ) for j : = 0 ; j < 3 ; j + + { var tmp int fmt . Scan ( & tmp ) arr [ i ] [ j ] = tmp } } for i : = 0 ; i < 101 ; i + + { for j : = 0 ; j < 101 ; j + + { for k : = 0 ; k < 101 ; k + + { x1 , y1 , z1 : = arr [ 0 ] [ 0 ] - i , arr [ 0 ] [ 1 ] - i , arr [ 0 ] [ 2 ] - i x2 , y2 , z2 : = arr [ 1 ] [ 0 ] - j , arr [ 1 ] [ 1 ] - j , arr [ 1 ] [ 2 ] - j x3 , y3 , z3 : = arr [ 2 ] [ 0 ] - k , arr [ 2 ] [ 1 ] - k , arr [ 2 ] [ 2 ] - k if x1 = = x2 & & x2 = = x3 & & y1 = = y2 & & y2 = = y3 & & z1 = = z2 & & z2 = = z3 { fmt . Println ( " " ) return } } } } fmt . Println ( " " ) } package main import " " func main ( ) { var m [ 3 ] [ 3 ] int for i : = 0 ; i < 3 ; i + + { for j : = 0 ; j < 3 ; j + + { fmt . Scan ( & m [ i ] [ j ] ) } } b1 , b2 , b3 : = m [ 0 ] [ 0 ] , m [ 0 ] [ 1 ] , m [ 0 ] [ 2 ] a21 , a22 , a23 : = m [ 1 ] [ 0 ] - b1 , m [ 1 ] [ 1 ] - b2 , m [ 1 ] [ 2 ] - b3 a31 , a32 , a33 : = m [ 2 ] [ 0 ] - b1 , m [ 2 ] [ 1 ] - b2 , m [ 2 ] [ 2 ] - b3 if a21 ! = a22 | | a22 ! = a23 | | a31 ! = a32 | | a32 ! = a33 { fmt . Println ( " " ) return } fmt . Println ( " " ) } package main import " " func main ( ) { var n int fmt . Scan ( & n ) v : = make ( [ ] int , n ) for i : = 0 ; i < n ; i + + { fmt . Scan ( & v [ i ] ) } ans : = 1000000 for i : = 0 ; i < = 100 ; i + + { tmp : = 0 for _ , x : = range v { tmp + = ( x - i ) * ( x - i ) } if tmp < ans { ans = tmp } } fmt . Println ( ans ) } package main import " " func main ( ) { var num int fmt . Scan ( & num ) fmt . Println ( num * num * num ) } package main import " " func main ( ) { var a , b , c , d , e , k int fmt . Scan ( & a , & b , & c , & d , & e , & k ) if e - a > k { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " " fmt " " io " " os " " sort " " strconv " " : ( " " Yay ! " package main import ( " " " fmt " " math " " os " " strconv " package main import " " import " " func main ( ) { var A , B , H , M float64 var ans float64 ; var kakudo float64 ; fmt . Scan ( & A , & B , & H , & M ) ; if H * 30 + M * 0.5 - M * 6 < 180 { kakudo = H * 30 + M * 0.5 - M * 6 ; } else { kakudo = 360 - ( H * 30 + M * 0.5 - M * 6 ) ; } kakudo = kakudo / 180 * math . Pi ; kakudo = math . Cos ( kakudo ) ; ans = ( A * A ) + ( B * B ) - ( 2 * A * B * kakudo ) ; fmt . Println ( math . Sqrt ( ans ) ) ; } package main import ( " " ) func main ( ) { var N , M int fmt . Scanln ( & N , & M ) var N _ array [ 101 ] [ 101 ] string var M _ array [ 101 ] [ 101 ] string for i : = 0 ; i < N ; i + + { var l string fmt . Scanln ( & l ) for j : = 0 ; j < N ; j + + { N _ array [ i ] [ j ] = string ( l [ j ] ) } } for i : = 0 ; i < M ; i + + { var l string fmt . Scanln ( & l ) for j : = 0 ; j < M ; j + + { M _ array [ i ] [ j ] = string ( l [ j ] ) } } var flag bool for i : = 0 ; i < N ; i + + { for j : = 0 ; j < N ; j + + { flag = true for k : = 0 ; k < M ; k + + { for l : = 0 ; l < M ; l + + { if N _ array [ i + k ] [ j + l ] ! = M _ array [ k ] [ l ] { flag = false break } } if flag = = false { break } } if flag { fmt . Println ( " " ) return } } } fmt . Println ( " " ) } package main import ( " " " fmt " " math " " os " " strconv " package main import ( " " ) func main ( ) { var N int fmt . Scan ( & N ) a : = make ( [ ] int , N ) amap : = make ( map [ int ] int ) for i : = 0 ; i < N ; i + + { fmt . Scan ( & a [ i ] ) amap [ i ] = a [ i ] } first : = a [ 0 ] cnt : = 1 for i : = 0 ; i < N ; i + + { if a [ i ] < first { cnt + + first = a [ i ] } } fmt . Println ( cnt ) } package main import ( " " ) func main ( ) { var a , b , c int fmt . Scanf ( " % d % d % d " " YES \ n " ) } else { fmt . Printf ( " \ n " ) } } else if b = = c { if b = = 5 & & a = = 7 { fmt . Printf ( " \ n " ) } else { fmt . Printf ( " \ n " ) } } else if a = = c { if a = = 5 & & b = = 7 { fmt . Printf ( " \ n " ) } else { fmt . Printf ( " \ n " ) } } else { fmt . Printf ( " \ n " ) } } package main import " " func main ( ) { var N int fmt . Scan ( & N ) for h : = 1 ; h < = 3500 ; h + + { for n : = 1 ; n < = 3500 ; n + + { if 4 * n * h > N * h + N * n & & N * h * n % ( 4 * n * h - N * h - N * n ) = = 0 { w : = N * h * n / ( 4 * n * h - N * h - N * n ) if w > 0 { fmt . Println ( h , n , w ) return } } } } } package main import " " var i int func main ( ) { fmt . Scan ( & i ) fmt . Println ( i * i * i ) } package main import ( " " ) func main ( ) { var n , k int fmt . Scanf ( " % d % d " " % d \ n " , ans ) } package main import ( " " ) func main ( ) { var ku [ 3 ] int fmt . Scanf ( " % d % d % d " , & ku [ 0 ] , & ku [ 1 ] , & ku [ 2 ] ) five : = 0 seven : = 0 for _ , v : = range ku { if v = = 5 { five + + } else if v = = 7 { seven + + } } if five = = 2 & & seven = = 1 { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " ) func main ( ) { var k , s , cnt int fmt . Scan ( & k , & s ) for x : = 0 ; x < = k ; x + + { for y : = 0 ; y < = k ; y + + { z : = s - x - y if 0 < = z & & z < = k { cnt + + } } } fmt . Println ( cnt ) } package main import ( " " ) func main ( ) { var n int fmt . Scan ( & n ) p : = make ( [ ] int , n ) for i : = range p { fmt . Scan ( & p [ i ] ) } min : = p [ 0 ] ans : = 1 for i : = 1 ; i < n ; i + + { if min > p [ i ] { ans + + min = p [ i ] } } fmt . Println ( ans ) } package main import ( " " " fmt " " os " " sort " " strconv " package main import " " func main ( ) { var k , s , ans int fmt . Scan ( & k , & s ) for i : = 0 ; i < = k ; i + + { for j : = 0 ; j < = k ; j + + { if 0 < = s - ( i + j ) & & s - ( i + j ) < = k { ans + + } } } fmt . Println ( ans ) } package main import ( " " " bytes " " fmt " " io " " os " " sort " " strconv " \ t \ n \ v \ f \ r \ n \ r \ n package main import " " func main ( ) { var N int fmt . Scan ( & N ) ans : = 1 for ans < = N { ans * = 2 } fmt . Println ( ans / 2 ) } package main import ( " " ) func main ( ) { var N int fmt . Scanf ( " % d \ n " , & N ) arr : = make ( [ ] int , N ) var sum int for i : = 0 ; i < N ; i + + { var n int fmt . Scanf ( " % d " package main import " " func main ( ) { var c [ 3 ] [ 3 ] int for i : = 0 ; i < 3 ; i + + { for j : = 0 ; j < 3 ; j + + { fmt . Scan ( & c [ i ] [ j ] ) } } var a [ 3 ] int var b [ 3 ] int for i : = 0 ; i < 3 ; i + + { b [ i ] = c [ 0 ] [ i ] - a [ 0 ] } for i : = 0 ; i < 3 ; i + + { a [ i ] = c [ i ] [ 0 ] - b [ 0 ] } for i : = 0 ; i < 3 ; i + + { for j : = 0 ; j < 3 ; j + + { if a [ i ] + b [ j ] ! = c [ i ] [ j ] { fmt . Println ( " " ) return } } } fmt . Println ( " " ) } package main import ( " " " fmt " " math " " os " " sort " " strconv " " func max : argument slice length must not be zero " " func min : argument slice length must not be zero " " Exponent must be a natural number " " Exponent must be a natural number " " func peekBack : zero length slice " " func peekFront : zero length slice " " func popBack : zero length slice " " func popFront : zero length slice " package main import ( " " " sort " " YES " " NO " package main import ( " " " fmt " " os " " strconv " " : ( " " : ( " " : ( " " : ( " " : ( " " : ( " " : ( " " : ( " " : ( " " : ( " " Yay ! " package main import ( " " " errors " " fmt " " io " " math " " os " " strconv " " Scan failed " " % b " " [ argument error ] : Strtoi only accepts integer string " package main import ( " " " fmt " " os " " sort " " strconv " package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var x int fmt . Scanln ( & x ) fmt . Println ( x * x * x ) } package main import ( " " " fmt " " io " " math " " os " " strconv " " : ( " " Yay ! " package main import " " func main ( ) { var a , b , c int fmt . Scanf ( " % d % d % d " " YES " ) } else { fmt . Println ( " " ) } } else if a = = 5 { if b = = 7 & & c = = 5 { fmt . Println ( " " ) } else if b = = 5 & & c = = 7 { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } else { fmt . Println ( " " ) } } package main import ( " " ) func solution ( n int ) int { l : = uint ( len ( fmt . Sprintf ( " " , n ) ) - 1 ) return 0 | ( 1 < < l ) } func main ( ) { var n int fmt . Scan ( & n ) fmt . Println ( solution ( n ) ) } package main import ( " " " fmt " " os " " strconv " " strings " " % s = % + v \ n " , name , value ) } func intMin ( a , b int ) int { if a < b { return a } return b } func intMax ( a , b int ) int { if a > b { return a } return b } func f ( A [ ] int ) int { N : = len ( A ) S : = 0 for i : = 0 ; i < N - 1 ; i + + { S + = A [ i ] S % = MOD } R : = A [ N - 1 ] * ( N - 1 ) - S R % = MOD for i : = N - 2 ; i > = 0 ; i -- { S - = A [ i ] if S < 0 { S + = MOD } R + = A [ i ] * i - S R % = MOD } return R } const ( MOD = 1000000007 ) func main ( ) { io : = NewIo ( ) defer io . Flush ( ) N : = io . NextInt ( ) M : = io . NextInt ( ) X : = make ( [ ] int , N ) Y : = make ( [ ] int , M ) for i : = 0 ; i < N ; i + + { X [ i ] = io . NextInt ( ) } for i : = 0 ; i < M ; i + + { Y [ i ] = io . NextInt ( ) } A : = f ( X ) B : = f ( Y ) io . PrintLn ( ( A * B ) % MOD ) } package main import " " func main ( ) { var N int fmt . Scanf ( " % d " " % d " package main import ( " " " os " " strconv " " strings " " bufio " " " package main import " " func main ( ) { var a , b , c int fmt . Scan ( & a , & b , & c ) var counter [ 10 ] int counter [ a ] + + counter [ b ] + + counter [ c ] + + if counter [ 5 ] = = 2 & & counter [ 7 ] = = 1 { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import " " func main ( ) { var N , K int fmt . Scan ( & N , & K ) if K = = 1 { fmt . Println ( " " ) } else { fmt . Println ( N - K ) } } package main import " " func main ( ) { s : = make ( [ ] int , 5 ) for i : = range s { fmt . Scan ( & s [ i ] ) } var k int fmt . Scan ( & k ) for i : = range s { for j : = i + 1 ; j < 5 ; j + + { if s [ j ] - s [ i ] > k { fmt . Println ( " " ) return } } } fmt . Println ( " " ) } package main import " " func main ( ) { var K , S , ans int fmt . Scan ( & K , & S ) for x : = 0 ; x < = K ; x + + { for y : = 0 ; y < = K ; y + + { z : = S - x - y if 0 < = z & & z < = K { ans + + } } } fmt . Println ( ans ) } package main import ( " " " " ) func main ( ) { var n , m , ans int mod : = 1000000007 fmt . Scan ( & n , & m ) ans = 1 if math . Abs ( float64 ( n - m ) ) > = 2 { ans = 0 } else { for i : = 1 ; i < = n ; i + + { ans * = i ans % = mod } for i : = 1 ; i < = m ; i + + { ans * = i ans % = mod } } if n = = m { ans * = 2 ans % = mod } fmt . Println ( ans ) } package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var i int fmt . Scan ( & i ) fmt . Println ( i * i * i ) } package main import ( " " ) func main ( ) { var a , b , c , d , e , k int fmt . Scan ( & a , & b , & c , & d , & e , & k ) if a < b & & b < c & & c < d & & d < e { if k > = b - a & & k > = c - a & & k > = d - a & & k > = e - a & & k > = c - b & & k > = d - b & & k > = e - b & & k > = d - c & & k > = e - c & & k > = e - d { fmt . Print ( " " ) } else { fmt . Print ( " " ) } } } package main import ( " " ) func main ( ) { var a , b , c int fmt . Scan ( & a , & b , & c ) m : = make ( map [ int ] int ) m [ a ] + + m [ b ] + + m [ c ] + + if m [ 5 ] = = 2 & & m [ 7 ] = = 1 { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " " " ) func abs ( n int ) int { if n < 0 { return - n } return n } func main ( ) { a : = make ( [ ] int , 3 ) fmt . Scan ( & a [ 0 ] , & a [ 1 ] , & a [ 2 ] ) sort . Sort ( sort . Reverse ( sort . IntSlice ( a ) ) ) fmt . Println ( abs ( a [ 1 ] - a [ 0 ] ) + abs ( a [ 2 ] - a [ 1 ] ) ) } package main import ( " " " fmt " " os " " strconv " package main ; import " " func main ( ) { var K , S int fmt . Scan ( & K , & S ) count : = 0 for i : = 0 ; i < = K ; i + + { for j : = 0 ; j < = S - i ; j + + { if j > K { break } if S - i - j < = K { count + + } } } fmt . Println ( count ) } func min ( a int , b int ) int { if a < b { return a } return b } package main import ( " " " fmt " " math " " os " " strconv " " strings " " " package main import ( " " " math " " % f % f % f % f " package main import ( " " ) func main ( ) { var N int fmt . Scanf ( " % d " " % d " package main import ( " " " bytes " " fmt " " io " " os " " strconv " \ t \ n \ v \ f \ r \ n \ r \ n package main import ( " " " fmt " " io " " math " " os " " strconv " " Scan failed " " Scan failed " package main import ( " " " " ) func main ( ) { var a , b , h , m int fmt . Scan ( & a , & b , & h , & m ) min : = float64 ( h * 60 + m ) long : = float64 ( 360 ) / float64 ( 60 ) short : = float64 ( 360 ) / float64 ( 12 * 60 ) temp : = long * min for temp > = 360.0 { temp - = 360.0 } ang : = abs ( short * min - temp ) ang = Min ( ang , 360 - ang ) aa : = float64 ( a ) bb : = float64 ( b ) fmt . Println ( math . Sqrt ( aa * aa + bb * bb - 2 * aa * bb * math . Cos ( ang * math . Pi / 180 ) ) ) } func abs ( a float64 ) float64 { if a < 0 { return ( - 1 ) * a } return a } func Min ( a , b float64 ) float64 { if a < b { return a } return b } package main import ( " " ) func main ( ) { var s , k , x , y , z int ans : = 0 fmt . Scan ( & k , & s ) for x = 0 ; x < = k ; x + + { for y = 0 ; y < = k ; y + + { z = s - x - y if 0 < = z & & z < = k { ans + + } } } fmt . Println ( ans ) } package main import ( " " " os " " strconv " " sort " " fmt " " failed scan string " " failed scan int " package main import " " func main ( ) { var a , b , c , d , e , k int fmt . Scan ( & a , & b , & c , & d , & e , & k ) if e - a > k | | e - b > k | | e - c > k | | e - d > k { fmt . Println ( " " ) return } fmt . Println ( " " ) } package main import ( " " " fmt " " math " " os " " reflect " " sort " " strconv " " strings " " " package main import ( " " " math " " math / big " package main import ( " " " fmt " " os " " strconv " " YES " " NO " package main import ( " " " fmt " " log " " os " " sort " " strconv " package main import ( " " " fmt " " math " " os " " strconv " " no values " " no values " package main import ( " " " bufio " " os " " strings " " fmt " " math " " " " " package main import ( " " ) func main ( ) { var n int fmt . Scan ( & n ) x : = make ( [ ] int , n ) sum : = 0 for i : = 0 ; i < len ( x ) ; i + + { fmt . Scan ( & x [ i ] ) sum + = x [ i ] } p : = int ( ( float64 ( sum ) / ( float64 ) ( len ( x ) ) + 0.5 ) ) hp : = 0 for i : = 0 ; i < len ( x ) ; i + + { hp + = ( x [ i ] - p ) * ( x [ i ] - p ) } fmt . Println ( hp ) } package main import " " func main ( ) { var n , k int fmt . Scan ( & n , & k ) if k = = 1 { fmt . Println ( 0 ) return } fmt . Println ( n - k ) } package main import ( " " " " ) func main ( ) { var aLength , bLength , hour , min float64 fmt . Scan ( & aLength , & bLength , & hour , & min ) var hourAngle , minAngle float64 minAngle = 6 * min hourAngle = 30 * hour + 30 * min / 60 angle : = minAngle - hourAngle if angle < 0 { angle * = - 1 } if angle > 180 { angle = 360 - angle } angleRad : = angle * math . Pi / 180 cLength2 : = aLength * aLength + bLength * bLength - 2 * aLength * bLength * math . Cos ( angleRad ) fmt . Println ( math . Sqrt ( cLength2 ) ) } package main import ( " " ) func main ( ) { var N int fmt . Scan ( & N ) for h : = 1 ; h < = 3500 ; h + + { for n : = 1 ; n < = 3500 ; n + + { a : = ( N * h * n ) b : = ( 4 * h * n - N * n - N * h ) if b < 0 | | a * b < = 0 | | a % b ! = 0 { continue } w : = a / b if w < = 3500 { fmt . Println ( h , n , w ) return } } } } package main import ( " " " fmt " " log " " math " " os " " strconv " package main import " " func check ( a , b [ ] string ) bool { la : = len ( a ) lb : = len ( b ) for i : = 0 ; i < = la - lb ; i + + { for j : = 0 ; j < = la - lb ; j + + { flg : = true for k : = 0 ; k < lb ; k + + { if a [ i + k ] [ j : j + lb ] ! = b [ k ] { flg = false break } } if flg { return true } } } return false } func main ( ) { var N , M int fmt . Scan ( & N , & M ) a : = make ( [ ] string , N ) b : = make ( [ ] string , M ) for i : = range a { fmt . Scan ( & a [ i ] ) } for i : = range b { fmt . Scan ( & b [ i ] ) } if check ( a , b ) { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import " " func main ( ) { var x int fmt . Scan ( & x ) fmt . Println ( x * x * x ) } package main import ( " " " " ) func main ( ) { var a , b , h , m int fmt . Scan ( & a , & b , & h , & m ) radH : = ( float64 ( h ) + float64 ( m ) / 60 ) * 2 * math . Pi / 12 radM : = float64 ( m ) * 2 * math . Pi / 60 rad : = math . Abs ( radH - radM ) ans : = float64 ( a * a ) + float64 ( b * b ) - 2 * float64 ( a * b ) * math . Cos ( rad ) ans = math . Sqrt ( ans ) fmt . Println ( ans ) } package main import ( " " " fmt " " math " " os " " strconv " package main import ( " " " bytes " " fmt " " io " " os " " strconv " \ t \ n \ v \ f \ r \ n \ r \ n " Yes " ) return } } } println ( " No " package main import ( " " " " ) func main ( ) { var a , b , h , m float64 fmt . Scan ( & a , & b , & h , & m ) angle : = math . Abs ( 30 * h + 0.5 * m - 6 * m ) d : = a * a + b * b - 2 * a * b * math . Cos ( angle * math . Pi / 180 ) d = math . Sqrt ( d ) fmt . Println ( d ) } package main import ( " " ) func main ( ) { var n int fmt . Scan ( & n ) res : = make ( map [ string ] bool ) for i : = 0 ; i < n ; i + + { var s string fmt . Scan ( & s ) res [ s ] = true } ans : = " " if len ( res ) = = 4 { ans = " " } fmt . Println ( ans ) } package main import ( " " " fmt " " log " " os " " strconv " package main import ( " " " fmt " " os " " strconv " " Yes " " No " package main import " " func min ( a int , b int ) int { if a > b { return b } else { return a } } func zet ( a int ) int { if a < 0 { return a * ( - 1 ) } else { return a } } func main ( ) { var n , m int fmt . Scan ( & n , & m ) ans : = 0 for i : = 0 ; i < = n ; i + = 1 { for j : = 0 ; j < = n ; j + = 1 { x : = m - i - j if x < = n & & x > = 0 { ans + = 1 } } } fmt . Println ( ans ) } package main import ( " " " fmt " " math " " os " " reflect " " sort " " strconv " " strings " " No " " Yes " " No " " " package main import ( " " " " ) func main ( ) { as : = make ( [ ] int , 3 ) for i : = 0 ; i < 3 ; i + + { fmt . Scan ( & as [ i ] ) } sort . Sort ( sort . Reverse ( sort . IntSlice ( as ) ) ) var sum int for i : = 1 ; i < len ( as ) ; i + + { sum + = as [ i - 1 ] - as [ i ] } fmt . Println ( sum ) } package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var n , k int fmt . Scanf ( " % d % d " package main import ( " " " math " " % d " " % d " package main import " " func main ( ) { var k , s int fmt . Scan ( & k , & s ) var cnt int for x : = 0 ; x < = k ; x + + { for y : = 0 ; y < = k ; y + + { z : = s - ( x + y ) if x + y < = s & & z < = k { cnt + = 1 } } } fmt . Println ( cnt ) } package main import " " func main ( ) { var k int var mat = make ( [ ] int , 5 ) for i : = range mat { fmt . Scan ( & mat [ i ] ) } fmt . Scan ( & k ) for i : = 0 ; i < len ( mat ) ; i + + { for j : = i + 1 ; j < len ( mat ) ; j + + { if mat [ j ] - mat [ i ] > k { fmt . Println ( " " ) return } } } fmt . Println ( " " ) } package main import ( " " " fmt " " math " " os " " sort " " strconv " package main import " " func imin ( a ... int ) ( int ) { min : = a [ 0 ] for _ , v : = range a { if v < min { min = v } } return min } func imax ( a ... int ) ( int ) { max : = a [ 0 ] for _ , v : = range a { if v > max { max = v } } return max } func main ( ) { var a , b , c int fmt . Scan ( & a , & b , & c ) fmt . Println ( imax ( a , b , c ) - imin ( a , b , c ) ) } package main import ( " " " fmt " " log " " os " " strconv " " Yes " " No " package main import ( " " " fmt " " log " " math " " os " " sort " " strconv " " YES " " NO " package main import " " func main ( ) { var i int fmt . Scan ( & i ) fmt . Println ( i * i * i ) } package main import ( " " " fmt " " os " " strconv " package main import ( " " ) func main ( ) { var K , S int fmt . Scan ( & K , & S ) cnt : = 0 for x : = 0 ; x < = K ; x + + { for y : = 0 ; y < = K ; y + + { z : = S - ( x + y ) if 0 < = z & & z < = K { cnt + + } } } fmt . Println ( cnt ) } package main import ( " " ) func main ( ) { var i int fmt . Scan ( & i ) fmt . Println ( i * i * i ) } package main import ( " " " math " " % f % f % f % f " " % .20 f \ n " , math . Sqrt ( ret ) ) } package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " io " " math " " os " " strconv " " Scan failed " package main import ( " " " fmt " " log " " os " " strconv " " strings " \ n " \ n " ) , 10 , 32 ) if err ! = nil { log . Fatal ( err ) } val = val * val * val fmt . Println ( val ) } package main import " " import " " func main ( ) { var n int fmt . Scan ( & n ) arr : = make ( [ ] int , n ) var a int for i : = 0 ; i < n ; i + + { fmt . Scan ( & a ) arr [ i ] = a } var min _ cost float64 min _ cost = math . Inf ( 0 ) for i : = 0 ; i < 100 ; i + + { var cost float64 for _ , x : = range arr { z : = float64 ( i - x ) cost = cost + math . Pow ( z , 2 ) } if cost < min _ cost { min _ cost = cost } } fmt . Println ( min _ cost ) } package main import " " func pow ( num int , time int ) int { res : = 1 for time > 0 { if time % 2 ! = 0 { res = res * num } num = num * num time / = 2 } return res } func Max ( nums ... int ) int { if len ( nums ) = = 0 { panic ( " " ) } res : = nums [ 0 ] for _ , val : = range nums { if res < val { res = val } } return res } func solve ( n int ) int { var cnt int for ; n % 2 = = 0 ; n / = 2 { cnt + + } return cnt } func main ( ) { var n , ans int fmt . Scan ( & n ) for i : = 1 ; i < = n ; i + + { ans = Max ( ans , solve ( i ) ) } fmt . Println ( pow ( 2 , ans ) ) } package main import ( " " " fmt " " os " " strconv " " debug " " . / test / sample - 1.i n " " There is no testfile . " package main import ( " " " fmt " " math " " os " " sort " " strconv " " strings " " % s = % + v \ n " , name , value ) } func abs ( a int ) int { if a > = 0 { return a } else { return - a } } func pow ( p , q int ) int { return int ( math . Pow ( float64 ( p ) , float64 ( q ) ) ) } func min ( nums ... int ) int { if len ( nums ) = = 0 { panic ( " " ) } res : = nums [ 0 ] for i : = 0 ; i < len ( nums ) ; i + + { res = int ( math . Min ( float64 ( res ) , float64 ( nums [ i ] ) ) ) } return res } func max ( nums ... int ) int { if len ( nums ) = = 0 { panic ( " " ) } res : = nums [ 0 ] for i : = 0 ; i < len ( nums ) ; i + + { res = int ( math . Max ( float64 ( res ) , float64 ( nums [ i ] ) ) ) } return res } func strSearch ( a [ ] string , b string ) bool { for i : = 0 ; i < len ( a ) ; i + + { if a [ i ] = = b { return true } } return false } func sortAsc ( a [ ] int ) [ ] int { sort . Ints ( a ) return a } func sortDesc ( a [ ] int ) [ ] int { sort . Sort ( sort . Reverse ( sort . IntSlice ( a ) ) ) return a } func gcd ( a , b int ) int { if b = = 0 { return a } return gcd ( b , a % b ) } func lcm ( a , b int ) int { if a = = 0 & & b = = 0 { return 0 } return a * b / gcd ( a , b ) } func cumSum ( nums [ ] int ) [ ] int { sums : = [ ] int { 0 } for i : = 0 ; i < len ( nums ) ; i + + { sums = append ( sums , sums [ i ] + nums [ i ] ) } return sums } package main import ( " " ) func main ( ) { m : = make ( map [ int ] int ) a : = 0 for i : = 0 ; i < 4 ; i + + { fmt . Scan ( & a ) m [ a ] + + } v : = [ ] int { 1 , 9 , 7 , 4 } for _ , e : = range v { if m [ e ] = = 0 { fmt . Println ( " " ) return } } fmt . Println ( " " ) } package main import " " func Cube ( x int ) int { return x * x * x } func main ( ) { var t int fmt . Scan ( & t ) fmt . Println ( Cube ( t ) ) } package main import ( " " " fmt " " os " " strconv " " YES " " NO " package main import ( " " " fmt " " os " " strconv " package main import ( " " ) func main ( ) { var a , b , c int fmt . Scan ( & a , & b , & c ) if ( a + b + c ) = = 17 { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import " " func main ( ) { var n int fmt . Scan ( & n ) ans : = 1 for ans * 2 < = n { ans * = 2 } fmt . Println ( ans ) } package main import ( " " " fmt " " math " " os " " strconv " package main import ( " " " fmt " " os " " strconv " " MASPY " " ますピ " { fp , T HE _ HARMONY _ OF _ PERFECT " ) ) cn t P Y " ) = = " " { wfp , _ = os . C U S10 " ) ) } scanner : = - -- -- -- -- -- -- -- -- -- - " ) so lv e ( sc an ne r , } } f m .Fprin l ( r ter , " No " ) } func e q a i , j int , a , b [ ] s r ng ) o o m : = le n b ) f r k : = 0 ; k < m ; + { f o = ; l < m ; + { i f a i k ] j + l = [ k ] [ l ] { r e ur f a l s e } ret rn tr e } package main import " " func main ( ) { var h1 , h2 , m1 , m2 , k int fmt . Scan ( & h1 , & m1 , & h2 , & m2 , & k ) s : = h1 * 60 + m1 e : = h2 * 60 + m2 r : = e - k - s fmt . Println ( r ) } package main import ( " " " fmt " " os " " % d % d " " % d \ n " , count ) } package main import " " func main ( ) { var k , s int fmt . Scanf ( " % d % d \ n " , & k , & s ) cnt : = 0 for x : = 0 ; x < = k ; x + + { for y : = 0 ; y < = k ; y + + { r : = s - x - y if 0 < = r & & r < = k { cnt + + } } } fmt . Println ( cnt ) } package main import " " func main ( ) { var i int fmt . Scan ( & i ) fmt . Println ( i * i * i ) } package main import ( " " " fmt " " math " " os " " strconv " " strings " " % .20 f " " % .20 f " " % .20 f " " \ n " ) } func getStdin ( ) string { sc . Scan ( ) return sc . Text ( ) } func getStdinInt ( ) int { str : = getStdin ( ) rtn , _ : = strconv . Atoi ( str ) return rtn } func getStdinIntArr ( ) [ ] int { str : = getStdin ( ) list : = strings . Split ( str , " " ) rtn : = make ( [ ] int , len ( list ) ) for idx , val : = range list { rtn [ idx ] , _ = strconv . Atoi ( val ) } return rtn } package main import ( " " ) func main ( ) { var n int fmt . Scanf ( " % d " " % d \ n " , count ) } func scanIntSlice ( size int ) [ ] int { input : = [ ] int { } for i : = 0 ; i < size ; i + + { var in int fmt . Scanf ( " " , & in ) input = append ( input , in ) } return input } package main import " " func main ( ) { var num int fmt . Scan ( & num ) fmt . Println ( num * num * num ) } package main import ( " " ) func main ( ) { var n , m int fmt . Scan ( & n , & m ) x : = make ( [ ] int , n ) y : = make ( [ ] int , m ) for i : = 0 ; i < n ; i + + { fmt . Scan ( & x [ i ] ) } for i : = 0 ; i < m ; i + + { fmt . Scan ( & y [ i ] ) } const mod = 1000000007 var yoko , tate int for i : = 0 ; i < n ; i + + { yoko + = ( x [ i ] * i ) % mod yoko = ( yoko + mod - ( x [ i ] * ( n - 1 - i ) ) ) % mod } for i : = 0 ; i < m ; i + + { tate + = ( y [ i ] * i ) % mod tate = ( tate + mod - ( y [ i ] * ( m - 1 - i ) ) ) % mod } res : = ( yoko * tate ) % mod if res < 0 { res + = mod } fmt . Println ( res ) } package main import ( " " " bufio " " strconv " " os " " : ( " " Yay ! " ) } } package main import " " func main ( ) { G : = false W : = false Y : = false P : = false var N int fmt . Scan ( & N ) for i : = 0 ; i < N ; i + + { var po string fmt . Scan ( & po ) if po = = " " { G = true } if po = = " " { W = true } if po = = " " { Y = true } if po = = " " { P = true } } ans : = 0 if G { ans + + } if W { ans + + } if Y { ans + + } if P { ans + + } if ans = = 3 { fmt . Println ( " " ) } if ans = = 4 { fmt . Println ( " " ) } } package main import ( " " " fmt " " os " " strconv " " No " " Yes " package main import ( " " " fmt " " os " " strconv " " Yes " " No " package main import " " func main ( ) { var k , s int fmt . Scan ( & k , & s ) count : = 0 for x : = 0 ; x < = k ; x + + { for y : = 0 ; y < = k ; y + + { z : = s - x - y if z > = 0 & & z < = k { count + + } } } fmt . Println ( count ) } package main import ( " " " math " " sort " package main import " " func main ( ) { var a [ 3 ] int fmt . Scan ( & a [ 0 ] , & a [ 1 ] , & a [ 2 ] ) five : = 0 seven : = 0 for i : = 0 ; i < 3 ; i + + { if a [ i ] = = 5 { five + + } if a [ i ] = = 7 { seven + + } } if five = = 2 & & seven = = 1 { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " strconv " package main import ( " " " math " " % d % d % d % d " package main import ( " " " fmt " " os " " strconv " " % s \ n " , ABC054B ( A , B ) ) } func ABC054B ( A , B [ ] string ) string { if len ( A ) = = len ( B ) { if checkUnderRect ( A , B , 0 , 0 ) { return " " } } else { for i : = 0 ; i < len ( A ) - len ( B ) ; i + + { for j : = 0 ; j < len ( A [ i ] ) - len ( B ) ; j + + { if A [ i ] [ j : j + len ( B ) ] = = B [ 0 ] { if checkUnderRect ( A , B , i , j ) { return " " } } } } } return " " } func checkUnderRect ( A , B [ ] string , i , j int ) bool { for k : = 1 ; k < len ( B ) ; k + + { ak : = k + i if A [ ak ] [ j : j + len ( B ) ] ! = B [ k ] { return false } } return true } package main import " " func main ( ) { var H1 , M1 , H2 , M2 , K int fmt . Scanf ( " % d % d % d % d % d " package main import ( " " ) func main ( ) { var n int fmt . Scan ( & n ) max _ n , max _ cnt : = 1 , 0 for i : = n ; i > 0 ; i -- { num : = i cnt : = 0 for num % 2 = = 0 { cnt + + num / = 2 } if cnt > max _ cnt { max _ cnt = cnt max _ n = i } } fmt . Println ( max _ n ) } package main import ( " " ) func main ( ) { var a , b , c , d , n , time , x , y int fmt . Scan ( & a , & b , & c , & d , & n ) x = 60 * a + b y = 60 * c + d time = y - x fmt . Println ( time - n ) } package main import ( " " " math " " sort " package main import ( " " " fmt " " os " " strconv " " YES " ) } else { fmt . Println ( " NO " package main import " " func main ( ) { a : = make ( [ ] int , 3 ) for i : = range a { fmt . Scan ( & a [ i ] ) } cnt : = make ( map [ int ] int ) for _ , v : = range a { cnt [ v ] + = 1 } if cnt [ 5 ] = = 2 & & cnt [ 7 ] = = 1 { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " ) func main ( ) { var a0 , a1 , a2 int fmt . Scan ( & a0 ) fmt . Scan ( & a1 ) fmt . Scan ( & a2 ) d : = make ( [ ] int , 3 ) d [ 0 ] = abs ( a0 - a1 ) d [ 1 ] = abs ( a1 - a2 ) d [ 2 ] = abs ( a2 - a0 ) max : = - 1 for _ , e : = range d { if max < e { max = e } } fmt . Println ( max ) } func abs ( x int ) int { if x < 0 { return - x } return x } package main import ( " " " fmt " " os " package main import ( " " ) func main ( ) { var k int var s int fmt . Scan ( & k ) fmt . Scan ( & s ) count : = 0 for i : = 0 ; i < = k ; i + + { c : = k if s - i < k { c = s - i } for j : = 0 ; j < = c ; j + + { if s - i - j < = k { count + + } } } fmt . Println ( count ) } package main import " " func main ( ) { var k , s int fmt . Scan ( & k , & s ) var ans int for x : = 0 ; x < = k ; x + + { if x = = s { ans + + break } for y : = 0 ; y < = k ; y + + { if z : = s - x - y ; 0 < = z & & z < = k { ans + + } } } fmt . Println ( ans ) } package main import " " type data struct { n , m int nImg , mImg [ ] string } func main ( ) { d : = newData ( ) if d . exist ( ) { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } func newData ( ) data { var n , m int fmt . Scanf ( " % d % d " " % s " package main import ( " " ) func sort ( nums [ ] int , n int ) { for i : = 1 ; i < n ; i + + { v : = nums [ i ] j : = i - 1 for j > = 0 & & v < nums [ j ] { nums [ j + 1 ] = nums [ j ] j - - } nums [ j + 1 ] = v } } func main ( ) { tasks : = make ( [ ] int , 3 ) for i : = range tasks { fmt . Scan ( & tasks [ i ] ) } sort ( tasks , 3 ) fmt . Println ( ( tasks [ 1 ] - tasks [ 0 ] ) + ( tasks [ 2 ] - tasks [ 1 ] ) ) } package main import ( " " " fmt " " os " " strconv " package main import ( " " ) func main ( ) { var ha , ma , hb , mb , k int fmt . Scan ( & ha , & ma , & hb , & mb , & k ) a : = 60 * ha + ma b : = 60 * hb + mb ansM : = ( b - k ) - a fmt . Println ( ansM ) } package main import ( " " " fmt " " os " " strconv " " YES " " NO " package main import ( " " ) func main ( ) { var n int fmt . Scan ( & n ) count : = 0 pow : = 1 for pow < < 1 < = n { count + + pow = pow < < 1 } fmt . Println ( pow ) } package main import ( " " " fmt " " math " " os " " strconv " " MASPY " " ますピ " { fp , T HE _ HARMONY _ OF _ PERFECT " ) ) cn t P Y " ) = = " " { wfp , _ = os . C U S10 " ) ) } scanner : = - -- -- -- -- -- -- -- -- -- - " ) so lv e ( sc an ne r , package main import ( " " " " ) func abs ( x float64 ) float64 { if x < 0 { return - x } return x } func min ( x , y float64 ) float64 { if x < y { return x } return y } func main ( ) { var a , b , h , m float64 fmt . Scan ( & a , & b , & h , & m ) hang : = 30 * h + 30 * ( m / 60 ) mang : = 360 * ( m / 60 ) ang : = abs ( hang - mang ) ang = min ( ang , 360 - ang ) fmt . Println ( math . Sqrt ( a * a + b * b - 2 * a * b * math . Cos ( math . Pi * ang / 180 ) ) ) } package main import " " func main ( ) { var a , b , c int fmt . Scan ( & a , & b , & c ) if b < a { a , b = b , a } if c < b { b , c = c , b } if a = = 5 & & b = = 5 & & c = = 7 { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " " fmt " " os " " strconv " " : ( " " Yay ! " package main import ( " " " " ) func main ( ) { var a , b , h , m float64 fmt . Scan ( & a , & b , & h , & m ) c : = a * a + b * b - 2 * a * b * math . Cos ( ( math . Pi / 6.0 ) * h - ( math . Pi / 30.0 ) * m + ( math . Pi / 360.0 ) * m ) fmt . Println ( math . Sqrt ( c ) ) } package main import " " func main ( ) { var ( h1 int m1 int h2 int m2 int k int ) fmt . Scanf ( " % d % d % d % d % d " " % d " package main import ( " " " fmt " " math " " os " " reflect " " sort " " strconv " " strings " " " package main import " " func main ( ) { var n , t , min int c : = 1 fmt . Scan ( & n ) fmt . Scan ( & min ) for i : = 1 ; i < n ; i + + { fmt . Scan ( & t ) if t < min { c + + min = t } } fmt . Println ( c ) } package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " sort " " strconv " package main import ( " " " bufio " " os " " strconv " " " package main import ( " " ) func main ( ) { var N int var S string var res string = " " fmt . Scan ( & N ) for i : = 0 ; i < N ; i + + { fmt . Scan ( & S ) if S = = " " { res = " " } } fmt . Println ( res ) } package main import " " func main ( ) { var c [ 4 ] [ 4 ] int for i : = 1 ; i < 4 ; i + + { for j : = 1 ; j < 4 ; j + + { fmt . Scan ( & c [ i ] [ j ] ) } } if ( c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] = = c [ 1 ] [ 2 ] - c [ 2 ] [ 2 ] ) & & ( c [ 1 ] [ 2 ] - c [ 2 ] [ 2 ] = = c [ 1 ] [ 3 ] - c [ 2 ] [ 3 ] ) & & ( c [ 2 ] [ 1 ] - c [ 3 ] [ 1 ] = = c [ 2 ] [ 2 ] - c [ 3 ] [ 2 ] ) & & ( c [ 2 ] [ 2 ] - c [ 3 ] [ 2 ] = = c [ 2 ] [ 3 ] - c [ 3 ] [ 3 ] ) & & ( c [ 3 ] [ 1 ] - c [ 1 ] [ 1 ] = = c [ 3 ] [ 2 ] - c [ 1 ] [ 2 ] ) & & ( c [ 3 ] [ 2 ] - c [ 1 ] [ 2 ] = = c [ 3 ] [ 3 ] - c [ 1 ] [ 3 ] ) { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " " fmt " " os " " sort " " strconv " package main import ( " " " fmt " " math " " os " " strconv " " func max : argument slice length must not be zero " " func min : argument slice length must not be zero " " func peekBack : zero length slice " " func peekFront : zero length slice " " func popBack : zero length slice " " func popFront : zero length slice " package main import ( " " " " ) func main ( ) { var n int fmt . Scan ( & n ) xs : = make ( [ ] int , n ) for i : = 0 ; i < n ; i + + { var tmp int fmt . Scan ( & tmp ) xs [ i ] = tmp } const minX = 1 const maxX = 100 min : = 10000000 for p : = minX ; p < = maxX ; p + + { sum : = 0 for _ , x : = range xs { sum + = int ( math . Pow ( float64 ( x - p ) , 2.0 ) ) } if sum < min { min = sum } } fmt . Println ( min ) } package main import ( " " " " ) func solution ( h1 , m1 , h2 , m2 , k int ) int { d1 : = time . Date ( 2020 , 1 , 1 , h1 , m1 , 0 , 0 , time . Local ) d2 : = time . Date ( 2020 , 1 , 1 , h2 , m2 , 0 , 0 , time . Local ) duration : = d2 . Sub ( d1 ) return int ( duration . Minutes ( ) ) - k } func main ( ) { var h1 , m1 , h2 , m2 , k int fmt . Scan ( & h1 , & m1 , & h2 , & m2 , & k ) fmt . Println ( solution ( h1 , m1 , h2 , m2 , k ) ) } package main import ( " " " fmt " " math " " os " " strconv " " % d " package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " strconv " " sort " package main import ( " " " os " " bufio " " sort " " math " package main import ( " " " fmt " " math " " os " " sort " " strconv " " MASPY " " ますピ " { fp , T HE _ HARMONY _ OF _ PERFECT " ) ) cn t P Y " ) = = " " { wfp , _ = os . C U S10 " ) ) } scanner : = - -- -- -- -- -- -- -- -- -- - " ) so lv e ( sc an ne r , package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " math " " os " " strconv " " funciton min ( ) requires at least one argument . " ) } res : = nums [ 0 ] for i : = 0 ; i < len ( nums ) ; i + + { res = int ( math . Min ( float64 ( res ) , float64 ( nums [ i ] ) ) ) } return res } func max ( nums ... int ) int { if len ( nums ) = = 0 { panic ( " " ) } res : = nums [ 0 ] for i : = 0 ; i < len ( nums ) ; i + + { res = int ( math . Max ( float64 ( res ) , float64 ( nums [ i ] ) ) ) } return res } func strSearch ( a [ ] string , b string ) bool { for i : = 0 ; i < len ( a ) ; i + + { if a [ i ] = = b { return true } } return false } func printIntArray ( array [ ] int ) { strArray : = fmt . Sprint ( array ) fmt . Println ( strArray [ 1 : len ( strArray ) - 1 ] ) } func calcMod ( x int ) int { return x % mod } func calcRound ( x float64 ) int { result : = int ( x ) if int ( x * 10 ) % 10 > = 5 { result + + } return result } package main import " " func main ( ) { var n , k int fmt . Scan ( & n , & k ) if k = = 1 { fmt . Println ( 0 ) } else { rem : = n - k fmt . Println ( rem ) } } package main import ( " " ) func main ( ) { var t1 , t2 int64 var a1 , a2 int64 var b1 , b2 int64 fmt . Scan ( & t1 , & t2 ) fmt . Scan ( & a1 , & a2 ) fmt . Scan ( & b1 , & b2 ) p : = ( a1 - b1 ) * t1 q : = ( a2 - b2 ) * t2 if p > 0 { p * = - 1 q * = - 1 } if p + q = = 0 { fmt . Println ( " " ) return } ans : = int64 ( 0 ) if p + q < 0 { ans = 0 } else { s : = ( - p ) / ( p + q ) t : = ( - p ) % ( p + q ) if t ! = 0 { ans = s * 2 + 1 } else { ans = s * 2 } } fmt . Println ( ans ) } package main import ( " " " fmt " " io " " os " " strconv " " Scan failed " package main import ( " " " fmt " " io " " os " " strconv " " Scan failed " " Yes " " No " package main import ( " " ) func main ( ) { c : = make ( [ ] [ ] int , 3 ) for i : = 0 ; i < 3 ; i + + { c [ i ] = make ( [ ] int , 3 ) fmt . Scan ( & c [ i ] [ 0 ] , & c [ i ] [ 1 ] , & c [ i ] [ 2 ] ) } a : = [ ] int { 0 , - 1 , - 1 } b : = [ ] int { - 1 , - 1 , - 1 } i : = 0 for j : = 0 ; j < 3 ; j + + { b [ j ] = c [ i ] [ j ] - a [ i ] } for i = 1 ; i < 3 ; i + + { for j : = 0 ; j < 3 ; j + + { a [ i ] = c [ i ] [ j ] - b [ j ] } } for ai : = 0 ; ai < 3 ; ai + + { for bi : = 0 ; bi < 3 ; bi + + { if a [ ai ] + b [ bi ] ! = c [ ai ] [ bi ] { fmt . Println ( " " ) return } } } fmt . Println ( " " ) } package main import ( " " ) func main ( ) { var K int var S int fmt . Scan ( & K ) fmt . Scan ( & S ) var counter int counter = 0 for i : = 0 ; i < = K ; i + + { for j : = 0 ; j < = K ; j + + { k : = S - i - j if k < = K & & k > = 0 { counter + + } } } fmt . Println ( counter ) } package main import ( " " ) func main ( ) { var N , A , ANS int max : = 0 min : = 101 fmt . Scan ( & N ) l : = make ( [ ] int , N ) for i : = 0 ; i < N ; i + + { fmt . Scan ( & A ) min = calcmin ( min , A ) max = calcmax ( max , A ) l [ i ] = A } ANS = 1000000000000 for i : = min ; i < = max ; i + + { SUM : = 0 for _ , v : = range l { SUM + = ( v - i ) * ( v - i ) } ANS = calcmin ( ANS , SUM ) } fmt . Println ( ANS ) } func calcmax ( a , b int ) int { if a < b { return b } else { return a } } func calcmin ( a , b int ) int { if a > b { return b } else { return a } } package main import ( " " " fmt " " os " " strings " " Three " " Four " " " package main import ( " " " os " " bufio " " strconv " package main import ( " " " fmt " " os " " sort " " strconv " " MASPY " " ますピ " { fp , T HE _ HARMONY _ OF _ PERFECT " ) ) cn t P Y " ) = = " " { wfp , _ = os . C U S10 " ) ) } scanner : = - -- -- -- -- -- -- -- -- -- - " ) so lv e ( sc an ne r , package main import ( " " " fmt " " os " " strconv " " strings " " " " : ( " " Yay ! " ) } package main import ( " " " fmt " " os " " strconv " " sort " " : ( " " Yay ! " ) } } package main import ( " " " bytes " " fmt " " io " " os " " strconv " \ t \ n \ v \ f \ r \ n \ r \ n package main import ( " " " math " " sort " package main import ( " " " fmt " " log " " math " " os " " strconv " package main import " " func main ( ) { var h1 , h2 , m1 , m2 , k int fmt . Scan ( & h1 , & m1 , & h2 , & m2 , & k ) begin : = h1 * 60 + m1 end : = h2 * 60 + m2 fmt . Println ( end - begin - k ) } package main import ( " " ) func main ( ) { var n int fmt . Scan ( & n ) fmt . Println ( num ( n ) ) } func num ( n int ) int { var max int key : = 1 for ; n > 0 ; n -- { var c int for t : = n ; t % 2 = = 0 ; t / = 2 { c + + } if c > max { max = c key = n } } return key } package main import ( " " " " ) func main ( ) { var a , b float64 var h , m float64 fmt . Scan ( & a , & b , & h , & m ) mc : = m * 6.0 hc : = ( 360 / 12 ) * h + mc / 12 if mc = = hc { fmt . Println ( math . Abs ( b - a ) ) return } ang : = math . Abs ( mc - hc ) if ang > 180 { ang = 360 - ang } c2 : = math . Pow ( a , 2 ) + math . Pow ( b , 2 ) - 2 * a * b * math . Cos ( math . Pi * ang / 180 ) r : = math . Sqrt ( c2 ) fmt . Println ( r ) } package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " strconv " " Yes " " No " package main import " " func main ( ) { var H1 , H2 , M1 , M2 , K int fmt . Scan ( & H1 ) fmt . Scan ( & M1 ) fmt . Scan ( & H2 ) fmt . Scan ( & M2 ) fmt . Scan ( & K ) ans : = ( H2 - H1 ) * 60 + ( M2 - M1 ) - K fmt . Println ( ans ) } package main import ( " " " sort " " YES " " NO " package main import ( " " " " ) func main ( ) { var a , b , h , m float64 fmt . Scan ( & a , & b , & h , & m ) r : = math . Abs ( m * 360.0 / 60 - ( h * 60.0 + m ) * 360.0 / ( 60.0 * 12.0 ) ) * math . Pi / 180.0 x : = a * a + b * b - 2 * a * b * math . Cos ( r ) fmt . Println ( math . Sqrt ( x ) ) } package main import ( " " " fmt " " os " " strconv " " Three " " Four " " scan error " " text to int error " " scan error " package main import ( " " " fmt " " io " " math " " os " " strconv " " % 0.15 f " package main import ( " " " os " " bufio " " strings " " strconv " " math " " " " " " " " " " Yes " " No " " No " " No " package main import ( " " " fmt " " os " " strconv " package main import ( " " ) func main ( ) { var N int fmt . Scan ( & N ) a : = make ( [ ] int , N + 1 ) i : = 1 maxn : = 1 for ; i < = N ; i + + { n : = i for { if n % 2 = = 1 { break } else { a [ i ] + + n / = 2 if a [ i ] > a [ maxn ] { maxn = i } } } } fmt . Println ( maxn ) } package main import ( " " " fmt " " log " " os " " strconv " " YES " " NO " package main import " " func main ( ) { var a , b , c , d , e , k int fmt . Scan ( & a , & b , & c , & d , & e , & k ) if e - a > k { fmt . Println ( " " ) return } fmt . Println ( " " ) } package main import ( " " " fmt " " math " " os " " strconv " " funciton min ( ) requires at least one argument . " ) } res : = nums [ 0 ] for i : = 0 ; i < len ( nums ) ; i + + { res = int ( math . Min ( float64 ( res ) , float64 ( nums [ i ] ) ) ) } return res } func max ( nums ... int ) int { if len ( nums ) = = 0 { panic ( " " ) } res : = nums [ 0 ] for i : = 0 ; i < len ( nums ) ; i + + { res = int ( math . Max ( float64 ( res ) , float64 ( nums [ i ] ) ) ) } return res } func strSearch ( a [ ] string , b string ) bool { for i : = 0 ; i < len ( a ) ; i + + { if a [ i ] = = b { return true } } return false } func printIntArray ( array [ ] int ) { strArray : = fmt . Sprint ( array ) fmt . Println ( strArray [ 1 : len ( strArray ) - 1 ] ) } func calcMod ( x int ) int { return x % mod } package main import " " func main ( ) { var k , s int fmt . Scan ( & k , & s ) count : = 0 for x : = 0 ; x < = k ; x + + { for y : = 0 ; y < = k ; y + + { z : = s - x - y if 0 < = z & & z < = k & & x + y + z = = s { count + + } } } fmt . Println ( count ) } package main import ( " " " fmt " " os " " strconv " package main import " " func max ( x , y int ) int { if x > y { return x } return y } func main ( ) { var h1 , m1 , h2 , m2 , k int fmt . Scan ( & h1 , & m1 , & h2 , & m2 , & k ) x : = h2 * 60 + m2 - ( h1 * 60 + m1 ) fmt . Println ( max ( x - k , 0 ) ) } package main import ( " " ) func main ( ) { var n int fmt . Scan ( & n ) var s string for i : = 0 ; i < n ; i + + { fmt . Scan ( & s ) if s = = " " { fmt . Println ( " " ) return } } fmt . Println ( " " ) } package main import ( " " " bufio " " os " " sort " " strings " " strconv " " " ) sort . Strings ( t ) return strings . Join ( t , " " ) } func reverseString ( s string ) string { t : = [ ] rune ( s ) for i , j : = 0 , len ( s ) - 1 ; i < j ; i , j = i + 1 , j - 1 { t [ i ] , t [ j ] = t [ j ] , t [ i ] } return string ( t ) } func stringRev ( s [ ] byte , l int , r int ) [ ] byte { for i : = 0 ; i < ( r - l + 1 ) / 2 ; i + + { s [ l - 1 + i ] , s [ r - 1 - i ] = s [ r - 1 - i ] , s [ l - 1 + i ] } return s } func inside ( h , w , H , W int ) bool { if h > = 0 & & h < H & & w > = 0 & & w < W { return true } return false } package main import ( " " ) func main ( ) { var k , s int fmt . Scan ( & k , & s ) cnt : = 0 for x : = 0 ; x < = k ; x + + { for y : = 0 ; y < = k ; y + + { z : = s - ( x + y ) if 0 < = z & & z < = k { cnt + + } } } fmt . Println ( cnt ) } package main import ( " " " bytes " " fmt " " io " " os " " strconv " \ t \ n \ v \ f \ r \ n \ r \ n package main import ( " " " sort " " Yay ! " " : ( " package main import ( " " " errors " " fmt " " io " " math " " os " " strconv " " Scan failed " " % b " " [ argument error ] : Strtoi only accepts integer string " package main import ( " " " sort " " % d " " YES " " NO " package main import " " func main ( ) { var a int count : = 0 result : = 1 fmt . Scan ( & a ) for i : = 1 ; i < = a ; i + + { countInternal : = 0 numberStore : = i for numberStore % 2 = = 0 { countInternal + + numberStore / = 2 } if countInternal > count { count = countInternal result = i } } fmt . Println ( result ) } package main import ( " " " " ) func main ( ) { var A , B , H , M float64 fmt . Scan ( & A , & B , & H , & M ) HH : = H * 30.0 + M * 0.5 MM : = M * 6.0 rad : = ( max ( HH , MM ) - min ( HH , MM ) ) * math . Pi / 180.0 ans : = math . Sqrt ( math . Pow ( A , 2 ) + math . Pow ( B , 2 ) - 2 * A * B * math . Cos ( rad ) ) fmt . Println ( ans ) } func max ( a , b float64 ) float64 { if a < b { return b } return a } func min ( a , b float64 ) float64 { if a < b { return a } return b } package main import " " func main ( ) { var n int var s string var four bool fmt . Scan ( & n ) for i : = 0 ; i < n ; i + + { fmt . Scan ( & s ) if s = = " " { four = true } } if four { fmt . Println ( " " ) return } fmt . Println ( " " ) } package main import ( " " " fmt " " math " " os " " strconv " " strings " " unsafe " " " " % # v \ n " , v ) } } func yes ( ) { fmt . Println ( " Yes " ) } func no ( ) { fmt . Println ( " No " ) } package main import ( " " ) func main ( ) { var N int fmt . Scan ( & N ) fmt . Println ( N * N * N ) ; } package main import " " func main ( ) { var n int fmt . Scan ( & n ) m : = make ( [ ] string , n ) for i : = range m { fmt . Scan ( & m [ i ] ) } hinaArare : = make ( map [ string ] struct { } ) for _ , v : = range m { hinaArare [ v ] = struct { } { } } if len ( hinaArare ) = = 3 { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import " " var ( c [ 3 ] [ 3 ] int ans string ) func dfs ( a0 int ) { b : = make ( [ ] int , len ( c ) ) for j : = range b { b [ j ] = c [ 0 ] [ j ] - a0 if b [ j ] < 0 { return } } flg : = false for i : = 1 ; i < len ( c ) ; i + + { for j : = range make ( [ ] struct { } , len ( c ) - 1 ) { if c [ i ] [ j ] - b [ j ] ! = c [ i ] [ j + 1 ] - b [ j + 1 ] { flg = true break } } if flg { break } } if ! flg { ans = " " return } dfs ( a0 + 1 ) } func main ( ) { for i : = range c { for j : = range c [ i ] { fmt . Scan ( & c [ i ] [ j ] ) } } ans = " " dfs ( 0 ) fmt . Println ( ans ) } package main import ( " " ) func main ( ) { var n int fmt . Scan ( & n ) nums : = make ( [ ] int , n ) min : = make ( [ ] int , n ) for i : = 0 ; i < n ; i + + { fmt . Scan ( & nums [ i ] ) if i = = 0 { min [ 0 ] = nums [ 0 ] } if i > 0 & & nums [ i ] < min [ i - 1 ] { min [ i ] = nums [ i ] } else if i > 0 & & nums [ i ] > = min [ i - 1 ] { min [ i ] = min [ i - 1 ] } } counter : = 0 for i , num : = range nums { if num = = min [ i ] { counter + + } if num = = 1 { fmt . Println ( counter ) return } } fmt . Println ( counter ) } package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var A , B int fmt . Scan ( & A , & B ) if B % 2 = = 0 { switch { case A > = 13 : fmt . Print ( B ) case A > = 6 & & A < = 12 : fmt . Print ( B / 2 ) case A < = 5 : fmt . Print ( " " ) } } } package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var n int fmt . Scan ( & n ) ans : = 1 for ans * 2 < = n { ans * = 2 } fmt . Println ( ans ) } package main import ( " " " fmt " " os " " strconv " package main import ( " " " " ) func main ( ) { var A , B , H , M float64 fmt . Scan ( & A , & B , & H , & M ) ans : = exec ( A , B , H , M ) fmt . Println ( ans ) } func exec ( A , B , H , M float64 ) float64 { ang : = math . Abs ( H * 30 + 0.5 * M - M * 6 ) v : = A * A + B * B - ( 2 * A * B * math . Cos ( ang * math . Pi / 180 ) ) return math . Sqrt ( v ) } package main import ( " " " " ) func main ( ) { var n int fmt . Scan ( & n ) ans : = 0.0 switch { case n < 2 : ans = 0.0 case n < 4 : ans = 1.0 case n < 8 : ans = 2.0 case n < 16 : ans = 3.0 case n < 32 : ans = 4.0 case n < 64 : ans = 5.0 default : ans = 6.0 } fmt . Println ( int ( math . Pow ( 2.0 , ans ) ) ) } package main import ( " " ) func main ( ) { var a , b , c , d , e , k int fmt . Scan ( & a , & b , & c , & d , & e , & k ) if e - a < = k { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " ) func main ( ) { var a , b , c int fmt . Scan ( & a , & b , & c ) m : = make ( map [ int ] int ) m [ a ] + + m [ b ] + + m [ c ] + + if m [ 5 ] = = 2 & & m [ 7 ] = = 1 { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import " " func main ( ) { var a int fmt . Scan ( & a ) fmt . Println ( a * a * a ) } package main import ( " " " fmt " " os " " strconv " package main import ( " " ) func main ( ) { ts : = make ( [ ] int , 6 ) for i : = 0 ; i < 6 ; i + + { fmt . Scan ( & ts [ i ] ) } if ts [ 4 ] - ts [ 0 ] < = ts [ 5 ] { fmt . Print ( " " ) } else { fmt . Print ( " " ) } } package main import ( " " " fmt " " os " " strconv " " : ( " " Yay ! " package main import ( " " ) var ( a , b , c , d , e , k int ) func main ( ) { fmt . Scanf ( " % d " " % d " " % d " " % d " " % d " " % d " " Yay ! " " : ( " package main import ( " " " os " " strconv " " strings " " fmt " " " " Yes " " No " package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var i int fmt . Scan ( & i ) fmt . Println ( i * i * i ) } package main import " " import " " func main ( ) { a : = make ( [ ] int , 3 ) for i : = 0 ; i < 3 ; i + + { fmt . Scan ( & a [ i ] ) } sort . Ints ( a ) if a [ 0 ] = = 5 & & a [ 1 ] = = 5 & & a [ 2 ] = = 7 { fmt . Print ( " " ) } else { fmt . Print ( " " ) } } package main import ( " " ) func main ( ) { var k , s int fmt . Scan ( & k , & s ) count : = 0 for x : = 0 ; x < = k ; x + + { for y : = 0 ; y < = k ; y + + { z : = s - x - y if z > = 0 & & z < = k { count + + } } } fmt . Println ( count ) } package main import ( " " " " ) func main ( ) { var N float64 fmt . Scan ( & N ) var h , n , w float64 for h = 1 ; h < = 3500 ; h + + { for n = 1 ; n < = 3500 ; n + + { x : = 4 / N - 1 / h - 1 / n if x > 1 | | x < 0 { continue } left : = - 0.1 right : = 100000.0 var mid float64 for right - left > 0.1 { mid = ( left + right ) / 2.0 if 1 / mid > = x { left = mid } else { right = mid } } w = math . Trunc ( mid ) if w > 0.0 { if 4 / N = = 1 / h + 1 / n + 1 / w { fmt . Println ( h , n , w ) return } } w = math . Ceil ( mid ) if w > 0.0 { if 4 / N = = 1 / h + 1 / n + 1 / w { fmt . Println ( h , n , w ) return } } } } var i int for { i + + } } package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var n , max , maxN int fmt . Scan ( & n ) for i : = 1 ; i < = n ; i + + { tmp : = i num : = 1 for tmp > 0 & & tmp % 2 = = 0 { tmp / = 2 num + + } if num > max { maxN = i max = num } } fmt . Printf ( " \ n " , maxN ) } package main import ( " " " " ) func main ( ) { a : = make ( [ ] int , 3 ) fmt . Scan ( & a [ 0 ] , & a [ 1 ] , & a [ 2 ] ) sort . Ints ( a ) fmt . Println ( a [ 2 ] - a [ 0 ] ) } package main import ( " " " fmt " " math " " os " " strconv " " strings " " " package main import ( " " " " ) func Degree2Radian ( deg float64 ) float64 { return deg * math . Pi / 180.0 } func Radian2Degree ( rad float64 ) float64 { return rad * 180.0 / math . Pi } func HourHandAngle ( h , m int ) float64 { return 30.0 * float64 ( h ) + float64 ( m ) / 2.0 } func MinuteHandAngle ( m int ) float64 { return 6.0 * float64 ( m ) } func AcuteAngle ( h , m int ) float64 { diff : = HourHandAngle ( h , m ) - MinuteHandAngle ( m ) if diff < 0 { diff * = - 1 } if diff > 180.0 { diff = 360.0 - diff } return diff } func main ( ) { var a , b , h , m int fmt . Scan ( & a , & b , & h , & m ) rad : = Degree2Radian ( AcuteAngle ( h , m ) ) ans : = math . Sqrt ( float64 ( a * a ) + float64 ( b * b ) - 2.0 * float64 ( a ) * float64 ( b ) * math . Cos ( rad ) ) fmt . Println ( ans ) } package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var N , M int fmt . Scan ( & N , & M ) As : = make ( [ ] string , N ) Bs : = make ( [ ] string , M ) for i : = 0 ; i < N ; i + + { fmt . Scan ( & As [ i ] ) } for i : = 0 ; i < M ; i + + { fmt . Scan ( & Bs [ i ] ) } for sy : = 0 ; sy < N - M + 1 ; sy + + { for sx : = 0 ; sx < N - M + 1 ; sx + + { if match ( As , Bs , sx , sy ) { fmt . Println ( " " ) return } } } fmt . Println ( " " ) } func match ( As , Bs [ ] string , sx , sy int ) bool { M : = len ( Bs ) for y : = 0 ; y < len ( Bs ) ; y + + { if As [ sy + y ] [ sx : sx + M ] ! = Bs [ y ] { return false } } return true } package main import " " func main ( ) { arr : = make ( [ ] [ ] int , 3 ) for i : = range arr { arr [ i ] = make ( [ ] int , 3 ) for j : = range arr [ i ] { fmt . Scan ( & arr [ i ] [ j ] ) } } t1 : = arr [ 0 ] [ 1 ] - arr [ 0 ] [ 0 ] t2 : = arr [ 0 ] [ 2 ] - arr [ 0 ] [ 1 ] s1 : = arr [ 1 ] [ 0 ] - arr [ 0 ] [ 0 ] s2 : = arr [ 2 ] [ 0 ] - arr [ 1 ] [ 0 ] for i : = range arr { if arr [ i ] [ 1 ] - arr [ i ] [ 0 ] ! = t1 | | arr [ i ] [ 2 ] - arr [ i ] [ 1 ] ! = t2 { fmt . Println ( " " ) return } if arr [ 1 ] [ i ] - arr [ 0 ] [ i ] ! = s1 | | arr [ 2 ] [ i ] - arr [ 1 ] [ i ] ! = s2 { fmt . Println ( " " ) return } } fmt . Println ( " " ) } package main import ( " " " os " " bufio " " strconv " package main import ( " " " fmt " " os " " sort " " strconv " package main import " " func main ( ) { var N int fmt . Scanf ( " % d " package main import ( " " " math " " % d \ n " , int ( ans ) ) } package main import " " func main ( ) { var K , S int fmt . Scanf ( " % d % d " package main import ( " " " fmt " " math " " os " " strconv " " : ( " " : ( " " : ( " " : ( " " : ( " " : ( " " : ( " " : ( " " : ( " " : ( " " Yay ! " ) } package main import " " func main ( ) { var K , S int fmt . Scanf ( " % d % d " package main import ( " " " fmt " " math " " os " " strconv " package main import " " func main ( ) { var n int fmt . Scanf ( " % d \ n " , & n ) x : = make ( [ ] int , n ) for i : = 0 ; i < n ; i + + { fmt . Scanf ( " " , & x [ i ] ) } best : = int ( 1e9 ) for i : = 1 ; i < = 100 ; i + + { score : = 0 for _ , e : = range x { score + = ( e - i ) * ( e - i ) } if best > score { best = score } } fmt . Printf ( " \ n " , best ) } package main import " " func main ( ) { var x int fmt . Scan ( & x ) fmt . Println ( x * x * x ) } package main import ( " " " fmt " " math " " os " " strconv " package main import ( " " " fmt " " os " " Yes " " No " package main import ( " " " fmt " " os " " strconv " " Yay ! " ) } else { fmt . Println ( " : ( " package main import ( " " " fmt " " os " " sort " " strconv " " strings " " " package main import ( " " " sort " " YES " " NO " package main import ( " " " " ) func main ( ) { var n int fmt . Scan ( & n ) xs : = make ( [ ] int , n ) for i : = range xs { fmt . Scan ( & xs [ i ] ) } min : = math . MaxInt32 for i : = 1 ; i < = 100 ; i + + { sum : = 0 for _ , x : = range xs { sum + = ( x - i ) * ( x - i ) } if sum < min { min = sum } } fmt . Println ( min ) } package main import " " func main ( ) { var n int fmt . Scan ( & n ) x : = make ( [ ] int , n ) for i : = 0 ; i < n ; i + + { fmt . Scan ( & x [ i ] ) } res : = 9999999999 for i : = 1 ; i < = 100 ; i + + { tmp : = 0 for j : = 0 ; j < n ; j + + { run : = x [ j ] - i tmp + = run * run } if tmp < res { res = tmp } } fmt . Println ( res ) } package main import " " func main ( ) { var a int fmt . Scan ( & a ) fmt . Println ( a * a * a ) } package main import ( " " " fmt " " os " " strconv " " strings " " " package main import " " func main ( ) { var x int fmt . Scan ( & x ) fmt . Println ( x * x * x ) } package main import ( " " ) func main ( ) { var a1 , a2 , a3 int fmt . Scan ( & a1 , & a2 , & a3 ) if a1 < = a2 & & a2 < = a3 { fmt . Println ( a2 - a1 + a3 - a2 ) } else if a2 < = a1 & & a1 < = a3 { fmt . Println ( a1 - a2 + a3 - a1 ) } else if a1 < = a3 & & a3 < = a2 { fmt . Println ( a3 - a1 + a2 - a3 ) } else if a2 < = a3 & & a3 < = a1 { fmt . Println ( a3 - a2 + a1 - a3 ) } else if a3 < = a1 & & a1 < = a2 { fmt . Println ( a1 - a3 + a2 - a1 ) } else if a3 < = a2 & & a2 < = a1 { fmt . Println ( a2 - a3 + a1 - a2 ) } } package main import ( " " ) func main ( ) { var N int fmt . Scanf ( " % d " " % d " package main import ( " " " fmt " " os " " strconv " " Yes " " No " package main import ( " " " fmt " " math " " os " " strconv " package main import ( " " " fmt " " math " " os " " strconv " package main import ( " " " fmt " " os " " strconv " " Three " " Four " package main import " " func main ( ) { grid : = make ( [ ] [ ] int , 3 ) for i : = range grid { grid [ i ] = make ( [ ] int , 3 ) if i ! = 2 { fmt . Scanf ( " \ n " , & grid [ i ] [ 0 ] , & grid [ i ] [ 1 ] , & grid [ i ] [ 2 ] ) } else { fmt . Scanf ( " " , & grid [ i ] [ 0 ] , & grid [ i ] [ 1 ] , & grid [ i ] [ 2 ] ) } } a : = make ( [ ] int , 3 ) b : = make ( [ ] int , 3 ) a [ 0 ] = 0 b [ 0 ] = grid [ 0 ] [ 0 ] b [ 1 ] = grid [ 1 ] [ 0 ] b [ 2 ] = grid [ 2 ] [ 0 ] a [ 1 ] = grid [ 0 ] [ 1 ] - b [ 0 ] a [ 2 ] = grid [ 0 ] [ 2 ] - b [ 0 ] flg : = true for i : = 0 ; i < 3 ; i + + { for j : = 0 ; j < 3 ; j + + { if grid [ i ] [ j ] = = ( a [ j ] + b [ i ] ) { continue } else { flg = false } } } if flg { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import " " func main ( ) { var n int fmt . Scan ( & n ) p : = make ( [ ] int , n ) for i : = range p { fmt . Scan ( & p [ i ] ) } var m , ans int for i , v : = range p { if i = = 0 | | v < m { m = v } if p [ i ] = = m { ans + + } } fmt . Println ( ans ) } package main import " " func main ( ) { var N , M int fmt . Scanf ( " % d % d " " % s " " % s " " No " ) } else { fmt . Println ( " " ) } } package main import ( " " " fmt " " os " " sort " " strconv " package main import ( " " " os " " : ( " " Yay ! " ) } package main import ( " " " fmt " " os " " strconv " " NO " " YES " " NO " package main import ( " " " sort " " YES " " NO " package main import " " func main ( ) { var x int for { i , _ : = fmt . Scanf ( " % d " package main import " " func main ( ) { var N , K int fmt . Scanf ( " % d % d " package main import ( " " " fmt " " math " " os " " strconv " " MASPY " " ますピ " { fp , T HE _ HARMONY _ OF _ PERFECT " ) ) cn t P Y " ) = = " " { wfp , _ = os . C U S10 " ) ) } scanner : = - -- -- -- -- -- -- -- -- -- - " ) so lv e ( sc an ne r , package main import ( " " " " ) func main ( ) { var input string fmt . Scanln ( & input ) var i , _ = strconv . ParseInt ( input , 10 , 0 ) fmt . Println ( i * i * i ) } package main import ( " " " fmt " " os " " strconv " " strings " " Three " " Four " " scan string failed " " scan string failed " " " package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var n int fmt . Scan ( & n ) nums : = make ( [ ] int , n ) for i : = 0 ; i < n ; i + + { fmt . Scan ( & nums [ i ] ) } var count int var min int for i : = 0 ; i < n ; i + + { if i = = 0 { min = nums [ i ] count + + } else { if min > nums [ i ] { min = nums [ i ] count + + } } } fmt . Println ( count ) } package main import ( " " " fmt " " math " " os " " reflect " " sort " " strconv " " strings " " " package main import " " func main ( ) { var x int fmt . Scanln ( & x ) fmt . Println ( x * x * x ) } package main import " " func main ( ) { var n int fmt . Scan ( & n ) fmt . Println ( n * n * n ) } package main import " " func main ( ) { var k , s int fmt . Scan ( & k , & s ) count : = 0 double : = 0 triple : = 0 for x : = 0 ; x < = k ; x + + { for y : = x ; y < = k ; y + + { for z : = y ; z < = k ; z + + { if x + y + z = = s { count + + if x = = y & & y = = z { triple + + } else if x = = y | | y = = z | | z = = x { double + + } } } } } count = ( count - ( double + triple ) ) * 6 + double * 3 + triple fmt . Println ( count ) } package main import ( " " " fmt " " os " package main import ( " " " fmt " " io " " os " " runtime / debug " " sort " " strconv " \ n \ r \ t package main import ( " " " fmt " " math " " os " " strconv " " % .10 f \ n " , ans ) } package main import ( " " ) func main ( ) { var ( d [ 5 ] int k int ) for i : = 0 ; i < 5 ; i + + { fmt . Scanln ( & d [ i ] ) } fmt . Scanln ( & k ) if d [ 4 ] - d [ 0 ] > k { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import " " func main ( ) { var x int fmt . Scan ( & x ) fmt . Println ( x * x * x ) } package main import ( " " " fmt " " math " " os " " strconv " package main import " " func main ( ) { var count [ 10 ] int var a , b , c int fmt . Scan ( & a , & b , & c ) count [ a ] + + count [ b ] + + count [ c ] + + if count [ 5 ] = = 2 & & count [ 7 ] = = 1 { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " " fmt " " math " " os " " reflect " " sort " " strconv " " strings " " " package main import ( " " " " ) func main ( ) { var a , b , c int fmt . Scan ( & a , & b , & c ) val : = [ ] int { a , b , c } sort . Sort ( sort . IntSlice ( val ) ) fmt . Println ( val [ 2 ] - val [ 0 ] ) } package main import ( " " ) func main ( ) { var n int fmt . Scan ( & n ) x : = make ( [ ] int , n ) for i , _ : = range x { fmt . Scan ( & x [ i ] ) } ans : = 1000000000000 for i : = 1 ; i < = 100 ; i + + { temp : = 0 for _ , v : = range x { temp + = ( i - v ) * ( i - v ) } ans = min ( temp , ans ) } fmt . Println ( ans ) } func min ( a , b int ) int { if a > b { return b } return a } package main import ( " " " sort " " : ( " " Yay ! " ) } } package main import " " func main ( ) { var N int fmt . Scan ( & N ) ans : = 0 for _ , n : = range [ ] int { 1 , 2 , 4 , 8 , 16 , 32 , 64 } { if n < = N { ans = n } } fmt . Println ( ans ) } package main import ( " " " sort " " NO " " YES " package main import " " func main ( ) { n , an : = 0 , 1 < < 63 - 1 var x [ ] int fmt . Scanf ( " " , & n ) for i : = 0 ; i < n ; i + + { tmp : = 0 fmt . Scanf ( " " , & tmp ) x = append ( x , tmp ) } for i : = 1 ; i < = 100 ; i + + { an1 : = 0 for _ , j : = range x { an1 + = ( j - i ) * ( j - i ) } if an > an1 { an = an1 } } fmt . Println ( an ) } package main import ( " " " " ) func main ( ) { nums : = make ( [ ] int , 3 ) for i : = 0 ; i < 3 ; i + + { fmt . Scan ( & nums [ i ] ) } sort . Ints ( nums ) fmt . Println ( nums [ 2 ] - nums [ 0 ] ) } package main import " " const div = 1000000000 + 7 func abs ( i int ) int { if i < 0 { return - i } return i } func mod ( i int ) int { return i % div } func fact ( i int ) int { if i = = 1 { return 1 } return mod ( i * fact ( i - 1 ) ) } func main ( ) { var n , m int fmt . Scan ( & n , & m ) if abs ( n - m ) > 1 { fmt . Println ( 0 ) return } mn : = fact ( n ) mm : = fact ( m ) if n = = m { fmt . Println ( mod ( mn * mm * 2 ) ) return } fmt . Println ( mod ( mn * mm ) ) } package main import ( " " " fmt " " os " " strconv " " Yes " ) } else { fmt . Fprintln ( wtr , " No " package main import " " func main ( ) { var K , S int fmt . Scan ( & K , & S ) var ans int for x : = 0 ; x < = K ; x + + { for y : = 0 ; y < = K ; y + + { z : = S - ( x + y ) if 0 < = z & & z < = K { ans + + } } } fmt . Println ( ans ) } package main import ( " " " fmt " " os " package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " strconv " " Yes " " No " package main import " " func main ( ) { c : = make ( [ ] [ ] int , 3 ) for i : = range c { for j : = 0 ; j < 3 ; j + + { var tmp int fmt . Scan ( & tmp ) c [ i ] = append ( c [ i ] , tmp ) } } var a1 , a2 , a3 , b1 , b2 , b3 int a1 = 0 b1 = c [ 0 ] [ 0 ] b2 = c [ 0 ] [ 1 ] b3 = c [ 0 ] [ 2 ] a2 = c [ 1 ] [ 0 ] - b1 a3 = c [ 2 ] [ 0 ] - b1 a : = [ ] int { a1 , a2 , a3 } b : = [ ] int { b1 , b2 , b3 } ans : = " " LABEL : for i : = range c { for j : = range c { if c [ i ] [ j ] ! = a [ i ] + b [ j ] { ans = " " break LABEL } } } fmt . Println ( ans ) } package main import " " func main ( ) { var N int fmt . Scan ( & N ) var b bool for i : = 0 ; i < N ; i + + { w : = " " fmt . Scan ( & w ) if w = = " " { b = true break } } if b { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " " fmt " " io " " math " " os " " strconv " " % 0.15 f " package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " math " " os " " reflect " " sort " " strconv " " strings " " % .12 f " " " package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var N int fmt . Scan ( & N ) P : = make ( [ ] int , N ) for i : = range P { fmt . Scan ( & P [ i ] ) } min : = P [ 0 ] res : = 0 for i : = range P { if min > = P [ i ] { res + + } if min > P [ i ] { min = P [ i ] } } fmt . Println ( res ) } package main import ( " " " fmt " " os " " strconv " " Yes " " No " " scan error " " text to int error " package main import ( " " " " ) func main ( ) { a : = make ( [ ] int , 3 ) for i : = 0 ; i < 3 ; i + + { fmt . Scan ( & a [ i ] ) } sort . Ints ( a ) fmt . Println ( a [ 2 ] - a [ 0 ] ) } package main import " " func main ( ) { var K , S int fmt . Scan ( & K , & S ) var count int for i : = 0 ; i < = K ; i + + { for j : = 0 ; j < = K ; j + + { k : = S - i - j if 0 < = k & & k < = K { count + + } } } fmt . Println ( count ) } package main import ( " " " fmt " " os " " strconv " " YES " " NO " package main import " " func main ( ) { var a [ 3 ] int var c5 , c7 int fmt . Scan ( & a [ 0 ] , & a [ 1 ] , & a [ 2 ] ) for _ , v : = range a { switch v { case 5 : c5 + + case 7 : c7 + + } } if c5 = = 2 & & c7 = = 1 { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " " sort " " YES " " NO " package main import " " func isHaikable ( a , b , c int ) { } func main ( ) { var a , b , c int ret : = " NO " fmt . Scan ( & a , & b , & c ) if a = = 7 { if b = = 5 & & c = = 5 { ret = " " } } else if b = = 7 { if a = = 5 & & c = = 5 { ret = " " } } else if c = = 7 { if b = = 5 & & a = = 5 { ret = " " } } fmt . Println ( ret ) } package main import " " func main ( ) { var n int fmt . Scan ( & n ) var s string bucket : = make ( map [ string ] int , 4 ) for i : = 0 ; i < n ; i + + { fmt . Scan ( & s ) bucket [ s ] + + } switch len ( bucket ) { case 3 : fmt . Println ( " " ) default : fmt . Println ( " " ) } } package main import ( " " ) func main ( ) { nums : = make ( [ ] [ ] int , 3 ) for i : = range nums { nums [ i ] = make ( [ ] int , 3 ) for j : = 0 ; j < 3 ; j + + { fmt . Scan ( & nums [ i ] [ j ] ) } } var x [ 3 ] int var y [ 3 ] int x [ 0 ] = 0 for i : = 0 ; i < 3 ; i + + { y [ i ] = nums [ 0 ] [ i ] - x [ 0 ] } for i : = 1 ; i < 3 ; i + + { x [ i ] = nums [ i ] [ 0 ] - y [ 0 ] } judge : = true for i : = 0 ; i < 3 ; i + + { for j : = 0 ; j < 3 ; j + + { if nums [ i ] [ j ] ! = x [ i ] + y [ j ] { judge = false break } } } if judge { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " ) func main ( ) { var h1 , m1 , h2 , m2 , k int fmt . Scan ( & h1 , & m1 , & h2 , & m2 , & k ) diffTime : = ( h2 - h1 ) * 60 + ( m2 - m1 ) if diffTime < k { fmt . Println ( 0 ) } else { fmt . Println ( diffTime - k ) } } package main import ( " " ) func main ( ) { var A , B , C int fmt . Scan ( & A , & B , & C ) a : = abs ( A - B ) + abs ( B - C ) b : = abs ( A - C ) + abs ( C - B ) c : = abs ( A - B ) + abs ( A - C ) fmt . Println ( min ( min ( a , b ) , c ) ) } func abs ( a int ) int { if a < 0 { return - a } return a } func min ( a , b int ) int { if a < b { return a } return b } package main import " " func main ( ) { var temp int var five int var seven int var i int five = 0 ; seven = 0 ; i = 0 for { fmt . Scanf ( " " , & temp ) ; if ( temp = = 5 ) { five + + ; } else if ( temp = = 7 ) { seven + + ; } i + + ; if i = = 3 { break } } if ( seven = = 1 & & five = = 2 ) { fmt . Printf ( " \ n " ) ; } else { fmt . Printf ( " \ n " ) ; } } package main import ( " " ) const ( N = 10 ) func abs ( a int ) int { if a < 0 { return - a } return a } func main ( ) { var a [ N ] int var k int n : = 5 for i : = 0 ; i < n ; i + + { fmt . Scan ( & a [ i ] ) } fmt . Scan ( & k ) for i : = 0 ; i < n ; i + + { for j : = i ; j < n ; j + + { if abs ( a [ i ] - a [ j ] ) > k { fmt . Println ( " : ( " ) return } } } fmt . Println ( " Yay ! " ) } package main import ( . " " " sort " " % d % d % d " package main import ( " " " fmt " " os " " strconv " " strings " " % d " " % d " " \ n " ) } func getStdin ( ) string { return readLine ( ) } func getStdinInt ( ) int { str : = getStdin ( ) rtn , _ : = strconv . Atoi ( str ) return rtn } func getStdinIntArr ( ) [ ] int { str : = getStdin ( ) list : = strings . Split ( str , " " ) rtn : = make ( [ ] int , len ( list ) ) for idx , val : = range list { rtn [ idx ] , _ = strconv . Atoi ( val ) } return rtn } func getStdinIntArr64 ( ) [ ] int64 { str : = getStdin ( ) list : = strings . Split ( str , " " ) rtn : = make ( [ ] int64 , len ( list ) ) for idx , val : = range list { rtn [ idx ] , _ = strconv . ParseInt ( val , 10 , 64 ) } return rtn } func readLine ( ) string { buf : = make ( [ ] byte , 0 , 0 ) for { l , p , e : = sc . ReadLine ( ) if e ! = nil { panic ( e ) } buf = append ( buf , l ... ) if ! p { break } } return string ( buf ) } package main import ( " " ) func scanNums ( len int ) ( nums [ ] int ) { var num int for i : = 0 ; i < len ; i + + { fmt . Scan ( & num ) nums = append ( nums , num ) } return } func main ( ) { nums : = scanNums ( 5 ) var k int fmt . Scan ( & k ) if nums [ 4 ] - nums [ 0 ] > k { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import " " func main ( ) { var h [ 3 ] [ 3 ] int for i : = 0 ; i < 3 ; i + + { fmt . Scan ( & h [ i ] [ 0 ] , & h [ i ] [ 1 ] , & h [ i ] [ 2 ] ) } for i : = 0 ; i < = 100 ; i + + { b1 : = h [ 0 ] [ 0 ] - i b2 : = h [ 0 ] [ 1 ] - i b3 : = h [ 0 ] [ 2 ] - i for j : = 0 ; j < = 100 ; j + + { if h [ 1 ] [ 0 ] - j = = b1 & & h [ 1 ] [ 1 ] - j = = b2 & & h [ 1 ] [ 2 ] - j = = b3 { for k : = 0 ; k < = 100 ; k + + { if h [ 2 ] [ 0 ] - k = = b1 & & h [ 2 ] [ 1 ] - k = = b2 & & h [ 2 ] [ 2 ] - k = = b3 { fmt . Println ( " " ) return } } } } } fmt . Println ( " " ) } package main import ( " " " fmt " " os " " strconv " " No more token . " " nextInt ( ) : cannot convert to int : " " No more token . " ) } return scanner . Text ( ) } func MinInt ( x , y int ) int { if x < y { return x } else { return y } } func MaxInt ( x , y int ) int { if x < y { return y } else { return x } } func AbsInt ( x int ) int { if x < 0 { return - x } return x } func ModPow ( base , exponent , modulo int ) ( result int ) { result = 1 for exponent > 0 { if exponent % 2 = = 1 { result * = base if modulo > 1 { result % = modulo } } base * = base if modulo > 1 { base % = modulo } exponent / = 2 } return } func Gcd ( vals ... int ) ( result int ) { if len ( vals ) = = 0 { return } result = vals [ 0 ] for i : = 1 ; i < len ( vals ) ; i + + { result = gcd ( result , vals [ i ] ) } return } func gcd ( x , y int ) int { x , y = AbsInt ( x ) , AbsInt ( y ) for y > 0 { x , y = y , x % y } return x } func Lcm ( vals ... int ) ( result int ) { if len ( vals ) = = 0 { return } result = vals [ 0 ] for i : = 1 ; i < len ( vals ) ; i + + { result = lcm ( result , vals [ i ] ) } return } func lcm ( x , y int ) int { return x * y / gcd ( x , y ) } package main import ( " " " sort " " YES " " NO " package main import ( " " " fmt " " math " " os " " strconv " " strings " " " " " " " " " " b " " a " " c " " d " package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " strconv " " : ( " " Yay ! " ) } package main import ( " " " fmt " " os " " strconv " " : ( " " Yay ! " package main import ( " " " strings " " Yes " " No " package main import ( " " " fmt " " os " " strconv " " YES " " NO " package main import ( " " " fmt " " os " package main import ( " " " fmt " " io " " os " " sort " " strconv " \ n \ r \ t package main import ( " " " fmt " " os " " sort " " strconv " package main import ( " " " fmt " " os " " strconv " " : ( " " Yay ! " ) } } package main import ( " " " fmt " " os " " strconv " " No " " Yes " package main import ( " " ) func solution ( a [ ] int ) string { k : = a [ 5 ] for i : = 0 ; i < 5 ; i + + { for j : = 0 ; j < 5 ; j + + { if i = = j { continue } if a [ i ] - a [ j ] > k { return " " } } } return " " } func main ( ) { a : = make ( [ ] int , 0 , 6 ) for i : = 0 ; i < 6 ; i + + { t : = 0 fmt . Scan ( & t ) a = append ( a , t ) } fmt . Println ( solution ( a ) ) } package main import ( " " " " ) func main ( ) { var a , b , h , m float64 fmt . Scan ( & a , & b , & h , & m ) hourDeg : = ( h * 60 + m ) / 2 minDeg : = m * 6 deg : = minDeg - hourDeg if deg < 0 { deg = - deg } if deg > = 180 { deg = 360 - deg } rad : = ( math . Pi / 180 ) * deg cc : = ( a * a ) + ( b * b ) - 2 * a * b * math . Cos ( rad ) fmt . Println ( math . Sqrt ( cc ) ) } package main import ( " " " fmt " " math " " os " " strconv " package main import ( " " ) func main ( ) { var data int fmt . Scan ( & data ) var result = data * data * data fmt . Printf ( " \ n " , result ) } package main import ( " " " fmt " " os " package main import " " func main ( ) { var N , M int fmt . Scan ( & N , & M ) A : = make ( [ ] [ ] byte , N ) B : = make ( [ ] [ ] byte , M ) var s string for i : = 0 ; i < N ; i + + { fmt . Scan ( & s ) for j : = 0 ; j < N ; j + + { A [ i ] = append ( A [ i ] , s [ j ] ) } } for i : = 0 ; i < M ; i + + { fmt . Scan ( & s ) for j : = 0 ; j < M ; j + + { B [ i ] = append ( B [ i ] , s [ j ] ) } } if N = = M { N + + } for i : = 0 ; i < N - M ; i + + { for j : = 0 ; j < N - M ; j + + { c : = true for y : = 0 ; y < M ; y + + { for x : = 0 ; x < M ; x + + { if A [ y + i ] [ x + j ] ! = B [ y ] [ x ] { c = false break } } } if c = = true { fmt . Println ( " " ) return } } } fmt . Println ( " " ) } package main import ( " " " sort " " strings " " Four " " Three " " " " " package main import ( " " " fmt " " os " " sort " " strconv " package main import " " func main ( ) { var k , s , cnt int fmt . Scanf ( " % d % d " " % d " package main import " " func main ( ) { var a , b , c int fmt . Scan ( & a , & b , & c ) if a + b + c = = 17 { if a = = 5 & & b = = 5 { fmt . Println ( " " ) } else if b = = 5 & & c = = 5 { fmt . Println ( " " ) } else if a = = 5 & & c = = 5 { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } else { fmt . Println ( " " ) } } package main import ( " " " errors " " fmt " " io " " math " " os " " strconv " " Scan failed " " % b " " [ argument error ] : PowInt does not accept negative integers " " [ argument error ] : Gcd only accepts two NATURAL numbers " " [ argument error ] : Gcd only accepts two NATURAL numbers " " [ argument error ] : Strtoi only accepts integer string " package main import ( " " " fmt " " os " " strconv " " MASPY " " ますピ " { fp , T HE _ HARMONY _ OF _ PERFECT " ) ) } i P Y " ) = = " " { wfp , _ = os . C U S10 " ) ) } scanner : = package main import " " func main ( ) { var A , B , C int fmt . Scan ( & A , & B , & C ) sum : = A + B + C ans : = " " if sum = = 17 { ans = " " } fmt . Println ( ans ) } package main import " " func main ( ) { slice : = make ( [ ] int , 3 ) fmt . Scanf ( " " , & slice [ 0 ] , & slice [ 1 ] , & slice [ 2 ] ) count5 : = 0 count7 : = 0 for i : = 0 ; i < 3 ; i + + { if slice [ i ] = = 5 { count5 + + } else if slice [ i ] = = 7 { count7 + + } } if count5 = = 2 & & count7 = = 1 { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " ) func main ( ) { var a , b int fmt . Scanf ( " % d % d " " % d \ n " , ans ) } package main import ( " " " fmt " " log " " os " " strconv " package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var num int fmt . Scan ( & num ) num = num * num * num fmt . Println ( num ) } package main import ( " " ) var a int func main ( ) { fmt . Scan ( & a ) fmt . Println ( a * a * a ) } package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " sort " " strconv " package main import " " func main ( ) { var n , m int var s string fmt . Scan ( & n , & m ) a : = make ( [ ] int64 , n ) b : = make ( [ ] int64 , m ) for i : = 0 ; i < n ; i + + { fmt . Scan ( & s ) for j : = 0 ; j < n ; j + + { if s [ j : j + 1 ] = = " " { a [ i ] | = 1 < < uint ( j ) } } } for i : = 0 ; i < m ; i + + { fmt . Scan ( & s ) for j : = 0 ; j < m ; j + + { if s [ j : j + 1 ] = = " " { b [ i ] | = 1 < < uint ( j ) } } } for i : = 0 ; i < n - m + 1 ; i + + { Mid : for j : = 0 ; j < n - m + 1 ; j + + { for k : = 0 ; k < m ; k + + { if ( ( a [ i + k ] > > uint ( j ) ) & b [ k ] ) ! = b [ k ] { continue Mid } } fmt . Println ( " " ) return } } fmt . Println ( " " ) } package main import " " var N int var P [ ] int func main ( ) { fmt . Scan ( & N ) P = make ( [ ] int , N ) for i : = range P { fmt . Scan ( & P [ i ] ) } min : = N + 100 ans : = 0 for i : = range P { if min > P [ i ] { min = P [ i ] ans + + } } fmt . Println ( ans ) } package main import " " func main ( ) { var k , s , m int fmt . Scan ( & k , & s ) for x : = 0 ; x < k + 1 ; x + + { for y : = 0 ; y < k + 1 ; y + + { z : = s - x - y if 0 < = z & & z < = k { m + + } } } fmt . Println ( m ) } package main import ( " " ) func abs ( a int ) int { if a < 0 { return - a } else { return a } } func main ( ) { a : = make ( [ ] int , 3 ) fmt . Scan ( & a [ 0 ] , & a [ 1 ] , & a [ 2 ] ) max : = a [ 0 ] min : = a [ 2 ] for i : = 0 ; i < 3 ; i + + { if a [ i ] > max { max = a [ i ] } if a [ i ] < min { min = a [ i ] } } fmt . Println ( max - min ) } package main import " " func prmFac ( x int ) map [ int ] int { pfm : = make ( map [ int ] int ) for i : = 2 ; i * i < = x ; i + + { for x % i = = 0 { x / = i pfm [ i ] + + } } if x > 1 { pfm [ x ] + + } return pfm } func main ( ) { var n , p int fmt . Scan ( & n , & p ) ans : = 1 for pn , cnt : = range prmFac ( p ) { for i : = 0 ; i < cnt ; i + + { x : = 1 for j : = 0 ; j < n ; j + + { x * = pn if x > p { break } else if j = = n - 1 & & p % x = = 0 { ans * = pn p / = x } } } } fmt . Println ( ans ) } package main import ( " " " " ) func main ( ) { var a , b , h , m , c float64 var arg1 , arg2 float64 fmt . Scan ( & a , & b , & h , & m ) arg1 = 30 * h + float64 ( 360 ) / float64 ( 12 ) / float64 ( 60 ) * m arg2 = 6 * m arg : = math . Abs ( arg1 - arg2 ) if arg > 180 { arg = 360 - arg } aS : = a * a bS : = b * b that : = 2 * a * b * math . Cos ( math . Pi * ( arg / 180 ) ) c = math . Sqrt ( aS + bS - that ) fmt . Println ( c ) } package main import ( " " ) func main ( ) { var k , s int ans : = 0 fmt . Scan ( & k , & s ) for i : = 0 ; i < = k ; i + + { for t : = 0 ; t < = k ; t + + { z : = s - i - t if 0 < = z & & z < = k { ans + + } } } fmt . Println ( ans ) } package main import ( " " " math " " % d % d % d % d \ n " , & a , & b , & H , & M ) sin1 , cos1 : = math . Sincos ( 2 * math . Pi * ( float64 ( H ) / 12.0 + float64 ( M ) / 60.0 / 12.0 ) ) sin2 , cos2 : = math . Sincos ( 2 * math . Pi * float64 ( M ) / 60.0 ) A , B : = float64 ( a ) , float64 ( b ) r : = math . Sqrt ( ( A * cos1 - B * cos2 ) * ( A * cos1 - B * cos2 ) + ( A * sin1 - B * sin2 ) * ( A * sin1 - B * sin2 ) ) fmt . Println ( r ) } package main import ( " " _ " " " fmt " " os " " sort " " strconv " package main import " " func main ( ) { c : = make ( [ ] int , 3 ) for i , _ : = range c { fmt . Scan ( & c [ i ] ) } if c [ 0 ] = = 7 & & c [ 1 ] = = 5 & & c [ 2 ] = = 5 { fmt . Println ( " " ) return } if c [ 0 ] = = 5 & & c [ 1 ] = = 7 & & c [ 2 ] = = 5 { fmt . Println ( " " ) return } if c [ 0 ] = = 5 & & c [ 1 ] = = 5 & & c [ 2 ] = = 7 { fmt . Println ( " " ) return } fmt . Println ( " " ) } package main import ( " " " fmt " " math " " os " " strconv " " strings " " % .19 f " " % .19 f " " \ n " ) } var sc = bufio . NewScanner ( os . Stdin ) func getStdin ( ) string { sc . Scan ( ) return sc . Text ( ) } func getStdinIntArr ( ) [ ] int { str : = getStdin ( ) list : = strings . Split ( str , " " ) rtn : = make ( [ ] int , len ( list ) ) for idx , val : = range list { rtn [ idx ] , _ = strconv . Atoi ( val ) } return rtn } package main import " " func main ( ) { var K , S int fmt . Scan ( & K ) fmt . Scan ( & S ) var cnt int for X : = 0 ; X < = K ; X + + { for Y : = 0 ; Y < = K ; Y + + { Z : = S - X - Y if 0 < = Z & & Z < = K { cnt + + } } } fmt . Println ( cnt ) } package main import " " func main ( ) { var K , S int fmt . Scanf ( " % d % d " package main import ( " " " math " " % f % f % f % f " package main import ( " " " " ) func main ( ) { var x float64 fmt . Scan ( & x ) fmt . Println ( int ( math . Pow ( x , 3 ) ) ) } package main import ( " " ) func main ( ) { var c [ 3 ] [ 3 ] int for i : = 0 ; i < 3 ; i + + { fmt . Scan ( & c [ i ] [ 0 ] , & c [ i ] [ 1 ] , & c [ i ] [ 2 ] ) } var a [ 3 ] int var b [ 3 ] int a [ 0 ] = 0 b [ 0 ] = c [ 0 ] [ 0 ] b [ 1 ] = c [ 0 ] [ 1 ] b [ 2 ] = c [ 0 ] [ 2 ] a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] for i : = 0 ; i < 3 ; i + + { for j : = 0 ; j < 3 ; j + + { if a [ i ] + b [ j ] ! = c [ i ] [ j ] { fmt . Println ( " " ) return } } } fmt . Println ( " " ) } package main import ( " " " sort " " YES " " NO " package main import ( " " ) func main ( ) { var n , m int fmt . Scan ( & n , & m ) board : = make ( [ ] string , n ) target : = make ( [ ] string , m ) for i : = 0 ; i < n ; i + + { fmt . Scan ( & board [ i ] ) } for i : = 0 ; i < m ; i + + { fmt . Scan ( & target [ i ] ) } for i : = 0 ; i < n - m + 1 ; i + + { for j : = 0 ; j < n - m + 1 ; j + + { flag : = false for dy : = 0 ; dy < m ; dy + + { for dx : = 0 ; dx < m ; dx + + { if board [ i + dy ] [ j + dx ] ! = target [ dy ] [ dx ] { flag = true break } } if flag { break } } if flag { continue } fmt . Println ( " " ) return } } fmt . Println ( " " ) } package main import ( " " ) func main ( ) { var N int fmt . Scan ( & N ) if N % 2 = = 0 { fmt . Println ( N / 2 , N , N ) } else if N % 3 = = 0 { fmt . Println ( N / 3 , 2 * N , 2 * N ) } else { w : = 0 for h : = 1 ; h < = 3500 ; h + + { for n : = 1 ; n < = 3500 ; n + + { if 4 * h * n - N * ( h + n ) < = 0 { continue } if N * h * n % ( 4 * h * n - N * ( h + n ) ) ! = 0 { continue } w = N * h * n / ( 4 * h * n - N * ( h + n ) ) fmt . Println ( h , n , w ) break } if w ! = 0 { break } } } } package main import ( " " ) func DivideBy2 ( i int ) int { cnt : = 0 num : = i for num % 2 = = 0 { cnt + + num / = 2 } return cnt } func main ( ) { var n int fmt . Scan ( & n ) max _ num : = 0 max _ cnt : = - 1 for i : = 1 ; i < = n ; i + + { if DivideBy2 ( i ) > max _ cnt { max _ cnt = DivideBy2 ( i ) max _ num = i } } fmt . Println ( max _ num ) } package main import ( " " " fmt " " io " " math / big " " os " " strconv " package main import " " func main ( ) { var h1 , m1 , h2 , m2 , k int fmt . Scan ( & h1 , & m1 , & h2 , & m2 , & k ) m _ val : = m2 - m1 h _ val : = h2 - h1 time : = h _ val * 60 + m _ val fmt . Println ( time - k ) } package main import ( " " " fmt " " os " " sort " " % d " " % d " " % d " package main import ( " " " " ) func abs ( a int ) int { if a > 0 { return a } return ( - 1 ) * a } func main ( ) { var a [ 3 ] int fmt . Scan ( & a [ 0 ] , & a [ 1 ] , & a [ 2 ] ) b : = a [ : ] sort . Ints ( b ) fmt . Println ( abs ( b [ 0 ] - b [ 1 ] ) + abs ( b [ 1 ] - b [ 2 ] ) ) } package main import ( " " ) func main ( ) { var k int var N [ 5 ] int fmt . Scan ( & N [ 0 ] , & N [ 1 ] , & N [ 2 ] , & N [ 3 ] , & N [ 4 ] , & k ) if N [ 4 ] - N [ 0 ] > k { fmt . Println ( " : ( " ) } else { fmt . Println ( " Yay ! " ) } } package main import ( " " " fmt " " os " " strconv " " strings " " % d " " " " " " " package main import ( " " " math " " % .0 f \ n " , math . Max ( math . Max ( a , b ) , c ) - math . Min ( math . Min ( a , b ) , c ) ) } package main import ( " " " errors " " fmt " " io " " math " " os " " strconv " " Scan failed " " % b " " [ argument error ] : Strtoi only accepts integer string " package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var a , b , c int fmt . Scanf ( " % d % d % d " " YES " ) } else { fmt . Println ( " " ) } } package main import ( " " ) func abs ( a int ) int { if a < 0 { return - a } return a } func main ( ) { var A1 , A2 , A3 int fmt . Scanf ( " % d % d % d " " % d \ n " , ans ) } package main import " " func solve ( ) { var N int fmt . Scan ( & N ) po : = 1 for po < = N { po * = 2 } fmt . Println ( po / 2 ) } func main ( ) { solve ( ) } func min ( a , b int ) int { if a < b { return a } return b } func max ( a , b int ) int { if a > b { return a } return b } func abs ( a int ) int { if a < 0 { return - a } return a } package main import " " func main ( ) { c : = make ( [ ] [ ] int , 3 ) for i : = range c { c [ i ] = make ( [ ] int , 3 ) for j : = range c [ i ] { fmt . Scan ( & c [ i ] [ j ] ) } } a : = make ( [ ] int , 3 ) for i : = 0 ; i < = 100 ; i + + { a [ 0 ] = i for j : = 0 ; j < = 100 ; j + + { a [ 1 ] = j for k : = 0 ; k < = 100 ; k + + { a [ 2 ] = k b00 : = c [ 0 ] [ 0 ] - a [ 0 ] b01 : = c [ 0 ] [ 1 ] - a [ 0 ] b02 : = c [ 0 ] [ 2 ] - a [ 0 ] b10 : = c [ 1 ] [ 0 ] - a [ 1 ] b11 : = c [ 1 ] [ 1 ] - a [ 1 ] b12 : = c [ 1 ] [ 2 ] - a [ 1 ] b20 : = c [ 2 ] [ 0 ] - a [ 2 ] b21 : = c [ 2 ] [ 1 ] - a [ 2 ] b22 : = c [ 2 ] [ 2 ] - a [ 2 ] if b00 = = b10 & & b00 = = b20 & & b10 = = b20 { if b01 = = b11 & & b01 = = b21 & & b11 = = b21 { if b02 = = b12 & & b02 = = b22 & & b12 = = b22 { fmt . Println ( " " ) return } } } } } } fmt . Println ( " " ) } package main import ( " " " " ) func main ( ) { var a , b , h , m float64 fmt . Scan ( & a , & b , & h , & m ) Adeg : = h * 30 + m / 60 * 30 Bdeg : = m / 5 * 30 Deg : = math . Abs ( Adeg - Bdeg ) if Deg > 180 { Deg = 360 - Deg } X : = math . Pow ( a , 2 ) + math . Pow ( b , 2 ) - 2 * a * b * math . Cos ( Deg / 180 * math . Pi ) fmt . Println ( math . Sqrt ( X ) ) } package main import ( " " ) func merge ( left , right [ ] int ) ( ret [ ] int ) { ret = [ ] int { } for len ( left ) > 0 & & len ( right ) > 0 { var x int if right [ 0 ] > left [ 0 ] { x , left = left [ 0 ] , left [ 1 : ] } else { x , right = right [ 0 ] , right [ 1 : ] } ret = append ( ret , x ) } ret = append ( ret , left ... ) ret = append ( ret , right ... ) return } func sort ( left , right [ ] int ) ( ret [ ] int ) { if len ( left ) > 1 { l , r : = split ( left ) left = sort ( l , r ) } if len ( right ) > 1 { l , r : = split ( right ) right = sort ( l , r ) } ret = merge ( left , right ) return } func split ( values [ ] int ) ( left , right [ ] int ) { left = values [ : len ( values ) / 2 ] right = values [ len ( values ) / 2 : ] return } func Sort ( values [ ] int ) ( ret [ ] int ) { left , right : = split ( values ) ret = sort ( left , right ) return } func main ( ) { a : = make ( [ ] int , 3 ) fmt . Scan ( & a [ 0 ] , & a [ 1 ] , & a [ 2 ] ) b : = Sort ( a ) fmt . Println ( b [ 2 ] - b [ 0 ] ) } package main import ( " " " fmt " " os " " sort " " strconv " package main import " " func main ( ) { var N = 5 at : = make ( [ ] int , N ) for i : = 0 ; i < N ; i + + { fmt . Scan ( & at [ i ] ) } var K int fmt . Scan ( & K ) var can = true for i : = N - 1 ; i > 0 ; i -- { for j : = 0 ; j < N ; j + + { if at [ i ] - at [ j ] > K { can = false break } } } if can { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " " math " " % 0.10 f \ n " , ans ) } package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " strconv " " Yes " " No " package main import ( " " " " ) func main ( ) { var n int fmt . Scan ( & n ) x : = make ( [ ] int , n ) sum : = 0 for i : = 0 ; i < n ; i + + { fmt . Scan ( & x [ i ] ) sum + = x [ i ] } avg : = sum / n p : = [ ] int { avg - 1 , avg , avg + 1 } res : = [ ] int { 0 , 0 , 0 } for i : = 0 ; i < n ; i + + { for j : = 0 ; j < len ( p ) ; j + + { res [ j ] + = ( x [ i ] - p [ j ] ) * ( x [ i ] - p [ j ] ) } } sort . Ints ( res ) fmt . Println ( res [ 0 ] ) } package main import " " func min ( a , b int ) int { if a < b { return a } return b } func main ( ) { var N int fmt . Scan ( & N ) X : = make ( [ ] int , N ) for i : = range X { fmt . Scan ( & X [ i ] ) } ans : = int ( 1e18 ) for p : = 1 ; p < = 100 ; p + + { cost : = 0 for i : = 0 ; i < N ; i + + { cost + = ( X [ i ] - p ) * ( X [ i ] - p ) } ans = min ( ans , cost ) } fmt . Println ( ans ) } package main import ( " " " fmt " " os " package main import ( " " " fmt " " os " " strconv " " : ( " " Yay ! " ) } package main import ( " " " fmt " " math " " os " " strconv " " strings " " " package main import " " func main ( ) { var N int fmt . Scan ( & N ) for i : = 0 ; i < N ; i + + { var A string fmt . Scan ( & A ) if A = = " " { fmt . Println ( " " ) return } } fmt . Println ( " " ) } package main import " " func main ( ) { var H1 , M1 , H2 , M2 , K int fmt . Scan ( & H1 , & M1 , & H2 , & M2 , & K ) if M2 > M1 { H2 -- M2 + = 60 } T : = M2 - M1 + ( H2 - H1 ) * 60 fmt . Println ( max ( 0 , T - K ) ) } func max ( a , b int ) int { if a > b { return a } return b } package main import ( " " " fmt " " os " " strconv " " NO " " YES " " NO " package main import " " func main ( ) { var c [ 3 ] [ 3 ] int for i : = 0 ; i < 3 ; i + + { for j : = 0 ; j < 3 ; j + + { fmt . Scan ( & c [ i ] [ j ] ) } } for a1 : = 0 ; a1 < = c [ 0 ] [ 0 ] ; a1 + + { b1 : = c [ 0 ] [ 0 ] - a1 b2 : = c [ 0 ] [ 1 ] - a1 b3 : = c [ 0 ] [ 2 ] - a1 a2 : = c [ 1 ] [ 0 ] - b1 a3 : = c [ 2 ] [ 0 ] - b1 if a2 + b2 = = c [ 1 ] [ 1 ] & & a3 + b3 = = c [ 2 ] [ 2 ] & & a2 + b3 = = c [ 1 ] [ 2 ] & & a3 + b2 = = c [ 2 ] [ 1 ] { fmt . Println ( " " ) return } } fmt . Println ( " " ) } package main import ( " " " math " " % d % d % d " package main import ( " " " fmt " " os " " strconv " " strings " " " " " " " " YES " " NO " package main import ( " " " fmt " " io " " os " package main import " " func main ( ) { c : = make ( [ ] [ ] int , 3 ) for i : = 0 ; i < 3 ; i + + { c [ i ] = make ( [ ] int , 3 ) for j : = 0 ; j < 3 ; j + + { fmt . Scan ( & c [ i ] [ j ] ) } } isOK : = true for i : = 0 ; i < = 1 ; i + + { for j : = 0 ; j < = 1 ; j + + { if c [ i ] [ j + 1 ] - c [ i ] [ j ] ! = c [ i + 1 ] [ j + 1 ] - c [ i + 1 ] [ j ] { isOK = false break } } } for i : = 0 ; i < = 1 ; i + + { for j : = 0 ; j < = 1 ; j + + { if c [ i + 1 ] [ j ] - c [ i ] [ j ] ! = c [ i + 1 ] [ j + 1 ] - c [ i ] [ j + 1 ] { isOK = false break } } } if isOK { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import " " func main ( ) { var k , s int fmt . Scan ( & k , & s ) cnt : = 0 for x : = 0 ; x < = k ; x + + { for y : = 0 ; y < = k ; y + + { if z : = s - x - y ; 0 < = z & & z < = k { cnt + + } } } fmt . Println ( cnt ) } package main import ( " " " " ) func main ( ) { ar : = make ( [ ] int , 3 ) for i : = range ar { fmt . Scan ( & ar [ i ] ) } sort . Ints ( ar ) fmt . Println ( ar [ 2 ] - ar [ 0 ] ) } package main import ( " " " fmt " " os " " strconv " " : ( " " Yay ! " package main import ( " " " fmt " " os " " strconv " " No " " Yes " package main import ( " " " fmt " " os " " strconv " " : ( " " Yay ! " ) } package main import ( " " " fmt " " os " " sort " " strconv " " strings " package main import ( " " " fmt " " os " " strconv " " Yes " ) return } } } fmt . Println ( " No " package main import ( " " " strings " " os " " bufio " " strconv " " math " " % d \ n " , int ( math . Pow ( float64 ( n ) , 3 ) ) ) } func StrStdin ( ) ( stringReturned string ) { scanner : = bufio . NewScanner ( os . Stdin ) scanner . Scan ( ) stringInput : = scanner . Text ( ) stringReturned = strings . TrimSpace ( stringInput ) return } func IntStdin ( ) ( int , error ) { stringInput : = StrStdin ( ) return strconv . Atoi ( strings . TrimSpace ( stringInput ) ) } func SplitWithoutEmpty ( stringTargeted string , delim string ) ( stringReturned [ ] string ) { stringSplited : = strings . Split ( stringTargeted , delim ) for _ , str : = range stringSplited { if str ! = " " { stringReturned = append ( stringReturned , str ) } } return } func SplitStrStdin ( delim string ) ( stringReturned [ ] string ) { stringInput : = StrStdin ( ) stringReturned = SplitWithoutEmpty ( stringInput , delim ) return } func SplitIntStdin ( delim string ) ( intSlices [ ] int , err error ) { stringSplited : = SplitStrStdin ( " " ) for i : = range stringSplited { var iparam int iparam , err = strconv . Atoi ( stringSplited [ i ] ) if err ! = nil { return } intSlices = append ( intSlices , iparam ) } return } package main import ( " " ) func main ( ) { var k int var s int fmt . Scanf ( " % d % d " package main import " " func main ( ) { var x int fmt . Scan ( & x ) fmt . Println ( x * x * x ) } package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " strconv " package main import ( " " ) func main ( ) { var N , P int fmt . Scan ( & N , & P ) if N = = 1 { fmt . Println ( P ) } else { m : = map [ int ] int { } for i : = 2 ; i * i < = P ; i + + { for P % i = = 0 { m [ i ] + + P / = i } } ans : = 1 for key , value : = range m { q : = value / N ans * = pow ( key , q ) } fmt . Println ( ans ) } } func pow ( a , b int ) int { if b = = 0 { return 1 } else if b = = 1 { return a } else { return a * pow ( a , b - 1 ) } } package main import ( " " " math " " % d % d % d % d " package main import ( " " " bytes " " fmt " " io " " os " " strconv " " Yes " " No " \ t \ n \ v \ f \ r \ n \ r \ n package main import " " import " " func main ( ) { var a [ 3 ] int fmt . Scanf ( " % d % d % d " , & a [ 0 ] , & a [ 1 ] , & a [ 2 ] ) sort . Ints ( a [ : ] ) if a [ 0 ] = = 5 & & a [ 1 ] = = 5 & & a [ 2 ] = = 7 { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " " fmt " " os " " strconv " package main import ( " " " os " " bufio " " strconv " " YES " " YES " " YES " " NO " package main import ( " " " fmt " " os " " strconv " " Yay ! " " : ( " package main import ( " " " fmt " " os " " strconv " " No " " Yes " package main import " " func main ( ) { var x int fmt . Scan ( & x ) fmt . Println ( x * x * x ) } package main import " " func main ( ) { s , k , an : = 0 , 0 , 0 fmt . Scanf ( " " , & k , & s ) for i : = 0 ; i < = k ; i + + { for j : = 0 ; j < = k ; j + + { if 0 < = ( s - i - j ) & & ( s - i - j ) < = k { an + + } } } fmt . Println ( an ) } package main import ( " " " fmt " " math " " os " " strconv " package main import ( " " " fmt " " math " " os " " strconv " " Three " " Four " package main import " " func main ( ) { var num1 , num2 , num3 , num4 int var ans = " " fmt . Scanf ( " \ n " , & num1 , & num2 , & num3 , & num4 ) if num1 = = 1 | | num2 = = 1 | | num3 = = 1 | | num4 = = 1 { if num1 = = 9 | | num2 = = 9 | | num3 = = 9 | | num4 = = 9 { if num1 = = 7 | | num2 = = 7 | | num3 = = 7 | | num4 = = 7 { if num1 = = 4 | | num2 = = 4 | | num3 = = 4 | | num4 = = 4 { ans = " " } } } } fmt . Println ( ans ) } package main import " " func main ( ) { grid : = make ( [ ] [ 3 ] int , 3 ) for i : = 0 ; i < 3 ; i + + { grid [ i ] = [ 3 ] int { } for j : = 0 ; j < 3 ; j + + { fmt . Scan ( & grid [ i ] [ j ] ) } } var a1 , a2 , a3 , b1 , b2 , b3 int b1 = grid [ 0 ] [ 0 ] - a1 b2 = grid [ 1 ] [ 0 ] - a1 b3 = grid [ 2 ] [ 0 ] - a1 a2 = grid [ 0 ] [ 1 ] - b1 a3 = grid [ 0 ] [ 2 ] - b1 flag : = true if grid [ 1 ] [ 1 ] ! = a2 + b2 { flag = false } if grid [ 1 ] [ 2 ] ! = a3 + b2 { flag = false } if grid [ 2 ] [ 1 ] ! = a2 + b3 { flag = false } if grid [ 2 ] [ 2 ] ! = a3 + b3 { flag = false } if flag = = true { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var n int fmt . Scan ( & n ) ans : = 1 v : = 2 for v < = n { ans = v v * = 2 } fmt . Println ( ans ) } package main import " " func main ( ) { var a int fmt . Scanf ( " % d " " % d \ n " , a * a * a ) } package main import ( " " " fmt " " os " " strconv " " Yes " " No " package main import ( " " " fmt " " os " " strconv " " AGC " " GAC " " ACG " " A " " G " " C " " T " " : ( \ n " ) return } } } fmt . Printf ( " \ n " ) } func main ( ) { check ( ) } package main import ( " " " fmt " " math " " os " " sort " " strconv " " strings " " " package main import ( " " " " ) func main ( ) { var ans int as : = make ( [ ] int , 3 ) for i : = 0 ; i < 3 ; i + + { fmt . Scan ( & as [ i ] ) } sort . Sort ( sort . IntSlice ( as ) ) for i , _ : = range as { if i = = 0 { continue } ans + = as [ i ] - as [ i - 1 ] } fmt . Println ( ans ) } package main import ( " " " os " " bufio " " strconv " " Yes " " No " package main import ( " " " fmt " " math " " os " " strconv " " % b " package main import " " import " " func main ( ) { var a , b , h , m int fmt . Scanf ( " % d % d % d % d " package main import ( " " " " ) func main ( ) { as : = make ( [ ] int , 3 ) for i : = 0 ; i < 3 ; i + + { fmt . Scan ( & as [ i ] ) } sort . Ints ( as ) result : = as [ 2 ] - as [ 0 ] fmt . Println ( result ) } package main import ( " " " " ) func main ( ) { tasks : = make ( [ ] int , 3 , 3 ) fmt . Scan ( & tasks [ 0 ] , & tasks [ 1 ] , & tasks [ 2 ] ) sort . Ints ( tasks ) answer : = ( tasks [ 2 ] - tasks [ 1 ] ) + ( tasks [ 1 ] - tasks [ 0 ] ) fmt . Println ( answer ) } package main import ( " " " " ) func main ( ) { var a , b , h , m float64 fmt . Scan ( & a , & b , & h , & m ) rec : = float64 ( 30 * h + m / 2 - 6 * m ) cosC : = math . Cos ( rec * math . Pi / 180 ) result : = a * a + b * b - float64 ( 2 * a * b * cosC ) fmt . Println ( math . Sqrt ( result ) ) } package main import " " func main ( ) { var K , S int fmt . Scanf ( " % d % d " package main import " " func main ( ) { var x int fmt . Scan ( & x ) fmt . Println ( x * x * x ) } package main import ( " " " " ) func main ( ) { var N int var min , ans = math . MaxInt32 , 0 fmt . Scan ( & N ) for i : = 0 ; i < N ; i + + { var tmp int fmt . Scan ( & tmp ) if min > tmp { ans + + min = tmp } } fmt . Println ( ans ) } package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var n int fmt . Scan ( & n ) for i : = 0 ; i < n ; i + + { var char string fmt . Scan ( & char ) if char = = " " { fmt . Println ( " " ) return } } fmt . Println ( " " ) } package main import ( " " " " ) func main ( ) { var a , b , h , m float64 fmt . Scan ( & a , & b , & h , & m ) ha : = 30 * h + 0.5 * m ma : = 6 * m switch { case math . Abs ( ha - ma ) = = 180 : fmt . Println ( a + b ) case ha = = ma : fmt . Println ( math . Abs ( a - b ) ) default : ang : = math . Max ( ha - ma , ma - ha ) if ang > 180 { ang = 360 - ang } ans : = math . Pow ( a , 2 ) + math . Pow ( b , 2 ) - ( 2 * a * b * ( math . Cos ( ang * math . Pi / 180 ) ) ) fmt . Println ( math . Sqrt ( ans ) ) } } package main import ( " " ) func main ( ) { var n , min , max int fmt . Scan ( & n ) x : = make ( [ ] int , n ) for i : = 0 ; i < n ; i + + { fmt . Scan ( & x [ i ] ) if max < x [ i ] { max = x [ i ] } if min > x [ i ] { min = x [ i ] } } answer : = 100000000 for i : = min ; i < max + 1 ; i + + { total : = 0 for j : = 0 ; j < n ; j + + { total + = ( x [ j ] - i ) * ( x [ j ] - i ) } if answer > total { answer = total } } fmt . Println ( answer ) } package main import ( " " " math " " % d % d % d % d " package main import " " func main ( ) { var N int fmt . Scan ( & N ) S : = make ( [ ] string , N ) result : = " " for i : = 0 ; i < N ; i + + { fmt . Scan ( & S [ i ] ) } for i : = 0 ; i < N ; i + + { if S [ i ] = = " " { result = " " } } fmt . Println ( result ) } package main import ( " " " fmt " " os " " sort " " strconv " package main import ( " " " math " " % f % f % f % f " package main import ( " " ) func main ( ) { var k , s int fmt . Scan ( & k , & s ) var sum int for i : = 0 ; i < = k ; i + + { for j : = 0 ; j < = k ; j + + { l : = s - ( i + j ) if 0 < = l & & l < = k { sum + + } } } fmt . Println ( sum ) } package main import ( " " " fmt " " os " " strconv " " Yes " " No " " \ t \ t There is a FALSE not to want . " " \ t \ t Error : Failed to convert text to int , " ) } return value } func IntArray ( s * bufio . Scanner , size int ) [ ] int { deepArray : = make ( [ ] int , size ) for i : = range deepArray { deepArray [ i ] = Int ( s ) } return deepArray } func GraphSetByEdge ( s * bufio . Scanner , v int ) [ ] [ ] int { g : = make ( [ ] [ ] int , v ) for i : = range g { g [ i ] = make ( [ ] int , 0 ) } for xxNonUsedInLoopI : = 0 ; xxNonUsedInLoopI < v - 1 ; xxNonUsedInLoopI + + { a , b : = Int ( s ) - 1 , Int ( s ) - 1 g [ a ] = append ( g [ a ] , b ) g [ b ] = append ( g [ b ] , a ) } return g } package main import ( " " " os " " NO " " YES " " NO " package main import ( " " " fmt " " math " " os " " strconv " package main import ( " " " bufio " " os " package main import ( " " " bufio " " strconv " " os " " Yay ! " " : ( " package main import " " func main ( ) { var n int fmt . Scan ( & n ) fmt . Println ( n * n * n ) } package main import " " func main ( ) { var h1 , m1 , h2 , m2 , k int fmt . Scanf ( " % d % d % d % d % d " package main import ( " " " time " " Asia / Tokyo " " % d % d % d % d % d " package main import ( " " ) func main ( ) { var a , b , c , d , e , k int fmt . Scan ( & a ) fmt . Scan ( & b ) fmt . Scan ( & c ) fmt . Scan ( & d ) fmt . Scan ( & e ) fmt . Scan ( & k ) ret : = k < e - a if ret { fmt . Println ( " : ( " ) } else { fmt . Println ( " Yay ! " ) } } package main import ( " " " " ) func main ( ) { var n int fmt . Scan ( & n ) x : = make ( [ ] int , n ) for i , _ : = range x { fmt . Scan ( & x [ i ] ) } sort . Ints ( x ) minSums : = 1000000 for p : = x [ 0 ] ; p < = x [ n - 1 ] ; p + + { sums : = 0 for i : = 0 ; i < n ; i + + { sums + = square ( x [ i ] - p ) } if minSums > sums { minSums = sums } } fmt . Println ( minSums ) } func square ( x int ) int { return x * x } package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " io " " os " " strconv " " Scan failed " " No " " No " " Yes " package main import ( " " " fmt " " os " " strconv " " Yes " " No " package main import " " func abs ( x int ) int { if x < 0 { return - x } return x } func main ( ) { var t1 , t2 , a1 , a2 , b1 , b2 int fmt . Scan ( & t1 , & t2 , & a1 , & a2 , & b1 , & b2 ) p : = ( b1 - a1 ) * t1 q : = ( b2 - a2 ) * t2 if ( p > 0 & & q > 0 ) | | ( p < 0 & & q < 0 ) { fmt . Println ( 0 ) } else if ( p > 0 & & q < 0 ) | | ( p < 0 & & q > 0 ) { if abs ( p ) > abs ( q ) { fmt . Println ( 0 ) } else if abs ( p ) < abs ( q ) { diff : = abs ( q ) - abs ( p ) ct : = 1 + abs ( p ) / diff * 2 if abs ( p ) % diff = = 0 { ct -- } fmt . Println ( ct ) } else { fmt . Println ( " " ) } } else { panic ( " " ) } } package main import " " func main ( ) { var num1 , num2 , num3 , num4 int var ans string fmt . Scanf ( " % d % d % d % d \ n " , & num1 , & num2 , & num3 , & num4 ) if num1 = = 1 | | num2 = = 1 | | num3 = = 1 | | num4 = = 1 { if num1 = = 9 | | num2 = = 9 | | num3 = = 9 | | num4 = = 9 { if num1 = = 7 | | num2 = = 7 | | num3 = = 7 | | num4 = = 7 { if num1 = = 4 | | num2 = = 4 | | num3 = = 4 | | num4 = = 4 { ans = " " } else { ans = " " } } else { ans = " " } } else { ans = " " } } else { ans = " " } fmt . Println ( ans ) } package main import " " func main ( ) { var x int fmt . Scan ( & x ) fmt . Println ( x * x * x ) } package main import ( " " ) func input ( ) ( int , int , int ) { var a , b , c int fmt . Scanf ( " % d % d % d " " YES " ) } else { fmt . Println ( " " ) } } package main import " " func main ( ) { var n , m int fmt . Scan ( & n , & m ) a : = make ( [ ] string , n ) for i : = range a { fmt . Scan ( & a [ i ] ) } b : = make ( [ ] string , m ) for i : = range b { fmt . Scan ( & b [ i ] ) } var ok bool for y : = 0 ; y < n ; y + + { for x : = 0 ; x < n ; x + + { ok = true var dy , dx int for dy = 0 ; dy < m & & y + dy < n ; dy + + { for dx = 0 ; dx < m & & x + dx < n ; dx + + { if a [ y + dy ] [ x + dx ] ! = b [ dy ] [ dx ] { ok = false break } } if ! ok { break } } if ok & & dy = = m & & dx = = m { fmt . Println ( " " ) return } } } fmt . Println ( " " ) } package main import ( " " " fmt " " io " " os " " Yes " " No " package main import ( " " " fmt " " os " " strconv " " Yes " " No " package main import ( " " ) func main ( ) { var N , K int fmt . Scan ( & N , & K ) var ans int if K = = 1 { ans = 0 } else { ans = N - K } fmt . Println ( ans ) } package main import ( " " " fmt " " math " " os " " strconv " " strings " " " " " package main import ( " " " fmt " " os " " strconv " " strings " " % s = % + v \ n " , name , value ) } func main ( ) { io : = NewIo ( ) defer io . Flush ( ) N : = io . NextInt ( ) M : = io . NextInt ( ) A : = make ( [ ] string , N ) for i : = 0 ; i < N ; i + + { A [ i ] = io . Next ( ) } B : = make ( [ ] string , M ) for i : = 0 ; i < M ; i + + { B [ i ] = io . Next ( ) } ans : = false for i : = 0 ; i + M < = N ; i + + { for j : = 0 ; j + M < = N ; j + + { ok : = true for y : = 0 ; y < M ; y + + { for x : = 0 ; x < M ; x + + { if B [ y ] [ x ] ! = A [ y + i ] [ x + j ] { ok = false } } } if ok { ans = true } } } if ans { io . PrintLn ( " " ) } else { io . PrintLn ( " " ) } } package main import ( " " " fmt " " os " " strconv " " No " " No " " Yes " package main import ( " " " sort " " YES " " NO " package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " strconv " package main import ( " " " " ) func main ( ) { A : = make ( [ ] int , 3 ) for i : = 0 ; i < 3 ; i + + { fmt . Scan ( & A [ i ] ) } sort . Ints ( A ) ans : = ( A [ 2 ] - A [ 1 ] ) + ( A [ 1 ] - A [ 0 ] ) fmt . Println ( ans ) } package main import " " func main ( ) { var a , b [ 4 ] int var c [ 3 ] [ 3 ] int for i : = 0 ; i < 3 ; i + + { for j : = 0 ; j < 3 ; j + + { fmt . Scan ( & c [ i ] [ j ] ) } } for a [ 1 ] = 0 ; a [ 1 ] < = c [ 0 ] [ 0 ] ; a [ 1 ] + + { for a [ 2 ] = 0 ; a [ 2 ] < = c [ 1 ] [ 0 ] ; a [ 2 ] + + { Po : for a [ 3 ] = 0 ; a [ 3 ] < = c [ 2 ] [ 0 ] ; a [ 3 ] + + { b [ 1 ] = c [ 0 ] [ 0 ] - a [ 1 ] b [ 2 ] = c [ 1 ] [ 1 ] - a [ 2 ] b [ 3 ] = c [ 2 ] [ 2 ] - a [ 3 ] for i : = 0 ; i < 3 ; i + + { for j : = 0 ; j < 3 ; j + + { if c [ i ] [ j ] ! = a [ i + 1 ] + b [ j + 1 ] { continue Po } } } fmt . Println ( " " ) return } } } fmt . Println ( " " ) } package main import ( " " " fmt " " math " " os " " strconv " package main import " " func main ( ) { var a , b , c int fmt . Scan ( & a , & b , & c ) if ( a + b = = 12 | | a + b = = 10 ) & & a + b + c = = 17 & & a % 2 ! = 0 & & b % 2 ! = 0 & & c % 2 ! = 0 { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " " fmt " " os " " strconv " package main import ( " " ) func main ( ) { var N int fmt . Scanf ( " % d " " % d " package main import ( " " " fmt " " os " " sort " " strconv " package main import ( " " " fmt " " os " " strconv " package main import ( " " " os " " strconv " " strings " " fmt " " " " infinity " package main import ( " " " math " " : ( " " Yay ! " " : ( " package main import " " func main ( ) { var n int fmt . Scan ( & n ) p : = make ( [ ] int , n ) for i , _ : = range p { fmt . Scan ( & p [ i ] ) } ans : = 0 min : = 9999999999999 for i : = 0 ; i < n ; i + + { min = Min ( min , p [ i ] ) if p [ i ] < = min { ans + + } } fmt . Println ( ans ) } func Min ( a , b int ) int { if a > b { return b } return a } package main import ( " " ) func main ( ) { var h1 , m1 , h2 , m2 , k int fmt . Scan ( & h1 , & m1 , & h2 , & m2 , & k ) getup : = ( h2 - h1 ) * 60 + ( m2 - m1 ) fmt . Println ( getup - k ) } package main import " " func main ( ) { var n int var k int _ , err : = fmt . Scan ( & n , & k ) if err ! = nil { fmt . Println ( " " , err ) return } fmt . Println ( n / k + n % k - n / k ) } package main import ( " " " fmt " " os " " strconv " " : ( " " Yay ! " package main import " " func main ( ) { var k , s int fmt . Scan ( & k , & s ) c : = 0 for x : = 0 ; x < = k ; x + + { for y : = 0 ; y < = k ; y + + { t : = s - ( x + y ) if 0 < = t & & t < = k { c + + } } } fmt . Println ( c ) } package main import ( " " ) func main ( ) { var N int fmt . Scan ( & N ) ans : = 1 for ans * 2 < = N { ans * = 2 } fmt . Println ( ans ) } package main import ( " " " fmt " " io " " math " " os " " strconv " " strings " " getInt ( % d ) " " % .10 f \ n " , math . Sqrt ( vecA . cos * vecA . cos + vecA . sin * vecA . sin + vecB . cos * vecB . cos + vecB . sin * vecB . sin + - 2 * ( vecA . cos * vecB . cos + vecA . sin * vecB . sin ) ) ) } package main import " " import " " func main ( ) { var n , m int fmt . Scan ( & n , & m ) A : = make ( [ ] [ ] string , 0 , 0 ) B : = make ( [ ] [ ] string , 0 , 0 ) for i : = 0 ; i < n ; i + + { var tmp string fmt . Scan ( & tmp ) tmpString : = strings . Split ( tmp , " " ) A = append ( A , tmpString ) } for i : = 0 ; i < m ; i + + { var tmp string fmt . Scan ( & tmp ) tmpString : = strings . Split ( tmp , " " ) B = append ( B , tmpString ) } result : = true for i : = 0 ; i < = n - m ; i + + { for j : = 0 ; j < = n - m ; j + + { result = true for k : = 0 ; k < m ; k + + { for l : = 0 ; l < m ; l + + { if B [ k ] [ l ] ! = A [ i + k ] [ j + l ] { result = false } } } if result { fmt . Println ( " " ) return } } } fmt . Println ( " " ) } package main import ( " " " " ) var N int var ans , ans _ c int func main ( ) { fmt . Scan ( & N ) if N = = 1 { fmt . Println ( 1 ) } else { for i : = 1 ; i < = N ; i + + { var cnt int var t int = i for t % 2 = = 0 { cnt + + t / = 2 } if ans _ c < cnt { ans = i ans _ c = cnt } } fmt . Println ( ans ) } } func max ( x , y int ) int { return int ( math . Max ( float64 ( x ) , float64 ( y ) ) ) } package main import ( " " " time " " % d % d % d % d % d " " % d \ n " , dist ) } package main import ( " " ) func main ( ) { var N , M int fmt . Scan ( & N ) fmt . Scan ( & M ) a : = make ( [ ] string , N ) for i : = 0 ; i < N ; i + + { fmt . Scan ( & a [ i ] ) } b : = make ( [ ] string , M ) for i : = 0 ; i < M ; i + + { fmt . Scan ( & b [ i ] ) } ans : = " " for i : = 0 ; i < N ; i + + { for j : = 0 ; j < N ; j + + { if ( i + M > N ) | | ( j + M > N ) { continue } flag : = true for y : = 0 ; y < M ; y + + { for x : = 0 ; x < M ; x + + { if a [ i + y ] [ j + x : j + x + 1 ] ! = b [ y ] [ x : x + 1 ] { flag = false } } } if flag { ans = " " } } } fmt . Printf ( " \ n " , ans ) } package main import ( " " " fmt " " os " " Yay ! " " : ( " package main import ( " " " fmt " " os " " strconv " " : ( " " Yay ! " ) } } package main import ( " " " fmt " " os " " math " " % v % v % v % v " package main import " " func main ( ) { var a , b , c , d , e , k int fmt . Scan ( & a , & b , & c , & d , & e , & k ) if e - a > k { fmt . Println ( " " ) return } fmt . Println ( " " ) } package main import ( " " ) func main ( ) { var n int fmt . Scan ( & n ) max _ n , max _ cnt : = 1 , 0 for i : = n ; i > 0 ; i -- { num : = i cnt : = 0 for { if num % 2 = = 0 { cnt + + num / = 2 } else { break } } if cnt > max _ cnt { max _ cnt = cnt max _ n = i } } fmt . Println ( max _ n ) } package main import ( " " " fmt " " math " " os " " strconv " package main import ( " " " fmt " " os " package main import " " func main ( ) { var n int fmt . Scan ( & n ) var s string for i : = 0 ; i < n ; i + + { fmt . Scan ( & s ) if s = = " " { fmt . Println ( " " ) return } } fmt . Println ( " " ) } package main import ( " " " io " " math " " os " " sort " " % d \ n " , & n ) xi : = make ( [ ] int , n ) for i : = 0 ; i < n ; i + + { fmt . Fscanf ( input , " " , & xi [ i ] ) } sort . Ints ( xi ) min : = math . MaxInt32 for p : = xi [ 0 ] ; p < = xi [ len ( xi ) - 1 ] ; p + + { sum : = 0 for _ , x : = range xi { sum + = ( x - p ) * ( x - p ) } if sum < min { min = sum } } fmt . Println ( min ) return 0 } func main ( ) { os . Exit ( run ( os . Stdin , os . Stdout ) ) } package main import ( " " " fmt " " os " package main import ( " " " fmt " " os " " sort " " strconv " package main import " " func main ( ) { a : = make ( [ ] int , 3 ) c : = make ( [ ] [ ] int , 3 ) for i : = range c { c [ i ] = make ( [ ] int , 3 ) fmt . Scan ( & c [ i ] [ 0 ] , & c [ i ] [ 1 ] , & c [ i ] [ 2 ] ) } for a [ 0 ] = 0 ; a [ 0 ] < = 100 ; a [ 0 ] + + { for a [ 1 ] = 0 ; a [ 1 ] < = 100 ; a [ 1 ] + + { for a [ 2 ] = 0 ; a [ 2 ] < = 100 ; a [ 2 ] + + { if c [ 0 ] [ 0 ] - a [ 0 ] = = c [ 0 ] [ 1 ] - a [ 1 ] & & c [ 0 ] [ 0 ] - a [ 0 ] = = c [ 0 ] [ 2 ] - a [ 2 ] & & c [ 1 ] [ 0 ] - a [ 0 ] = = c [ 1 ] [ 1 ] - a [ 1 ] & & c [ 1 ] [ 0 ] - a [ 0 ] = = c [ 1 ] [ 2 ] - a [ 2 ] & & c [ 2 ] [ 0 ] - a [ 0 ] = = c [ 2 ] [ 1 ] - a [ 1 ] & & c [ 2 ] [ 0 ] - a [ 0 ] = = c [ 2 ] [ 2 ] - a [ 2 ] { fmt . Println ( " " ) return } } } } fmt . Println ( " " ) } package main import ( " " " bufio " " os " package main import ( " " ) func main ( ) { var a1 , a2 , a3 int fmt . Scanf ( " % d % d % d " package main import ( " " " bytes " " fmt " " io " " os " " strconv " " Three " " Four " \ t \ n \ v \ f \ r \ n \ r \ n package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " package main import ( " " " " ) func main ( ) { var a1 , a2 , a3 float64 var sl [ ] int fmt . Scan ( & a1 , & a2 , & a3 ) sl = append ( sl , int ( math . Abs ( a1 - a2 ) + math . Abs ( a2 - a3 ) ) ) sl = append ( sl , int ( math . Abs ( a2 - a3 ) + math . Abs ( a3 - a1 ) ) ) sl = append ( sl , int ( math . Abs ( a3 - a1 ) + math . Abs ( a1 - a2 ) ) ) min : = 300 for _ , v : = range sl { if v < min { min = v } } fmt . Println ( min ) } package main import ( " " ) func main ( ) { var N int fmt . Scanf ( " % d \ n " , & N ) min : = int ( 10e7 ) ans : = 0 for i : = 0 ; i < N ; i + + { var n int fmt . Scan ( & n ) if min > = n { min = n ans + + } } fmt . Println ( ans ) } package main import ( " " " fmt " " os " " strconv " " Yes " " No " package main import ( " " ) func main ( ) { var n int fmt . Scanf ( " % d " package main import ( " " " sort " " NO " " YES " package main import " " var C [ ] [ ] int func main ( ) { C = make ( [ ] [ ] int , 3 ) for i : = 0 ; i < 3 ; i + + { C [ i ] = make ( [ ] int , 3 ) } for i : = 0 ; i < 3 ; i + + { for j : = 0 ; j < 3 ; j + + { fmt . Scanf ( " " , & C [ i ] [ j ] ) } } ans : = true for i : = 0 ; i < 2 ; i + + { for j : = 0 ; j < 2 ; j + + { ans = ans & & ( C [ i ] [ j ] - C [ i + 1 ] [ j ] + C [ i + 1 ] [ j + 1 ] = = C [ i ] [ j + 1 ] ) } } if ans { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var x int fmt . Scanf ( " % d " package main import ( " " " fmt " " math " " os " " % d % d \ n " , & n , & p ) if n = = 1 { fmt . Println ( p ) return } result : = 1 for value , count : = range Factoring ( p , 2 ) { result * = int ( math . Pow ( float64 ( value ) , float64 ( count / n ) ) ) } fmt . Println ( result ) } func Factoring ( num , pnum int ) map [ int ] int { result : = make ( map [ int ] int ) if pnum * pnum > num { if num ! = 1 { result [ num ] + = 1 } return result } if num % pnum = = 0 { num / = pnum result [ pnum ] + + } else { pnum + + } return merge ( result , Factoring ( num , pnum ) ) } func merge ( m1 , m2 map [ int ] int ) map [ int ] int { ans : = map [ int ] int { } for k , v : = range m1 { ans [ k ] + = v } for k , v : = range m2 { ans [ k ] + = v } return ans } package main import " " var N int var P [ ] int func main ( ) { fmt . Scan ( & N ) P = make ( [ ] int , N ) for i : = range P { fmt . Scan ( & P [ i ] ) } n : = N + 1 ans : = 0 for _ , p : = range P { if n > p { ans + + n = p } } fmt . Println ( ans ) } package main import . " " import . " " func main ( ) { var n int var l [ ] int l = [ ] int { 1 , 2 , 4 , 8 , 16 , 32 , 64 , 128 } Scan ( & n ) for i : = 0 ; i < 7 ; i + + { if l [ i ] < = n & & n < l [ i + 1 ] { Println ( l [ i ] ) Exit ( 0 ) } } } package main import ( " " " fmt " " io " " os " " strconv " " Scan failed " " : ( " ) return } println ( " Yay ! " ) } package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var n int fmt . Scan ( & n ) ss : = make ( [ ] string , n ) for i : = range ss { fmt . Scan ( & ss [ i ] ) } counter : = make ( map [ string ] int ) for _ , s : = range ss { counter [ s ] + + } if len ( counter ) = = 3 { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " ) func main ( ) { var n int fmt . Scanf ( " % d " " % d " " % d " package main import ( " " " fmt " " os " " strconv " " : ( " " Yay ! " package main import ( " " " sort " " % d % d % d " " YES " " NO " package main import ( " " " " ) func main ( ) { var a , b , h , m float64 fmt . Scan ( & a , & b , & h , & m ) hDeg : = h * 30 + m * 0.5 mDeg : = m * 6 ang : = math . Abs ( hDeg - mDeg ) fmt . Println ( math . Sqrt ( a * a + b * b - 2 * a * b * math . Cos ( ang * math . Pi / 180 ) ) ) } package main import ( " " ) func main ( ) { var a , b , c , d , e , k int fmt . Scan ( & a , & b , & c , & d , & e , & k ) if ( e - a ) < = k { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var K , S int fmt . Scan ( & K , & S ) count : = 0 for x : = 0 ; x < = K ; x + + { for y : = 0 ; y < = K ; y + + { z : = S - x - y if 0 < = z & & z < = K { count + + } } } fmt . Println ( count ) } package main import ( " " " fmt " " os " " strconv " " strings " " " " " package main import " " func main ( ) { c : = make ( [ ] [ ] int , 3 ) for i : = 0 ; i < 3 ; i + + { c [ i ] = make ( [ ] int , 3 ) } for i : = 0 ; i < 3 ; i + + { for j : = 0 ; j < 3 ; j + + { fmt . Scan ( & c [ i ] [ j ] ) } } for i : = 0 ; i < = 100 ; i + + { for j : = 0 ; j < = 100 ; j + + { for k : = 0 ; k < = 100 ; k + + { if c [ 0 ] [ 0 ] - i = = c [ 1 ] [ 0 ] - j & & c [ 1 ] [ 0 ] - j = = c [ 2 ] [ 0 ] - k & & c [ 0 ] [ 1 ] - i = = c [ 1 ] [ 1 ] - j & & c [ 1 ] [ 1 ] - j = = c [ 2 ] [ 1 ] - k & & c [ 0 ] [ 2 ] - i = = c [ 1 ] [ 2 ] - j & & c [ 1 ] [ 2 ] - j = = c [ 2 ] [ 2 ] - k { fmt . Println ( " " ) return } } } } fmt . Println ( " " ) } package main import ( " " " fmt " " os " " strconv " " strings " " No " " No " " Yes " " " package main import ( " " " fmt " " math " " os " " sort " " strconv " " strings " " " " Yes " " No " " YES " " NO " " yes " " no " package main import ( " " " reflect " " sort " " 1 " , " " , " " , " " } fmt . Scan ( & s [ 0 ] , & s [ 1 ] , & s [ 2 ] , & s [ 3 ] ) sort . Strings ( s ) if reflect . DeepEqual ( s , t ) { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " ) func main ( ) { var n int fmt . Scan ( & n ) i : = 1 var result int for i < = n { result = i i * = 2 } fmt . Println ( result ) } package main import ( " " ) func main ( ) { var ( a , b , c , d , e , k int ) fmt . Scan ( & a , & b , & c , & d , & e , & k ) if e - a < = k { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import " " func main ( ) { var a , b , c , d , e , k int fmt . Scan ( & a ) fmt . Scan ( & b ) fmt . Scan ( & c ) fmt . Scan ( & d ) fmt . Scan ( & e ) fmt . Scan ( & k ) if e - a > k { fmt . Println ( " " ) } else { fmt . Print ( " " ) } } package main import ( " " " fmt " " log " " os " " strconv " package main import ( " " " fmt " " os " package main import ( " " ) func main ( ) { var n , p , w , g , y int var s string fmt . Scan ( & n ) for i : = 0 ; i < n ; i + + { fmt . Scan ( & s ) if s = = " " { p = 1 } else if s = = " " { w = 1 } else if s = = " " { g = 1 } else if s = = " " { y = 1 } } an : = p + w + g + y if an = = 3 { fmt . Println ( " " ) } else if an = = 4 { fmt . Println ( " " ) } } package main import ( " " " fmt " " io " " os " " strconv " " empty ! " " empty ! " " empty ! " " Scan failed " package main import ( " " " math " " % d " package main import ( " " " fmt " " os " " sort " " strconv " package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var a , b , c , d , e , k int fmt . Scan ( & a , & b , & c , & d , & e , & k ) if e - a < = k { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " " sort " " % d % d % d % d \ n " , & a , & b , & c , & d ) arr : = [ ] int { a , b , c , d } sort . Ints ( arr ) if arr [ 0 ] = = 1 & & arr [ 1 ] = = 4 & & arr [ 2 ] = = 7 & & arr [ 3 ] = = 9 { fmt . Println ( " YES " " NO " package main import ( " " " math " " Yes " " No " package main import ( " " " math " " Three " " Four " package main import ( " " " fmt " " math " " os " " strconv " " strings " package main import ( " " " fmt " " os " " strconv " " strings " " " " Three " " Four " package main import ( " " " fmt " " math " " os " " strconv " package main import ( " " " fmt " " math " " os " " strconv " package main import ( " " " " " fmt " " os " " sort " " strconv " " stack is empty " " stack is empty " package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " " strconv " " strings " \ n " \ n " ) N , _ : = strconv . Atoi ( text ) values , _ : = reader . ReadString ( ' \ n ' ) var n [ ] int for j , f : = range strings . Fields ( values ) { if j = = N { break } i , err : = strconv . Atoi ( f ) if err = = nil { n = append ( n , i ) } } minpower : = 1000000000 for i : = 1 ; i < = 100 ; i + + { power : = calc ( i , n ) if minpower > power { minpower = power } } fmt . Printf ( " \ n " , minpower ) } package main import ( " " " fmt " " os " " strconv " " strings " " " package main import " " func main ( ) { var m [ 3 ] [ 3 ] int for i : = 0 ; i < 3 ; i + + { for j : = 0 ; j < 3 ; j + + { fmt . Scan ( & m [ i ] [ j ] ) } } var diff [ 3 ] [ 4 ] int for i : = 0 ; i < 3 ; i + + { diff [ i ] [ 0 ] = m [ i ] [ 1 ] - m [ i ] [ 0 ] diff [ i ] [ 1 ] = m [ i ] [ 2 ] - m [ i ] [ 1 ] diff [ i ] [ 2 ] = m [ 1 ] [ i ] - m [ 0 ] [ i ] diff [ i ] [ 3 ] = m [ 2 ] [ i ] - m [ 1 ] [ i ] } for i : = range diff [ 0 ] { if diff [ 0 ] [ i ] ! = diff [ 0 ] [ i ] | | diff [ 1 ] [ i ] ! = diff [ 2 ] [ i ] { fmt . Println ( " " ) return } } fmt . Println ( " " ) } package main import ( " " " os " " bufio " " strconv " package main import ( " " " fmt " " os " " strconv " " strings " " : ( " ) return } io . PrintLn ( " Yay ! " package main import " " func main ( ) { var x int fmt . Scan ( & x ) var y = x * x * x fmt . Println ( y ) } package main import ( " " " fmt " " os " " strconv " package main import ( " " " sort " " strings " " : ( " " Yay ! " " " " " package main import ( " " " math " " Three " " Four " package main import ( " " " fmt " " math " " os " " strconv " package main import " " func main ( ) { var K , S int fmt . Scan ( & K , & S ) ans : = 0 for x : = 0 ; x < = K ; x + + { for y : = 0 ; y < = K ; y + + { z : = S - ( x + y ) if 0 < = z & & z < = K { ans + + } } } fmt . Println ( ans ) } package main import ( " " " math " " % d " " % d " package main import " " func main ( ) { var k , s , ans int fmt . Scan ( & k , & s ) for x : = 0 ; x < = k ; x + + { for y : = 0 ; y < = k ; y + + { z : = s - x - y if 0 < = z & & z < = k { ans + + } } } fmt . Println ( ans ) } package main import ( " " " fmt " " os " " strconv " " No " " Yes " package main import ( . " " . " " ) func main ( ) { var n , m int var a , b [ ] string Scan ( & n , & m ) a = make ( [ ] string , n ) b = make ( [ ] string , m ) for i : = 0 ; i < n ; i + + { Scan ( & a [ i ] ) } for i : = 0 ; i < m ; i + + { Scan ( & b [ i ] ) } for i : = 0 ; i < n - m + 1 ; i + + { LABEL : for j : = 0 ; j < n - m + 1 ; j + + { for k : = 0 ; k < m ; k + + { if a [ i + k ] [ j : j + m ] ! = b [ k ] { continue LABEL } } Println ( " " ) Exit ( 0 ) } } Println ( " " ) } package main import ( " " " fmt " " os " " strconv " package main import ( " " ) func main ( ) { var a , b , c int five : = 0 seven : = 0 fmt . Scanf ( " % d " " % d " " % d " " NO " if five = = 2 & & seven = = 1 { ans = " " } fmt . Printf ( " " , ans ) } package main import ( " " " fmt " " os " " strconv " " Yay ! " " : ( " package main import " " func main ( ) { var a , b , c int fmt . Scanf ( " % d % d % d " " YES \ n " ) } else { fmt . Printf ( " \ n " ) } } package main import ( " " ) func main ( ) { var A , B , C int fmt . Scanf ( " % d % d % d " " YES " ) } else { fmt . Println ( " " ) } } package main import ( " " " " ) func main ( ) { var n int fmt . Scan ( & n ) x : = make ( [ ] int , n ) mean : = 0 for i : = 0 ; i < n ; i + + { fmt . Scan ( & x [ i ] ) mean + = x [ i ] } mean = int ( round ( float64 ( mean ) / float64 ( n ) ) ) sum : = 0 for i : = 0 ; i < n ; i + + { sum + = ( x [ i ] - mean ) * ( x [ i ] - mean ) } fmt . Println ( sum ) } func round ( f float64 ) float64 { return math . Floor ( f + .5 ) } package main import ( " " " " ) func main ( ) { a : = make ( [ ] int , 3 ) fmt . Scan ( & a [ 0 ] , & a [ 1 ] , & a [ 2 ] ) sort . Ints ( a ) fmt . Println ( a [ 2 ] - a [ 0 ] ) } package main import " " func main ( ) { var a int fmt . Scan ( & a ) fmt . Println ( a * a * a ) } package main import " " func main ( ) { var x int fmt . Scanf ( " % d " " % d \ n " , x * x * x ) } package main import ( " " " fmt " " math " " os " " strconv " " MASPY " " ますピ " { fp , T HE _ HARMONY _ OF _ PERFECT " ) ) cn t P Y " ) = = " " { wfp , _ = os . C U S10 " ) ) } scanner : = - -- -- -- -- -- -- -- -- -- - " ) so lv e ( sc an ne r , package main import " " func isMatched ( a , b [ ] [ ] int ) ( matched bool ) { matched = false L1 : for i : = 0 ; i < = len ( a ) - len ( b ) ; i + + { L2 : for j : = 0 ; j < = len ( a ) - len ( b ) ; j + + { for k : = 0 ; k < len ( b ) ; k + + { for l : = 0 ; l < len ( b ) ; l + + { if a [ i + k ] [ j + l ] ! = b [ k ] [ l ] { continue L2 } } } matched = true break L1 } } return } func main ( ) { var N , M int fmt . Scan ( & N , & M ) a : = make ( [ ] [ ] int , N ) b : = make ( [ ] [ ] int , M ) for i : = 0 ; i < N ; i + + { a [ i ] = make ( [ ] int , N ) var tmp string fmt . Scan ( & tmp ) for j , r : = range tmp { switch r { case ' .' : a [ i ] [ j ] = 0 case ' # ' : a [ i ] [ j ] = 1 } } } for i : = 0 ; i < M ; i + + { b [ i ] = make ( [ ] int , M ) var tmp string fmt . Scan ( & tmp ) for j , r : = range tmp { switch r { case ' .' : b [ i ] [ j ] = 0 case ' # ' : b [ i ] [ j ] = 1 } } } if isMatched ( a , b ) { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import " " func main ( ) { var n int fmt . Scan ( & n ) m : = make ( map [ string ] int ) for i : = 0 ; i < n ; i + + { var s string fmt . Scan ( & s ) m [ s ] + + } if len ( m ) = = 3 { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import " " func main ( ) { var in int fmt . Scan ( & in ) ans : = 1 for ans * 2 < = in { ans = ans * 2 } fmt . Println ( ans ) } package main import ( " " " fmt " " os " " strconv " " MASPY " " ますピ " { fp , T HE _ HARMONY _ OF _ PERFECT " ) ) cn t P Y " ) = = " " { wfp , _ = os . C U S10 " ) ) } scanner : = - -- -- -- -- -- -- -- -- -- - " ) so lv e ( sc an ne r , fm t . printl ( r ter , " YES " ) } package main import ( " " " fmt " " os " " strconv " " strings " " " " Yes " " No " " Yes " " No " package main import ( " " " fmt " " math " " os " " strconv " " strings " " " package main import ( " " ) func main ( ) { var num int fmt . Scan ( & num ) fmt . Println ( num * num * num ) } package main import ( " " " fmt " " os " " strconv " " strings " " scan string failed " " scan string failed " " " package main import " " func main ( ) { var a , o , e , k int fmt . Scan ( & a , & o , & o , & o , & e , & k ) if e - a > k { fmt . Println ( " " ) return } fmt . Println ( " " ) } package main import ( " " " fmt " " os " " strconv " " Yes " " No " package main import ( " " " os " " bufio " " strconv " " strings " " " package main import " " var k , s int func main ( ) { fmt . Scan ( & k , & s ) cnt : = 0 for x : = 0 ; x < = k ; x + + { for y : = 0 ; y < = k ; y + + { z : = s - x - y if 0 < = z & & z < = k { cnt + + } } } fmt . Println ( cnt ) } package main import " " func main ( ) { C : = make ( [ ] [ ] int , 3 ) for i : = 0 ; i < 3 ; i + + { C [ i ] = make ( [ ] int , 3 ) } for i : = 0 ; i < 3 ; i + + { for j : = 0 ; j < 3 ; j + + { fmt . Scan ( & C [ i ] [ j ] ) } } for i : = 0 ; i < 3 ; i + + { p : = C [ 0 ] [ 1 ] - C [ 0 ] [ 0 ] q : = C [ 0 ] [ 2 ] - C [ 0 ] [ 1 ] if C [ i ] [ 1 ] - C [ i ] [ 0 ] ! = p { fmt . Println ( " " ) return } if C [ i ] [ 2 ] - C [ i ] [ 1 ] ! = q { fmt . Println ( " " ) return } } for i : = 0 ; i < 3 ; i + + { p : = C [ 1 ] [ 0 ] - C [ 0 ] [ 0 ] q : = C [ 2 ] [ 0 ] - C [ 1 ] [ 0 ] if C [ 1 ] [ i ] - C [ 0 ] [ i ] ! = p { fmt . Println ( " " ) return } if C [ 2 ] [ i ] - C [ 1 ] [ i ] ! = q { fmt . Println ( " " ) return } } fmt . Println ( " " ) } package main import ( " " ) func main ( ) { var N int fmt . Scan ( & N ) n : = 1 var m int for i : = 2 ; i < = N ; i + + { for j : = 1 ; ; j + + { if i % ( pow ( 2 , j ) ) ! = 0 { if j > m { n , m = i , j - 1 } break } } } fmt . Println ( n ) } func pow ( n int , p int ) int { r : = n for i : = 1 ; i < p ; i + + { r = r * n } return r } package main import ( " " " fmt " " math " " os " " strconv " package main import " " func main ( ) { var x int fmt . Scanf ( " % d " package main import ( " " " fmt " " math " " os " " strconv " package main import ( " " " fmt " " os " " sort " " strconv " package main import ( " " " math " " strconv " " % g " package main import ( " " ) func main ( ) { var K , S int fmt . Scan ( & K , & S ) cnt : = 0 for x : = 0 ; x < = K ; x + + { for y : = 0 ; y < = K ; y + + { z : = S - x - y if 0 < = z & & z < = K { cnt + + } } } fmt . Println ( cnt ) } package main import ( " " " " ) func main ( ) { var a [ ] int for i : = 0 ; i < 3 ; i + + { var tmp int fmt . Scan ( & tmp ) a = append ( a , tmp ) } sort . Ints ( a ) diff : = 0 for i : = 2 ; i > 0 ; i -- { diff + = a [ i ] - a [ i - 1 ] } fmt . Println ( diff ) } package main import ( " " " math " " % d % d % d % d " package main import " " func main ( ) { var a , b , c int fmt . Scan ( & a , & b , & c ) if ( a + b + c = = 17 ) { fmt . Println ( " " ) } else { fmt . Println ( " " ) } } package main import ( " " " fmt " " infinity " " infinity " " % d % d " package main import ( " " " fmt " " os " " strconv " package main import ( " " " sort " " Yay ! " " : ( " package main import ( " " " fmt " " os " " strconv " " strings " " " package main import ( " " " fmt " " os " " Yes " " No " package main import ( " " " " ) func main ( ) { var n int fmt . Scan ( & n ) xList : = make ( [ ] int , n ) for i : = 0 ; i < n ; i + + { fmt . Scan ( & xList [ i ] ) } var p int S : = sumArray ( xList ) Z : = prodSumArray ( xList ) p _ correct : = float64 ( S ) / float64 ( n ) p _ upper : = int ( math . Ceil ( p _ correct ) ) p _ under : = int ( math . Floor ( p _ correct ) ) p = p _ upper result1 : = n * int ( math . Pow ( float64 ( p ) , 2.0 ) ) - 2 * S * p + Z p = p _ under result2 : = n * int ( math . Pow ( float64 ( p ) , 2.0 ) ) - 2 * S * p + Z result : = int ( math . Min ( float64 ( result1 ) , float64 ( result2 ) ) ) fmt . Println ( result ) } func prodSumArray ( a [ ] int ) int { sum : = 0 for _ , x : = range a { sum + = int ( math . Pow ( float64 ( x ) , float64 ( 2 ) ) ) } return sum } func sumArray ( a [ ] int ) int { sum : = 0 for _ , x : = range a { sum + = x } return sum } package main import ( " " " math " " % d % d % d % d % d " package main import " " func main ( ) { var ( H1 , M1 , H2 , M2 , K int ) fmt . Scan ( & H1 , & M1 , & H2 , & M2 , & K ) start : = H1 * 60 + M1 end : = H2 * 60 + M2 answer : = end - K - start if answer < 0 { fmt . Println ( 0 ) } else { fmt . Println ( answer ) } } package main import ( " " " fmt " " math " " os " " strconv " package main import ( " " " fmt " " os " " strconv " " Yes " " No " package main import ( " " " fmt " " io " " os " " strconv " " Yes " " No " package main import ( " " " " ) func main ( ) { var n int fmt . Scan ( & n ) count , prev : = 0 , math . MaxInt64 for i : = 0 ; i < n ; i + + { var p int fmt . Scan ( & p ) if p < prev { prev = p count + + } } fmt . Println ( count ) } package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var k , s int fmt . Scan ( & k , & s ) ans : = 0 for i : = 0 ; i < = k ; i + + { for j : = 0 ; j < = k ; j + + { if 0 < = s - i - j & & s - i - j < = k { ans + + } } } fmt . Println ( ans ) } package main import ( " " " fmt " " os " " strconv " " : ( " " Yay ! " ) } package main import ( " " ) func main ( ) { var n , k int fmt . Scanf ( " % d % d " package main import ( " " " fmt " " os " " strconv " package main import " " func main ( ) { var N , v int fmt . Scan ( & N ) for N > 0 { v = N & - N N - = v } fmt . Println ( v ) } package main import ( " " " " ) func main ( ) { var x , powX float64 fmt . Scan ( & x ) powX = math . Pow ( x , 3 ) fmt . Println ( int ( powX ) ) } package main import ( " " " errors " " fmt " " io " " math " " os " " strconv " " Scan failed " " % b " " [ argument error ] : Strtoi only accepts integer string " package main import ( " " " fmt " " os " " strconv " " % v \ n " , " " ) return } b : = nextInt ( ) if b ! = 5 & & b ! = 7 { fmt . Printf ( " \ n " , " " ) return } c : = nextInt ( ) if c ! = 5 & & c ! = 7 { fmt . Printf ( " \ n " , " " ) return } if a + b + c ! = 17 { fmt . Printf ( " \ n " , " " ) return } fmt . Printf ( " \ n " , " " ) } package main import ( " " " fmt " " os " " strconv " package main import ( " " " bufio " " os " " strconv " package main import ( " " ) func main ( ) { var k , s int fmt . Scan ( & k , & s ) count : = 0 for X : = 0 ; X < = k ; X + + { for Y : = 0 ; Y < = k ; Y + + { Z : = s - ( X + Y ) if 0 < = Z & & Z < = k { count + + } } } fmt . Println ( count ) } package main import ( " " " fmt " " os " " strconv " package main import ( " " ) func find ( target int , ary [ ] int ) ( bool , [ ] int ) { for i , a : = range ary { if a = = target { ary = append ( ary [ : i ] , ary [ i + 1 : ] ... ) return true , ary } } return false , ary } func main ( ) { var a , b , c int fmt . Scan ( & a , & b , & c ) ary : = [ ] int { a , b , c } var result bool bunsetsu : = [ ] int { 5 , 7 , 5 } for _ , b : = range bunsetsu { result , ary = find ( b , ary ) if ! result { fmt . Println ( " " ) return } } fmt . Println ( " " ) } package main import " " func main ( ) { var k , s int fmt . Scan ( & k , & s ) ans : = 0 for x : = 0 ; x < = k ; x + + { for y : = 0 ; y < = k ; y + + { v : = s - x - y if 0 < = v & & v < = k { ans + + } } } fmt . Println ( ans ) } package main import ( " " " fmt " " os " " strings " " " " 7 " { cnt7 + + } if arr [ i ] = = " " { cnt5 + + } } if cnt7 = = 1 & & cnt5 = = 2 { fmt . Println ( " YES " " NO " package main import ( " " " fmt " " math " " os " " sort " " strconv " " strings " " hoge " " " " Yes " " No " " YES " " NO " " yes " " no " package main import ( " " " fmt " " math " " os " " sort " " strconv " " strings " " func intsMax : zero length slice " " func intsMaxIdx : zero length slice " " func intsMin : zero length slice " " func intsMinIdx : zero length slice " " func peekBack : zero length slice " " func peekFront : zero length slice " " func popBack : zero length slice " " func popFront : zero length slice " " Exponent must be a natural number " " Exponent must be a natural number " " YES " } else { return " NO " " Yes " " No " " abcdefghijklmnopqrstuvwxyz " " ABCDEFGHIJKLMNOPQRSTUVWXYZ " package main import ( " " ) func main ( ) { var a int fmt . Scan ( & a ) fmt . Println ( a * a * a ) } package main import ( " " ) func main ( ) { var x int fmt . Scan ( & x ) fmt . Println ( x * x * x ) } package main import ( " " ) func main ( ) { var a , b , c string fmt . Scan ( & a , & b , & c ) var fv , sv int for _ , s : = range [ ] string { a , b , c } { if s = = " " { fv + + } if s = = " " { sv + + } } if fv = = 2 & & sv = = 1 { fmt . Println ( " " ) return } fmt . Println ( " " ) } package main import ( " " " fmt " " os " " strconv " " Yes " " No " package main import ( " " " fmt " " os " " strconv " package main import ( " " " fmt " " os " package main import ( " " " fmt " " io " " math " " os " " strconv " " % 0.15 f " package main import ( " " " fmt " " os " " strconv " " Yes " " No " package main import ( " " " " ) func main ( ) { var a , b , h , m int var m _ val , h _ val , val , c2 float64 fmt . Scan ( & a , & b , & h , & m ) m _ val = float64 ( 6 * m ) h _ val = float64 ( float64 ( 30 * h ) + float64 ( float64 ( m ) * float64 ( 0.5 ) ) ) if h _ val < m _ val { if m _ val - h _ val < = 180 { val = m _ val - h _ val } else { val = 360 - m _ val + h _ val } } else { if h _ val - m _ val < = 180 { val = h _ val - m _ val } else { val = 360 - h _ val + m _ val } } c2 = float64 ( a * a + b * b ) - ( float64 ( 2 * a * b ) * math . Cos ( val / 90 * ( math . Pi / 2 ) ) ) fmt . Println ( math . Sqrt ( c2 ) ) } package main import ( " " " math " " % d % d % d % d " package main import ( " " " fmt " " os " " strconv " " MASPY " " ますピ " { fp , T HE _ HARMONY _ OF _ PERFECT " ) ) } i P Y " ) = = " " { wfp , _ = os . C U S10 " ) ) } scanner : = r n } if a 1 a 1 b1 & & a < b2 { fm .P in l ( " " re t urn } i f 1 = b1 | 2 = 2 f t. ri tl ( " " re t urn } i f 1 * 1 + a2 * t b * t 1 + b 2 * t 2 { i a 1 > b1 { m .P in l ( " " re t urn } p e r i f : = ( a * 1 + a2 * 2 ) - ( b 1 * 1 + b 2 * t ) a ns : = ( 1 - a 1 * 1 pe d ff i ( b1-a1 ) t ) pe d i ff > 0 { a n s + + } f t P i tln ( a s re t urn } i f a1 b1 { m .P in l ( " " re t urn } p e r i f : = ( b * 1 + b2 * 2 ) - ( a 1 * 1 + a 2 * t ) a ns : = ( 1 - b 1 * 1 pe d ff i ( a1-b1 ) t ) pe d i ff > 0 { a n s + + } f t P i tln ( a s wr i ter.Flu s h ( ) def get _ i ( ) return gets . chomp . split ( " " ) . map ( & : to _ i ) end def get _ f ( ) return gets . chomp . split ( " " ) . map ( & : to _ f ) end def get ( ) return gets . chomp . split ( " " ) end def get _ nsp ( ) return gets . chomp . split ( " " ) end def yn _ judge ( bool , y = " Yes " , n = " No " ) return bool ? y : n end def array ( size1 , init = nil , size2 = - 1 ) if size2 = = - 1 return Array . new ( size1 ) { init } else return Array . new ( size2 ) { Array . new ( size1 ) { init } } end end def max ( a , b ) return a > b ? a : b end def min ( a , b ) return a > b ? b : a end INF = Float : : INFINITY N = gets . to _ i 1 . upto ( 3500 ) do | h | 1 . upto ( 3500 ) do | n | w = - 1 w = N * h * n / ( 4 * h * n - N * n - N * h ) if ( 4 * h * n - N * n - N * h ) . nonzero ? and ( ( N * h * n ) % ( 4 * h * n - N * n - N * h ) ) . zero ? if w > 0 puts [ h , n , w ] . join ( " " ) exit end end end i = gets . chomp . split ( " " ) . map ( & : to _ i ) one , nine , seven , four = false i . each do | hoge | one = true if hoge = = 1 nine = true if hoge = = 9 seven = true if hoge = = 7 four = true if hoge = = 4 end if one and nine and seven and four then puts " YES " else puts " NO " end require ' prime ' require ' set ' require ' tsort ' include Math ALP = ( ' a ' .. ' z ' ) . to _ a INF = 0xffffffffffffffff def max ( a , b ) ; a > b ? a : b end def min ( a , b ) ; a < b ? a : b end def swap ( a , b ) ; a , b = b , a end def gif ; gets . to _ i end def gff ; gets . to _ f end def gsf ; gets . chomp end def gi ; gets . split . map ( & : to _ i ) end def gf ; gets . split . map ( & : to _ f ) end def gs ; gets . chomp . split . map ( & : to _ s ) end def gc ; gets . chomp . split ( ' ' ) end def pr ( num ) ; num . prime _ division end def pr ? ( num ) ; Prime . prime ? ( num ) end def digit ( num ) ; num . to _ s . length end def array ( s , ini = nil ) ; Array . new ( s ) { ini } end def darray ( s1 , s2 , ini = nil ) ; Array . new ( s1 ) { Array . new ( s2 ) { ini } } end def rep ( num ) ; num . times { | i | yield ( i ) } end def repl ( st , en , n = 1 ) ; st . step ( en , n ) { | i | yield ( i ) } end n = gif puts gs . uniq . size = = 4 ? ' Four ' : ' Three ' n = gets . to _ i arr = gets . chomp . split ( ' ' ) . map ( & : to _ i ) count = 0 min = n + 1 i = 0 while i < arr . size if arr [ i ] < = min count + = 1 min = arr [ i ] end i + = 1 end puts count gets count = 0 min = nil gets . split ( / / ) . map ( & : to _ i ) . each do | v | min = v if min . nil ? | | min > v count + = 1 if min > = v end puts count n , * a = $ < . map { | l | l . split . map & : to _ i } ; t = 1 ; a . zip ( n ) { | x , m | i = s = 0 ; x . map { | k | s + = k . * ~ m + i + = 2 } ; t * = s } ; p t . % 10 * * 9 + 7 d = [ ] 5 . times do d < < gets . to _ i end k = gets . to _ i flag = true 5 . times do | i | 5 . times do | j | if ( d [ i ] - d [ j ] ) . abs > k flag = false end end end if flag puts ' Yay ! ' else puts ' : ( ' end n = gets ary = gets . split if ary . uniq ! . size = = 3 puts " Three " else puts " Four " end n = gets . to _ i p = gets . split . map ( & : to _ i ) arr = p . map . with _ index { | pi , i | [ i , pi ] } . sort { | a , b | a [ 1 ] < = > b [ 1 ] } . map { | a | a [ 0 ] } tmp = arr [ 0 ] ans = 1 i = 1 until tmp = = 0 if tmp > arr [ i ] ans + = 1 tmp = arr [ i ] end i + = 1 end p ans k , s = gets . split . map ( & : to _ i ) ans = 0 ( k + 1 ) . times do | x | ( k + 1 ) . times do | y | z = s - x - y if z > = 0 & & z < = k ans + = 1 end end end p ans k , s = gets . split . map ( & : to _ i ) count = 0 ( 0 .. k ) . each do | x | ( 0 .. k ) . each do | y | z = s - x - y if z > = 0 & & z < = k if x + y + z = = s count + = 1 end end end end puts count gets ; puts gets . split . count ( " Y " ) > 0 ? : Four : : Three n = gets . to _ i pow = 0 while 2 * * ( pow + 1 ) < = n pow + = 1 end puts 2 * * pow ary = [ ] 3 . times do | i | ary [ i ] = gets . split . map ( & : to _ i ) end a1 = 0 b1 = ary [ 0 ] [ 0 ] - a1 b2 = ary [ 0 ] [ 1 ] - a1 b3 = ary [ 0 ] [ 2 ] - a1 a2 = ary [ 1 ] [ 0 ] - b1 a3 = ary [ 2 ] [ 0 ] - b1 if ( a1 + b1 = = ary [ 0 ] [ 0 ] & & a1 + b2 = = ary [ 0 ] [ 1 ] & & a1 + b3 = = ary [ 0 ] [ 2 ] & & a2 + b1 = = ary [ 1 ] [ 0 ] & & a2 + b2 = = ary [ 1 ] [ 1 ] & & a2 + b3 = = ary [ 1 ] [ 2 ] & & a3 + b1 = = ary [ 2 ] [ 0 ] & & a3 + b2 = = ary [ 2 ] [ 1 ] & & a3 + b3 = = ary [ 2 ] [ 2 ] ) puts ' Yes ' else puts ' No ' end require ' pp ' n = gets . chomp ! . to _ i p _ n = gets . chomp ! . split . map ( & : to _ i ) count = 0 min = p _ n [ 0 ] p _ n . each do | a | if a < = min count + = 1 min = a end end puts count a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i puts e - a < = k ? " Yay ! " : " : ( " num = [ ] 3 . times do num < < gets . strip . split . map ( & : to _ i ) end l1 = num [ 0 ] [ 1 ] - num [ 0 ] [ 0 ] l2 = num [ 1 ] [ 1 ] - num [ 1 ] [ 0 ] l3 = num [ 2 ] [ 1 ] - num [ 2 ] [ 0 ] r1 = num [ 0 ] [ 2 ] - num [ 0 ] [ 1 ] r2 = num [ 1 ] [ 2 ] - num [ 1 ] [ 1 ] r3 = num [ 2 ] [ 2 ] - num [ 2 ] [ 1 ] if l1 = = l2 & & l2 = = l3 & & r1 = = r2 & & r2 = = r3 puts " Yes " else puts " No " end N = gets . to _ i P = gets . split . map ( & : to _ i ) checker = N count = 0 P . each { | n | if checker > = n count + = 1 checker = n end } puts count def solve ( c ) 2 . times do | i | d = c [ i + 1 ] [ 0 ] - c [ i ] [ 0 ] 1 . upto ( 2 ) do | j | if c [ i + 1 ] [ j ] - c [ i ] [ j ] ! = d return false end end end 2 . times do | j | d = c [ 0 ] [ j + 1 ] - c [ 0 ] [ j ] 1 . upto ( 2 ) do | i | if c [ i ] [ j + 1 ] - c [ i ] [ j ] ! = d return false end end end return true end c = Array . new ( 3 ) 3 . times do | i | c [ i ] = gets . split . map ( & : to _ i ) end puts solve ( c ) ? " Yes " : " No " def ina gets . split ( ' ' ) . map ( & : to _ i ) end t1 , t2 = ina a1 , a2 = ina b1 , b2 = ina k1 = t1 * ( a1 - b1 ) k2 = t2 * ( a2 - b2 ) stride = k1 + k2 if stride . zero ? puts ' infinity ' elsif ( k1 * stride ) . positive ? puts 0 else ceil = ( k1 . abs + ( stride . abs - 1 ) ) / stride . abs bent = k1 % stride = = 0 res = ( ceil - 1 ) + ceil + ( bent ? 1 : 0 ) p res end a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i h = [ a , b , c , d , e ] if h . max - h . min > k puts ' : ( ' else puts ' Yay ! ' end INF = 1 < < 29 def contain ( names ) contained = [ ] names . permutation ( 2 ) . each do | s , t | contained < < t if s . include ? ( t ) end contained . each { | name | names . delete ( name ) } names end def overlap ( names , size ) overlap _ size = size . times . map { [ 0 ] * size } ( 0 ... size ) . to _ a . permutation ( 2 ) . each do | i , j | k = [ @ len [ i ] , @ len [ j ] ] . min loop do if names [ i ] [ @ len [ i ] - k .. - 1 ] = = names [ j ] [ 0 , k ] overlap _ size [ i ] [ j ] = k break end k - = 1 end end overlap _ size end while n = gets . to _ i break if n = = 0 s = n . times . map { gets . chomp } s = contain ( s ) m = s . size @ len = s . map { | name | name . size } overlap _ size = overlap ( s , m ) dp = ( 1 < < m ) . times . map { [ INF ] * m } m . times { | i | dp [ 1 < < i ] [ i ] = @ len [ i ] } ( 1 < < m ) . times do | bits | m . times do | i | if ( bits & ( 1 < < i ) ) ! = 0 pre = dp [ bits ] [ i ] m . times do | j | bit = 1 < < j if ( bits & bit ) = = 0 if dp [ bits | bit ] [ j ] > pre + @ len [ j ] - overlap _ size [ i ] [ j ] dp [ bits | bit ] [ j ] = pre + @ len [ j ] - overlap _ size [ i ] [ j ] end end end end end end p dp [ ( 1 < < m ) - 1 ] . min end require ' prime ' N , P = gets . split . map & : to _ i primes = Prime . prime _ division ( P ) ans = 1 for pr , n in primes do if n > = N then ans * = pr * * ( n / N ) end end p ans a , b , c , d = gets . chomp . split ( ' ' ) . map ( & : to _ i ) h = { } h [ a ] = true h [ b ] = true h [ c ] = true h [ d ] = true if h [ 1 ] & & h [ 9 ] & & h [ 7 ] & & h [ 4 ] puts ' YES ' else puts ' NO ' end a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i puts e - a > k ? " : ( " : " Yay ! " n = gets . to _ i a = gets . split . map & : to _ i res = 0 minv = 10 * * 9 a . each { | e | if e < minv res + = 1 minv = e end } puts res k , s = gets . split . map & : to _ i c = 0 ( 0 .. k ) . each do | x | ( 0 .. k ) . each do | y | next unless ( 0 .. k ) . include ? ( s - x - y ) c + = 1 end end p c n = gets . chomp . to _ i s = gets . chomp . split ( " " ) . map { | e | e . to _ s } . uniq if s . length = = 3 puts " Three " else puts " Four " end K , S = gets . split . map ( & : to _ i ) cnt = 0 min _ x = [ 0 , S - 2 * K ] . max max _ x = [ K , S ] . min min _ x . upto ( max _ x ) do | i | rest = S - i if rest < = K cnt + = rest + 1 else cnt + = K - ( rest - K ) + 1 end end puts cnt n = gets . chomp . to _ i inputs = gets . split . map ( & : to _ i ) reject = 0 temp = 200000 ( 0 ... n ) . each do | i | _ temp _ 1 = inputs [ i ] if temp < _ temp _ 1 reject + = 1 else temp = _ temp _ 1 end end puts n - reject k , s = gets . split . map ( & : to _ i ) ans = 0 0 . upto ( k ) do | x | 0 . upto ( k ) do | y | z = s - ( x + y ) ans + = 1 if ( z > = 0 & & z < = k ) & & x + y + z = = s end end puts ans ar = [ ] 6 . times do tmp = gets if tmp = = nil then exit end ar < < tmp . to _ i end if ( ar [ 4 ] - ar [ 0 ] ) > ar [ 5 ] then puts " : ( " else puts " Yay ! " end k , s = gets . split . map ( & : to _ i ) cnt = 0 k . next . times do | i | k . next . times do | j | break if i + j > s cnt + = 1 if s - i - j < = k end end puts cnt a = 5 . times . map { gets . to _ i } k = gets . to _ i puts a . combination ( 2 ) . all ? { | x , y | ( x - y ) . abs < = k } ? ' Yay ! ' : ' : ( ' line = readlines numlines = line [ 1 ] nums = numlines . split ( ' ' ) ans = 1 if nums . length = = 1 else min = nums [ 0 ] . to _ i nums . each do | num | if num . to _ i < min ans + = 1 min = num . to _ i end end end puts ans A = gets . to _ i gets . to _ i gets . to _ i gets . to _ i E = gets . to _ i puts ( E - A ) < = gets . to _ i ? ' Yay ! ' : ' : ( ' a = 5 . times . map { gets . to _ i } k = gets . to _ i def can _ communicate ( a , k ) ( 0 .. 4 ) . each do | i | ( 0 .. 4 ) . each do | j | return false if ( a [ i ] - a [ j ] ) . abs > k end end true end puts can _ communicate ( a , k ) ? ' Yay ! ' : ' : ( ' max , ans = gets . chomp . split ( " " ) . map ( & : to _ i ) count = 0 ( 0 .. max ) . each do | x | ( 0 .. max ) . each do | y | z = ans - x - y count + = 1 if x + y + z = = ans & & z < = max & & z > = 0 end end puts count k , s = gets . split ( " " ) . map ( & : to _ i ) cnt = 0 0 . upto ( k ) do | x | 0 . upto ( k ) do | y | z = s - x - y if z > = 0 & & z < = k cnt + = 1 end end end puts cnt K , S = gets . split . map ( & : to _ i ) num = 0 ( K + 1 ) . times do | a | ( K + 1 ) . times do | b | res = S - a - b if 0 < = res & & res < = K then num + = 1 end end end p num c11 , c12 , c13 = gets . chomp . split . map ( & : to _ i ) c21 , c22 , c23 = gets . chomp . split . map ( & : to _ i ) c31 , c32 , c33 = gets . chomp . split . map ( & : to _ i ) exist = true exist = false unless c11 - c12 = = c21 - c22 exist = false unless c21 - c22 = = c31 - c32 exist = false unless c12 - c13 = = c22 - c23 exist = false unless c22 - c23 = = c32 - c33 puts exist ? " Yes " : " No " k , s = gets . chomp . split ( ' ' ) . map ( & : to _ i ) i = 0 c = 0 while i < = k j = 0 while j < = k l = s - i - j c + = 1 if l > = 0 & & l < = k j + = 1 end i + = 1 end p c k , s = gets . split . map ( & : to _ i ) ret = 0 ( 0 .. k ) . each do | x | ( 0 .. k ) . each do | y | z = s - x - y next unless 0 < = z & & z < = k ret + = 1 end end puts ret K , S = gets . split . map ( & : to _ i ) ans = 0 min = ( S / 3.0 ) . ceil ( min .. K ) . each do | a | rest = S - a next if rest > K * 2 minb = ( rest / 2.0 ) . ceil maxb = [ rest , K , a ] . min ( minb .. maxb ) . each do | b | c = rest - b if a = = b if b = = c ans + = 1 else ans + = 3 end elsif b = = c ans + = 3 else ans + = 6 end end end p ans n = gets . to _ i s = gets puts ( s . index ( ? Y ) ) ? ' Four ' : ' Three ' a , b , c , d , e , k = 6 . times . map { gets . to _ i } ; puts e - a < = k ? " Yay ! " : " : ( " eval " N , X , * A = " + ` dd ` . split * ? , p ( 0 .. N ) . map { | i | A = A . zip ( b = A . rotate ) . map & : min i * X + b . inject ( : + ) } . min n = gets . to _ i p = [ ] n . times { | i | p [ i ] = gets . split . map ( & : to _ i ) } p < < p [ 0 ] q = gets . to _ i q . times { x , y = gets . split . map ( & : to _ i ) count = 0 on _ line = false n . times { | i | a = [ p [ i ] [ 0 ] - x , p [ i ] [ 1 ] - y ] b = [ p [ i + 1 ] [ 0 ] - x , p [ i + 1 ] [ 1 ] - y ] if a [ 0 ] * b [ 1 ] - a [ 1 ] * b [ 0 ] = = 0 & & a [ 0 ] * b [ 0 ] + a [ 1 ] * b [ 1 ] < = 0 on _ line = true break end a , b = b , a if a [ 1 ] > b [ 1 ] count + = 1 if a [ 1 ] < = 0 & & b [ 1 ] > 0 & & a [ 0 ] * b [ 1 ] - a [ 1 ] * b [ 0 ] > 0 } if on _ line = = true puts " 1 " elsif count % 2 = = 0 puts " 0 " else puts " 2 " end } n = gets . chomp . to _ i ans = 1 while ans * 2 < = n ans * = 2 end puts ans n , m = gets . chomp . split ( " " ) . map ( & : to _ i ) x = gets . chomp . split ( " " ) . map ( & : to _ i ) y = gets . chomp . split ( " " ) . map ( & : to _ i ) px , py = x [ 0 ] , y [ 0 ] sumx = 0 ans = 0 mod = 10 * * 9 + 7 for i in 1 .. n - 1 sumx + = ( x [ i ] - px ) * ( n - i ) * i sumx % = mod px = x [ i ] end for i in 1 .. m - 1 ans + = ( y [ i ] - py ) * ( m - i ) * i ans % = mod py = y [ i ] end puts ans * sumx % mod gets p = gets . chop . split . map ( & : to _ i ) count = 0 prev _ min = p [ 0 ] p . each do | p _ i | count + = 1 if prev _ min > = p _ i prev _ min = [ prev _ min , p _ i ] . min end puts count gets r = gets . to _ i - 1 x = 2 $ < . each { | _ | e = _ . to _ i if e = = x x + = 1 end r + = ( e - 1 ) / x } p r a = gets . chomp . split ( " " ) . map ( & : to _ i ) ; if a . include ? ( 1 ) & & a . include ? ( 9 ) & & a . include ? ( 7 ) & & a . include ? ( 4 ) puts " YES " else puts " NO " end x = gets . to _ i r = 6 ( x - 1 ) . times do r = r * 2 + 2 end puts r gets puts gets . split . uniq . size = = 3 ? " Three " : " Four " n = gets . to _ i arr = gets . split . map ( & : to _ i ) ans = 0 min = 10 * * 8 arr . each _ with _ index do | ar , i | if ar < = min min = ar ans + = 1 end end puts ans $ / = ' ' ; k , s = $ < . map & : to _ i ; r = 0 ; k + = 1 ; ( k * k ) . times { | x | z = s - x / k - x % k ; z < 0 | | z < k & & r + = 1 } ; p r puts [ C = $ < . map { | s | s . split . map & : to _ i } , C . transpose ] . any ? { | x | x . map { | a , b , c | [ a - b , b - c ] } . uniq [ 1 ] } ? : No : : Yes N = gets . to _ i a = gets . split . uniq . count puts ' Four ' if a = = = 4 ; puts ' Three ' if a = = = 3 ; C = 3 . times . map { gets . chomp . split . map ( & : to _ i ) } 3 . times do | i | m = C [ i ] . min 3 . times do | j | C [ i ] [ j ] - = m end end 3 . times do | i | if C [ 0 ] [ i ] ! = C [ 1 ] [ i ] | | C [ 1 ] [ i ] ! = C [ 2 ] [ i ] puts ' No ' exit end end puts ' Yes ' n = gets . to _ i 1 . upto ( 3500 ) do | a | 1 . upto ( 3500 ) do | b | bs = n * a * b bb = 4 * a * b - n * ( a + b ) if bb > 0 & & bs % bb = = 0 c = bs / bb puts [ a , b , c ] . join ( " " ) exit end end end K , S = readline . split ( ' ' ) . map ( & : to _ i ) count = 0 for x in ( 0 .. K ) remain = S - x next if remain > 2 * K break if remain < 0 for y in ( 0 .. K ) remain2 = S - x - y break if remain2 < 0 next if remain2 > K count + = 1 end end puts count a = [ ] 5 . times do | i | a [ i ] = gets . to _ i end k = gets . to _ i dis = [ ] 5 . times do | i | 5 . times do | j | dis . push ( ( a [ i ] - a [ j ] ) . abs ) end end success = true dis . each do | d | if d > k then puts " : ( " success = false break end end puts ' Yay ! ' if success ae = [ ] 5 . times { ae < < gets . to _ i } k = gets . to _ i puts ae [ 4 ] - ae [ 0 ] > k ? ' : ( ' : ' Yay ! ' N = gets . to _ i p = gets . split . map ( & : to _ i ) minel = Float : : INFINITY count = 0 N . times do | i | if p [ i ] < minel minel = p [ i ] count + = 1 end end puts count cc = [ ] 3 . times { cc < < gets . split . map ( & : to _ i ) } aa = [ 0 , 0 , 0 ] bb = [ 0 , 0 , 0 ] count = 0 [ 0 , 1 , 2 ] . each do | i | [ 0 , 1 , 2 ] . each do | j | aa [ i ] = cc [ i ] [ 0 ] - bb [ 0 ] bb [ j ] = cc [ 0 ] [ j ] - aa [ 0 ] count + = 1 if cc [ i ] [ j ] = = aa [ i ] + bb [ j ] end end puts count = = 9 ? ' Yes ' : ' No ' d = [ ] for i in 1 .. 3 do b = gets d < < b . split end c = " " a = [ ] d . each { | hai | a < < hai . map ( & : to _ i ) } for j in 0 .. 1 do for k in j ... 2 do if ! ( ( a [ j ] [ 0 ] - a [ k + 1 ] [ 0 ] = = a [ j ] [ 1 ] - a [ k + 1 ] [ 1 ] ) & & ( a [ j ] [ 0 ] - a [ k + 1 ] [ 0 ] = = a [ j ] [ 2 ] - a [ k + 1 ] [ 2 ] ) ) then c = " No " isBreak = true break ; else c = " Yes " end end break if isBreak end print c k , s = gets . split . map ( & : to _ i ) puts ( [ 0 , s - 2 * k ] . max .. [ k , s ] . min ) . map { | x | [ k , s - x ] . min - [ 0 , s - x - k ] . max + 1 } . reduce ( : + ) ary = [ ] 3 . times do | i | ary [ i ] = gets . split . map ( & : to _ i ) end 0 . upto ( ary [ 0 ] . max ) do | a1 | b1 = ary [ 0 ] [ 0 ] - a1 b2 = ary [ 0 ] [ 1 ] - a1 b3 = ary [ 0 ] [ 2 ] - a1 0 . upto ( ary [ 1 ] . max ) do | a2 | 0 . upto ( ary [ 2 ] . max ) do | a3 | if ( a1 + b1 = = ary [ 0 ] [ 0 ] & & a1 + b2 = = ary [ 0 ] [ 1 ] & & a1 + b3 = = ary [ 0 ] [ 2 ] & & a2 + b1 = = ary [ 1 ] [ 0 ] & & a2 + b2 = = ary [ 1 ] [ 1 ] & & a2 + b3 = = ary [ 1 ] [ 2 ] & & a3 + b1 = = ary [ 2 ] [ 0 ] & & a3 + b2 = = ary [ 2 ] [ 1 ] & & a3 + b3 = = ary [ 2 ] [ 2 ] ) puts ' Yes ' exit end end end end puts ' No ' cn = $ stdin . readline . to _ i 1 . step ( 3500 ) do | h | h . step ( 3500 ) do | n | rem = 4 * h * n - cn * h - cn * n next if rem < 1 num = n * h * cn if num % rem = = 0 w = num / rem puts [ h , n , w ] . join ( " " ) exit end end end a , b , c , d , e , f , g , h , i = 3 . times . flat _ map { gets . split . map ( & : to _ i ) } puts a - b = = d - e & & d - e = = g - h & & b - c = = e - f & & e - f = = h - i ? ' Yes ' : ' No ' n = gets . chomp . to _ i ret = 0 ( 0 .. n - 1 ) . each do | i | break if 2 * * i > n ret = 2 * * i end puts ret N , K = gets . chomp . split . map ( & : to _ i ) count = 0 ( 0 .. N ) . each do | e | ( 0 .. N ) . each do | ee | if K - e - ee < = N & & K - e - ee > = 0 count + = 1 end end end puts count array = [ ] 6 . times do array < < gets . to _ i end num = array [ 4 ] - array [ 0 ] if num < = array [ 5 ] puts ' Yay ! ' else puts " : ( " end n , num = gets . chomp . split ( " " ) . map ( & : to _ i ) if num = = 1 puts 1 exit elsif n = = 1 puts num exit end require ' prime ' ary = Prime . prime _ division ( num ) c = 1 ary . each do | a | if a [ 1 ] > = n ii = a [ 1 ] / n c = c * a [ 0 ] * * ii end end puts c n = gets . to _ i s = gets . split flg = " Three " for i in 0 .. n if ( s [ i ] = = " Y " ) then flg = " Four " break end end puts flg n = gets . to _ i a = gets . split . map ( & : to _ i ) b = gets . split . map ( & : to _ i ) diff = [ ] cnt = 0 diff _ sum = 0 n . times do | i | d = a [ i ] - b [ i ] diff [ i ] = d if d < 0 cnt + = 1 diff _ sum - = d end end if cnt = = 0 puts cnt else ans = cnt diff . sort ! . reverse ! i = 0 while diff _ sum > 0 if diff [ i ] < 0 puts - 1 exit end diff _ sum - = diff [ i ] ans + = 1 i + = 1 end puts ans end ns = 5 . times . map { gets . to _ i } . sort k = gets . to _ i puts ns [ 4 ] - ns [ 0 ] > k ? " : ( " : " Yay ! " a = gets . chomp . split . map { | aa | aa . to _ i } require ' prime ' b = a [ 1 ] . prime _ division anan = Array . new ( b . size ) . map { Array . new } ans = [ ] for bb in 0 ... b . size b [ bb ] [ 1 ] . times do anan [ bb ] . push ( b [ bb ] [ 0 ] ) end end for bb in 0 ... anan . size if ( anan [ bb ] . size / a [ 0 ] ) > = 1 ( anan [ bb ] . size / a [ 0 ] ) . times do ans . push ( anan [ bb ] [ 0 ] ) end end end if ans . size = = 0 puts " 1 " elsif a [ 0 ] = = 1 puts a [ 1 ] elsif a [ 1 ] = = 1 puts " 1 " else aaaa = 1 puts ans . map { | aaa | aaaa = aaaa * aaa } . pop end antenas = 5 . times . map { STDIN . gets . strip . to _ i } k = STDIN . gets . strip . to _ i puts antenas [ 4 ] - antenas [ 0 ] > k ? ' : ( ' : ' Yay ! ' a = gets . chomp . to _ i b = gets . chomp . to _ i c = gets . chomp . to _ i d = gets . chomp . to _ i e = gets . chomp . to _ i k = gets . chomp . to _ i [ a , b , c , d , e ] . each do | p | [ a , b , c , d , e ] . each do | q | if q - p > k then puts " : ( " exit end end end puts " Yay ! " n = gets . chomp . to _ i ary = gets . split ( " " ) . map ( & : to _ s ) if ary . uniq . size = = 3 puts " Three " else puts " Four " end N = gets . split . map ( & : to _ i ) A _ ARRAY = gets . split . map ( & : to _ i ) B _ ARRAY = gets . split . map ( & : to _ i ) result = 0 gap = 0 yobis = [ ] A _ ARRAY . zip ( B _ ARRAY ) . each do | ary | a = ary [ 0 ] b = ary [ 1 ] if b > a result + = 1 gap + = b - a else yobis < < a - b end end if result . zero ? puts 0 exit end yobis . sort ! . reverse _ each do | i | result + = 1 gap - = i if gap < = 0 puts result exit end end puts - 1 n , m , a , b = gets . chomp . split . map ( & : to _ i ) arr = gets . chomp . split . map ( & : to _ i ) keep , drop = [ ] , [ ] k = false arr . each { | x | k = true if x < a if k keep < < x else drop < < x end } if keep . length < m while ! drop . empty ? & & drop . last < = b drop . pop end end puts drop . length n = gets . to _ i s = gets . chomp . split colors = { " p " : false , " w " : false , " g " : false , " y " : false } n . times do | i | case s [ i ] when " P " colors [ : p ] = true when " W " colors [ : w ] = true when " G " colors [ : g ] = true when " Y " colors [ : y ] = true end end if colors [ : p ] & & colors [ : w ] & & colors [ : g ] & & colors [ : y ] puts " Four " elsif colors [ : p ] & & colors [ : w ] & & colors [ : g ] puts " Three " end n = gets . to _ i s = gets . chomp . split . uniq puts s . size = = 3 ? " Three " : " Four " n = gets . to _ i s = gets . chomp . split ( " " ) puts ( s . uniq . size = = 4 ) ? " Four " : " Three " n = gets . chomp . split ( " " ) . map ( & : to _ i ) . uniq if n . count ( 1 ) + n . count ( 9 ) + n . count ( 7 ) + n . count ( 4 ) = = 4 puts " YES " else puts " NO " end K , S = gets . split . map ( & : to _ i ) ans = 0 ( 0 .. K ) . each do | x | ( 0 .. K ) . each do | y | z = S - x - y ans + = 1 if z > = 0 & & z < = K end end puts ans N = gets . to _ i S = gets . chomp pp = S . count ( " P " ) ww = S . count ( " W " ) gg = S . count ( " G " ) yy = S . count ( " Y " ) if pp > = 1 & & ww > = 1 & & gg > = 1 & & yy = = 0 puts ( " Three " ) elsif pp > = 1 & & ww > = 1 & & gg > = 1 & & yy > = 1 puts ( " Four " ) end n = gets . to _ i four = false gets . split ( ' ' ) . each do | c | four = true if c = = ' Y ' end if four then puts ' Four ' else puts ' Three ' end a = gets puts gets . split . uniq . size = = 3 ? " Three " : " Four " ; n = gets . to _ i now = gets . split . map ( & : to _ i ) pass = gets . split . map ( & : to _ i ) ans = 0 sum = 0 check = 0 change = [ ] for i in 0 .. n - 1 if now [ i ] < pass [ i ] sum + = pass [ i ] - now [ i ] ans + = 1 else check + = now [ i ] - pass [ i ] change . push ( now [ i ] - pass [ i ] ) end end change . sort ! if change . length = = 0 | | sum > check puts - 1 exit end while sum > 0 sum - = change [ - 1 ] ans + = 1 change . delete _ at ( - 1 ) end puts ans c = 3 . times . map { gets . chomp . split ( " " ) . map ( & : to _ i ) } b = [ c [ 0 ] [ 0 ] , c [ 1 ] [ 0 ] , c [ 2 ] [ 0 ] ] if c [ 0 ] [ 1 ] - b [ 0 ] = = c [ 1 ] [ 1 ] - b [ 1 ] & & c [ 1 ] [ 1 ] - b [ 1 ] = = c [ 2 ] [ 1 ] - b [ 2 ] & & c [ 0 ] [ 2 ] - b [ 0 ] = = c [ 1 ] [ 2 ] - b [ 1 ] & & c [ 1 ] [ 2 ] - b [ 1 ] = = c [ 2 ] [ 2 ] - b [ 2 ] puts " Yes " else puts " No " end n = gets . to _ i s = gets . split p _ flag = false w _ flag = false g _ flag = false y _ flag = false ( 0 .. n - 1 ) . each do | i | case s [ i ] when ' P ' then p _ flag = true when ' W ' then w _ flag = true when ' G ' then g _ flag = true when ' Y ' then y _ flag = true end end cnt = 0 [ p _ flag , w _ flag , g _ flag , y _ flag ] . each do | i | if i = = true cnt + = 1 end end if cnt = = 3 puts " Three " else puts " Four " end n = gets . chomp . to _ i s = gets . chomp . split ( ' ' ) puts s . uniq . size = = 3 ? ' Three ' : ' Four ' n = gets . chomp . to _ i arr = gets . chomp . split ( ' ' ) . map ( & : to _ i ) count = 0 min _ num = 200001 n . times do i = arr . shift if min _ num > = i count + = 1 min _ num = i end end print ( count ) c = Array . new ( 3 ) { Array . new ( 3 ) } 3 . times do | i | c [ i ] = gets . chomp . split ( " " ) . map ( & : to _ i ) end a = [ ] b = [ ] a [ 0 ] = 0 b [ 0 ] = c [ 0 ] [ 0 ] b [ 1 ] = c [ 0 ] [ 1 ] b [ 2 ] = c [ 0 ] [ 2 ] a [ 1 ] = c [ 1 ] [ 1 ] - b [ 1 ] a [ 2 ] = c [ 2 ] [ 2 ] - b [ 2 ] equal _ c = true 3 . times do | i | 3 . times do | j | equal _ c = false if a [ i ] + b [ j ] ! = c [ i ] [ j ] end end if equal _ c puts " Yes " else puts " No " end a , b , c , d , e , k = 6 . times . map { gets . to _ i } if ( e - a < = k ) & & ( e - b < = k ) & & ( e - c < = k ) & & ( e - d < = k ) puts " Yay ! " else puts " : ( " end n = gets . to _ i s = gets . split puts s . uniq . size = = 3 ? " Three " : " Four " n = gets . to _ i p = gets . split . map & : to _ i f = 0 com = p [ 0 ] p . each _ with _ index do | el , i | next if i = = 0 f + = 1 if el > com com = [ el , com ] . min end p n - f c = readlines . map { | m | m . split . map ( & : to _ i ) } a = [ 0 ] * 3 b = [ 0 ] * 3 ans = true 0 . upto ( 100 ) do | n | a [ 0 ] = n b [ 0 ] = c [ 0 ] [ 0 ] - a [ 0 ] b [ 1 ] = c [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = c [ 0 ] [ 2 ] - a [ 0 ] a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] 3 . times do | i | 3 . times do | j | ans = false if c [ i ] [ j ] ! = a [ i ] + b [ j ] end end break if ans = = true end puts ans = = true ? " Yes " : " No " require ' pp ' $ DEBUG ? define _ method ( : dpp ) { | e | pp e } : define _ method ( : dpp ) { | e | } class Array define _ method ( : sum ) { self . inject ( : + ) . to _ i } unless method _ defined ? ( : sum ) end def gets _ i ( ) gets . chomp . to _ i end def gets _ i _ list ( ) gets . chomp . split ( " " ) . map ( & : to _ i ) end N = gets _ i a _ list = gets _ i _ list b _ list = gets _ i _ list negative _ diffs = [ ] positive _ diffs = [ ] 0 . upto ( N - 1 ) do | i | if a _ list [ i ] < b _ list [ i ] negative _ diffs . push ( b _ list [ i ] - a _ list [ i ] ) else a _ list [ i ] > b _ list [ i ] positive _ diffs . push ( a _ list [ i ] - b _ list [ i ] ) end end diff _ total = negative _ diffs . sum if diff _ total = = 0 puts " 0 " exit else count = 0 positive _ diffs . sort ! positive _ diffs . reverse _ each do | d | diff _ total - = d count + = 1 break if diff _ total < = 0 end if diff _ total < = 0 puts count + negative _ diffs . size else puts - 1 end end counter = gets . to _ i target = gets . chomp . split ( ) . map ( & : to _ i ) min = 0 answer = 0 counter . times do | count | if count = = 0 | | min > target [ count ] min = target [ count ] answer = answer + 1 end end puts answer a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i antena = [ a , b , c , d , e ] if antena . sort [ - 1 ] - antena . sort [ 0 ] > k puts ( " : ( " ) else puts ( " Yay ! " ) end line = gets . chomp . split ( ' ' ) . map { | e | e . to _ i } k = line [ 0 ] s = line [ 1 ] count = 0 for x in 0 .. k for y in 0 .. k z = s - x - y if 0 < = z & & z < = k count + = 1 end end end puts count k , s = gets . split . map ( & : to _ i ) puts ( 0 .. [ k , s ] . min ) . inject ( 0 ) { | t , x | t + ( 0 .. [ k , s - x ] . min ) . count { | y | s - x - y < = k } } puts [ : Three , : Four ] [ ` dd ` . split . uniq . size - 4 ] a , b , c , d , e , k = readlines . map ( & : to _ i ) if b - a < = k & & c - a < = k & & d - a < = k & & e - a < = k & & c - b < = k & & d - b < = k & & e - b < = k & & d - c < = k & & e - c < = k & & e - d < = k puts " Yay ! " else puts " : ( " end n = gets . chomp . to _ i ar = gets . chomp . split ( ' ' ) . map ( & : to _ i ) br = gets . chomp . split ( ' ' ) . map ( & : to _ i ) diffs = ar . zip ( br ) . map { | a , b | a - b } . reject { | n | n = = 0 } diffs = diffs . sort if diffs . inject ( 0 ) { | sum , x | sum + x } < 0 puts ' -1 ' exit 0 end d = 0 changes = 0 while ! diffs . empty ? if 0 < = d s = diffs . shift if 0 < = s puts changes exit 0 end d = s + d else s = diffs . pop if s < 0 puts ' -1 ' exit 0 end d = s + d end changes + = 1 end puts changes pos = 5 . times . map { gets . to _ i } k = gets . to _ i puts pos [ 4 ] - pos [ 0 ] > k ? " : ( " : " Yay ! " input = readlines . map & : chomp limit = input [ 5 ] . to _ i number _ list = [ ] [ * ( 0 .. 4 ) ] . each do | number | number _ list . push ( input [ number ] . to _ i ) end max = number _ list . max min = number _ list . min if ( max - min ) > limit puts ' : ( ' else puts ' Yay ! ' end y , r = gets . split . map ( & : to _ i ) puts y > - r ? 1 : y < - r ? - 1 : 0 K , S = gets . split . map ( & : to _ i ) c = 0 0 . upto ( K ) do | x | 0 . upto ( K ) do | y | z = ( S - ( x + y ) ) if 0 < = z & & z < = K c + = 1 end end end puts c N = gets . strip . to _ i i = 0 result = 0 while 2 * * i < = N result = 2 * * i i + = 1 end puts result n = gets . chomp . split ( ' ' ) . map ( & : to _ i ) if n . include ? ( 1 ) & & n . include ? ( 7 ) & & n . include ? ( 9 ) & & n . include ? ( 4 ) puts ' YES ' else puts ' NO ' end C = 3 . times . map { gets . split . map ( & : to _ i ) } if C [ 0 ] [ 0 ] - C [ 0 ] [ 1 ] = = C [ 1 ] [ 0 ] - C [ 1 ] [ 1 ] & & C [ 1 ] [ 0 ] - C [ 1 ] [ 1 ] = = C [ 2 ] [ 0 ] - C [ 2 ] [ 1 ] & & C [ 0 ] [ 2 ] - C [ 0 ] [ 1 ] = = C [ 1 ] [ 2 ] - C [ 1 ] [ 1 ] & & C [ 1 ] [ 2 ] - C [ 1 ] [ 1 ] = = C [ 2 ] [ 2 ] - C [ 2 ] [ 1 ] puts " Yes " else puts " No " end n = gets . to _ i s = gets . split . map ( & : to _ s ) puts s . include ? ( ' Y ' ) ? : Four : : Three grids = Array . new ( 3 , Array . new ( 3 ) ) 3 . times do | i | grids [ i ] = STDIN . gets . split ( ' ' ) . map ( & : to _ i ) end correct = false 0 . upto ( 100 ) do | a1 | 0 . upto ( 100 ) do | a2 | 0 . upto ( 100 ) do | a3 | b1 _ 1 = grids [ 0 ] [ 0 ] - a1 b1 _ 2 = grids [ 1 ] [ 0 ] - a2 b1 _ 3 = grids [ 2 ] [ 0 ] - a3 b2 _ 1 = grids [ 0 ] [ 1 ] - a1 b2 _ 2 = grids [ 1 ] [ 1 ] - a2 b2 _ 3 = grids [ 2 ] [ 1 ] - a3 b3 _ 1 = grids [ 0 ] [ 2 ] - a1 b3 _ 2 = grids [ 1 ] [ 2 ] - a2 b3 _ 3 = grids [ 2 ] [ 2 ] - a3 if ( ( b1 _ 1 = = b1 _ 2 & & b1 _ 2 = = b1 _ 3 ) & & ( b2 _ 1 = = b2 _ 2 & & b2 _ 2 = = b2 _ 3 ) & & ( b3 _ 1 = = b3 _ 2 & & b3 _ 2 = = b3 _ 3 ) ) correct = true break end end end end if correct puts ' Yes ' else puts ' No ' end d , n = gets . strip . split ( ' ' ) . map { | s | s . to _ i } ts = d . times . map { gets . strip . to _ i } wears = n . times . map { gets . strip . split ( ' ' ) . map { | s | s . to _ i } } max _ dc = [ ] for i in ( 0 ... n ) if wears [ i ] [ 0 ] < = ts [ 0 ] & & ts [ 0 ] < = wears [ i ] [ 1 ] max _ dc < < [ wears [ i ] [ 2 ] , 0 ] end end for j in ( 1 ... d ) p _ max _ dc = max _ dc max _ dc = [ ] for i in ( 0 ... n ) if wears [ i ] [ 0 ] < = ts [ j ] & & ts [ j ] < = wears [ i ] [ 1 ] ci = wears [ i ] [ 2 ] sdc = 0 for pmdc in p _ max _ dc pci , psdc = pmdc dc = ( ci - pci ) . abs + psdc sdc = dc if sdc < dc end max _ dc < < [ ci , sdc ] end end end puts max _ dc . map { | mdc | mdc [ 1 ] } . max a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i if e - a > k puts ' : ( ' exit elsif d - a > k puts ' : ( ' exit elsif c - a > k puts ' : ( ' exit elsif b - a > k puts ' : ( ' exit end if e - b > k puts ' : ( ' exit elsif d - b > k puts ' : ( ' exit elsif c - b > k puts ' : ( ' exit end if e - c > k puts ' : ( ' exit elsif d - c > k puts ' : ( ' exit end if e - d > k puts ' : ( ' exit else puts ' Yay ! ' end K , S = gets . chomp . split ( " " ) . map ( & : to _ i ) count = 0 for x in 0 .. K do for y in 0 .. K do if S - ( x + y ) < = K & & S - ( x + y ) > = 0 count = count + 1 end end end puts count n = gets . to _ i a = gets . split ( " " ) . map ( & : to _ i ) b = gets . split ( " " ) . map ( & : to _ i ) asum = a . inject ( : + ) bsum = b . inject ( : + ) if bsum > asum puts " -1 " else diff = a . map . with _ index { | v , idx | v - b [ idx ] } lacks = diff . select { | d | d < 0 } remains = diff . select { | d | d > 0 } . sort . reverse count = lacks . size lacksum = lacks . empty ? ? 0 : lacks . inject ( : + ) while lacksum < 0 count + = 1 lacksum + = remains . shift end puts count end a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i array = a , b , c , d , e array . sort if k < ( array . last - array . first ) print " : ( " else print " Yay ! " end gets puts ( gets = ~ / Y / ? " Four " : " Three " ) ( N , ) , A , B = $ < . map { | s | s . split . map & : to _ i } c = 0 v = [ ] w = 0 A . zip ( B ) . map { | a , b | if a < b w + = b - a c + = 1 elsif a > b v < < a - b end } v . sort ! . reverse ! v . map { | d | if w > 0 c + = 1 end w - = d } p w > 0 ? - 1 : c n = gets . chomp . to _ i a = [ ] n . times { a . push ( gets . chomp . to _ i ) } ans = a [ 0 ] - 1 a [ 0 ] = 1 th = 2 ( 1 ... n ) . each { | i | if a [ i ] = = th th + = 1 else ans + = ( a [ i ] - th - 1 ) / th + 1 end } puts ans N = gets . to _ i data = gets . split if data . uniq . size = = 3 puts ' Three ' else puts ' Four ' end h , w = gets . chomp . split . map ( & : to _ i ) a = [ ] h . times { a < < gets . chomp . split . map ( & : to _ i ) } min = nil for y in 0 ... h for x in 0 ... w dist = 0 for y2 in 0 ... h for x2 in 0 ... w dist + = [ ( y2 - y ) . abs , ( x2 - x ) . abs ] . min * a [ y2 ] [ x2 ] end end min = dist if min . nil ? | | min > dist end end puts min a , b = readlines . map ( & : chomp ) . map ( & : to _ i ) . each _ slice ( 5 ) . to _ a puts a . permutation ( 2 ) . select { | n , m | m - n > b [ 0 ] } . any ? ? " : ( " : " Yay ! " require ' prime ' DBG = ! true n , p = gets . split . map { | z | z . to _ i } f = p . prime _ division prod = 1 for x in f pr = x [ 0 ] ex = x [ 1 ] prod * = pr * * ( ex / n ) end print prod gets s = gets . chomp . split ( " " ) if s . count { | c | c = = " Y " } > 0 then puts " Four " else puts " Three " end require ' set ' ; require ' prime ' INF = Float : : INFINITY a = gets . chomp . split if a . sort . join ( ' ' ) = = ' 1479 ' puts ' YES ' else puts ' NO ' end n = gets . chomp . to _ i ; a = gets . chomp . split ( " " ) . map ( & : to _ i ) ; b = gets . chomp . split ( " " ) . map ( & : to _ i ) ; sum _ a = 0 sum _ b = 0 for i in 0 .. n - 1 sum _ a = sum _ a + a [ i ] sum _ b = sum _ b + b [ i ] end if sum _ a < sum _ b p - 1 else count = 0 odds = 0 list = [ ] for i in 0 .. n - 1 if a [ i ] < b [ i ] count = count + 1 odds = odds + ( b [ i ] - a [ i ] ) else list . push ( a [ i ] - b [ i ] ) end end if count = = 0 p 0 else list = list . sort . reverse len = list . length sum = 0 i = 0 while sum < odds & & i < len sum = sum + list [ i ] count = count + 1 i = i + 1 end p count end end K , S = gets . chomp . split ( " " ) . map ( & : to _ i ) ans = 0 ( 0 .. K ) . each { | i | next if S - i > 2 * K if S - i < = K then ans + = ( S - i + 1 ) if S - i + 1 > 0 else ans + = ( 2 * K - S + i + 1 ) end } puts ans n = gets . to _ i sequence = gets . split . map ( & : to _ i ) result = 0 min _ num = 2 * 10 * * 5 sequence . each do | num | min _ num = [ min _ num , num ] . min result + = 1 if min _ num > = num end puts result require ' prime ' ; n , x = gets . split . map & : to _ i ; p x . prime _ division . map { | m , k | m * * ( k / n ) } . reduce 1 , : * as = [ ] 5 . times do as < < gets . to _ i end k = gets . to _ i as . each do | a1 | as . each do | a2 | if ( a1 - a2 ) . abs > k puts " : ( " exit end end end puts " Yay ! " a = gets . chomp . to _ i b = gets . chomp . to _ i c = gets . chomp . to _ i d = gets . chomp . to _ i e = gets . chomp . to _ i k = gets . chomp . to _ i if e - a < = k puts " Yay ! " else puts " : ( " end a0 = gets . chop . split . map ( & : to _ i ) . take ( 3 ) a1 = gets . chop . split . map ( & : to _ i ) . take ( 3 ) a2 = gets . chop . split . map ( & : to _ i ) . take ( 3 ) if a0 [ 0 ] - a0 [ 1 ] = = a1 [ 0 ] - a1 [ 1 ] & & a2 [ 0 ] - a2 [ 1 ] = = a0 [ 0 ] - a0 [ 1 ] & & a0 [ 1 ] - a0 [ 2 ] = = a1 [ 1 ] - a1 [ 2 ] & & a2 [ 1 ] - a2 [ 2 ] = = a0 [ 1 ] - a0 [ 2 ] & & a0 [ 2 ] - a0 [ 0 ] = = a1 [ 2 ] - a1 [ 0 ] & & a2 [ 2 ] - a2 [ 0 ] = = a0 [ 2 ] - a0 [ 0 ] & & a0 [ 0 ] - a1 [ 0 ] = = a0 [ 1 ] - a1 [ 1 ] & & a0 [ 2 ] - a1 [ 2 ] = = a0 [ 0 ] - a1 [ 0 ] & & a1 [ 0 ] - a2 [ 0 ] = = a1 [ 1 ] - a2 [ 1 ] & & a1 [ 2 ] - a2 [ 2 ] = = a1 [ 0 ] - a2 [ 0 ] & & a2 [ 0 ] - a0 [ 0 ] = = a2 [ 1 ] - a0 [ 1 ] & & a2 [ 2 ] - a0 [ 2 ] = = a2 [ 0 ] - a0 [ 0 ] puts " Yes " else puts " No " end N = gets . to _ i a = gets . split . map ( & : to _ i ) res = 0 cnt = Float : : INFINITY N . times do | i | if cnt > a [ i ] res + = 1 cnt = a [ i ] end end puts res a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i if e - a < = k then puts " Yay ! " else puts " : ( " end gets p = gets . split . map ( & : to _ i ) c = Float : : INFINITY ans = 0 p . each do | n | if n < c c = n ans + = 1 end end puts ans ns = gets . split . map ( & : to _ i ) ans = ' NO ' if ns . include ? ( 1 ) & & ns . include ? ( 9 ) & & ns . include ? ( 7 ) & & ns . include ? ( 4 ) ans = ' YES ' end puts ans a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i p = [ ] p < < a p < < b p < < c p < < d p < < e p . sort ! puts ( p [ 4 ] - p [ 0 ] < = k ) ? : Yay ! : ' : ( ' a = 6 . times . map { gets . to _ i } puts a [ 4 ] - a [ 0 ] > a [ 5 ] ? " : ( " : " Yay ! " n = gets . to _ i p 2 * * Math . log2 ( n ) . floor a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i output = " Yay ! " antennas = [ a , b , c , d , e ] antennas _ combi = antennas . combination ( 2 ) antennas _ combi . each do | antenna _ combi | if ( antenna _ combi [ 0 ] - antenna _ combi [ 1 ] ) . abs > k output = " : ( " break end end puts output a = STDIN . read . lines [ 1 ] . split . map { | v | v . to _ i } ; cnt = 0 ; min = a [ 0 ] + 1 a . each _ with _ index do | v , i | min > = v & & ( min = v and cnt + = 1 ) end puts cnt arr = [ ] 5 . times do | i | arr < < gets . to _ i end k = gets . to _ i sa = arr [ - 1 ] - arr [ 0 ] puts sa < = k ? " Yay ! " : " : ( " list = [ ] count = 0 6 . times do list < < gets . chomp . to _ i end for i in 0 .. 4 do for j in ( i + 1 ) .. 4 do if ( list [ j ] - list [ i ] ) > list [ 5 ] count + = 1 end end end if count ! = 0 puts " : ( " else puts " Yay ! " end k , s = gets . chomp . split . map ( & : to _ i ) arr = ( 0 .. k ) counter = 0 arr . each do | x | arr . each do | y | z = s - ( x + y ) counter + = 1 if 0 < = z & & z < = k end end puts counter k , s = gets . chomp . split . map ( & : to _ i ) cnt = 0 0 . upto ( k ) do | x | 0 . upto ( k ) do | y | z = s - ( x + y ) if 0 < = z & & z < = k cnt + = 1 end end end puts cnt k , s = gets . split . map ( & : to _ i ) count = 0 ( 0 .. k ) . each do | h | ( 0 .. k ) . each do | i | j = s - h - i if j < = k & & 0 < = j count + = 1 end end end puts count n = gets . to _ i r = - 1 while n > 0 n / = 2 r + = 1 end puts 2 * * r m = gets . to _ i nums = gets . split . map ( & : to _ i ) c = 0 nums . each { | val | if val < = m m = val c + = 1 end } puts c N = gets . chomp P = gets . split . map ( & : to _ i ) count = 1 min = P [ 0 ] 1 . upto ( P . size - 1 ) do | i | if P [ i ] < = min min = P [ i ] count + = 1 end end puts count a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i if e - a < = k puts " Yay ! " else puts " : ( " end C = 3 . times . map { [ ] } 3 . times do | i | C [ i ] = gets . split . map ( & : to _ i ) end N = 100 ans = ' No ' 0 . step 100 do | a1 | b1 = C [ 0 ] [ 0 ] - a1 a2 = C [ 1 ] [ 0 ] - b1 a3 = C [ 2 ] [ 0 ] - b1 if [ C [ 0 ] [ 1 ] - a1 , C [ 1 ] [ 1 ] - a2 , C [ 2 ] [ 1 ] - a3 ] . uniq . size = = 1 if [ C [ 0 ] [ 2 ] - a1 , C [ 1 ] [ 2 ] - a2 , C [ 2 ] [ 2 ] - a3 ] . uniq . size = = 1 ans = ' Yes ' break end end end puts ans n = gets . to _ i p = gets . split . map ( & : to _ i ) min = 2 * ( 10 * * 5 ) count = 0 n . times do | i | count + = 1 if min > = p [ i ] min = p [ i ] if min > p [ i ] end puts count gets c = gets . chomp puts c . match ( ' Y ' ) ? ' Four ' : ' Three ' N = gets . to _ i a = gets puts a . count ( ? Y ) > 0 ? " Four " : " Three " k , s = gets . chomp . split ( ' ' ) . map ( & : to _ i ) ans = 0 ( 0 .. k ) . each do | x | ( 0 .. k ) . each do | y | z = s - x - y ans + = 1 if ( 0 < = z & & z < = k ) end end puts ans K , S = gets . split . map ( & : to _ i ) k = K + 1 way = 0 k . times do | x | k . times do | y | xy = x + y z = S - xy way + = 1 if z > = 0 & & z < = K end end p way a = [ ] a = gets . split . map ( & : to _ i ) cnt = 0 for i in 0 .. a [ 0 ] for j in 0 .. a [ 0 ] if a [ 1 ] - i - j > = 0 & & i < = a [ 0 ] & & j < = a [ 0 ] & & ( a [ 1 ] - i - j ) < = a [ 0 ] cnt = cnt + 1 end end end puts cnt n = gets . to _ i as = gets . split . map ( & : to _ i ) bs = gets . split . map ( & : to _ i ) diff = Array . new ( n ) { | i | as [ i ] - bs [ i ] } remains = diff . select { | i | i > 0 } . sort requires = diff . select { | i | i < 0 } . sort valid = true changed = 0 charge = 0 while ! ( requires . empty ? ) req = - requires . pop changed + = 1 while ! ( remains . empty ? ) & & charge < req charge + = remains . pop changed + = 1 end if remains . empty ? & & charge < req valid = false break end charge - = req end puts ( valid ? changed : - 1 ) n = gets . chomp . to _ i arr = gets . chomp . split ( ' ' ) . map ( & : to _ i ) min = arr [ 0 ] count = 0 ( 0 ... n ) . each do | i | min = [ arr [ i ] , min ] . min count + = 1 if min > = arr [ i ] end puts count n = gets . to _ i p _ n = gets . chomp . split ( " " ) . map ( & : to _ i ) min = p _ n [ 0 ] res = 0 n . times do | i | if p _ n [ i ] < = min res + = 1 end if p _ n [ i ] < min min = p _ n [ i ] end end puts ( res ) num1 = gets . to _ i 3 . times do gets end num2 = gets . to _ i k = gets . to _ i if ( num2 - num1 ) < = k print " Yay ! " else print " : ( " end require ' pp ' def gets _ i ( ) gets . chomp . to _ i end N = gets _ i puts 2 * * Math : : log ( N , 2 ) . floor n = gets . to _ i ary = gets . split . map ( & : to _ i ) min = ary . first ans = 1 ( 1 .. n - 1 ) . each do | i | if ary [ i ] < min ans + = 1 min = ary [ i ] end end puts ans n = gets . to _ i s = gets . chomp . split cnt = 0 cl = Hash . new ( 0 ) s . each { | c | cl [ c ] + = 1 } cl . each { | v | cnt + = 1 } ( cnt = = 3 ) ? ( puts " Three " ) : ( puts " Four " ) s = $ stdin . gets s = s . split for e in 0 ... s . length s [ e ] = s [ e ] . to _ i end counter = 0 for i in 0 .. s [ 0 ] max = s [ 1 ] - i < = s [ 0 ] ? s [ 1 ] - i : s [ 0 ] for j in 0 .. max k = s [ 1 ] - i - j if k > = 0 & & k < = s [ 0 ] then counter + = 1 end end end print counter a = gets . chomp . to _ i b = gets . chomp . to _ i c = gets . chomp . to _ i d = gets . chomp . to _ i e = gets . chomp . to _ i k = gets . chomp . to _ i if e - a < = k puts ' Yay ! ' else puts ' : ( ' end c = [ ] csum0 = 0 3 . times do row = gets . chomp . split ( " " ) . map ( & : to _ i ) csum0 + = row . inject ( : + ) c < < row end csum1 = c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] csum2 = c [ 0 ] [ 2 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 0 ] if csum0 = = csum1 * 3 & & csum0 = = csum2 * 3 then puts " Yes " else puts " No " end n , p = gets . chomp . split . map ( & : to _ i ) if n = = 1 p p exit end if p = = 1 p 1 exit end i = 0 while true if ( i + 1 ) * * n > p break end i + = 1 end i . downto ( 1 ) do | u | if p % ( u * * n ) = = 0 p u exit end end _ = gets print gets . split . uniq . size = = 3 ? " Three " : " Four " gets ; puts gets . split . uniq . size = = 3 ? " Three " : " Four " a = gets . to _ i b = gets . to _ i c = gets . to _ i c = gets . to _ i e = gets . to _ i k = gets . to _ i puts e - a > k ? " : ( " : " Yay ! " a = gets . to _ i b = 0 4 . times do b = gets . to _ i end k = gets . to _ i puts ( b - a < = k ) ? " Yay ! " : " : ( " k , s = gets . strip . split . map ( & : to _ i ) result = 0 ( 0 .. k ) . each do | x | ( 0 .. k ) . each do | y | result + = 1 if s - ( x + y ) < = k & & s - ( x + y ) > = 0 end end puts result k , s = gets . split . map & : to _ i cnt = 0 ( k + 1 ) . times do | x | ( k + 1 ) . times do | y | z = s - x - y if z > = 0 & & z < = k cnt + = 1 end end end puts cnt k , s = gets . chomp . split ( ' ' ) . map { | n | n . to _ i } ans = 0 for x in 0 .. k for y in 0 .. k z = s - x - y if z > = 0 & & z < = k ans = ans + 1 end end end puts ans n = gets . to _ i y = $ < . map { | e | e . split . map & : to _ i } . transpose . map { | x , y | x - y } . sort x = y . dup l = 0 r = n - 1 while l < r & & x [ l ] < 0 r - = 1 if x [ r ] = = 0 x [ l ] + = z = [ x [ r ] , - x [ l ] ] . min x [ r ] - = z l + = 1 if x [ l ] = = 0 end p x [ l ] < 0 ? - 1 : ( 0 ... n ) . count { | i | x [ i ] ! = y [ i ] } puts ( gets . chomp . split . map ( & : to _ i ) . sort ! = = [ 1 , 4 , 7 , 9 ] ) ? " YES " : " NO " N = gets . to _ i P = gets . split . map & : to _ i min = N cnt = 0 P . each do | e | if e < = min cnt + = 1 min = e end end puts cnt N = gets . strip . to _ i P = gets . strip . split . map ( & : to _ i ) mn = N + 1 count = 0 P . each do | i | if i < mn then mn = i count + = 1 end end puts count N = gets . to _ i ans = 1 while 2 * * ans < = N ans + = 1 end puts 2 * * ( ans - 1 ) a = gets . to _ i b = gets . split ( " " ) if b . count ( " Y " ) > = 1 puts " Four " else puts " Three " end k , s = gets . split . map ( & : to _ i ) cnt = 0 ( k + 1 ) . times do | x | ( k + 1 ) . times do | y | cnt + = 1 if s - x - y < = k & & s - x - y > = 0 end end puts cnt a = STDIN . read . lines [ 1 ] . split . map { | v | v . to _ i } ; cnt = 0 ; min = a . max + 1 a . each _ with _ index do | v , i | min > = v & & ( min = v and cnt + = 1 ) end puts cnt $ debugFlag = ( ARGV [ 0 ] ! = nil ) p " = = = = DEBUG MODE = = = = " if $ debugFlag def pd ( str ) p str if $ debugFlag end inputs = [ ] lc = 0 while l = $ stdin . gets do if false inputs < < l . chomp . split ( " " ) . map ( & : to _ s ) else inputs < < l . chomp . split ( " " ) . map ( & : to _ i ) end lc + = 1 end if $ debugFlag p " --- INPUT ( begin ) --- " inputs . each do | l _ i | p l _ i end p " --- INPUT ( end ) --- " print " \ n " end aa = inputs [ 0 ] [ 0 ] ll = inputs [ - 2 ] [ 0 ] kk = inputs [ - 1 ] [ 0 ] if $ debugFlag p aa p ll p kk end if ll - aa > kk puts " : ( " else puts " Yay ! " end N = gets . to _ i A = gets . split puts A . include ? ( " Y " ) ? " Four " : " Three " n = gets . to _ i P _ arr = gets . split . map ( & : to _ i ) counter = 0 P _ max = P _ arr . max n . times do | i | if P _ max > = P _ arr [ i ] counter + = 1 P _ max = P _ arr [ i ] end end p counter DBG = true a = gets . split . map { | x | x . to _ i } x = a . include ? ( 1 ) & & a . include ? ( 7 ) & & a . include ? ( 9 ) & & a . include ? ( 4 ) if x print ' YES ' else print ' NO ' end _ = gets . to _ i arr = gets . chomp . split ( ' ' ) arr . uniq ! puts arr . size = = 4 ? ' Four ' : ' Three ' a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i ans = ( e - a ) < = k ? ' Yay ! ' : ' : ( ' puts ans n = gets . to _ i max = 0 num = 1 ( 1 .. n ) . each do | i | j = i if i % 2 = = 0 count = 0 while j % 2 = = 0 j / = 2 count + = 1 end if max < count max = count num = i end end end puts num s = gets . split puts s . include ? ( ' 1 ' ) & & s . include ? ( ' 9 ' ) & & s . include ? ( ' 7 ' ) & & s . include ? ( ' 4 ' ) ? " YES " : " NO " c = Array . new ( 3 ) c [ 0 ] = gets . split . map ( & : to _ i ) c [ 1 ] = gets . split . map ( & : to _ i ) c [ 2 ] = gets . split . map ( & : to _ i ) if 0 = = c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] - c [ 0 ] [ 1 ] - c [ 1 ] [ 2 ] - c [ 2 ] [ 0 ] & & 0 = = c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] - c [ 0 ] [ 2 ] - c [ 1 ] [ 0 ] - c [ 2 ] [ 1 ] then print " Yes \ n " else print " No \ n " end antena = 5 . times . map { gets . chomp . to _ i } n = gets . chomp . to _ i flag = true for i in 0 .. antena . size - 2 do for j in 1 .. antena . size - 1 do if ( antena [ i ] - antena [ j ] ) . abs > n flag = false end end end if flag puts ' Yay ! ' else puts ' : ( ' end k , s = gets . split . map & : to _ i count = 0 for x in 0 .. k do for y in 0 .. k do z = s - ( x + y ) if z > = 0 & & z < = k & & x + y + z = = s count + = 1 end end end puts count n = gets . to _ i s = gets . chomp . split ( " " ) a = s . count { | color | color = = " Y " } if a ! = 0 puts " Four " else puts " Three " end eval " T , U , A , X , B , Y = " + ` dd ` . split * ? , x , y = ( A - B ) * T , ( X - Y ) * U x , y = - x , - y if x > 0 puts x + y = = 0 ? : infinity : ( s = - x / y + = x ; s < 0 ? 0 : s * 2 + ( x % y > 0 ? 1 : 0 ) ) N = gets . chomp . split . map ( & : to _ i ) puts N . include ? ( 1 ) & & N . include ? ( 9 ) & & N . include ? ( 7 ) & & N . include ? ( 4 ) ? " YES " : " NO " n = gets . to _ i puts gets . chomp . split ( " " ) . count ( " Y " ) > 0 ? : Four : : Three n = gets . to _ i P _ arr = gets . chomp . split . map ( & : to _ i ) counter = 0 P _ max = P _ arr . max n . times do | i | if P _ max > = P _ arr [ i ] counter + = 1 P _ max = P _ arr [ i ] end end p counter a = gets . chomp . to _ i b = gets . chomp . to _ i c = gets . chomp . to _ i d = gets . chomp . to _ i e = gets . chomp . to _ i k = gets . chomp . to _ i puts e - a < = k ? " Yay ! " : " : ( " k , s = gets . split . map ( & : to _ i ) x = ( 0 .. k ) . to _ a ans = 0 x . each do | xx | x . each do | yy | z = s - xx - yy ans + = 1 if z > = 0 & & z < = k end end p ans N = STDIN . gets . chomp . to _ i P = STDIN . gets . split ( ' ' ) . map { | s | s . to _ i } ans = 0 min = [ ] N . times do | i | if i = = 0 min [ i ] = P [ 0 ] else min [ i ] = [ min [ i - 1 ] , P [ i ] ] . min end if P [ i ] < = min [ i ] ans + = 1 end end puts ans gets . to _ i puts gets . split . uniq . length = = 3 ? " Three " : " Four " cs = $ < . read . split . map ( & : to _ i ) cs = cs . each _ slice ( 3 ) . to _ a i = 0 while i < 3 cs [ i ] = cs [ i ] . map { | c | c - cs [ i ] . min } i + = 1 end cs = cs . transpose i = 0 while i < 3 cs [ i ] = cs [ i ] . map { | c | c - cs [ i ] . min } i + = 1 end b = cs . flatten . inject ( & : + ) = = 0 puts ( b ? ' Yes ' : ' No ' ) array = 5 . times . map { gets . to _ i } k = gets . to _ i if array . max - array . min > k puts " : ( " else puts " Yay ! " end a = $ stdin . gets . chomp . to _ i b = $ stdin . gets . chomp . to _ i c = $ stdin . gets . chomp . to _ i d = $ stdin . gets . chomp . to _ i e = $ stdin . gets . chomp . to _ i k = $ stdin . gets . chomp . to _ i if e - a < = k puts " Yay ! " else puts " : ( " end a , b , c , d = gets . split . map ( & : to _ i ) . sort if a = = 1 & & b = = 4 & & c = = 7 & & d = = 9 puts " YES " else puts " NO " end n = gets . to _ i p = gets . split . map ( & : to _ i ) vmin = n cnt = 0 n . times do | i | vmin = [ vmin , p [ i ] ] . min cnt + = 1 if p [ i ] < = vmin end puts cnt n4 = gets . chomp . split ( / \ s / ) . map { | x | x . to _ i } . sort puts ( n4 [ 0 ] = = 1 and n4 [ 1 ] = = 4 and n4 [ 2 ] = = 7 and n4 [ 3 ] = = 9 ) ? ' YES ' : ' NO ' k , s = gets . chomp . split ( ' ' ) . map ( & : to _ i ) cnt = 0 if k * 3 < s cnt = 0 elsif k * 3 = = s cnt = 1 else 0 . upto ( k ) do | a | 0 . upto ( s - a ) do | b | next if b > k | | ( a + b ) > s cnt + = 1 if s - a - b < = k end end end puts cnt input = readlines input . each { | num | num = num . chomp ! } i = input . length stat = " 0 " if input [ i - 1 ] . to _ i < ( input [ i - 2 ] . to _ i - input [ 0 ] . to _ i ) print " : ( " else print " Yay ! " end a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i answer = " Yay ! " array = [ a , b , c , d , e ] array . combination ( 2 ) do | first , second | if second - first > k answer = " : ( " end end puts answer N = gets . to _ i P = gets . split . map ( & : to _ i ) cnt = 0 min = 999999999 ( 0 .. ( N - 1 ) ) . each do | i | if P [ i ] < = min min = P [ i ] end if ! ( P [ i ] > min ) cnt + = 1 end end puts cnt if _ _ FILE _ _ = = $ 0 reads _ i = lambda { | s , d | s . strip . split ( d ) . map ( & : to _ i ) } data = reads _ i [ gets , " " ] k = data [ 0 ] s = data [ 1 ] cnt = 0 for x in 0 .. k for y in 0 .. k z = s - ( x + y ) if x + y = = s | | ( z < = k & & z > 0 ) then cnt + = 1 end end end p cnt end n = gets . to _ i numbers = gets . split . map ( & : to _ i ) maximum = numbers [ 0 ] count = 0 numbers . each do | number | if number < = maximum count + = 1 maximum = number end end puts count c = 3 . times . map { gets . split . map ( & : to _ i ) } if ( c [ 0 ] . map { | ci | ci - c [ 0 ] [ 0 ] } = = c [ 1 ] . map { | ci | ci - c [ 1 ] [ 0 ] } ) & & ( c [ 0 ] . map { | ci | ci - c [ 0 ] [ 0 ] } = = c [ 2 ] . map { | ci | ci - c [ 2 ] [ 0 ] } ) & & ( c . transpose [ 0 ] . map { | ci | ci - c . transpose [ 0 ] [ 0 ] } = = c . transpose [ 1 ] . map { | ci | ci - c . transpose [ 1 ] [ 0 ] } ) & & ( c . transpose [ 0 ] . map { | ci | ci - c . transpose [ 0 ] [ 0 ] } = = c . transpose [ 2 ] . map { | ci | ci - c . transpose [ 2 ] [ 0 ] } ) puts ' Yes ' else puts ' No ' end ARR = gets . split ( " " ) . map { | i | i . to _ i } if ( ARR . include ? ( 1 ) & & ARR . include ? ( 9 ) & & ARR . include ? ( 7 ) & & ARR . include ? ( 4 ) ) puts " YES " else puts " NO " end a , b , c , d = gets . split ( " " ) . map ( & : to _ i ) if ( a = = 1 or a = = 9 or a = = 7 or a = = 4 ) and ( b = = 1 or b = = 9 or b = = 7 or b = = 4 ) and ( a ! = b ) and ( b ! = d ) and ( b ! = c ) and ( c = = 1 or c = = 9 or c = = 7 or c = = 4 ) and ( a ! = c ) and ( d = = 1 or d = = 9 or d = = 7 or d = = 4 ) and ( a ! = d ) and ( c ! = d ) puts " YES " else puts " NO " end a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i arr = [ a , b , c , d , e ] def five _ antennas ( arr , k ) for i in 0 .. 3 do for j in i + 1 .. 4 if ( arr [ j ] - arr [ i ] ) > k return " : ( " end end end " Yay ! " end puts five _ antennas ( arr , k ) require ' pp ' $ DEBUG ? define _ method ( : dpp ) { | e | pp e } : define _ method ( : dpp ) { | e | } class Array define _ method ( : sum ) { self . inject ( : + ) } unless method _ defined ? ( : sum ) end def gets _ i ( ) gets . chomp . to _ i end def gets _ i _ list ( ) gets . chomp . split ( " " ) . map ( & : to _ i ) end N = gets _ i a _ list = gets _ i _ list b _ list = gets _ i _ list negative _ diffs = [ ] positive _ diffs = [ ] 0 . upto ( N - 1 ) do | i | if a _ list [ i ] < b _ list [ i ] negative _ diffs . push ( b _ list [ i ] - a _ list [ i ] ) else a _ list [ i ] > b _ list [ i ] positive _ diffs . push ( a _ list [ i ] - b _ list [ i ] ) end end diff _ total = negative _ diffs . sum . to _ i dpp diff _ total if diff _ total = = 0 puts " 0 " exit else count = 0 positive _ diffs . sort ! positive _ diffs . reverse _ each do | d | diff _ total - = d count + = 1 break if diff _ total < = 0 end if diff _ total < = 0 puts count + negative _ diffs . size else puts - 1 end end k , s = gets . to _ s . chomp . split ( ' ' ) . map ( & : to _ i ) x = 0 y = 0 z = 0 result = 0 while x < = k y = 0 while y < = k z = s - x - y if z > = 0 & & z < = k & & x + y + z = = s result + = 1 end y + = 1 end x + = 1 end puts result a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i puts e - a < = k ? " Yay ! " : " : ( " k , s = gets . chomp . split . map ( & : to _ i ) ans = 0 0 . upto ( k ) do | x | 0 . upto ( k ) do | y | z = s - x - y ans + = 1 if 0 < = z & & z < = k end end p ans a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i if [ e - d , e - c , e - b , e - a , d - c , d - b , d - a , c - b , c - a , b - a ] . max < = k puts " Yay ! " else puts " : ( " end def main ( argv ) ns = gets . chomp . split ( ' ' ) . map ( & : to _ i ) . sort puts ( ns = = [ 1 , 4 , 7 , 9 ] ? ' YES ' : ' NO ' ) end if self . to _ s = = ' main ' then main ( ARGV ) end _ n = gets . to _ i array = gets . split ( " " ) count = array . uniq . length if count = = 3 then puts " Three " elsif count = = 4 then puts " Four " end n = gets . to _ i ans = 1 max _ count = 0 current = 0 1 . upto ( n ) do | i | current = i count = 0 while i % 2 = = 0 i / = 2 count + = 1 end if count > max _ count max _ count = count ans = current end end puts ans def get _ i ( ) return gets . chomp . split ( " " ) . map ( & : to _ i ) end def get _ f ( ) return gets . chomp . split ( " " ) . map ( & : to _ f ) end def get ( ) return gets . chomp . split ( " " ) end def get _ nsp ( ) return gets . chomp . split ( " " ) end def yn _ judge ( bool , y = " Yes " , n = " No " ) return bool ? y : n end def array ( size1 , init = nil , size2 = 1 ) if size2 = = 1 return Array . new ( size1 ) { init } else return Array . new ( size2 ) { Array . new ( size1 ) { init } } end end N = gets . to _ i S = get . uniq ! puts yn _ judge ( S . size = = 4 , " Four " , " Three " ) N = gets . to _ i P = gets . chomp . split ( " " ) . map ( & : to _ i ) ans , wk = [ 0 , N + 1 ] P . each { | q | ( ans + = 1 ; wk = q ) if wk > q } puts ans K , S = gets . split ( " " ) . map ( & : to _ i ) cnt = 0 for i in 0 .. K do for j in 0 .. K do k = S - i - j if k > = 0 & & k < = K then cnt = cnt + 1 end end end puts ( cnt ) k , s = gets . split . map ( & : to _ i ) sum = 0 ( 0 .. k ) . each do | num | rest = s - num sum + = [ [ ( k * 2 ) - rest + 1 , rest + 1 ] . min , 0 ] . max end puts sum grid = Array . new ( 3 ) 3 . times do | i | grid [ i ] = gets . split . map ( & : to _ i ) end flag = false 0 . upto ( 100 ) do | a1 | b1 , b2 , b3 = grid [ 0 ] [ 0 ] - a1 , grid [ 0 ] [ 1 ] - a1 , grid [ 0 ] [ 2 ] - a1 if [ b1 , b2 , b3 ] . any ? { | b | b < 0 } then next end if grid [ 1 ] [ 0 ] - b1 = = grid [ 1 ] [ 1 ] - b2 & & grid [ 1 ] [ 1 ] - b2 = = grid [ 1 ] [ 2 ] - b3 & & grid [ 2 ] [ 0 ] - b1 = = grid [ 2 ] [ 1 ] - b2 & & grid [ 2 ] [ 1 ] - b2 = = grid [ 2 ] [ 2 ] - b3 then flag = true break end end puts flag ? ' Yes ' : ' No ' K , S = gets . split ( " " ) . map ( & : to _ i ) c = 0 for i in 0 .. K do for j in 0 .. K do if S - ( i + j ) < = K & & 0 < = S - ( i + j ) then c + = 1 end end end puts c n = [ ] for i in 1 .. 5 do n < < gets . to _ i end k = gets . to _ i puts n . max - n . min > k ? ' : ( ' : ' Yay ! ' n = gets . to _ i ss = gets . split puts ss . index ( ' Y ' ) = = nil ? ' Three ' : ' Four ' n = gets . chomp . split . sort . join puts n = = " 1479 " ? " YES " : " NO " n = gets . to _ i p = gets . split . map ( & : to _ i ) min = 10 * * 6 ans = 0 p . each do | c | if c < = min ans + = 1 min = c end end puts ans c = [ ] c < < gets . split . map ( & : to _ i ) c < < gets . split . map ( & : to _ i ) c < < gets . split . map ( & : to _ i ) a = [ 0 , c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] , c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] ] b = [ c [ 0 ] [ 0 ] , c [ 0 ] [ 1 ] , c [ 0 ] [ 2 ] ] if a [ 1 ] + b [ 1 ] ! = c [ 1 ] [ 1 ] | | a [ 1 ] + b [ 2 ] ! = c [ 1 ] [ 2 ] | | a [ 2 ] + b [ 1 ] ! = c [ 2 ] [ 1 ] | | a [ 2 ] + b [ 2 ] ! = c [ 2 ] [ 2 ] puts " No " else puts " Yes " end p = Array . new ( 5 ) do gets . strip . to _ i end k = gets . strip . to _ i ok = true 0 . upto ( 3 ) do | i | ( i + 1 ) . upto ( 4 ) do | j | ok = false if p [ j ] - p [ i ] > k end end puts ok ? " Yay ! " : " : ( " n = gets . to _ i ss = gets . split ( " " ) print " Three \ n " if ss . uniq . size = = 3 print " Four \ n " if ss . uniq . size = = 4 i = gets . to _ i ary = gets . chomp . split ( " " ) puts [ " P " , " W " , " G " , " Y " ] . all ? { | n | ary . include ? ( n ) } ? " Four " : " Three " eval " T , U , A , X , B , Y = " + ` dd ` . split * ? , x = ( A - B ) * T y = x + ( X - Y ) * U puts y = = 0 ? : infinity : [ 0 , - x / y * 2 + ( x % y ! = 0 ? 1 : 0 ) ] . max require ' prime ' n , q = gets . split . map ( & : to _ i ) ret = 1 q . prime _ division . each do | a , b | if b / n ! = 0 ret * = a * * ( b / n ) end end p ret N , _ = gets . split ( " " ) . map { | i | i . to _ i } A = gets . split ( " " ) . map { | i | i . to _ i } B = gets . split ( " " ) . map { | i | i . to _ i } Asum = A . inject { | sum , a | sum + a } Bsum = B . inject { | sum , b | sum + b } if ( Asum < Bsum ) puts - 1 exit 0 end AminB = Array . new ( N ) { | i | 0 } for i in 0 .. ( N - 1 ) AminB [ i ] = A [ i ] - B [ i ] end AminB _ positive _ sorted = AminB . reject { | n | n < 0 } . sort { | n , m | n < = > m } maxdif = Asum - Bsum i = 0 cnt = 0 while ( maxdif > = 0 & & i < = AminB _ positive _ sorted . size - 1 ) if ( AminB _ positive _ sorted [ i ] < = maxdif ) maxdif - = AminB _ positive _ sorted [ i ] cnt + = 1 i + = 1 else puts N - cnt exit 0 end end if ( i = = AminB _ positive _ sorted . size ) puts N - cnt exit 0 end puts N h = Hash . new ( 0 ) num = gets . to _ i st = gets . chomp ! . split ( " " ) st . each do | s | h [ s ] + = 1 end h . delete ( " " ) if h . keys . length = = 3 puts " Three " elsif h . keys . length = = 4 puts " Four " end n = gets . chomp . to _ i colors = gets . chomp . split puts colors . include ? ( " Y " ) ? " Four " : " Three " cell = Array [ 9 ] 3 . times do | i | cell [ i * 3 ] , cell [ i * 3 + 1 ] , cell [ i * 3 + 2 ] = gets . split ( " " ) . map ( & : to _ i ) end flg = true if cell [ 0 ] - cell [ 3 ] ! = cell [ 1 ] - cell [ 4 ] flg = false end if cell [ 1 ] - cell [ 4 ] ! = cell [ 2 ] - cell [ 5 ] flg = false end if cell [ 3 ] - cell [ 6 ] ! = cell [ 4 ] - cell [ 7 ] flg = false end if cell [ 4 ] - cell [ 7 ] ! = cell [ 5 ] - cell [ 8 ] flg = false end if cell [ 0 ] - cell [ 6 ] ! = cell [ 1 ] - cell [ 7 ] flg = false end if cell [ 1 ] - cell [ 7 ] ! = cell [ 2 ] - cell [ 8 ] flg = false end puts flg ? " Yes " : " No " a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i if b - a < = k & & c - a < = k & & d - a < = k & & e - a < = k & & c - b < = k & & d - b < = k & & e - b < = k & & d - c < = k & & e - c < = k & & e - d < = k puts ( " Yay ! " ) else puts ( " : ( " ) end k , s = gets . split . map ( & : to _ i ) exit 1 if k < 2 | | k > 2500 | | s < 0 | | s > 3 * k puts ( 0 .. k ) . map { | x | [ [ s - x , k ] . min - [ s - x - k , 0 ] . max + 1 , 0 ] . max } . inject ( & : + ) K , S = gets . split . map & : to _ i ans = 0 mn = [ 0 , S - K * 2 ] . max mx = [ K , S ] . min for x in mn .. mx rest = S - x if rest < = K a = rest + 1 else d = rest - K a = K - d + 1 end ans + = a end p ans data _ set = readlines as = data _ set [ 1 ] . split . map ( & : to _ i ) bs = data _ set [ 2 ] . split . map ( & : to _ i ) ds = as . zip ( bs ) . map { | a , b | a - b } if ds . reduce ( : + ) < 0 puts - 1 exit end lack _ list = ds . select { | x | x < 0 } lack = lack _ list . reduce ( : + ) unless lack puts 0 exit end exceed _ list = ds . select { | x | x > 0 } . sort . reverse c = 1 sum = 0 0 . upto ( exceed _ list . size - 1 ) do | i | sum + = exceed _ list [ i ] break if sum + lack > = 0 c + = 1 end puts c + lack _ list . size N = 5 def main ( argv ) a = [ 0 ] * N N . times { | i | a [ i ] = gets . chomp . to _ i } k = gets . chomp . to _ i f = true N . times do | i | N . times do | j | f & = ( a [ j ] - a [ i ] ) . abs < = k end end puts f ? ' Yay ! ' : ' : ( ' end if self . to _ s = = ' main ' then main ( ARGV ) end puts $ < . read . index ( " Y " ) ? : Four : : Three n = gets . to _ i ps = gets . chomp . split . map ( & : to _ i ) m = [ ] n . times do | i | if i ! = 0 m < < [ m [ - 1 ] , ps [ i ] ] . min else m < < ps [ i ] end end puts ( 0 ... n ) . to _ a . count { | i | ps [ i ] = = m [ i ] } n = gets . to _ i p = gets . split ( ' ' ) . map ( & : to _ i ) count = 1 min = p [ 0 ] ( 1 ... n ) . each do | i | if min > p [ i ] count + = 1 min = p [ i ] end end puts count n = gets . split . map ( & : to _ i ) . sort if n = = [ 1 , 4 , 7 , 9 ] puts " YES " else puts " NO " end puts $ < . map { | s | s . split . map ( & : to _ i ) } . map { | a , b , c | [ a - b , b - c ] } . uniq . length = = 1 ? " Yes " : " No " puts gets . split . sort = = % w ( 1 4 7 9 ) ? : YES : : NO a , b , c , d , e , k = 6 . times . map { gets . to _ i } if e - a < = k puts " Yay ! " else puts " : ( " end N = gets . chomp . to _ i P = gets . chomp . split ( " " ) . map ( & : to _ i ) ans = 0 min = Float : : INFINITY N . times do | i | if P [ i ] < min ans + = 1 min = P [ i ] end end puts ans N = gets . to _ i P = gets . split . map { | e | e . to _ i } _ max = 0 _ min = 0 ans = 0 P . each _ with _ index do | p , i | if i = = 0 ans + = 1 _ max = p next end if i = = 1 if _ max < p _ min = _ max _ max = p else _ min = p ans + = 1 end next end if p < = _ min and p < = _ max ans + = 1 else _ max = p if p > _ max end _ min = p if p < _ min end puts ans ca = Array . new ( 5 ) { gets . to _ i } k = gets . to _ i puts ( ca [ 4 ] - ca [ 0 ] > k ) ? " : ( " : " Yay ! " a , b , c , d , e , k = STDIN . read . lines . map ( & : chomp ) . map ( & : to _ i ) if e - a < = k then puts ' Yay ! ' else puts ' : ( ' end antennas = 5 . times . map do gets . chomp . to _ i end k = gets . chomp . to _ i puts ( if ( antennas . max - antennas . min ) < = k then ' Yay ! ' else ' : ( ' end ) a = [ ] 6 . times do a < < gets . to _ i end puts a [ 4 ] - a [ 0 ] > a [ 5 ] ? " : ( " : " Yay ! " n = gets . to _ i puts 0 . upto ( 6 ) . map { | i | 2 * * i < = n ? 2 * * i : 0 } . max k , s = gets . split ( " \ s " ) . map { | s | s . to _ i } kai = 0 0 . upto ( k ) do | x | 0 . upto ( k ) do | y | if s - x - y > = 0 & & s - x - y < = k then kai + = 1 end end end puts kai k , s = gets . split . map ( & : to _ i ) count = 0 ( k + 1 ) . times do | i | ( k + 1 ) . times do | j | z = s - i - j count + = 1 if 0 < = z & & z < = k end end puts count a = [ ] for i in 0 .. 4 a [ i ] = gets . to _ i end k = gets . to _ i a . sort ! if a [ 4 ] - a [ 0 ] > k puts " : ( " else puts " Yay ! " end _ = gets . to _ i arare = gets . chomp . split case arare . uniq . size when 3 then puts " Three " when 4 then puts " Four " end gets numbers = gets . split . map ( & : to _ i ) lastNumber = numbers . max matchCount = 0 numbers . each do | number | if lastNumber > = number matchCount + = 1 lastNumber = number end end puts matchCount n = gets . to _ i p = gets . split . map ( & : to _ i ) min = Float : : INFINITY count = 0 for i in 0 .. n - 1 if p [ i ] < = min min = p [ i ] count + = 1 end end puts count a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i if e - a < = k puts ' Yay ! ' else puts ' : ( ' end r = 1 < < 30 H , W = gets . split . map & : to _ i M = H . times . map { gets . split . map & : to _ i } H . times { | h | W . times { | w | s = 0 ; H . times { | i | W . times { | j | s + = M [ i ] [ j ] * [ ( h - i ) . abs , ( w - j ) . abs ] . min } } ; r = [ r , s ] . min } } p r _ , A , B = $ < . map { | s | s . split . map & : to _ i } v = [ ] w = 0 c = A . zip ( B ) . count { | a , b | a < b ? w + = b - a : ! ( v < < b - a ) } + v . sort . count { | d | d < w + = d } p w > 0 ? - 1 : c c = [ ] 3 . times do | i | c [ i ] = $ stdin . gets . chomp . split ( ' ' ) . map ( & : to _ i ) end 2 . times do | i | unless ( 0 .. 2 ) . map { | j | c [ j ] [ 2 ] - c [ j ] [ i ] } . uniq . length = = 1 print ' No ' exit end unless ( 0 .. 2 ) . map { | j | c [ 2 ] [ j ] - c [ i ] [ j ] } . uniq . length = = 1 print ' No ' exit end end print ' Yes ' N = gets . to _ i P = gets . split . map ( & : to _ i ) res = 1 min = P [ 0 ] N . times do | i | next if i = = 0 next if min < P [ i ] res + = 1 min = P [ i ] if P [ i ] < min end puts res _ = gets puts gets . chomp . split . uniq . size = = 3 ? " Three " : " Four " a = 5 . times . map { gets . to _ i } k = gets . to _ i puts a . max - a . min > k ? " : ( " : " Yay ! " k , s = gets . chomp . split ( " " ) . map ( & : to _ i ) count = 0 xStart = ( s - 2 * k < 0 ) ? 0 : ( s - 2 * k ) xEnd = ( s < k ) ? s : k for x in xStart .. xEnd do yStart = ( s - x - k < 0 ) ? 0 : ( s - x - k ) yEnd = ( s < x + k ) ? ( s - x ) : k for y in yStart .. yEnd do z = s - x - y count + = 1 if 0 < = z & & z < = k end end puts count antena = [ ] 5 . times { antena < < gets . chomp . to _ i } k = gets . chomp . to _ i flag = false 5 . times do | i | 5 . times do | j | next if i = = j flag = true if ( antena [ i ] - antena [ j ] ) . abs > k end end puts flag ? ' : ( ' : ' Yay ! ' gets ary = gets . chomp . split . map ( & : to _ i ) ret = 0 min = ary [ 0 ] ary . each . with _ index ( 1 ) do | pi , i | next if pi > min min = pi ret + = 1 end puts ret a , b , c , d , e , k = ARGF . read . lines . map ( & : to _ i ) puts ( if e - a > k then " : ( " else " Yay ! " end ) gets puts gets . chomp . split ( " " ) . uniq . size = = 4 ? " Four " : " Three " arr = [ ] 6 . times do arr . push ( gets . to _ i ) end if arr [ 4 ] - arr [ 0 ] > arr [ 5 ] puts " : ( " else puts " Yay ! " end a = gets . to _ i b = gets . split . map ( & : to _ i ) c = 20000000 ans = 0 for num in 0 .. a - 1 do if b [ num ] < c c = b [ num ] ans + = 1 end end p ans gets ; puts gets . split ( ' ' ) . uniq . size = = 3 ? " Three " : " Four " K , S = gets . chomp . split . map ( & : to _ i ) count = 0 for i in 0 .. K do for j in 0 .. K do rem = S - i - j count + = 1 if rem > = 0 & & rem < = K end end puts count bef = gets . split . map ( & : to _ i ) 1 . upto ( 2 ) do aft = gets . split . map ( & : to _ i ) d = aft [ 0 ] - bef [ 0 ] 1 . upto ( 2 ) do | j | if aft [ j ] - bef [ j ] ! = d puts " No " exit end end bef = aft end puts " Yes " N , * P = $ < . read . split . map ( & : to _ i ) p P . inject ( [ 0 , P [ 0 ] ] ) { | ( sum , min ) , p | p < = min ? [ sum + 1 , p ] : [ sum , min ] } [ 0 ] N = gets . to _ i A = gets . split . map ( & : to _ i ) B = gets . split . map ( & : to _ i ) stock = A . zip ( B ) . map { | a , b | a - b } . sort diff = 0 ans = 0 N . times do | i | if A [ i ] < B [ i ] ans + = 1 diff + = A [ i ] - B [ i ] end while diff < 0 & & ! stock . empty ? diff + = stock . pop ans + = 1 end end if diff < 0 puts - 1 else puts ans end gets puts ( ( gets . split . uniq . length = = 3 ) ? ' Three ' : ' Four ' ) a = gets . chomp . to _ i b = gets . chomp . to _ i c = gets . chomp . to _ i d = gets . chomp . to _ i e = gets . chomp . to _ i k = gets . chomp . to _ i if ( e - a ) < = k puts " Yay ! " else puts " : ( " end nums = gets . split . map ( & : to _ i ) nums = nums . sort x = nums [ 0 ] * 1000 + nums [ 1 ] * 100 + nums [ 2 ] * 10 + nums [ 3 ] if x = = 1479 puts " YES " else puts " NO " end MOD = 10 * * 9 + 7 cnt = 0 ; sum = 0 ; prev = nil ; can = true ; h = Hash . new ( 0 ) def gs ( ) gets . chomp end def gi ( ) gets . chomp . to _ i end def gsmi ( ) gets . chomp . split . map ( & : to _ i ) end def desc ( ar ) ar . sort ! { | x , y | y < = > x } end def min ( a , b ) a < = b ? a : b end def max ( a , b ) a > = b ? a : b end def sum ( ar ) ar . inject ( : + ) end def C ( a , b ) b = = 0 | | a = = b ? 1 : ( b = a - b if a / 2 < b ; ( a - b + 1 .. a ) . inject ( : * ) / ( 1 .. b ) . inject ( : * ) ) end def rui ( ar ) s = [ 0 ] ; ar . size . times { | i | s < < s [ - 1 ] + ar [ i ] } ; s end def rev _ rui ( ar ) s = [ 0 ] ; ar . size . times . reverse _ each { | i | s < < s [ - 1 ] + ar [ i ] } ; s end def puts _ yesno ( b ) puts ( b ? ' Yes ' : ' No ' ) end def putsend ( s ) puts s ; exit end def debug ( k , v ) puts " n = gi pp = gsmi prevmin = 2 * 10 * * 5 + 1 n . times do | i | cnt + = 1 if prevmin > = pp [ i ] prevmin = pp [ i ] if prevmin > pp [ i ] end puts cnt n = gets . to _ i exit if n < 3 val = [ 0 , 0 , 0 , 0 ] arares = gets . chomp . split ( " " ) n . times do | i | val [ 0 ] = val [ 0 ] + 1 if arares [ i ] = = " P " & & val [ 0 ] = = 0 val [ 1 ] = val [ 1 ] + 1 if arares [ i ] = = " W " & & val [ 1 ] = = 0 val [ 2 ] = val [ 2 ] + 1 if arares [ i ] = = " G " & & val [ 2 ] = = 0 val [ 3 ] = val [ 3 ] + 1 if arares [ i ] = = " Y " & & val [ 3 ] = = 0 end case val . inject { | sum , n | sum + n } when 3 then puts " Three " when 4 then puts " Four " else end require ' set ' ; require ' prime ' INF = Float : : INFINITY n = gets . chomp . to _ i a = gets . chomp . split . map ( & : to _ i ) b = gets . chomp . split . map ( & : to _ i ) sum = a . inject ( : + ) bsum = b . inject ( : + ) if sum < bsum puts - 1 exit end ans = 0 needsum = 0 amari = Array . new ( n , 0 ) n . times do | i | if b [ i ] > a [ i ] needsum + = b [ i ] - a [ i ] ans + = 1 else amari [ i ] = a [ i ] - b [ i ] end end amari . sort ! . reverse ! amari _ i = 0 while needsum > 0 needsum - = amari [ amari _ i ] amari _ i + = 1 end puts ans + amari _ i a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i puts e - a > k ? ' : ( ' : ' Yay ! ' puts $ < . read . include ? ( ' Y ' ) ? : Four : : Three arg = gets . chomp arg = arg . split ( " " ) k = arg [ 0 ] . to _ i s = arg [ 1 ] . to _ i numPettern = 0 if k * 3 = = s puts 1 exit end ( 0 .. k ) . each do | x | if x + k + k < s next end if x = = s numPettern + = 1 next end ( 0 .. k ) . each do | y | if x + y + k < s next end if x + y > s break end if x + y = = s numPettern + = 1 break end z = s - x - y if z < = s numPettern + = 1 end end end puts numPettern a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i puts ( a - b ) . abs < = k & & ( a - c ) . abs < = k & & ( a - d ) . abs < = k & & ( a - e ) . abs < = k & & ( b - c ) . abs < = k & & ( b - d ) . abs < = k & & ( b - e ) . abs < = k & & ( c - d ) . abs < = k & & ( c - e ) . abs < = k & & ( d - e ) . abs < = k ? ' Yay ! ' : ' : ( ' N = gets . chomp . to _ i puts gets . chomp . split . uniq . count = = 3 ? " Three " : " Four " cs = 3 . times . map { gets . split . map ( & : to _ i ) } ans = " Yes " 3 . times do | i | diff = cs [ i ] [ 0 ] - cs [ i - 1 ] [ 0 ] 3 . times do | j | ans = " No " if diff ! = cs [ i ] [ j ] - cs [ i - 1 ] [ j ] end end puts ans n = gets . chomp ! . to _ i ls = gets . split ( " " ) . map ( & : to _ i ) min = ls [ 0 ] count = 1 for i in 1 .. n - 1 do if ls [ i ] < min min = ls [ i ] count + = 1 end end p count n = gets . to _ i ps = gets . split . map ( & : to _ i ) max = ps . first count = 0 ps . each do | p0 | if p0 < = max count + = 1 max = p0 end end puts count input = $ stdin . read . split ( " \ n " ) n = input . shift . to _ i as = input . map ( & : to _ i ) stepcount = as . shift - 1 minvalue = 2 as . each do | currency | if currency = = minvalue minvalue = minvalue + 1 else currency > minvalue stepcount = stepcount + ( ( currency - 1 ) / minvalue ) end end puts stepcount N = gets . to _ i Ps = gets . split . map ( & : to _ i ) ans , mn = 0 , 10 * * 6 Ps . each do | p | next if p > mn ans + = 1 mn = p end puts ans ar = [ gets . to _ i ] ar . push gets . to _ i ar . push gets . to _ i ar . push gets . to _ i ar . push gets . to _ i k = gets . to _ i ar . minmax ( ) . each _ cons ( 2 ) { | e | if e [ 1 ] - e [ 0 ] < = k then puts " Yay ! " ; else puts " : ( " ; end } a = gets . chop . to _ i b = gets . chop c = gets . chop d = gets . chop e = gets . chop . to _ i k = gets . chop . to _ i distance = e - a if k > = distance puts " Yay ! " else puts " : ( " end N = gets . to _ i two _ array = [ ] 7 . times { | i | two _ array < < 2 * * i } two _ array _ abs = two _ array . select { | v | v < = N } . map { | v | ( v - N ) . abs } index = two _ array _ abs . index ( two _ array _ abs . min ) puts two _ array [ index ] require ' pp ' c = [ ] c [ 0 ] = gets . chomp ! . split ( " " ) . map ( & : to _ i ) c [ 1 ] = gets . chomp ! . split ( " " ) . map ( & : to _ i ) c [ 2 ] = gets . chomp ! . split ( " " ) . map ( & : to _ i ) if c [ 0 ] . zip ( c [ 1 ] ) . map { | i , j | i - j } . uniq . length = = 1 & & c [ 1 ] . zip ( c [ 2 ] ) . map { | i , j | i - j } . uniq . length = = 1 & & c [ 2 ] . zip ( c [ 0 ] ) . map { | i , j | i - j } . uniq . length = = 1 x = c . transpose if x [ 0 ] . zip ( x [ 1 ] ) . map { | i , j | i - j } . uniq . length = = 1 & & x [ 1 ] . zip ( x [ 2 ] ) . map { | i , j | i - j } . uniq . length = = 1 & & x [ 2 ] . zip ( x [ 0 ] ) . map { | i , j | i - j } . uniq . length = = 1 puts " Yes " else puts " No " end else puts " No " end input _ lines = readlines length = input _ lines . length i = 0 while i < length input _ lines [ i ] = input _ lines [ i ] . chomp . to _ i i + = 1 end if ( input _ lines [ 4 ] - input _ lines [ 0 ] ) > input _ lines [ 5 ] print " : ( " else print " Yay ! " end n , as , bs = ARGF . read . split ( " \ n " ) . map { | e | e . split } xs = as . zip ( bs ) . map { | e | a , b = e . map { | ee | ee . to _ i } a - b } . sort ms = xs . select { | e | e < 0 } ps = xs . select { | e | e > 0 } if ms . length = = 0 puts 0 exit end c = ms . length val = 0 ms . each { | e | m = e . abs if val < = m loop { if ps . length = = 0 puts ' -1 ' exit else val + = ps . pop c + = 1 if val > = m val - = m break end end } else val - = m end } puts c n = gets . chomp . to _ i a = gets . chomp . split . map ( & : to _ i ) ans = 1 nowmin = a [ 0 ] if n ! = 1 then ( 1 .. n ) . each do | i | if a [ i ] < nowmin then ans + = 1 nowmin = a [ i ] end if nowmin = = 1 break end end end puts ans k , s = gets . chomp . split ( " " ) . map ( & : to _ i ) cnt = 0 for x in 0 .. k for y in 0 .. k cnt + = 1 if s - x - y < = k & & s - x - y > = 0 end end puts cnt gets puts gets . chomp . split ( ' ' ) . uniq . count = = 3 ? ' Three ' : ' Four ' antenas = 5 . times . map { STDIN . gets . strip . to _ i } k = STDIN . gets . strip . to _ i puts antenas [ 4 ] - antenas [ 0 ] > k ? ' : ( ' : ' Yay ! ' gets a = gets . split . map ( & : to _ i ) b = gets . split . map ( & : to _ i ) if a . inject ( & : + ) < b . inject ( & : + ) puts - 1 exit ( 0 ) end d = a . zip ( b ) . map { | a , b | a - b } dp = d . select ( & : positive ? ) . sort . reverse dn = - d . select ( & : negative ? ) . inject ( 0 , & : + ) if dn = = 0 puts 0 exit ( 0 ) end ( dp . size - 1 ) . times . each do | i | dp [ i + 1 ] + = dp [ i ] end puts ( dp . each _ with _ index . to _ a . bsearch { | x , i | dn < = x } | | [ 0 , - 1 ] ) [ 1 ] + d . select ( & : negative ? ) . size + 1 N = gets . split . map ( & : to _ i ) if N . sort = = [ 1 , 4 , 7 , 9 ] puts ' YES ' else puts ' NO ' end n = gets . to _ i nums = gets . split . map ( & : to _ i ) res = 0 min = n + 1 n . times do | i | if min > nums [ i ] res + = 1 min = nums [ i ] end end puts res n = gets . to _ i ps = gets . split . map ( & : to _ i ) min = ps [ 0 ] ans = 0 ps . each do | pn | if pn < = min min = pn ans + = 1 end end puts ans eval " N , X , * A = " + ` dd ` . split * ? , p A . map { A = A . zip ( b = A . rotate ) . map & : min b . reduce ( : + ) + X * ~ $ . - = 1 } . min puts $ < . map { | s | eval " 100 * ( % d-c = % d ) + % d-c " % s . split } . uniq [ 1 ] ? : No : : Yes K , S = $ < . read . split . map ( & : to _ i ) c = 0 0 . upto ( K ) do | x | 0 . upto ( K ) do | y | z = S - x - y c + = 1 if 0 < = z & & z < = K end end puts c require ' pp ' N , d = gets . chomp . split ( ' ' ) . map { | n | n . to _ i } S = gets . chomp . split ( ' ' ) . map { | n | n } if ( S . any ? { | s | s = = " Y " } ) puts " Four " else puts " Three " end c = 3 . times . map { gets . split . map ( & : to _ i ) } all = c . map { | e | e . inject ( : + ) } . inject ( : + ) % 3 = = 0 al2 = 2 . times . all ? { | i | c [ i .. i + 1 ] . map { | e | e [ i .. i + 1 ] . inject ( : + ) } . inject ( : + ) % 2 = = 0 } puts all & & al2 ? : Yes : : No d = [ ] 5 . times { d < < gets . to _ i } puts ( d . max - d . min ) < = gets . to _ i ? ' Yay ! ' : ' : ( ' antena = [ ] for i in 0 .. 4 do antena [ i ] = gets . chomp . to _ i end k = gets . chomp . to _ i if antena [ 4 ] - antena [ 0 ] > k print ( " : ( \ n " ) else print ( " Yay ! \ n " ) end require ' prime ' n , q = gets . split . map & : to _ i a = q . prime _ division result = 1 a . each do | i , j | result * = i * * ( j / n ) if j > = n end puts result antenas = [ ] 5 . times do | i | antenas < < gets . chomp . to _ i end k = gets . chomp . to _ i puts antenas [ - 1 ] - antenas [ 0 ] < = k ? ' Yay ! ' : ' : ( ' N = gets . to _ i A = gets . split . map ( & : to _ i ) count = 0 A . inject ( 2 * N ) do | smin , a | count + = 1 if a < = smin a < smin ? a : smin end puts count k , s = gets . split ( ' ' ) . map ! ( & : to _ i ) count = 0 loop _ range = ( 0 .. k ) loop _ range . each do | x | loop _ range . each do | y | z = s - x - y count + = 1 if z > = 0 & & z < = k end end puts count attrs = Array . new while line = $ stdin . gets attrs < < line . chomp . split . map { | v | v . to _ i } end attrs . flatten ! k = attrs . pop ng = 0 for i in 0 .. ( attrs . length - 1 ) do for j in 0 .. ( attrs . length - 1 ) do if i = = j then next end if ( attrs [ i ] - attrs [ j ] ) . abs > k then ng = 1 end end end if ng = = 0 then puts " Yay ! " else puts " : ( " end axises = ( 1 .. 5 ) . map { gets . to _ i } k = gets . to _ i dists = [ ] axises . each _ with _ index do | a , i | axises . each _ with _ index do | b , j | next if i = = j dists < < ( a - b ) . abs end end if dists . all ? { | x | x < = k } puts ' Yay ! ' else puts ' : ( ' end K , S = gets . chomp . split . map ( & : to _ i ) count = 0 0 . upto ( K ) do | x | 0 . upto ( K ) do | y | z = S - x - y if 0 < = z & & z < = K count + = 1 end end end print count c = [ ] 3 . times do c < < gets . chomp . split ( " " ) . map ( & : to _ i ) end ( 0 .. 100 ) . each do | a1 | ( 0 .. 100 ) . each do | a2 | ( 0 .. 100 ) . each do | a3 | flags = [ ] 3 . times do | i | flag1 = c [ i ] [ 0 ] - a1 flag2 = c [ i ] [ 1 ] - a2 flag3 = c [ i ] [ 2 ] - a3 if flag1 = = flag2 & & flag2 = = flag3 & & flag3 = = flag1 then flags < < true else flags < < false end end if flags . all ? { | v | v } then puts " Yes " exit end end end end puts " No " Z = Array . new ( 5 ) { | _ | gets . to _ i } a , b , c , d , e = Z R = gets . to _ i puts Z . map { | r | r - a } [ - 1 ] > R ? " : ( " : " Yay ! " s = gets . split . map ( & : to _ s ) . sort . join t = [ 1 , 9 , 7 , 4 ] . sort . join if s = = t puts " YES " else puts " NO " end def cin ; gets . split . map ( & : to _ i ) end def cout ( * x ) ; puts x . join ( " " ) end exit if $ 0 ! = _ _ FILE _ _ M = 10 * * 9 + 7 n , m = cin xs = cin ys = cin xx = [ * ( 1 .. n ) ] . inject ( 0 ) { | s , i | ( s + ( ( ( 2 * i ) % M - n - 1 ) * xs [ i - 1 ] ) % M ) % M } yy = [ * ( 1 .. m ) ] . inject ( 0 ) { | s , i | ( s + ( ( ( 2 * i ) % M - m - 1 ) * ys [ i - 1 ] ) % M ) % M } puts ( xx * yy ) % M c = 3 . times . map { gets . split . map ( & : to _ i ) } x = [ ] ; y = [ ] x [ 0 ] = 0 3 . times { | i | y [ i ] = c [ 0 ] [ i ] - x [ 0 ] } 3 . times { | i | x [ i ] = c [ i ] [ 0 ] - y [ 0 ] } res = ' Yes ' ( 0 .. 2 ) . each do | i | ( 0 .. 2 ) . each do | j | res = ' No ' if x [ i ] + y [ j ] ! = c [ i ] [ j ] end end puts res N = gets . to _ i nums = gets . split . map ( & : to _ i ) min = Float : : INFINITY cnt = 0 nums . each do | pi | if pi < min min = pi cnt + = 1 end end p cnt k , s = gets . chomp . split ( " " ) . map ( & : to _ i ) cnt = 0 ( 0 .. k ) . each do | x | ( 0 .. k ) . each do | y | c = s - x - y if c > = 0 & & c < = k cnt + = 1 end end end puts cnt N = gets . to _ i Ps = gets . split . map ( & : to _ i ) ans = N min = Ps . first Ps . each do | pi | ans - = 1 if pi > min min = pi if pi < min end puts ans n = gets . to _ i K = ( 3 * n / 4 ) . ceil MAX = 3500 MAX . downto ( K ) do | c | K . downto ( 1 ) do | a | b _ bunbo = 4 * c * a - a * n - c * n b _ bunshi = n * c * a next if b _ bunbo < = 0 | | b _ bunshi % b _ bunbo ! = 0 b = b _ bunshi / b _ bunbo puts " exit end end k , s = STDIN . readline . strip . split ( ' ' ) . map ( & : to _ i ) sum = 0 ( 0 .. k ) . each do | a | rest _ a = s - a ( 0 .. k ) . each do | b | rest _ b = rest _ a - b next if rest _ b < 0 or rest _ b > k c = rest _ b sum + = 1 end end puts sum i = gets . split . map ( & : to _ i ) j = gets . split . map ( & : to _ i ) k = gets . split . map ( & : to _ i ) def checker ( i , j , k ) ( 0 .. 100 ) . each do | x | a1 = x b1 = i [ 0 ] - a1 b2 = i [ 1 ] - a1 b3 = i [ 2 ] - a1 a2 = j [ 0 ] - b1 a3 = k [ 0 ] - b1 if ( j [ 1 ] = = a2 + b2 & & j [ 2 ] = = a2 + b3 & & k [ 1 ] = = a3 + b2 & & k [ 2 ] = = a3 + b3 ) return true end end return false end puts checker ( i , j , k ) ? " Yes " : " No " def calc ( l ) return 0 if l < = 2 return calc ( ( l - 1 ) / 2 ) + 1 end x = gets . to _ i l = 2 h = 10000000000000 while l < h c = ( l + h + 1 ) / 2 y = calc ( c ) if y < = x l = c else h = c - 1 end end p l require " prime " N , P = gets . chomp . split ( ' ' ) . map ( & : to _ i ) ans = 1 Prime . prime _ division ( P ) . each do | a , n | t = n / N ans * = a * * t if t > 0 end puts ans a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i if ( e - a ) > k puts " : ( " else puts " Yay ! " end a = ARGF . to _ a . map ( & : to _ i ) print a [ 4 ] - a [ 0 ] < = a [ 5 ] ? " Yay ! " : " : ( " N = gets . to _ i S = gets . chomp . split if S . uniq . size = = 3 puts ' Three ' else puts ' Four ' end require ' set ' ; require ' prime ' INF = Float : : INFINITY n = gets . chomp . to _ i p = gets . chomp . split . map ( & : to _ i ) mini = INF ans = [ ] n . times do | i | if p [ i ] < = mini ans . push ( i + 1 ) mini = p [ i ] end end puts ans . count eval " T , U , A , X , B , Y = " + ` dd ` . split * ? , x = ( A - B ) * T y = x + ( X - Y ) * U puts y = = 0 ? : infinity : ( s = - x / y ; s < 0 ? 0 : s * 2 + ( x % y ! = 0 ? 1 : 0 ) ) require ' set ' while 1 n , m = gets . split . map ( & : to _ i ) break if n = = 0 & & m = = 0 g = { } ( 1 .. n ) . each { | i | g [ i ] = [ ] } m . times do i , j = gets . split . map ( & : to _ i ) g [ i ] < < j g [ j ] < < i end color = { 1 = > 0 } queue = [ 1 ] until queue . empty ? i = queue . shift c = color [ i ] g [ i ] . each do | j | if color [ j ] & & color [ j ] ! = 1 - c queue = [ ] color = nil break elsif ! color [ j ] color [ j ] = 1 - c queue < < j end end end ans = Set . new if color k = color . values . count ( 0 ) if k . even ? ans < < k / 2 end if ( n - k ) . even ? ans < < ( n - k ) / 2 end end p ans . size puts ans . sort end def C ( n , k ) k = n - k if n - k < k k . times . inject ( 1 ) { | s , i | s * ( n - i ) / ( i + 1 ) } end K , S = gets . split . map ( & : to _ i ) ans = ( 0 .. 3 ) . inject ( 0 ) do | t , i | sign = i . even ? ? 1 : - 1 n = S + 3 - ( K + 1 ) * i - 1 n > = 2 ? t + sign * C ( n , 2 ) * C ( 3 , i ) : t end puts ans puts gets . split . sort . join . to _ i = = 1479 ? : YES : : NO C = ( 0 ... 3 ) . map { gets . split . map ( & : to _ i ) } puts ( 0 ... 3 ) . all ? { | a | ( 0 ... 3 ) . map { | b | C [ b ] [ ( a + 1 ) % 3 ] - C [ b ] [ a ] } . uniq . size = = 1 & & ( 0 ... 3 ) . map { | b | C [ ( a + 1 ) % 3 ] [ b ] - C [ a ] [ b ] } . uniq . size = = 1 } ? " Yes " : " No " require ' prime ' n , pr = gets . chomp . split ( " " ) . map { | e | e . to _ i } a = pr . prime _ division def search ( a , n ) ans = 1 for x in a do i = x [ 1 ] / n ans * = ( x [ 0 ] * * i ) end return ans end puts search ( a , n ) antenna = [ ] count = 0 n = 0 5 . times do antenna < < gets . chomp . to _ i end dis = gets . chomp . to _ i antenna . each do | a | antenna . each do | b | if a - b > dis count + = 1 end end end if count > = 1 puts " : ( " else puts " Yay ! " end a = gets . chomp . to _ i nums = gets . chomp . split ( " " ) . map ( & : to _ i ) min = 200000 count = 0 ( 0 ... a ) . each do | i | if nums [ i ] < = min min = nums [ i ] count + = 1 end end puts count enter = [ ] upenter = [ ] ans = " Yay ! " for i in 0 .. 5 do enter [ i ] = gets . chomp . to _ i if i = = 1 upenter [ 0 ] = enter [ i ] - enter [ i - 1 ] elsif i = = 2 upenter [ 1 ] = enter [ i ] - enter [ i - 1 ] upenter [ 2 ] = enter [ i ] - enter [ i - 2 ] elsif i = = 3 upenter [ 3 ] = enter [ i ] - enter [ i - 1 ] upenter [ 4 ] = enter [ i ] - enter [ i - 2 ] upenter [ 5 ] = enter [ i ] - enter [ i - 3 ] elsif i = = 4 upenter [ 6 ] = enter [ i ] - enter [ i - 1 ] upenter [ 7 ] = enter [ i ] - enter [ i - 2 ] upenter [ 8 ] = enter [ i ] - enter [ i - 3 ] upenter [ 9 ] = enter [ i ] - enter [ i - 4 ] end end upenter . select do | x | if x > enter [ 5 ] ans = " : ( " break end end puts ans n = STDIN . gets . split . map ( & : to _ i ) . sort if n = = [ 1 , 4 , 7 , 9 ] puts ' YES ' else puts ' NO ' end gets puts gets . chomp . split . include ? ( ' Y ' ) ? ' Four ' : ' Three ' * A , K = readlines . map ( & : to _ i ) puts A . permutation ( 2 ) . to _ a . all ? { | a , b | b - a < = K } ? " Yay ! " : " : ( " n = gets . chomp . to _ i arr = gets . chomp . split ( " " ) . map ( & : to _ i ) sum = 0 min = 114514810 n . times do | i | if min > arr [ i ] then min = arr [ i ] sum + = 1 end end puts sum c = 3 . times . map { gets . split . map ( & : to _ i ) } if c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] ! = c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] | | c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] ! = c [ 2 ] [ 1 ] - c [ 2 ] [ 0 ] then puts ' No ' ; exit ; end if c [ 0 ] [ 2 ] - c [ 0 ] [ 0 ] ! = c [ 1 ] [ 2 ] - c [ 1 ] [ 0 ] | | c [ 0 ] [ 2 ] - c [ 0 ] [ 0 ] ! = c [ 2 ] [ 2 ] - c [ 2 ] [ 0 ] then puts ' No ' ; exit ; end puts ' Yes ' k , s = gets . split . map ( & : to _ i ) count = 0 l = [ ] 0 . upto ( k ) do | x | unless ( x * 3 > s or 2 * k < s - x ) x . upto ( k ) do | y | unless ( x + y * 2 > s or k < s - x - y ) l < < [ x , y , ( s - x - y ) ] . uniq end end end end l . each do | a | count + = ( 0 .. a . size ) . inject ( : + ) end puts count c = 3 . times . map { gets . split . map ( & : to _ i ) } heIsRight = false a = Array . new ( 3 ) b = Array . new ( 3 ) isOut = false a [ 0 ] = 0 ( 0 ... 3 ) . each do | i | b [ i ] = c [ 0 ] [ i ] - a [ 0 ] end a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] ( 0 ... 3 ) . each do | j | if c [ 1 ] [ j ] ! = a [ 1 ] + b [ j ] isOut = true end end a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] ( 0 ... 3 ) . each do | k | if c [ 2 ] [ k ] ! = a [ 2 ] + b [ k ] isOut = true end end if ! isOut puts ' Yes ' else puts ' No ' end def inp ( ) a = gets . to _ s . chomp . split ( " " ) . map { | u | u . to _ i } end def r _ up ( a , b ) ( a + b - 1 ) / b end def r _ sort ( a ) a . sort { | a , b | b < = > a } end bn = inp [ 0 ] ( 1 .. 3500 ) . each do | h | ( 1 .. 3500 ) . each do | n | si = bn * h * n bo = ( 4 * h * n - bn * h - bn * n ) next if ( si < = 0 ) next if ( bo < = 0 ) if ( si % bo = = 0 ) r = si / bo puts " exit end end end ary = Array . new ( 3 , Array . new ( 3 , nil ) ) ary [ 0 ] = gets . split ( ' ' ) . map ( & : to _ i ) . dup ary [ 1 ] = gets . split ( ' ' ) . map ( & : to _ i ) . dup ary [ 2 ] = gets . split ( ' ' ) . map ( & : to _ i ) . dup i = 0 [ * 0 .. 1 ] . each { | j | a = ary [ i ] [ j ] - ary [ i ] [ j + 1 ] if ( ary [ i + 1 ] [ j ] - ary [ i + 1 ] [ j + 1 ] ) ! = a or ( ary [ i + 2 ] [ j ] - ary [ i + 2 ] [ j + 1 ] ) ! = a then puts ' No ' exit end a = ary [ j ] [ i ] - ary [ j + 1 ] [ i ] if ( ary [ j ] [ i + 1 ] - ary [ j + 1 ] [ i + 1 ] ) ! = a or ( ary [ j ] [ i + 2 ] - ary [ j + 1 ] [ i + 2 ] ) ! = a then puts ' No ' exit end } puts ' Yes ' n = gets . to _ i nums = gets . split . map ( & : to _ i ) min = nums [ 0 ] count = 0 n . times do | i | if min > = nums [ i ] count + = 1 min = nums [ i ] end end puts count DBG = true n = gets . to _ i a = gets . split . map { | x | x . to _ i } b = gets . split . map { | x | x . to _ i } sa = a . inject ( : + ) sb = b . inject ( : + ) if sa < sb print - 1 exit end fusoku = 0 nfusoku = 0 amari = [ ] for i in 0 ... n dif = b [ i ] - a [ i ] if dif > 0 fusoku + = dif nfusoku + = 1 elsif dif < 0 amari < < - dif end end if nfusoku = = 0 print 0 exit end amari . sort _ by ! { | x | - x } namari = 0 sum = 0 for i in 0 ... amari . size sum + = amari [ i ] namari + = 1 if sum > = fusoku print namari + nfusoku exit end end INF = 1 < < 29 def contain ( names ) contained = [ ] names . permutation ( 2 ) . each do | s , t | contained < < t if s . include ? ( t ) end contained . each { | name | names . delete ( name ) } names end def overlap ( names , size ) mapping = size . times . map { [ 0 ] * size } ( 0 ... size ) . to _ a . permutation ( 2 ) . each do | i , j | k = [ @ len [ i ] , @ len [ j ] ] . min loop do if names [ i ] [ @ len [ i ] - k .. - 1 ] = = names [ j ] [ 0 , k ] mapping [ i ] [ j ] = k break end k - = 1 end end mapping end while n = gets . to _ i break if n = = 0 s = n . times . map { gets . chomp } s = contain ( s ) m = s . size @ len = s . map { | name | name . size } dp _ table = overlap ( s , m ) dp _ cache = ( 1 < < m ) . times . map { [ INF ] * m } m . times { | i | dp _ cache [ 1 < < i ] [ i ] = @ len [ i ] } ( 1 < < m ) . times do | bits | m . times do | i | next if dp _ cache [ bits ] [ i ] = = INF pre = dp _ cache [ bits ] [ i ] m . times do | j | next if i = = j | | ( bits | ( 1 < < j ) ) = = bits if dp _ cache [ bits | ( 1 < < j ) ] [ j ] > pre + @ len [ j ] - dp _ table [ i ] [ j ] dp _ cache [ bits | ( 1 < < j ) ] [ j ] = pre + @ len [ j ] - dp _ table [ i ] [ j ] end end end end p dp _ cache [ ( 1 < < m ) - 1 ] . min end N = gets . chomp P = gets . split . map ( & : to _ i ) count = 0 min = P [ 0 ] 0 . upto ( P . size - 1 ) do | i | if P [ i ] < = min min = P [ i ] count + = 1 end end puts count a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i if b - a < = k & & c - a < = k & & d - a < = k & & e - a < = k & & c - b < = k & & d - b < = k & & e - b < = k & & d - c < = k & & e - c < = k & & e - d < = k puts " Yay ! " else puts " : ( " end ary = [ ] 3 . times do ary < < gets . chomp . split . map ( & : to _ i ) end a = [ 0 , 0 , 0 ] b = [ 0 , 0 , 0 ] flag = nil ( ary [ 0 ] . min + 1 ) . times do | n | a [ 0 ] = n b [ 0 ] = ary [ 0 ] [ 0 ] - a [ 0 ] b [ 1 ] = ary [ 0 ] [ 1 ] - a [ 0 ] b [ 2 ] = ary [ 0 ] [ 2 ] - a [ 0 ] a [ 1 ] = ary [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = ary [ 2 ] [ 0 ] - b [ 0 ] isCorrect = 0 3 . times do | na | 3 . times do | nb | if ary [ na ] [ nb ] ! = a [ na ] + b [ nb ] then isCorrect = nil end end end if isCorrect then flag = 0 end end print " puts gets . split . sort . join . to _ i = = 1479 ? : YES : : NO $ / = ' ' ; k , s = $ < . map & : to _ i ; k + = 1 ; p ( 0 ... k * k ) . count { | i | z = s - i % k - i / k ; 0 < = z & & z < k } n = gets . split . map ( & : to _ i ) data = gets . split ( ' ' ) . map ( & : to _ i ) c = 0 ; min = nil ; data . each _ with _ index { | v , i | if min = = nil | | min > v then min = v end if min > = v then c + = 1 end } p c d = gets . chomp . split . map ( & : to _ i ) if d . include ? ( 1 ) & & d . include ? ( 9 ) & & d . include ? ( 7 ) & & d . include ? ( 4 ) puts ' YES ' else puts ' NO ' end a = [ ] a < < gets . chomp . to _ i a < < gets . chomp . to _ i a < < gets . chomp . to _ i a < < gets . chomp . to _ i a < < gets . chomp . to _ i k = gets . chomp . to _ i flag = 0 j = 1 5 . times do | i | for jj in j .. 4 do if ( ( a [ jj ] - a [ i ] ) . abs > k ) then flag = 1 break end end j + = 1 if flag = = 1 then break end end if flag = = 1 then puts " : ( " else puts " Yay ! " end t = 1 ; gets . split . zip ( $ < ) { | m , x | i = s = 0 ; x . split . map { | k | s + = k . to _ i . * ~ m . to _ i + i + = 2 } ; t * = s } ; p t . % 10 * * 9 + 7 require " prime " n , p = gets . split . map & : to _ i ary = Prime . prime _ division ( p ) ans = 1 ary . each do | c | if c [ 1 ] > = n ( c [ 1 ] / n ) . times { ans * = c [ 0 ] } end end puts ans n = gets . to _ i s = gets . split ( " " ) . map ! { | o | o . to _ s } frag = " Three " 0 . upto ( n - 1 ) do | i | if s [ i ] = = " Y " frag = " Four " end end puts frag n = gets . chomp . split ( " " ) . map { | a | a . to _ i } answer = " NO " if n . include ? ( 1 ) if n . include ? ( 7 ) if n . include ? ( 9 ) if n . include ? ( 4 ) answer = " YES " end end end end puts answer require " prime " N , P = gets . split . map & : to _ i gcd = 1 tmp = Math . sqrt ( P ) . to _ i if N > = 2 if N < P Prime . each ( tmp ) do | p | _ p = P cnt = 0 while _ p % p = = 0 _ p / = p cnt + = 1 end gcd * = p * * ( cnt / N ) if cnt > 0 end end puts gcd else puts P end c = 3 . times . map { gets . split . map ( & : to _ i ) } heIsRight = false a = Array . new ( 3 ) b = Array . new ( 3 ) ( 0 .. 100 ) . each do | n | isOut = false a [ 0 ] = n ( 0 ... 3 ) . each do | i | b [ i ] = c [ 0 ] [ i ] - a [ 0 ] end a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] ( 0 ... 3 ) . each do | j | if c [ 1 ] [ j ] ! = a [ 1 ] + b [ j ] isOut = true break end end next if isOut a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] ( 0 ... 3 ) . each do | k | if c [ 2 ] [ k ] ! = a [ 2 ] + b [ k ] isOut = true break end end unless isOut heIsRight = true break end end if heIsRight puts ' Yes ' else puts ' No ' end a , k = Array . new ( 5 ) { gets . to _ i } , gets . to _ i puts a . combination ( 2 ) . any ? { | x , y | k < ( x - y ) . abs } ? ' : ( ' : ' Yay ! ' n = gets . to _ i a = gets . chomp . split ( " " ) . map ( & : to _ i ) b = gets . chomp . split ( " " ) . map ( & : to _ i ) diff = a . map . with _ index { | x , i | x - b [ i ] } . sort minus = diff . select { | x | x < 0 } plus = diff . select { | x | x > = 0 } sum = minus . inject ( & : + ) sum _ p = plus . inject ( & : + ) if sum . nil ? puts " 0 " exit end if sum _ p . nil ? puts " -1 " exit end if sum + sum _ p < 0 puts " -1 " exit end i = 0 while sum < 0 i + = 1 sum + = diff [ - i ] end puts minus . size + i N = gets . chomp . to _ i strs = gets . chomp . split ( ' ' ) . map ( & : to _ i ) ans = 0 mini = strs [ 0 ] strs . each _ with _ index do | str , i | if str < = mini ans + = 1 mini = str end end puts ans K , S = gets . chomp . split . map ( & : to _ i ) ans = 0 ( K + 1 ) . times do | i | ( K + 1 ) . times do | j | z = S - i - j if z < = K & & 0 < = z ans + = 1 end end end puts ans ns = gets . split . map ( & : to _ i ) . sort . join puts ns = = ' 1479 ' ? ' YES ' : ' NO ' ( ( N , X ) , A ) = $ stdin . read . lines . map ( & : chomp ) . map { | l | l . split ( " " ) . map ( & : to _ i ) } b = Array . new ( N ) { Array . new ( N ) } class Array def sum self . inject ( : + ) end end N . times do | i | s = nil N . times do | k | s = A [ i - k ] if s . nil ? | | s > A [ i - k ] b [ k ] [ i ] = s end end a = nil N . times do | k | al = b [ k ] . sum + k * X a = al if a . nil ? or a > al end puts a n = gets . to _ i a = n . times . map { gets . to _ i } sum = 0 maxa = 0 n . times do | i | if i . zero ? sum = a [ 0 ] . pred a [ 0 ] = 1 else if a [ i ] < = maxa . succ else t = a [ i ] / maxa . succ f = a [ i ] % maxa . succ if f . zero ? a [ i ] = 1 sum + = t . pred else a [ i ] = f sum + = t end end end maxa = [ a [ i ] , maxa ] . max end p sum def get _ i ( ) return gets . chomp . split ( " " ) . map ( & : to _ i ) end def get _ f ( ) return gets . chomp . split ( " " ) . map ( & : to _ f ) end def get ( ) return gets . chomp . split ( " " ) end def get _ nsp ( ) return gets . chomp . split ( " " ) end def yn _ judge ( bool , y = " Yes " , n = " No " ) return bool ? y : n end def array ( size , n = 1 , init = nil ) if n = = 1 return Array . new ( size ) { init } else return Array . new ( n ) . map { Array . new ( size ) { init } } end end k , s = get _ i ans = 0 ( k + 1 ) . times do | x | ( k + 1 ) . times do | y | if s > = x + y and s - x - y < = k ans + = 1 end end end puts ans def solution k , s = gets . split ( ' ' ) . map ( & : to _ i ) answer = 0 ( 0 .. k ) . each do | x | ( 0 .. k ) . each do | y | z = s - x - y answer + = 1 if ( 0 .. k ) . include ? ( z ) end end answer end puts solution N , P = gets . split . map & : to _ i ; require ' prime ' ; p Prime . prime _ division ( P ) . inject ( 1 ) { | s , x | ( x [ 1 ] < N ) ? s : s * x [ 0 ] * * ( x [ 1 ] / N ) } antennas = [ ] 5 . times do | i | antennas . push ( gets . to _ i ) end K = gets . to _ i if antennas [ 4 ] - antennas [ 0 ] > K puts " : ( " else puts " Yay ! " end N = eval * $ < ; ( t = 1 .. 4e3 ) . any ? { | i | t . any ? { | j | n = 4 * i * j - N * i - d = N * j ; n > 0 & & d % n < 1 & & $ > < < [ i , j , d * i / n ] * ? \ s } } n = gets . to _ i ar = gets . chomp . split if ar . uniq . count = = 3 puts " Three " else puts " Four " end n = gets . to _ i max = 1 maxCnt = 0 ( 1 .. n ) . each do | val | tmpCnt = 0 if val . odd ? next else calcVal = val while calcVal . even ? calcVal / = 2 tmpCnt + = 1 end end if tmpCnt > maxCnt maxCnt = tmpCnt max = val end end puts max a = $ stdin . gets . chomp . to _ i b = $ stdin . gets . chomp . to _ i c = $ stdin . gets . chomp . to _ i d = $ stdin . gets . chomp . to _ i e = $ stdin . gets . chomp . to _ i k = $ stdin . gets . chomp . to _ i cond = ( e - a < = k ) if cond puts " Yay ! " else puts " : ( " end N = gets . to _ i Ss = gets . chomp . split if Ss . uniq . length = = 3 then puts ( " Three " ) elsif Ss . uniq . length = = 4 then puts ( " Four " ) end a = [ ] 3 . times do a < < gets . split . map ( & : to _ i ) end m = Array . new ( 2 ) { Array . new ( 3 , 0 ) } mm = Array . new ( 2 ) { Array . new ( 3 , 0 ) } 2 . times do | i | 3 . times do | j | m [ i ] [ j ] = a [ j ] [ i + 1 ] - a [ j ] [ i + 1 ] mm [ i ] [ j ] = a [ i ] [ j ] - a [ i + 1 ] [ j ] end end 2 . times do | i | if ( 1 < m [ i ] . uniq . size or 1 < mm [ i ] . uniq . size ) puts " No " exit end end puts " Yes " K , S = gets . split . map ( & : to _ i ) a , b = if S < = K [ 0 , S ] elsif S < = 2 * K [ 0 , K ] else [ S - 2 * K , K ] end ans = ( a .. b ) . reduce ( 0 ) do | x , i | t = S - i x + ( t < = K ? t + 1 : 2 * K - t + 1 ) end puts ans a = 5 . times . map { gets . strip . to _ i } n = gets . strip . to _ i puts ( a [ 4 ] - a [ 0 ] ) < = n ? ' Yay ! ' : ' : ( ' cs = [ ] 3 . times do cs < < gets . split . map ( & : to _ i ) end w _ div = [ ] h _ div = [ ] for i in 0 .. 2 do w _ div < < [ cs [ i ] [ 0 ] - cs [ i ] [ 1 ] , cs [ i ] [ 1 ] - cs [ i ] [ 2 ] ] h _ div < < [ cs [ 0 ] [ i ] - cs [ 1 ] [ i ] , cs [ 1 ] [ i ] - cs [ 2 ] [ i ] ] end ans = ' Yes ' for i in 0 .. 1 do if w _ div [ i ] ! = w _ div [ i + 1 ] | | h _ div [ i ] ! = h _ div [ i + 1 ] ans = ' No ' end end puts ans input = STDIN . read . chomp . split ( " " ) . map { | a | a . to _ i } puts ( input . include ? ( 1 ) & & input . include ? ( 7 ) & & input . include ? ( 9 ) & & input . include ? ( 4 ) ) ? " YES " : " NO " gets a = gets . chomp . split ( " " ) puts a . include ? ( ' Y ' ) ? " Four " : " Three " n = gets . chomp . to _ i a = [ 1 , 2 , 4 , 8 , 16 , 32 , 64 , 999 ] for i in 0 .. 7 do if ( n < a [ i ] ) puts a [ i - 1 ] exit end end n = gets . split . map ( & : to _ i ) for i in 0 .. 3 if n [ i ] = = 1 break end if i = = 3 puts " NO " exit end end for i in 0 .. 3 if n [ i ] = = 9 break end if i = = 3 puts " NO " exit end end for i in 0 .. 3 if n [ i ] = = 7 break end if i = = 3 puts " NO " exit end end for i in 0 .. 3 if n [ i ] = = 4 break end if i = = 3 puts " NO " exit end end puts " YES " a = 5 . times . map { gets . to _ i } k = gets . to _ i puts a . max - a . min > k ? ' : ( ' : ' Yay ! ' n = gets . split . map ( & : to _ i ) . sort puts n = = [ 1 , 4 , 7 , 9 ] ? " YES " : " NO " n = gets . to _ i p = gets . split ( ) . map ( & : to _ i ) num = 1000000 ans = 0 p . each do | i | num = [ num , i ] . min next if i ! = num ans + = 1 end puts ans n = gets . to _ i a = gets . chomp . split if a . include ? ' Y ' puts " Four " else puts " Three " end N = gets . to _ i max _ num = 0 res = 1 [ * 1 .. N ] . each do | n | num = 0 x = n loop do break if x % 2 ! = 0 num + = 1 x / = 2 end if max _ num < num then max _ num = num res = n end end puts res k , s = gets . split . map & : to _ i h = { } ( k + 1 ) . times do | i | h [ i ] = 1 end hh = Array . new ( k * * 2 + 1 , 0 ) ( k + 1 ) . times do | i | h . each do | e | hh [ e [ 0 ] + i ] + = e [ 1 ] end end if 3 * k > = s g = s - k g = 0 if g < 0 p hh [ g .. [ k * 2 , s ] . min ] . inject ( 0 ) { | s , i | s + i } else p 0 end require ' set ' class Hash def push ( key , value ) self [ key ] = [ ] if self [ key ] = = nil self [ key ] . push ( value ) end end class Array def lower _ bound ( value ) left = - 1 ; right = self . length ; while left + 1 < right mid = left + ( right - left ) / 2 ; if self [ mid ] > = value right = mid else left = mid end end right end def unique res = [ self . first ] each _ cons ( 2 ) do | a , b | if a ! = b res . push ( b ) end end res end end def get _ ints gets . chomp . split . map ( & : to _ i ) end def get _ ints _ minus _ one get _ ints . map { | x | x - 1 } end def get _ int gets . chomp . to _ i end N = get _ int S = gets . chomp . split if S . to _ set . length = = 4 puts ' Four ' else puts ' Three ' end ns = gets . split . map ( & : to _ i ) if ns . sort = = [ 1 , 4 , 7 , 9 ] puts ' YES ' else puts ' NO ' end gets puts gets . split . uniq . size = = 4 ? : Four : : Three eval " K , S = " + gets . split * ? , ; p ( 0 .. K ) . map { | i | [ 0 , [ 2 * K - S + i , S - i ] . min + 1 ] . max } . inject ( : + ) a = [ ] a . push gets . to _ i a . push gets . to _ i a . push gets . to _ i a . push gets . to _ i a . push gets . to _ i k = gets . to _ i catch : break do for i in 0 ... a . size for j in ( i + 1 ) ... a . size unless a [ j ] - a [ i ] < = k puts ' : ( ' throw : break end end end puts ' Yay ! ' end line = gets line . chomp ! a = line . to _ i line = gets line . chomp ! b = line . to _ i line = gets line . chomp ! c = line . to _ i line = gets line . chomp ! d = line . to _ i line = gets line . chomp ! e = line . to _ i line = gets line . chomp ! k = line . to _ i if ( e - a < = k ) print " Yay ! " else print " : ( " end N = eval * $ < ( t = 1 .. 4e3 ) . any ? { | i | t . any ? { | j | n = 4 * i * j - N * i - d = N * j d * = i n > 0 & & d % n < 1 & & $ > < < [ i , j , d / n ] * ? \ s } } n = gets . to _ i hina = gets . split ( " " ) . uniq if hina . size = = 3 puts " Three " else puts " Four " end a = gets . split . map ( & : to _ i ) s = " % d + % d % d + % d % d % d = = % d % d % d " nums = ( 1 .. 9 ) . to _ a - a . select { | x | x ! = - 1 } if nums . empty ? p eval ( sprintf ( s , * a ) ) ? 1 : 0 else k = 0 nums . permutation ( nums . size ) do | perm | d = a . dup perm . each do | k | d [ d . index { | x | x < 0 } ] = k end k + = 1 if eval ( sprintf ( s , * d ) ) end p k end N , * P = $ < . read . split . map & : to _ i m = P [ 0 ] p P . count { | i | m = i if i < = m } input = STDIN . read . split ( " \ n " ) . map { | l | l . split ( " " ) . map { | a | a . to _ i } } N = input [ 0 ] [ 0 ] A = input [ 1 ] B = input [ 2 ] short _ cnt = 0 short _ score = 0 reserves = [ ] for i in 0 .. ( A . length - 1 ) a = A [ i ] b = B [ i ] if a = = b next end if a < b short _ cnt = short _ cnt + 1 short _ score = short _ score + ( b - a ) else reserves . push ( a - b ) end end reserves = reserves . sort . reverse changed _ cnt = 0 if short _ cnt > 0 for i in 0 .. ( reserves . length - 1 ) short _ score = short _ score - reserves [ i ] changed _ cnt = changed _ cnt + 1 if short _ score < = 0 break end end end if short _ score > 0 puts - 1 else puts ( changed _ cnt + short _ cnt ) end k , s = gets . split . map ( & : to _ i ) count = 0 ( 0 .. k ) . each do | x | ( 0 .. k ) . each do | y | z = s - x - y count + = 1 if ( 0 .. k ) . include ? ( z ) end end puts count n = gets . to _ i 1 . upto ( 3500 ) do | i | 1 . upto ( 3500 ) do | j | a = n * i * j b = 4 * i * j - n * i - n * j if b > 0 & & a % b = = 0 puts [ i , j , a / b ] . join ( ' ' ) exit end end end def get _ i ( ) return gets . chomp . split ( " " ) . map ( & : to _ i ) end def get _ f ( ) return gets . chomp . split ( " " ) . map ( & : to _ f ) end def get ( ) return gets . chomp . split ( " " ) end def get _ nsp ( ) return gets . chomp . split ( " " ) end def yn _ judge ( bool , y = " Yes " , n = " No " ) return bool ? y : n end def array ( size1 , init = nil , size2 = 1 ) if size2 = = 1 return Array . new ( size1 ) { init } else return Array . new ( size2 ) { Array . new ( size1 ) { init } } end end c = array ( 3 ) 3 . times do | i | c [ i ] = get _ i end flag = true - 100 . upto ( 100 ) do | a | b = [ c [ 0 ] [ 0 ] - a , c [ 0 ] [ 1 ] - a , c [ 0 ] [ 2 ] - a ] flag = true 1 . upto ( 2 ) do | i | unless c [ i ] [ 0 ] - b [ 0 ] = = c [ i ] [ 1 ] - b [ 1 ] and c [ i ] [ 1 ] - b [ 1 ] = = c [ i ] [ 2 ] - b [ 2 ] flag = false end end end puts yn _ judge ( flag ) ns = gets . split . map ( & : to _ i ) if ns . include ? ( 1 ) & & ns . include ? ( 9 ) & & ns . include ? ( 7 ) & & ns . include ? ( 4 ) puts ' YES ' else puts ' NO ' end n = gets . to _ i pp = gets . split . map ( & : to _ i ) hoge = [ ] min = Float : : INFINITY pp . each do | num | min = [ min , num ] . min hoge < < min end res = 0 n . times do | i | if hoge [ i ] > = pp [ i ] res + = 1 end end p res ary = [ ] 3 . times do | i | ary < < gets . split . map ( & : to _ i ) end for a0 in 0 .. 100 b0 = ary [ 0 ] [ 0 ] - a0 b1 = ary [ 0 ] [ 1 ] - a0 b2 = ary [ 0 ] [ 2 ] - a0 if b0 < 0 | | b1 < 0 | | b2 < 0 then next end a1 = ary [ 1 ] [ 0 ] - b0 a2 = ary [ 2 ] [ 0 ] - b0 if a1 < 0 | | a2 < 0 then next end if ary [ 1 ] [ 1 ] ! = a1 + b1 then next end if ary [ 1 ] [ 2 ] ! = a1 + b2 then next end if ary [ 2 ] [ 1 ] ! = a2 + b1 then next end if ary [ 2 ] [ 2 ] ! = a2 + b2 then next end puts : Yes exit end puts : No N = gets . to _ i ary = gets . split ( " " ) . map ( & : to _ i ) ary _ min = ary . min min = 2000000 count = 0 ary . each do | i | if min > i count + = 1 min = i end break if i = = ary _ min end puts count c = [ ] 3 . times { c < < gets . split . map ( & : to _ i ) } ( 0 .. 100 ) . any ? do | a1 | a = [ ] b = [ ] 3 . times do | n | b [ n ] = c [ 0 ] [ n ] - a1 end a [ 1 ] = c [ 1 ] [ 0 ] - b [ 0 ] a [ 2 ] = c [ 2 ] [ 0 ] - b [ 0 ] [ 1 , 2 ] . all ? { | i | [ 1 , 2 ] . all ? { | j | c [ i ] [ j ] = = a [ i ] + b [ j ] } } end . tap { | ans | puts ans ? ' Yes ' : ' No ' } require ' prime ' n , x = gets . split . map ( & : to _ i ) puts x . prime _ division . map { | p , e | p * * ( e / n ) } . reduce ( 1 , : * ) c = 3 . times . map { gets . chomp . split ( " " ) . map ( & : to _ i ) } if c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] & & c [ 0 ] [ 2 ] - c [ 0 ] [ 0 ] = = c [ 1 ] [ 2 ] - c [ 1 ] [ 0 ] & & c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] = = c [ 2 ] [ 1 ] - c [ 2 ] [ 0 ] & & c [ 0 ] [ 2 ] - c [ 0 ] [ 0 ] = = c [ 2 ] [ 2 ] - c [ 2 ] [ 0 ] puts " Yes " else puts " No " end require ' prime ' N , P = readline . chomp . split . map ( & : to _ i ) common = 1 P . prime _ division . each do | pi , ei | while ei > = N common * = pi ei - = N end end puts common ks = gets . strip k , s = ks . split ( ' ' ) . map ( & : to _ i ) count = 0 Array ( 0 .. k ) . repeated _ permutation ( 2 ) { | x , y | z = s - x - y count + = 1 if ( 0 .. k ) . include ? ( z ) } puts count input = gets . chomp . split ( ' ' ) k = input [ 0 ] . to _ i s = input [ 1 ] . to _ i x = k + 1 y = k + 1 count = 0 x . times do | x _ a | y . times do | y _ a | z = s - x _ a - y _ a if 0 < = z & & z < = k count + = 1 end end end p count B = 3 . times . map { gets . split . map ( & : to _ i ) } h = [ B [ 0 ] [ 0 ] - B [ 0 ] [ 1 ] , B [ 0 ] [ 1 ] - B [ 0 ] [ 2 ] ] v = [ B [ 0 ] [ 0 ] - B [ 1 ] [ 0 ] , B [ 1 ] [ 0 ] - B [ 2 ] [ 0 ] ] r = ( 1 .. 2 ) . all ? do | i | [ B [ i ] [ 0 ] - B [ i ] [ 1 ] , B [ i ] [ 1 ] - B [ i ] [ 2 ] ] = = h & & [ B [ 0 ] [ i ] - B [ 1 ] [ i ] , B [ 1 ] [ i ] - B [ 2 ] [ i ] ] = = v end puts r ? ' Yes ' : ' No ' n = gets . to _ i ps = gets . split . map ( & : to _ i ) ans = 0 min = n + 1000 ps . each do | p | if p < min min = p ans + = 1 end end puts ans a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i puts e - a > k ? " : ( " : " Yay ! " antennas = [ ] 5 . times do | i | antennas < < gets . chop . to _ i end k = gets . chop . to _ i if antennas [ 4 ] - antennas [ 0 ] > k puts " : ( " else puts " Yay ! " end k , s = gets . strip . split . map ( & : to _ i ) count = 0 ( 0 .. k ) . each do | x | ( 0 .. k ) . each do | y | z = s - x - y count + = z > = 0 & & z < = k ? 1 : 0 end end puts count ant = [ ] while a = gets do ant . push ( a ) end k = ant . last . to _ i ant . delete _ at ( ant . length - 1 ) connect = " Yay ! " last = ant [ 0 ] . to _ i ant . each do | a | distance = a . to _ i - last . to _ i if distance . to _ i > k connect = " : ( " end end puts connect require ' pp ' n = gets . to _ i d = gets . split . map ( & : to _ i ) cnt = 0 min = d . max + 1 d . each do | dd | if dd < = min min = dd cnt + = 1 else end end p cnt n = gets . chomp s = gets . chomp . split if s . include ? ( ' Y ' ) puts ' Four ' else puts ' Three ' end N = gets . chomp . to _ i P = gets . chomp . split ( " " ) . map ( & : to _ i ) min = ( 2 * 10 * * 5 ) + 1 count = 0 P . each { | i | if i < min count + = 1 min = i end } puts count arr = [ ] 3 . times { arr < < gets . split . map ( & : to _ i ) } a = arr [ 0 ] [ 0 ] b = arr [ 0 ] [ 1 ] c = arr [ 0 ] [ 2 ] d = arr [ 1 ] [ 0 ] e = arr [ 1 ] [ 1 ] f = arr [ 1 ] [ 2 ] g = arr [ 2 ] [ 0 ] h = arr [ 2 ] [ 1 ] i = arr [ 2 ] [ 2 ] if d - a = = e - b & & e - b = = f - c & & g - d = = h - e & & h - e = = i - f & & b - a = = e - d & & e - d = = h - g & & c - b = = f - e & & f - e = = i - h puts " Yes " else puts " No " end a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i if ( b - a < = k ) & & ( c - a < = k ) & & ( d - a < = k ) & & ( e - a < = k ) & & ( c - b < = k ) & & ( d - b < = k ) & & ( e - b < = k ) & & ( d - c < = k ) & & ( e - c < = k ) & & ( e - d < = k ) puts " Yay ! " else puts " : ( " end n = gets . chomp . to _ i s = gets . chomp . split ( " " ) s . each do | item | if item = = " Y " then puts " Four " exit end end puts " Three " n = gets . to _ i arr = [ ] min = 1000000 count = 0 arr = gets . chomp . split ( " " ) . map ( & : to _ i ) arr . each do | x | if min > x min = x count = count + 1 end end print ( " n = gets . chomp . to _ i pn = gets . chomp . split ( " " ) . map ( & : to _ i ) num = 0 minimum = n for i in 0 .. n - 1 do num + = 1 if pn [ i ] < = minimum minimum = pn [ i ] if pn [ i ] < minimum break if minimum = = 1 end print num antennas = [ ] 5 . times do antennas < < gets . chomp . to _ i end k = gets . chomp . to _ i min = antennas . min def determine ( antennas , min , k ) return ' Yay ! ' if antennas . empty ? max = antennas . delete ( antennas . max ) return ' : ( ' if max - min > k determine ( antennas , min , k ) end puts determine ( antennas , min , k ) c = ( 1 .. 3 ) . map { gets . split . map & : to _ i } b0 , b1 , b2 = ( 0 .. 2 ) . map { | i | c [ 0 ] [ i ] } puts ( 1 .. 2 ) . any ? { | i | x , y , z = b0 - c [ i ] [ 0 ] , b1 - c [ i ] [ 1 ] , b2 - c [ i ] [ 2 ] x ! = y | | y ! = z | | z ! = x } ? : No : : Yes k , s = gets . split . map ( & : to _ i ) cnt = 0 ( 0 .. k ) . each do | x | ( 0 .. k ) . each do | y | z = s - x - y cnt + = 1 if z > = 0 & & z < = k & & x + y + z = = s end end p cnt n = gets . to _ i a = gets . split . map ( & : to _ i ) min = 10 * * 6 cnt = 0 a . each { | x | if x < min min = x cnt + = 1 end } p cnt k , s = gets . chomp . split ( " " ) . map ( & : to _ i ) count = 0 ( 0 .. k ) . each do | i | ( 0 .. k ) . each do | e | z = s - i - e if z > = 0 & & i + e + z = = s & & z < = k count + = 1 end end end puts count def cin ; gets . split . map ( & : to _ i ) end def cout ( * x ) ; puts x . join ( " " ) end a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i if e - a < = k then puts ' Yay ! ' exit end puts ' : ( ' a , b , c , d , e , k = readlines . map ( & : to _ i ) ps = [ a , b , c , d , e ] if ps . max - ps . min < = k puts ' Yay ! ' else puts ' : ( ' end n = gets . chomp . to _ i break _ count _ top = 0 break _ count _ top _ num = 1 ( 1 .. n ) . each do | num | break _ count = 0 num _ sandbox = num loop do if num _ sandbox % 2 = = 0 break _ count + = 1 num _ sandbox / = 2 else break end end if break _ count > break _ count _ top break _ count _ top = break _ count break _ count _ top _ num = num end end puts break _ count _ top _ num a = $ stdin . readline . to _ i $ stdin . readline $ stdin . readline $ stdin . readline e = $ stdin . readline . to _ i k = $ stdin . readline . to _ i if e - a < = k then print " Yay ! " else print " : ( " end K , S = gets . split . map ( & : to _ i ) sum = 0 for x in 0 .. K for y in 0 .. K z = S - x - y if 0 < = z & & z < = K then sum = sum + 1 end end end puts sum n = gets . to _ i puts gets . split . uniq . size = = 3 ? " Three " : " Four " x = ` dd ` . split . map & : to _ i puts ( x [ 4 ] - x [ 0 ] ) . abs > x [ 5 ] ? " : ( " : : Yay ! N = gets . to _ i P = gets . split . map ( & : to _ i ) min = Float : : INFINITY count = 0 N . times do | i | unless P [ i ] > min count + = 1 min = P [ i ] end end puts count n = gets . split ( " " ) . map ( & : to _ i ) puts n . sort . join = = ' 1479 ' ? ' YES ' : ' NO ' ae = [ ] 5 . times { | i | ae < < gets . to _ i } k = gets . to _ i ae . each do | i | ae . each do | j | if ( i - j ) . abs > k puts ' : ( ' exit 0 end end end puts ' Yay ! ' gets arare = gets . split puts arare . include ? ( ' Y ' ) ? ' Four ' : ' Three ' a = gets . chomp . to _ i b = gets . chomp . to _ i c = gets . chomp . to _ i d = gets . chomp . to _ i e = gets . chomp . to _ i k = gets . chomp . to _ i diffs = [ e - d , e - c , e - b , e - a , d - c , d - b , d - a , c - b , c - a , b - a ] if diffs . all ? { | x | x < = k } puts ' Yay ! ' else puts ' : ( ' end c = [ nil ] * 3 3 . times { | i | c [ i ] = gets . chomp . split ( ' ' ) . map ( & : to _ i ) } d = [ 0 ] * 3 d [ 0 ] = c [ 0 ] [ 0 ] + c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] d [ 1 ] = c [ 0 ] [ 1 ] + c [ 1 ] [ 2 ] + c [ 2 ] [ 0 ] d [ 2 ] = c [ 0 ] [ 2 ] + c [ 1 ] [ 0 ] + c [ 2 ] [ 1 ] puts ( ( ( d [ 0 ] = = d [ 1 ] ) and ( d [ 1 ] = = d [ 2 ] ) ) ? ' Yes ' : ' No ' ) k , s = gets . split . map ( & : to _ i ) a = 0 ( k + 1 ) . times { | i | ( k + 1 ) . times { | j | a + = 1 if s - i - j > = 0 & & s - i - j < = k } } p a n = gets . to _ i pp = gets . split . map ( & : to _ i ) ans = 0 min = n + 1 n . times do | i | if min > pp [ i ] ans + = 1 min = pp [ i ] end end puts ans def inpf ( ) a = gets . chomp . split ( " " ) . map ( & : to _ f ) end def inps ( ) a = gets . chomp . split ( " " ) end def copy ( a ) Marshal . load ( Marshal . dump ( a ) ) end def kaijo ( n , r = 10 * * 9 + 7 ) ( n < 2 ) ? 1 : ( 2 .. n ) . inject { | memo , u | memo = ( memo * u ) % r } end def na ( n , d = 0 ) Array . new ( n , d ) end def na2 ( n , m , d = 0 ) Array . new ( n ) { Array . new ( m , d ) } end def na3 ( n , m , l , d = 0 ) Array . new ( n ) { Array . new ( m ) { Array . new ( l , d ) } } end def inp ( ) a = gets . chomp . split ( " " ) . map ( & : to _ i ) end def r _ up ( a , b ) ( a + b - 1 ) / b end def sum ( a ) a . inject ( : + ) end n = inp [ 0 ] s = inps h = { } ans = 0 s . each do | c | if ( h [ c ] = = nil ) h [ c ] = true ans + = 1 end end puts ( ans < 4 ) ? " Three " : " Four " def saiki ( sumn , count ) if ( count = = 3 ) if ( ( ( $ s - sumn ) < = $ k ) and ( ( $ s - sumn ) > = 0 ) ) $ ans + = 1 end return end ( 0 .. $ k ) . each do | d | sum = sumn + d saiki ( sum , ( count + 1 ) ) end end $ k , $ s = gets . chomp . split ( " " ) . map ( & : to _ i ) $ ans = 0 saiki ( 0 , 1 ) puts $ ans ary = [ ] 6 . times do ary < < gets . to _ i end num = ary [ 0 .. 4 ] if num . max - num . min > ary [ 5 ] puts " : ( " else puts " Yay ! " end n = gets . chomp . to _ i ; p = gets . chomp . split ( " " ) . map ( & : to _ i ) ; b = [ ] b [ 0 ] = p [ 0 ] mi = p [ 0 ] for i in 1 .. n - 1 if p [ i ] < mi mi = p [ i ] b [ i ] = mi else b [ i ] = mi end end count = 1 for i in 1 .. n - 1 if p [ i ] < = b [ i ] count = count + 1 end end puts count eval " K , S = " + ` tr ' ' , ` ; K + = 1 ; p ( 0 ... K * K ) . count { | i | z = S - i % K - i / K ; z > = 0 & & z < K } gets . to _ i nums = gets . split ( ' ' ) . map ( & : to _ i ) c = 0 min = nums [ 0 ] nums . each do | n | c + = 1 if min > = n min = n if min > = n end puts c a = gets . chomp ! . to _ i b = gets . chomp ! . to _ i c = gets . chomp ! . to _ i d = gets . chomp ! . to _ i e = gets . chomp ! . to _ i k = gets . chomp ! . to _ i comb = [ a , b , c , d , e ] . combination ( 2 ) if comb . all ? { | x , y | y - a < = k } puts " Yay ! " else puts " : ( " end C = ( 1 .. 3 ) . map { gets . split . map & : to _ i } a = [ 0 , nil , nil ] b = ( 0 ... 3 ) . map { | i | C [ 0 ] [ i ] - a [ 0 ] } for i in 1 .. 2 a [ i ] = C [ i ] [ 0 ] - b [ 0 ] end for i in 0 ... 3 for j in 0 ... 3 if C [ i ] [ j ] ! = a [ i ] + b [ j ] puts " No " exit end end end puts " Yes " c = [ nil ] 3 . times do c < < [ nil ] + gets . split . map ( & : to _ i ) end puts [ c [ 1 ] [ 1 ] + c [ 2 ] [ 2 ] = = c [ 1 ] [ 2 ] + c [ 2 ] [ 1 ] , c [ 2 ] [ 2 ] + c [ 3 ] [ 3 ] = = c [ 2 ] [ 3 ] + c [ 3 ] [ 2 ] , c [ 1 ] [ 2 ] + c [ 2 ] [ 3 ] = = c [ 1 ] [ 3 ] + c [ 2 ] [ 2 ] , c [ 2 ] [ 1 ] + c [ 3 ] [ 2 ] = = c [ 2 ] [ 2 ] + c [ 3 ] [ 1 ] ] . all ? { | x | x } ? ' Yes ' : ' No ' n = gets . to _ i a = 2 n . times do | i | a = a + a + 1 + 1 end p a N = gets . chomp . to _ i P = gets . chomp . split ( " " ) . map ( & : to _ i ) min _ list = [ ] min = Float : : INFINITY P . each do | n | min = [ n , min ] . min min _ list < < min end cnt = 0 P . each . with _ index do | n , i | cnt + = 1 if P [ i ] < = min _ list [ i ] end puts cnt require ' prime ' n , x = gets . split . map ( & : to _ i ) puts x < 2 ? 1 : Prime . prime _ division ( x ) . map { | p , e | e > = n ? p * * ( e / n ) : 1 } . reduce ( : * ) K , S = gets . split . map ( & : to _ i ) cnt = 0 z = 0 0 . upto ( K ) do | x | 0 . upto ( K ) do | y | z = S - x - y cnt = cnt + 1 if ( z > = 0 ) & & ( z < = K ) end end puts cnt n = gets . chomp . to _ i a = gets . chomp . split . map ( & : to _ i ) b = gets . chomp . split . map ( & : to _ i ) if b . sum > a . sum then puts - 1 exit end plus = [ ] minus = [ ] n . times do | i | tmp = a [ i ] - b [ i ] if tmp > 0 then plus < < tmp elsif tmp < 0 then minus < < tmp end end if minus . empty ? then puts 0 exit end plus . sort ! minus . sort ! ans = 0 tmp = 0 until minus . empty ? & & tmp > = 0 if tmp = = 0 then tmp = minus . shift + plus . pop ans + = 2 elsif tmp > 0 then tmp + = minus . shift ans + = 1 else tmp + = plus . pop ans + = 1 end end puts ans arr = Array . new ( 6 , 0 ) arr . size . times do | i | arr [ i ] = gets . to _ i end if arr [ 4 ] - arr [ 0 ] > arr [ 5 ] puts ' : ( ' else puts ' Yay ! ' end n = gets ary = gets . split ( ' ' ) . map ( & : to _ s ) m = ary . sort . uniq . size if m = = 3 then puts " Three " else puts " Four " end require ' prime ' class InputLine def self . to _ s gets . chomp end def self . to _ i InputLine . to _ s . to _ i end def self . to _ f InputLine . to _ s . to _ f end def self . to _ sa InputLine . to _ s . split ( ' ' ) end def self . to _ ia InputLine . to _ sa . map ( & : to _ i ) end def self . to _ fa InputLine . to _ sa . map ( & : to _ f ) end end def main ( argv ) ( n , p ) = InputLine . to _ ia q = 1 p . prime _ division . each do | b , e | q * = ( b * * ( e / n ) ) end puts q . to _ s end if self . to _ s = = ' main ' then main ( ARGV ) end n = gets . chomp . to _ i s = gets . chomp . split puts s . uniq . size = = 3 ? ' Three ' : ' Four ' $ > < < [ : Three , : Four ] [ $ < . read . index ( " Y " ) ? 1 : 0 ] as = [ ] 5 . times { as < < gets . to _ i } k = gets . to _ i print ( as . max - as . min ) > k ? " : ( " : " Yay ! " inputs = [ ] 5 . times do inputs < < gets . chomp . to _ i end k = gets . chomp . to _ i puts inputs [ - 1 ] - inputs [ 0 ] > k ? " : ( " : " Yay ! " n = gets . split . map ( & : to _ i ) n . sort ! if n = = [ 1 , 4 , 7 , 9 ] puts " YES " else puts " NO " end t1 , t2 = gets . split . map ( & : to _ i ) a1 , a2 = gets . split . map ( & : to _ i ) b1 , b2 = gets . split . map ( & : to _ i ) d1 = t1 * ( a1 - b1 ) d2 = d1 + t2 * ( a2 - b2 ) if d2 = = 0 puts " infinity " elsif d1 * d2 > 0 puts 0 else d1 = d1 . abs d2 = d2 . abs ans = 0 if d1 % d2 > 0 ans + = 1 end puts ans + ( d1 / d2 ) * 2 end k , s = gets . split . map ( & : to _ i ) ans = 0 0 . upto ( k ) do | x | 0 . upto ( k ) do | y | z = s - x - y ans + = 1 if z . between ? ( 0 , k ) end end puts ans k , s = gets . strip . split . map ( & : to _ i ) count = 0 ( 0 .. k ) . each do | x | ( 0 .. k ) . each do | y | z = s - x - y if z > = 0 & & z < = k then count + = 1 end end end puts count puts gets . split . sort . join = = ' 1479 ' ? ' YES ' : ' NO ' a , * _ , e , f = $ < . map & : to _ i puts e - a > f ? " : ( " : " Yay ! " N = gets . to _ i nums = gets . split . map ( & : to _ i ) min = Float : : INFINITY ans = 0 nums . each _ with _ index do | ai | if ai < min min = ai ans + = 1 end end p ans c = readlines . map { | line | line . chomp . split . map ( & : to _ i ) } b = c [ 0 ] . map { | i | i - c [ 0 ] [ 0 ] } a = ( 0 .. 2 ) . map { | j | c [ j ] [ 0 ] - b [ 0 ] } d = ( 0 .. 2 ) . map { | i | ( 0 .. 2 ) . map { | j | a [ i ] + b [ j ] } } puts c = = d ? : Yes : : No n = gets . chomp . to _ i s = gets . chomp . split ( " " ) for i in 0 .. s . length if s [ i ] = = " Y " print ( " Four " ) exit ( ) end end print ( " Three " ) list = [ ] 6 . times do list < < gets . chomp . to _ i end if list [ 4 ] - list [ 0 ] > list [ 5 ] puts " : ( " else puts " Yay ! " end n = gets . chomp . to _ i s _ arr = gets . chomp . split ( " " ) if s _ arr . any ? { | s | s = = " Y " } then puts " Four " else puts " Three " end N = gets . to _ i A = N . times . map { gets . to _ i } ans = A [ 0 ] - 1 cur = 2 1 . upto ( N - 1 ) do | i | a = A [ i ] if cur = = a cur + = 1 ans + = a / cur elsif a % cur = = 0 ans + = ( a - ( 2 * cur ) ) / cur + 1 else ans + = a / cur end end puts ans a = [ ] 5 . times { | n | a [ n ] = gets . to _ i } s = a . sort max = gets . to _ i if s [ 4 ] - s [ 0 ] > max then puts " : ( " else puts " Yay ! " end puts $ < . map { | s | eval " [ % d-c = % d , c- % d ] " % s . split } . uniq [ 1 ] ? : No : : Yes io = STDIN d = [ ] 6 . times { d < < io . gets . to _ i } dis = d [ 0 .. - 2 ] k = d [ - 1 ] max = dis . max min = dis . min if max - min < = k puts ' Yay ! ' else puts ' : ( ' end d = [ ] 5 . times do | i | d [ i ] = gets . strip . to _ i end k = gets . to _ i d . combination ( 2 ) do | a | if ( a [ 0 ] - a [ 1 ] ) . abs > k puts ' : ( ' exit end end puts ' Yay ! ' k , s = gets . chomp . split ( " " ) . map ( & : to _ i ) ret = 0 ( 0 .. k ) . each do | z | ( 0 .. k ) . each do | x | y = s - z - x if y > = 0 & & y < = k then ret + = 1 end end end puts ret N = eval * $ < ( t = 1 .. 4e3 ) . any ? { | i | t . any ? { | j | n = 4 * i * j - N * i - d = N * j n > 0 & & d * i % n < 1 & & $ > < < [ i , j , d * i / n ] * ? \ s } } N = gets . to _ i P = gets . split ( ' ' ) . map ( & : to _ i ) count = N lowest = P [ 0 ] ( 1 .. ( N - 1 ) ) . each do | i | now = count if lowest < P [ i ] count - = 1 end lowest = P [ i ] if now = = count end puts count numbers = [ ] 3 . times { numbers < < gets . split . map ( & : to _ i ) } def deduct _ minimum ( ary ) ary . each _ with _ index do | row , index | min = row . min row . each _ with _ index do | num , index2 | ary [ index ] [ index2 ] - = min end end ary end numbers = deduct _ minimum ( numbers ) numbers = deduct _ minimum ( numbers . transpose ) puts numbers . flatten . inject ( : + ) = = 0 ? " Yes " : " No " n = gets arr = gets . chomp . split puts ( arr . include ? " Y " ) ? " Four " : " Three " N = gets . to _ i ( 1 .. 3500 ) . each do | a | ( a .. 3500 ) . each do | b | next if ( 4 * a * b - N * b - N * a ) < 1 c , m = ( N * a * b ) . divmod ( 4 * a * b - N * b - N * a ) next if m > 0 puts [ a , b , c ] . join ( ' ' ) ; exit end end k , s = gets . split ( " " ) . map ( & : to _ i ) cnt = 0 0 . upto ( k ) do | x | 0 . upto ( k ) do | y | z = s - x - y cnt + = 1 if z > = 0 & & z < = k end end puts cnt n = gets . to _ i if gets . split . uniq . size = = 3 puts ' Three ' else puts ' Four ' end a = gets . chomp . to _ i b = gets . chomp . to _ i c = gets . chomp . to _ i d = gets . chomp . to _ i e = gets . chomp . to _ i k = gets . chomp . to _ i l = [ a , b , c , d , e ] puts l . max - l . min > k ? " : ( " : " Yay ! " a = gets . chomp . to _ i b = gets . chomp . to _ i c = gets . chomp . to _ i d = gets . chomp . to _ i e = gets . chomp . to _ i k = gets . chomp . to _ i puts ( if ( ( e - a ) < = k ) then " Yay ! " else " : ( " end ) i = 0 arr = [ ] while i < 5 n = gets . chomp . to _ i arr < < n i + = 1 end k = gets . chomp . to _ i if k < ( arr [ 0 ] - arr [ - 1 ] ) . abs puts " : ( " else puts " Yay ! " end array = gets . chomp . split ( ' ' ) . map ( & : to _ i ) a , b , c , d = false , false , false , false array . each do | i | if i = = 1 a = true end if i = = 9 b = true end if i = = 7 c = true end if i = = 4 d = true end end if a & & b & & c & & d puts " YES " else puts " NO " end def f k , s ; s < = k ? ( s + 1 ) * ( s + 2 ) / 2 : s > = 2 * k ? ( 3 * k - s + 1 ) * ( 3 * k - s + 2 ) / 2 : ( 3 * ( k + 1 ) * ( k + 1 ) + 1 - ( k * 3 - s * 2 ) * * 2 ) / 4 end eval " p f " + ` tr ' ' , ` puts ` dd ` . split . uniq . size > 4 ? ' Four ' : ' Three ' k , s = gets . chomp . split ( ' ' ) . map ( & : to _ i ) ans = 0 ( 0 .. k ) . each do | x | ( 0 .. k ) . each do | y | ans + = 1 if ( s - x - y ) . between ? ( 0 , k ) end end puts ans n = gets . chomp . to _ i s = gets . chomp . split ( " " ) . map ( & : to _ i ) count = 0 arr = Float : : INFINITY n . times do | i | mokuteki = s [ i ] arr = [ mokuteki , arr ] . min count + = 1 if mokuteki < = arr end puts count k , s = gets . chomp . split ( ' ' ) . map ( & : to _ i ) cnt = 0 0 . upto ( k ) do | a | 0 . upto ( s - a ) do | b | next if b > k c = s - a - b if c > = 0 & & c < = k cnt + = 1 end end end puts cnt k , s = gets . split ( ' ' ) . map ( & : to _ i ) ans = 0 for x in 0 .. k do for y in 0 .. k do z = s - x - y ans + = 1 if z > = 0 & & z < = k end end p ans a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i if e - a > k puts " : ( " else puts " Yay ! " end k , s = gets . chomp . split ( " " ) . map ( & : to _ i ) ; cnt = 0 for a in 0 .. k do break if a > s for b in 0 .. k do break if ( a + b ) > s z = s - ( a + b ) cnt + = 1 if ( 0 < = z & & z < = k ) & & a + b + z = s end end puts cnt k , s = gets . chomp . split . map ( & : to _ i ) ans = 0 for i in 0 .. k for j in 0 .. k z = s - i - j if z > = 0 and z < = k ans + = 1 end end end p ans N = gets . to _ i A = gets . split . map & : to _ i B = gets . split . map & : to _ i diffs = A . zip ( B ) . collect { | a , b | a - b } ans = - 1 minus = diffs . select { | n | n < 0 } S _ minus = - minus . inject ( 0 , : + ) plus = diffs . select { | n | n > 0 } . sort _ by { | n | - n } if plus . inject ( 0 , : + ) - S _ minus > = 0 then ans = minus . size plus _ sum = 0 i = 0 while plus _ sum < S _ minus do plus _ sum + = plus [ i ] i + = 1 end ans + = i end puts ans n = gets . chomp . to _ i p _ arr = gets . chomp . split ( " " ) . map ( & : to _ i ) min = p _ arr [ 0 ] count = 0 0 . upto ( n - 1 ) do | i | if p _ arr [ i ] > min then next else min = p _ arr [ i ] count + = 1 end end print ( " K , S = gets . split . map & : to _ i count = 0 0 . upto ( [ K , S ] . min ) do | x | 0 . upto ( [ K , S - x ] . min ) do | y | if S - x - y < = K count + = 1 end end end puts count k , s = gets . chomp . split . map ( & : to _ i ) ans = 0 for i in 0 .. k for j in 0 .. k ans + = 1 if s - i - j < = k & & s - i - j > = 0 end end puts ans n = gets . to _ i s = gets . chomp . split h = Hash . new { 0 } n . times do | i | h [ s [ i ] ] + = 1 end puts h . size = = 3 ? " Three " : " Four " gets puts gets . chomp . split . uniq . size = = 4 ? ' Four ' : ' Three ' N = gets . to _ i ps = gets . split ( ' ' ) . map ( & : to _ i ) result = 0 ; na = [ ] min = 4611686018427387903 ps . each _ with _ index do | p , index | if index = = 0 result + = 1 ; next ; end na . push ( ps [ index - 1 ] ) if min > ps [ index - 1 ] min = ps [ index - 1 ] end if p < min result + = 1 ; end end puts result ; a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i puts e - a > k ? " : ( " : " Yay ! " ns = gets . split . map ( & : to _ i ) . sort if ns = = [ 1 , 4 , 7 , 9 ] puts ( ' YES ' ) else puts ( ' NO ' ) end c = Array . new ( 3 ) 3 . times do | i | c [ i ] = gets . split . map ( & : to _ i ) end d = [ 0 , c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] , c [ 0 ] [ 2 ] - c [ 0 ] [ 0 ] ] e = [ 0 , c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] , c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] ] truth = true 3 . times do | i | 3 . times do | j | truth & = ( c [ 0 ] [ 0 ] + d [ j ] + e [ i ] = = c [ i ] [ j ] ) end end if truth puts " Yes " else puts " No " end module Memoizable def memoize ( name ) original = " _ _ original _ ( [ Class , Module ] .include ? ( self.class ) ? self : self.class ) .class _ eval { alias _ method ( original , name ) private ( original ) cache = { } define _ method ( name ) { | * args | cache [ args ] | | = send ( original , * args ) } } end end def addition ( s1 , s2 ) match _ len = s2.size-1 match _ len - = 1 until match _ len = = 0 | | s1 = ~ / s2.size - match _ len end include Memoizable memoize : addition loop { n = gets.to _ i break if n = = 0 names = ( 1 .. n ) .map { gets.chomp } trivial = [ ] names.combination ( 2 ) { | a , b | trivial < < b if a = ~ / trivial < < a if b = ~ / } trivial.uniq ! n - = trivial.size names - = trivial names < < " " a = { } ( 0 .. n ) . to _ a . permutation ( 2 ) { | i , j | a [ [ i , j ] ] = addition ( names [ i ] , names [ j ] ) } table = [ { n = > 0 } ] ( 1 .. ( 1 < < n ) - 1 ) . each { | x | table [ x ] = Hash . new ( Float : : INFINITY ) t = table [ x ] is = ( 0 .. n - 1 ) . select { | i | x [ i ] = = 1 } is . each { | i | y = x - ( 1 < < i ) last _ name = names [ i ] table [ y ] . each { | k , len | l = len + a [ [ k , i ] ] t [ i ] = l if l < t [ i ] } } } p table [ ( 1 < < n ) - 1 ] . values . min } array = [ ] 5 . times do array < < gets . chomp . to _ i end k = gets . chomp . to _ i out = 0 5 . times do | i | i + 1 . times do | j | if array [ i ] - array [ j ] > k out + = 1 end end end puts out = = 0 ? ' Yay ! ' : ' : ( ' class StdinGetter def initialize ( has _ header = false ) @ stdin = initialized _ stdin ( readlines ) @ header = initialized _ header ( has _ header ) @ body = initialized _ body ( has _ header ) end def header ( ) @ header end def body ( ) @ body end def splited _ body ( splitter ) @ body . map { | line | line . split ( splitter ) } end private def initialized _ stdin ( lines ) lines . nil ? ? [ ] : lines . map { | line | line . chomp } end def initialized _ header ( has _ header ) has _ header ? @ stdin [ 0 ] : [ ] end def initialized _ body ( has _ header ) has _ header ? @ stdin . slice ( 1 .. - 1 ) : @ stdin end end class HinaArare @ @ arare _ colors = [ " P " , " W " , " G " , " Y " ] @ @ count _ messages = { 3 = > " Three " , 4 = > " Four " } def initialize ( arares ) @ arares = arares end def arare _ valiation ( ) @ @ arare _ colors . select { | color | @ arares . uniq . include ? ( color ) } . length end def print _ arere _ counts ( ) if @ @ count _ messages . has _ key ? ( arare _ valiation ) puts @ @ count _ messages [ arare _ valiation ] else puts " Invalid Arare Select " end end end stdin _ getter = StdinGetter . new ( true ) arares = stdin _ getter . splited _ body ( " " ) [ 0 ] hina _ arare = HinaArare . new ( arares ) hina _ arare . print _ arere _ counts gets t , * ps = gets . split . map & : to _ i puts 1 + ps . count { | e | e < t ? t = e : nil } c = 3 . times . map { gets . split . map ( & : to _ i ) } ans = true 3 . times do | i | c [ i ] [ 1 ] - = c [ i ] [ 0 ] c [ i ] [ 2 ] - = c [ i ] [ 0 ] end for i in 1 .. 2 ans = false if c [ 0 ] [ i ] ! = c [ 1 ] [ i ] | | c [ 0 ] [ i ] ! = c [ 2 ] [ i ] end puts ans ? " Yes " : " No " N = gets . strip . split . map ( & : to _ i ) N . sort ! if N [ 0 ] = = 1 & & N [ 1 ] = = 4 & & N [ 2 ] = = 7 & & N [ 3 ] = = 9 puts ' YES ' else puts ' NO ' end grid = [ ] 3 . times do grid < < gets . split ( " " ) . map ( & : to _ i ) end ans = " Yes " 2 . times do | i | row = grid [ i ] nextrow = grid [ i + 1 ] tmp1 = row [ 0 ] - nextrow [ 0 ] tmp2 = row [ 1 ] - nextrow [ 1 ] tmp3 = row [ 2 ] - nextrow [ 2 ] if ! ( tmp1 = = tmp2 & & tmp1 = = tmp3 ) ans = " No " break end end 2 . times do | i | grid = grid . transpose row = grid [ i ] nextrow = grid [ i + 1 ] tmp1 = row [ 0 ] - nextrow [ 0 ] tmp2 = row [ 1 ] - nextrow [ 1 ] tmp3 = row [ 2 ] - nextrow [ 2 ] if ! ( tmp1 = = tmp2 & & tmp1 = = tmp3 ) ans = " No " break end end puts ans c = ( 1 .. 3 ) . map { gets . split . map ( & : to _ i ) } b = c [ 0 ] a = [ 0 , c [ 1 ] [ 0 ] - b [ 0 ] , c [ 2 ] [ 0 ] - b [ 0 ] ] puts ( 0 .. 2 ) . all ? { | i | ( 0 .. 2 ) . all ? { | j | a [ i ] + b [ j ] = = c [ i ] [ j ] } } ? : Yes : : No n = gets . to _ i 1 . upto ( 3500 ) do | a | a . upto ( 3500 ) do | b | if 4 * a * b - n * ( a + b ) ! = 0 if ( n * a * b ) % ( 4 * a * b - n * ( a + b ) ) = = 0 c = ( n * a * b ) / ( 4 * a * b - n * ( a + b ) ) if c > 0 puts [ a , b , c ] . join ( " " ) exit end end end end end x = 5 . times . map { gets . to _ i } k = gets . to _ i puts x . max - x . min > k ? " : ( " : " Yay ! " puts " " < ` awk ' 2 < + + a [ $ 1- $ 2 , $ 2- $ 3 ] ' ` ? : Yes : : No t = 1 gets . split . zip ( $ < ) { | m , x | m = ~ m . to _ i t * = x . split . sum { _ 1 . to _ i * m + = 2 } } p t . % 10 * * 9 + 7 a = gets . split . sort * ' ' puts a = = " 1479 " ? : YES : : NO a = [ ] b = [ ] c = [ ] c [ 0 ] = gets . chomp . split ( " " ) . map { | s | s . to _ i } c [ 1 ] = gets . chomp . split ( " " ) . map { | s | s . to _ i } c [ 2 ] = gets . chomp . split ( " " ) . map { | s | s . to _ i } a [ 0 ] = 0 for j in 0 .. 2 b [ j ] = c [ 0 ] [ j ] end for i in 0 .. 2 a [ i ] = c [ i ] [ 0 ] - b [ 0 ] end f = true for i in 0 .. 2 for j in 0 .. 2 f = false unless c [ i ] [ j ] = = a [ i ] + b [ j ] end end if f puts " Yes " else puts " No " end c = [ ] 3 . times { c < < gets . chomp . split . map ( & : to _ i ) } a = [ 0 ] b = c [ 0 ] 1 . upto ( 2 ) { | i | a [ i ] = c [ i ] [ 0 ] - b [ 0 ] } 1 . upto ( 2 ) do | i | 1 . upto ( 2 ) do | j | if c [ i ] [ j ] ! = a [ i ] + b [ j ] puts " No " exit end end end puts " Yes " n = gets . chomp . to _ i s = gets . chomp . split ( ' ' ) if s . uniq . size = = 3 then puts ' Three ' else puts ' Four ' end puts 1 < < ( gets . to _ i . bit _ length - 1 ) $ / = ' ' ; k , s = $ < . map & : to _ i ; p ( 0 ... ( k + = 1 ) * k ) . count { | i | z = s - i % k - i / k ; 0 < = z & & z < k } K , S = gets . split . map ( & : to _ i ) p ( 0 .. K ) . map { | x | s = S - x next 0 if s < 0 s > = K ? [ 2 * K - s + 1 , 0 ] . max : s + 1 } . inject ( : + ) a = gets . chomp . to _ i b = gets . chomp . to _ i c = gets . chomp . to _ i d = gets . chomp . to _ i e = gets . chomp . to _ i k = gets . chomp . to _ i array = [ a , b , c , d , e ] array . each _ with _ index do | v , x | x = x + 1 x . upto ( 4 ) do | i | if array [ i ] - v > k puts " : ( " exit end end end puts " Yay ! " a , b , c , d , e , k = 6 . times . map { gets . to _ i } if e - a < = k puts " Yay ! " else puts " : ( " end k , s = gets . split . map ( & : to _ i ) ans = 0 ( k + 1 ) . times do | x | ( k + 1 ) . times do | y | z = s - x - y if z < = k & & z > = 0 ans + = 1 end end end puts ans antennas = [ ] 5 . times do antennas < < gets . to _ i end max = gets . to _ i c = 0 4 . downto ( 1 ) do | i | c + = 1 if antennas [ i ] - antennas [ 0 ] > max end if c > 0 puts " : ( " else puts " Yay ! " end k , s = gets . strip . split . map ( & : to _ i ) cnt = 0 ( 0 .. k ) . each do | x | ( 0 .. k ) . each do | y | cnt + = 1 if ( x + y < = s & & s - x - y < = k ) end end puts cnt n = gets . to _ i puts gets . chomp . split ( " " ) . include ? ( " Y " ) ? : Four : : Three c = [ 0 , 0 , 0 ] for i in 0 .. 2 c [ i ] = gets . split . map & : to _ i end b = c [ 0 ] a = [ 0 , 0 , 0 ] for i in 0 .. 2 a [ i ] = c [ i ] [ 0 ] - b [ 0 ] end ok = 1 for i in 0 .. 2 for j in 0 .. 2 ok & & = a [ i ] + b [ j ] = = c [ i ] [ j ] end end puts ( ok ? ' Yes ' : ' No ' ) k , s = gets . split . map ( & : to _ i ) array = [ ] ( 0 .. k ) . each do | x | ( 0 .. k ) . each do | y | z = s - x - y if z < 0 break else array < < [ x , y , z ] if z < = k end end end puts array . size t = 1 A , * B = $ < . map { _ 1 . split . map & : to _ i } A . zip ( B ) { | m , x | t * = x . sum { _ 1 * ~ m - = 2 } } p t . % 10 * * 9 + 7 def get _ i ( ) return gets . chomp . split ( " " ) . map ( & : to _ i ) end def get _ f ( ) return gets . chomp . split ( " " ) . map ( & : to _ f ) end def get ( ) return gets . chomp . split ( " " ) end def get _ nsp ( ) return gets . chomp . split ( " " ) end def yn _ judge ( bool , y = " Yes " , n = " No " ) return bool ? y : n end def array ( size1 , init = nil , size2 = - 1 ) if size2 = = - 1 return Array . new ( size1 ) { init } else return Array . new ( size2 ) { Array . new ( size1 ) { init } } end end def max ( a , b ) return a > b ? a : b end def min ( a , b ) return a > b ? b : a end INF = Float : : INFINITY N = gets . to _ i a = get _ i b = get _ i r = 0 if a . inject ( : + ) < b . inject ( : + ) puts - 1 exit end dif = array ( N ) N . times do | i | dif [ i ] = a [ i ] - b [ i ] end ans = 0 neg = dif . select { | x | x < 0 } ans + = neg . size sum = neg . inject ( 0 ) { | res , x | res - = x } dif . sort { | x , y | y < = > x } . each do | d | if sum < = 0 break end sum - = d ans + = 1 end puts ans n = gets . chop . to _ i arr = gets . split . map res = [ 0 , 0 , 0 , 0 ] cnt = 0 arr . each do | c | if c = = ' P ' & & res [ 0 ] = = 0 cnt + = 1 res [ 0 ] = 1 elsif c = = ' W ' & & res [ 1 ] = = 0 cnt + = 1 res [ 1 ] = 1 elsif c = = ' G ' & & res [ 2 ] = = 0 cnt + = 1 res [ 2 ] = 1 elsif c = = ' Y ' & & res [ 3 ] = = 0 cnt + = 1 res [ 3 ] = 1 end end puts cnt = = 3 ? ' Three ' : ' Four ' a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i puts ( e - a ) < = k ? " Yay ! " : " : ( " require ' prime ' include Math define _ method : max , - > ( a , b ) { a > b ? a : b } define _ method : min , - > ( a , b ) { a < b ? a : b } define _ method : swap , - > ( a , b ) { a , b = b , a } define _ method : gi , - > ( ) { gets . split . map ( & : to _ i ) } define _ method : gs , - > ( ) { gets . chomp } define _ method : gc , - > ( ) { gets . chomp . split ( ' ' ) } define _ method : gif , - > ( ) { gets . to _ i } define _ method : pr , - > ( num ) { num . prime _ division } define _ method : darray , - > ( size1 , size2 , init = nil ) { Array . new ( size1 ) { Array . new ( size2 ) { init } } } define _ method : array , - > ( size , init = nil ) { Array . new ( size ) { init } } define _ method : putall , - > ( obj ) { obj . each { | o | puts o } } define _ method : repl , - > ( st , en , & block ) { st . upto en do | i | block . call ( i ) end } define _ method : rep , - > ( num , & block ) { num . times do | i | block . call ( i ) end } n = gi count = 0 rep n [ 0 ] + 1 do | x | rep n [ 0 ] + 1 do | y | count + = 1 if n [ 1 ] - x - y > = 0 & & n [ 1 ] - x - y < = n [ 0 ] end end puts count n = gets . to _ i s = gets . strip . split puts s . uniq . length = = 4 ? " Four " : " Three " n = gets . to _ i a = gets . split . map ( & : to _ i ) b = gets . split . map ( & : to _ i ) ex = [ ] lack = 0 ans = 0 n . times do | i | t = a [ i ] - b [ i ] ex < < t if t > 0 if t < 0 lack + = - t ans + = 1 end end ex . sort ! . reverse ! ex . each do | v | if lack > 0 lack - = v ans + = 1 end end p lack < = 0 ? ans : - 1 k , s = gets . split . map ( & : to _ i ) sum = 0 0 . upto ( k ) do | i | 0 . upto ( [ k , s - i ] . min ) do | j | sum + = 1 if s - i - j < = k end end p sum n , p = gets . split ( " " ) . map ! { | k | k . to _ i } require " prime " a = Prime . prime _ division ( p ) b = 1 a . length . times do | j | if a [ j ] [ 1 ] > = n c = a [ j ] [ 1 ] / n d = a [ j ] [ 0 ] * * c b = b * d end end puts b n = gets . split ( ' ' ) if n . include ? ( ' 1 ' ) & & n . include ? ( ' 9 ' ) & & n . include ? ( ' 7 ' ) & & n . include ? ( ' 4 ' ) puts ' YES ' else puts ' NO ' end n = gets . to _ i pontas = gets . split . map ( & : to _ i ) answer = 0 minimum = pontas [ 0 ] pontas . each do | ponta | answer + = 1 if ponta < = minimum minimum = ponta if minimum > ponta end puts answer gets puts gets = ~ / Y / ? " Four " : " Three " cc = 3 . times . map { gets . split . map ( & : to _ i ) } cc . each do | c | mi = c . min 3 . times do | i | c [ i ] - = mi end end puts cc [ 0 ] = = cc [ 1 ] & & cc [ 1 ] = = cc [ 2 ] ? ' Yes ' : ' No ' a = [ ] 5 . times do | i | a [ i ] = gets . to _ i end k = gets . to _ i check = true for i in 0 .. 3 for j in ( i + 1 ) .. 4 if k < ( a [ i ] - a [ j ] ) . abs then check = false end end end if check then puts " Yay ! " else puts " : ( " end N = gets . to _ i ans = 0 N . times do | i | if 2 * * i < = N ans = 2 * * i end end puts ans gets puts gets . include ? ( ? Y ) ? : Four : : Three k , s = gets . strip . split . map ( & : to _ i ) cnt = 0 ( k + 1 ) . times do | i | ( k + 1 ) . times do | j | z = s - i - j if 0 < = z & & z < = k cnt + = 1 end end end puts cnt n = gets . chomp . to _ i ans = 1 while ans * 2 < = n do ans * = 2 end puts ans num = " 1 " ary = [ ] < < num . to _ i ( 2 ) 7 . times do num < < " 0 " ary < < num . to _ i ( 2 ) end n = gets . to _ i ary . each _ cons ( 2 ) { | a , b | puts a if ( a ... b ) . include ? ( n ) } n = gets . to _ i a = gets . split . map ( & : to _ i ) min = a [ 0 ] + 1 sum = 0 a . each do | i | if i < = min sum + = 1 min = i end end p sum gets puts gets . split . uniq . size = = 3 ? ' Three ' : ' Four ' _ n , * hinaarare = $ stdin . read . split ans = hinaarare . uniq . size = = 4 ? " Four " : " Three " puts ans K , S = gets . split . map ( & : to _ i ) ans = 0 0 . upto K do | i | 0 . upto K do | j | h = S - i - j ans + = 1 if 0 < = h and h < = K end end puts ans a = [ ] for i in 0 .. 5 a < < gets . chomp . to _ i end puts a [ 4 ] - a [ 0 ] > a [ 5 ] ? " : ( " : " Yay ! " T1 , T2 = gets . chomp . split ( " " ) . map ( & : to _ i ) A1 , A2 = gets . chomp . split ( " " ) . map ( & : to _ i ) B1 , B2 = gets . chomp . split ( " " ) . map ( & : to _ i ) R1 = A1 - B1 R2 = A2 - B2 DR1 = R1 * T1 DR2 = R2 * T2 DR = DR1 + DR2 if DR . zero ? puts " infinity " exit end if DR1 * DR > 0 puts 0 exit end n , m = DR1 . divmod ( DR ) if m . zero ? puts 1 + ( n . abs - 1 ) * 2 + 1 else puts 1 + ( n . abs - 1 ) * 2 end c = 3 . times . map { gets . split . map ( & : to _ i ) } d = c [ 0 ] [ 1 ] - c [ 0 ] [ 0 ] e = c [ 0 ] [ 2 ] - c [ 0 ] [ 0 ] if c [ 1 ] [ 1 ] - c [ 1 ] [ 0 ] = = d & & c [ 1 ] [ 2 ] - c [ 1 ] [ 0 ] = = e & & c [ 2 ] [ 1 ] - c [ 2 ] [ 0 ] = = d & & c [ 2 ] [ 2 ] - c [ 2 ] [ 0 ] = = e puts " Yes " else puts " No " end n = gets . chomp . split ( ' ' ) . map ( & : to _ i ) a = [ 0 , 0 , 0 , 0 ] 4 . times do | i | if n [ i ] = = 1 a [ 0 ] + = 1 elsif n [ i ] = = 9 a [ 1 ] + = 1 elsif n [ i ] = = 7 a [ 2 ] + = 1 elsif n [ i ] = = 4 a [ 3 ] + = 1 end end if a [ 0 ] = = 1 & & a [ 1 ] = = 1 & & a [ 2 ] = = 1 & & a [ 3 ] = = 1 puts " YES " else puts " NO " end k , s = gets . split . map ( & : to _ i ) sum = 0 ( 0 .. k ) . each do | num1 | ( 0 .. k ) . each do | num2 | if num1 + num2 < = s & & num1 + num2 + k > = s sum + = 1 end end end puts sum def hoge ( x ) return 1 if x = = 0 return hoge ( x - 1 ) * 2 + 1 end p hoge ( gets . to _ i + 1 ) - 1 ( n , p ) = gets . chomp . split ( / / ) . map ( & : to _ i ) array = [ ] if ( n = = 1 ) puts p exit end if ( p = = 1 ) puts 1 exit end i = 2 ans = 1 while ( i * i < = p ) if ( p % i = = 0 ) if ( ( p % ( i * * n ) ) = = 0 ) ans * = i p / = i * * n else p / = i end else i + = 1 end end puts ans def test a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i return ' : ( ' if b - a > k | | c - a > k | | d - a > k | | e - a > k return ' : ( ' if c - b > k | | d - b > k | | e - b > k return ' : ( ' if d - c > k | | e - c > k return ' : ( ' if e - d > k return ' Yay ! ' end puts test K , S = gets . chomp . split ( " " ) . map ( & : to _ i ) count = 0 for x in 0 .. K for y in 0 .. K z = S - ( x + y ) if 0 < = z & & z < = K count + = 1 end end end print ( count ) a = gets . chomp . to _ i b = gets . chomp . split . map ( & : to _ i ) c = 0 d = 0 f = b [ 0 ] b . each do | x | if f > = x d + = 1 f = x end end puts d a = [ ] 5 . times do a . push gets . chomp . to _ i end k = gets . chomp . to _ i 5 . times do | i | ( ( i + 1 ) .. 4 ) . each do | j | if ( a [ i ] - a [ j ] ) . abs > k puts ' : ( ' exit end end end puts ' Yay ! ' a , b , c , d , e , k = 6 . times . map { gets . to _ i } if e - a < = k puts " Yay ! " else puts " : ( " end k , s = gets . split . map ( & : to _ i ) num = 0 ( 0 .. k ) . each do | i | a = s - i break if a < 0 ( 0 .. k ) . each do | j | b = a - j num + = 1 if b > = 0 & & b < = k end end puts num a = 3 . times . map { gets . split . map ( & : to _ i ) } yes = 2 . times . all ? do a = a . transpose 2 . times . all ? do | i | a [ i ] [ 1 ] - a [ i ] [ 0 ] = = a [ i + 1 ] [ 1 ] - a [ i + 1 ] [ 0 ] & & a [ i ] [ 2 ] - a [ i ] [ 1 ] = = a [ i + 1 ] [ 2 ] - a [ i + 1 ] [ 1 ] end end puts yes ? " Yes " : " No " k , s = gets . split . map { | i | i . to _ i } res = 0 for x in 0 .. k do for y in 0 .. k do z = s - x - y if 0 < = z & & z < = k then res + = 1 end end end puts res include Math n = $ stdin . gets . chomp . to _ i puts 2 * * ( log ( n , 2 ) . floor ) t = 1 ; gets . split . zip ( $ < ) { | m , x | s , m = 0 , ~ m . to _ i ; x . split . map { | k | s + = k . to _ i * m + = 2 } ; t * = s } ; p t . % 10 * * 9 + 7 temp = [ ] 6 . times do temp < < gets . chomp . to _ i end if ( temp [ 4 ] - temp [ 0 ] ) < = temp [ 5 ] puts " Yay ! " else puts " : ( " end k , s = gets . chomp . split . map ( & : to _ i ) count = 0 for i in 0 .. k for j in 0 .. k l = s - ( i + j ) if l > = 0 & & l < = k count + = 1 end end end puts count as = 5 . times . map { gets . to _ i } k = gets . to _ i puts as [ 4 ] - as [ 0 ] > k ? ' : ( ' : ' Yay ! ' ca = Array . new ( 5 ) { gets . to _ i } k = gets . to _ i puts ( ca [ 4 ] - ca [ 0 ] > k ) ? " : ( " : " Yay ! " K , S = gets . split . map ( & : to _ i ) cnt = 0 min _ x = [ 0 , S - 2 * K ] . max max _ x = [ K , S ] . min min _ x . upto ( max _ x ) do | i | max _ y = [ S - i , K ] . min 0 . upto ( max _ y ) do | j | k = S - i - j cnt + = 1 if k . between ? ( 0 , K ) end end puts cnt antinas = 5 . times . map { gets . to _ i } k = gets . to _ i nonSendflag = false ( 0 .. 3 ) . each do | index | p = antinas [ index ] antinas [ ( index + 1 ) .. 4 ] . each do | q | if k < q - p nonSendflag = true break end end break if nonSendflag end puts nonSendflag ? " : ( " : " Yay ! " n = gets . chomp . to _ i p = gets . chomp . split . map ( & : to _ i ) min = p [ 0 ] ans = 1 1 . upto ( n - 1 ) do | i | if min > = p [ i ] ans + = 1 end min = [ min , p [ i ] ] . min end p ans n = gets . to _ i puts gets . split . uniq . size = = 3 ? : Three : : Four n = gets . to _ i for i in 1 .. 3500 do for j in i .. 3500 do numera = 4 * i * j - n * ( i + j ) delim = n * i * j if numera > 0 & & delim % numera = = 0 then puts " exit end end end K , S = gets . split . map ( & : to _ i ) puts [ * 0 .. K ] . repeated _ permutation ( 2 ) . count { | x , y | z = S - x - y ; 0 < = z & & z < = K } a = gets . chomp . to _ i b = gets . chomp . to _ i c = gets . chomp . to _ i d = gets . chomp . to _ i e = gets . chomp . to _ i k = gets . chomp . to _ i arr = [ a , b , c , d , e ] can = true [ * 0 .. 4 ] . each { | i | [ * 0 .. 4 ] . each { | j | can = false if ( arr [ j ] - arr [ i ] ) . abs > k break unless can } } puts can ? " Yay ! " : " : ( " n = gets . to _ i p = gets . split ( " \ s " ) . map ( & : to _ i ) min = p [ 0 ] result = 0 p . each do | i | if min > = i min = i result + = 1 end end print result A , B , C , D , E , K = readlines . map ( & : to _ i ) puts [ A , B , C , D , E ] . combination ( 2 ) . map { | p , q | ( q - p ) . abs } . all ? { | x | x < = K } ? ' Yay ! ' : ' : ( ' k , s = gets . split . map ( & : to _ i ) count = 0 0 . upto ( k ) do | x | 0 . upto ( k ) do | y | z = s - x - y count + = 1 if 0 < = z & & z < = k end end puts count n = gets . to _ i p = gets . split . map ( & : to _ i ) . first ( n ) min = ( 2 * 10 * * 5 ) + 1 ans = 0 n . times do | i | next if p [ i ] > min min = p [ i ] ans + = 1 end puts ans n = gets . to _ i array = gets . chop . split . map ( & : to _ i ) count = 0 tmp = array [ 0 ] array . each do | num | if tmp > num tmp = num end if tmp > = num count + = 1 end end puts count * a , k = $ < . map & : to _ i puts a . combination ( 2 ) . any ? { | x , y | y - x > k } ? " : ( " : " Yay ! " C = [ ] 3 . times { C < < gets . split . map ( & : to _ i ) } if C [ 0 ] [ 0 ] - C [ 0 ] [ 1 ] = = C [ 1 ] [ 0 ] - C [ 1 ] [ 1 ] & & C [ 0 ] [ 0 ] - C [ 0 ] [ 1 ] = = C [ 2 ] [ 0 ] - C [ 2 ] [ 1 ] & & C [ 0 ] [ 1 ] - C [ 0 ] [ 2 ] = = C [ 1 ] [ 1 ] - C [ 1 ] [ 2 ] & & C [ 0 ] [ 1 ] - C [ 0 ] [ 2 ] = = C [ 2 ] [ 1 ] - C [ 2 ] [ 2 ] & & C [ 0 ] [ 0 ] - C [ 1 ] [ 0 ] = = C [ 0 ] [ 1 ] - C [ 1 ] [ 1 ] & & C [ 0 ] [ 0 ] - C [ 1 ] [ 0 ] = = C [ 0 ] [ 2 ] - C [ 1 ] [ 2 ] & & C [ 0 ] [ 0 ] - C [ 2 ] [ 0 ] = = C [ 0 ] [ 1 ] - C [ 2 ] [ 1 ] & & C [ 0 ] [ 0 ] - C [ 2 ] [ 0 ] = = C [ 0 ] [ 2 ] - C [ 2 ] [ 2 ] puts " Yes " else puts " No " end gets s = gets . chomp . split puts s . uniq . size = = 3 ? ' Three ' : ' Four ' inp = gets . chomp . split ( " " ) . map ( & : to _ i ) ok = [ 1 , 9 , 7 , 4 ] diff = ok - inp if diff . size = = 0 puts " YES " else puts " NO " end k , s = gets . split . map ( & : to _ i ) ans = 0 ( k + 1 ) . times do | i | c1 = i break if c1 > s next if s > 2 * k + c1 ( [ s - c1 , k ] . min + 1 ) . times do | j | c2 = c1 + j break if c2 > s next if s > k + c2 ans + = 1 if s - c2 < = k end end p ans K , S = gets . split . map ( & : to _ i ) ans = 0 ( 0 .. K ) . each do | i | ( 0 .. K ) . each do | j | break if i + j > S ans + = 1 if S - i - j < = K end end puts ans n = gets . to _ i ary = gets . chomp . split ( ' ' ) . map ( & : to _ i ) ans = 1 min = ary [ 0 ] 1 . upto ( ary . size - 1 ) do | i | if ary [ i ] < = min ans + = 1 min = ary [ i ] end end puts ans h , r = gets . chomp . split . map ( & : to _ i ) puts ( h > - r ) ? 1 : ( h = = - r ) ? 0 : - 1 N = gets . split . map & : to _ i ; if ( N . sort ) = = [ 1 , 4 , 7 , 9 ] then puts " YES " else puts " NO " end n = gets . to _ i s = gets . chomp . split a = s . uniq . count if a = = 3 puts " Three " else puts " Four " end arr = [ ] 3 . times do arr < < gets . split . map ( & : to _ i ) end pre = Array . new ( 3 ) 3 . times do | i | 3 . times do | j | if pre [ j ] & & pre [ j ] ! = arr [ ( j + 1 ) % 3 ] [ i ] - arr [ j ] [ i ] puts " No " exit end pre [ j ] = arr [ ( j + 1 ) % 3 ] [ i ] - arr [ j ] [ i ] end end pre2 = Array . new ( 3 ) 3 . times do | i | 3 . times do | j | if pre2 [ j ] & & pre2 [ j ] ! = arr [ i ] [ ( j + 1 ) % 3 ] - arr [ i ] [ j ] puts " No " exit end pre2 [ j ] = arr [ i ] [ ( j + 1 ) % 3 ] - arr [ i ] [ j ] end end puts " Yes " k , s = gets . split . map ( & : to _ i ) ans = 0 ( k + 1 ) . times do | i | ( k + 1 ) . times do | j | t = s - i - j ans + = 1 if 0 < = t & & t < = k end end puts ans a , * , e , k = $ < . map & : to _ i puts e - a > k ? " : ( " : " Yay ! " K , S = gets . split . map ( & : to _ i ) ans = 0 for i in 0 .. K do for j in 0 .. K do if S - ( i + j ) > = 0 & & S - ( i + j ) < = K ans + = 1 end end end puts ans N = gets . to _ i Ss = gets . chomp . split puts Ss . include ? ( ' Y ' ) ? ' Four ' : ' Three ' k , s = gets . split . map ( & : to _ i ) cnt = 0 0 . upto ( k ) do | x | break if x > s 0 . upto ( k ) do | y | break if x + y > s next if x + y + k < s cnt + = 1 end end puts cnt eval " N , X , * A = " + ` dd ` . split * ? , p ( 0 .. N ) . map { | i | i > 0 & & A = A . zip ( A . rotate ) . map ( & : min ) i * X + A . reduce ( : + ) } . min n = gets . to _ i l = 6 . downto ( 0 ) . map { | i | 2 * * i } puts l . detect { | i | n > = i } K , S = gets . split . map ( & : to _ i ) sum = 0 for x in 0 .. K for y in 0 .. K z = S - x - y sum + = 1 if ( 0 < = z & & z < = K ) end end puts sum n = gets . to _ i p = gets . split . map ( & : to _ i ) cnt = 0 min = p [ 0 ] for i in 0 .. ( n - 1 ) min = [ min , p [ i ] ] . min cnt + = 1 if min > = p [ i ] end puts cnt n = gets . to _ i d = gets . chomp . split . map ( & : to _ i ) count = d [ 0 ] res = 0 d . each do | i | if count > = i res + = 1 count = i end break if count = = 1 end puts res T = gets . split . map ( & : to _ i ) A = gets . split . map ( & : to _ i ) B = gets . split . map ( & : to _ i ) b = ( T [ 0 ] * A [ 0 ] + T [ 1 ] * A [ 1 ] ) - ( T [ 0 ] * B [ 0 ] + T [ 1 ] * B [ 1 ] ) if b = = 0 puts " infinity " else a = T [ 0 ] * ( A [ 0 ] - B [ 0 ] ) if a * b > 0 puts 0 else c = ( a / b ) * - 2 if a % b ! = 0 c - = 1 end puts c end end c = Array . new ( 3 ) { Array . new ( 3 , 0 ) } 3 . times do | i | tmp = gets . split ( " \ s " ) . map { | s | s . to _ i } c [ i ] [ 0 ] = tmp [ 0 ] c [ i ] [ 1 ] = tmp [ 1 ] c [ i ] [ 2 ] = tmp [ 2 ] end d00 = c [ 0 ] [ 0 ] - c [ 1 ] [ 0 ] d10 = c [ 1 ] [ 0 ] - c [ 2 ] [ 0 ] d20 = c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] d01 = c [ 0 ] [ 1 ] - c [ 1 ] [ 1 ] d11 = c [ 1 ] [ 1 ] - c [ 2 ] [ 1 ] d21 = c [ 2 ] [ 1 ] - c [ 0 ] [ 1 ] d02 = c [ 0 ] [ 2 ] - c [ 1 ] [ 2 ] d12 = c [ 1 ] [ 2 ] - c [ 2 ] [ 2 ] d22 = c [ 2 ] [ 2 ] - c [ 0 ] [ 2 ] if d00 = = d01 & & d01 = = d02 & & d02 = = d00 & & d10 = = d11 & & d11 = = d12 & & d12 = = d10 & & d20 = = d21 & & d21 = = d22 & & d22 = = d20 then puts " Yes " else puts " No " end arr = 3 . times . map { gets . chomp . split ( " " ) . map ( & : to _ i ) } ans = arr . inject ( : + ) . inject ( : + ) all = arr [ 0 ] [ 0 ] + arr [ 1 ] [ 1 ] + arr [ 2 ] [ 2 ] bll = arr [ 0 ] [ 2 ] + arr [ 1 ] [ 1 ] + arr [ 2 ] [ 0 ] if all = = ( ans / 3 ) & & ans % 3 = = 0 puts " Yes " elsif bll = = ( ans / 3 ) & & ans % 3 = = 0 puts " Yes " else puts " No " end K , S = gets . split . map ( & : to _ i ) count = 0 ( 0 .. K ) . each do | x | ( 0 .. K ) . each do | y | z = S - ( x + y ) count + = 1 if 0 < = z & & z < = K end end puts count MOD = 10 * * 9 + 7 n , m = gets . split ( / / ) . collect { | x | x . to _ i } xs = gets . split ( / / ) . collect { | x | x . to _ i } ys = gets . split ( / / ) . collect { | x | x . to _ i } len _ x = 0 ( n - 1 ) . times { | i | len _ x = ( len _ x + ( xs [ i + 1 ] - xs [ i ] ) * ( i + 1 ) * ( n - i - 1 ) ) % MOD } len _ y = 0 ( m - 1 ) . times { | i | len _ y = ( len _ y + ( ys [ i + 1 ] - ys [ i ] ) * ( i + 1 ) * ( m - i - 1 ) ) % MOD } puts ( len _ x * len _ y ) % MOD n = gets . to _ i ps = gets . split . map ( & : to _ i ) ans = 1 min = ps . shift ps . each do | p | if min > = p ans + = 1 min = p end end puts ans N = gets . to _ i x = [ 1 , 2 , 4 , 8 , 16 , 32 , 64 ] x . reverse . each do | e | if e < = N puts e exit end end number = gets . split ( ' ' ) k = number [ 0 ] . to _ i s = number [ 1 ] . to _ i count = 0 for x in 0 .. k do for y in 0 .. k do z = s - x - y if z < = k and z > = 0 then count = count + 1 end end end puts count * p , k = STDIN . read . split ( " \ n " ) . map ( & : to _ i ) if p . max - p . min < = k print " Yay ! " else print " : ( " end C = readlines . map { | l | l . split . map ( & : to _ i ) } require ' matrix ' a = Array . new ( 9 ) { Array . new ( 9 , 0 ) } b = Array . new ( 9 , 0 ) C . flatten . each _ with _ index do | c , i | x , y = i . divmod ( 3 ) y + = 3 a [ i ] [ x ] = 1 a [ i ] [ y ] = 1 b [ i ] = c end m = Matrix [ * a ] em = m . hstack ( Matrix . column _ vector ( b ) ) puts m . rank = = em . rank ? ' Yes ' : ' No ' x = [ ] 5 . times do | i | x < < gets . to _ i end k = gets . to _ i if x [ - 1 ] - x [ 0 ] < = k puts " Yay ! " else puts " : ( " end a = gets . chomp . split . map ( & : to _ i ) ans = 0 for aa in 0 .. a [ 0 ] for bb in 0 .. a [ 0 ] ans + = 1 if ( cc = a [ 1 ] - aa - bb ) > = 0 & & cc < = a [ 0 ] & & aa + bb + cc = = a [ 1 ] end end puts ans def int gets . to _ i end def ints gets . split . map ( & : to _ i ) end a = int b = int c = int d = int e = int k = int pos = [ a , b , e , d , e ] . sort puts ( pos . last - pos . first ) < = k ? ' Yay ! ' : ' : ( ' n = gets . chomp . to _ i s = gets . split flag = false n . times { | i | flag = true if s [ i ] = = ' Y ' } puts flag ? ' Four ' : ' Three ' a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i puts ( e - a > k ) ? " : ( " : " Yay ! " N = gets . to _ i s = gets puts s . index ( ? Y ) ? " Four " : " Three " as = 5 . times . map { gets . to _ i } k = gets . to _ i puts as [ 4 ] - as [ 0 ] > k ? " : ( " : " Yay ! " K , S = gets . split . map ( & : to _ i ) ans = 0 0 . step ( K ) do | x | 0 . step ( K ) do | y | ans + = 1 if ( S - x - y ) . between ? ( 0 , K ) end end puts ans a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i arr = [ a , b , c , d , e ] . sort ! first = arr . first last = arr . last if ( last - first ) > k puts ' : ( ' else puts ' Yay ! ' end antena = Array . new 5 . times { antena < < gets . to _ i } k = gets . to _ i if antena . combination ( 2 ) . any ? { | a , b | ( a - b ) . abs > k } puts ' : ( ' else puts ' Yay ! ' end a = gets . to _ i b = gets . to _ i c = gets . to _ i d = gets . to _ i e = gets . to _ i k = gets . to _ i max = [ a , b , c , d , e ] . max min = [ a , b , c , d , e ] . min if max - min > k puts " : ( " else puts " Yay ! " end line = readlines . map ( & : to _ i ) if line [ 4 ] - line [ 0 ] > line [ 5 ] then puts " : ( " else puts " Yay ! " end n = gets . chomp . to _ i s = gets . chomp . split ( " " ) hash = Hash . new ( 0 ) s . each do | i | hash [ i ] + = 1 end if hash . size = = 3 puts " Three " else puts " Four " end a = readlines . map { | e | e . chomp . to _ i } k = a [ 5 ] x = 1 ( 0 .. 4 ) . each do | i | ( 1 .. 4 ) . each do | j | x * = a [ j ] - a [ i ] < = k ? 1 : 0 end end print x = = 1 ? ' Yay ! ' : ' : ( ' a = [ ] 5 . times do | i | a [ i ] = gets . to _ i end k = gets . to _ i check = true for i in 0 .. 3 for j in ( i + 1 ) .. 4 if k < ( a [ i ] - a [ j ] ) . abs then check = false end end end if check then puts " Yay ! " else puts " : ( " end k , s = gets . split . map ( & : to _ i ) ans = 0 0 . upto ( k ) do | x | 0 . upto ( k ) do | y | z = s - x - y ans + = 1 if 0 < = z & & z < = k end end puts ans k , s = gets . split . map ( & : to _ i ) ans = 0 0 . upto ( k ) do | x | 0 . upto ( k ) do | y | z = s - ( x + y ) ans + = 1 if z > = 0 & & z < = k end end puts ans K , S = gets . split . map ( & : to _ i ) cnt = 0 0 . upto ( K ) do | i | 0 . upto ( K ) do | j | k = S - ( i + j ) cnt + = 1 if k > = 0 & & k < = K end end puts cnt antena = [ ] 5 . times do antena < < gets . to _ i end k = gets . to _ i antena . combination ( 2 ) . to _ a . each do | i , j | if ( i - j ) . abs > k puts " : ( " exit end end puts " Yay ! " k , s = gets . split . map ( & : to _ i ) count = 0 result = [ ] for x in 0 .. k for y in 0 .. k z = s - ( x + y ) if z < = k & & z > = 0 count + = 1 end end end p count T1 , T2 , A1 , A2 , B1 , B2 = 3 . times . collect { gets . chomp . split ( / / ) . collect ( & : to _ i ) } . flatten delta1 = T1 * ( B1 - A1 ) delta2 = T2 * ( B2 - A2 ) if delta1 * delta2 > 0 puts ( 0 ) else if delta1 . abs > delta2 . abs puts ( 0 ) elsif delta1 . abs = = delta2 . abs puts ( ' infinity ' ) else delta3 = Rational ( - delta1 , delta1 + delta2 ) puts ( 2 * delta3 . floor + ( delta3 . ceil - delta3 . floor ) ) end end n = gets . chomp . to _ i pp = gets . chomp . split ( ) . map ( & : to _ i ) i = 0 count = 0 min = [ ] while true if i = = 0 min . push ( pp [ i ] ) else if min [ ( i - 1 ) ] > pp [ i ] min . push ( pp [ i ] ) else min . push ( min [ i - 1 ] ) end end i + = 1 if i = = n break end end j = 0 while true q = pp [ j ] if min [ j ] > = q count + = 1 end j + = 1 if j = = n break end end print count K , S = gets . split . map ( & : to _ i ) tot = 0 ( 0 .. K ) . each do | a | ( 0 .. K ) . each do | b | c = S - a - b tot + = 1 if 0 < = c & & c < = K end end puts tot * a , k = $ < . map & : to _ i ; puts a [ - 1 ] - a [ 0 ] > k ? ' : ( ' : ' Yay ! ' cs = [ ] 3 . times do | i | cs [ i ] = gets . split . map ( & : to _ i ) end [ 1 , 2 ] . each do | i | diff1 = [ 0 , 1 , 2 ] . map do | j | cs [ i ] [ j ] - cs [ 0 ] [ j ] end diff2 = [ 0 , 1 , 2 ] . map do | j | cs [ j ] [ i ] - cs [ j ] [ 0 ] end if diff1 . uniq . length > 1 | | diff2 . uniq . length > 1 puts ' No ' exit end end puts ' Yes ' MOD = 10 * * 9 + 7 cnt = 0 ; sum = 0 ; prev = nil ; can = true ; h = Hash . new ( 0 ) def gs ( ) gets . chomp end def gi ( ) gets . to _ i end def gsmi ( ) gets . chomp . split . map ( & : to _ i ) end def desc ( ar ) ar . sort { | x , y | y < = > x } end def min ( a , b ) a < = b ? a : b end def max ( a , b ) a > = b ? a : b end def sum ( ar ) ar . inject ( : + ) end def C ( a , b ) b = = 0 | | a = = b ? 1 : ( b = a - b if a / 2 < b ; ( a - b + 1 .. a ) . inject ( : * ) / ( 1 .. b ) . inject ( : * ) ) end def puts _ yesno ( can ) puts ( can ? ' Yes ' : ' No ' ) end def putsend ( s ) puts s ; exit end def debug ( k , v ) puts " t1 , t2 = gsmi gcd = t1 . gcd ( t2 ) t1 / = gcd t2 / = gcd a1 , a2 = gsmi b1 , b2 = gsmi da1 = t1 * a1 da2 = t2 * a2 db1 = t1 * b1 db2 = t2 * b2 da = da1 + da2 db = db1 + db2 diff = ( da - db ) . abs putsend ' infinity ' if diff = = 0 putsend 0 if da > db & & da1 > = db1 | | da < db & & da1 < = db1 d = ( da1 - db1 ) . abs cnt = ( d / diff . to _ f ) . ceil * 2 cnt + = 1 if d % diff = = 0 cnt - = 1 puts cnt n = gets . to _ i s = gets . chomp . split puts s . include ? ( ' Y ' ) ? ' Four ' : ' Three ' N = gets . chomp . to _ i arr = gets . chomp . split ( ' ' ) y = arr . select { | item | item = = " Y " } if y . count = = 0 puts " Three " else puts " Four " end N = gets . to _ i AS = N . times . map { gets . to _ i } x = 1 num = 0 AS . each do | a | if x = = 1 num + = a - 1 a = 1 elsif x < a if a % x = = 0 num + = ( a - 1 ) / x a = x - 1 else num + = a / x a % = x end end if x = = a x + = 1 end end puts num n = gets . to _ i puts 2 * * Math : : log2 ( n ) . to _ i a = [ ] 5 . times do a . push ( gets . to _ i ) end k = gets . to _ i puts a . max - a . min > k ? ' : ( ' : ' Yay ! ' a = 5 . times . map { gets . to _ i } k = gets . to _ i puts a [ 4 ] - a [ 0 ] > k ? ' : ( ' : ' Yay ! ' h , w = gets . split . map ( & : to _ i ) a = ( 1 .. h ) . map { gets . split . map ( & : to _ i ) } p ( 0 .. h - 1 ) . to _ a . product ( ( 0 .. w - 1 ) . to _ a ) . map { | i , j | ( 0 .. h - 1 ) . to _ a . product ( ( 0 .. w - 1 ) . to _ a ) . map { | y , x | a [ y ] [ x ] * [ ( i - y ) . abs , ( j - x ) . abs ] . min } . inject ( : + ) } . min a = 5 . times . map { gets . to _ i } k = gets . to _ i def can _ communicate ( a , k ) ( 0 .. 4 ) . each do | i | ( 0 .. 4 ) . each do | j | return false if ( a [ i ] - a [ j ] ) . abs > k end end true end puts can _ communicate ( a , k ) ? ' Yay ! ' : ' : ( ' as = 5 . times . map { gets . to _ i } K = gets . to _ i puts as [ 4 ] - as [ 0 ] > K ? " : ( " : " Yay ! "