from collections import * n , m = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) l . sort ( ) d = defaultdict ( int ) for i in l : d [ i ] += 1 x = list ( d . values ( ) ) s = sum ( x ) k = len ( x ) c = 0 for i in range ( k - 1 ) : s = s - x [ i ] c = c + s * x [ i ] print ( c ) NEW_LINE


import java . io . * ;    import java . util . * ;      public class Main { static PrintWriter out = new PrintWriter ( System . out ) ;   public static void solve ( ) throws Exception { int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int freq [ ] = new int [ m ] ;   for ( int i = 0 ; i < n ; ++ i ) freq [ in . nextInt ( ) - 1 ] ++ ;     long ans = ( ( long ) n * ( n - 1 ) ) / 2 ;   for ( int i = 0 ; i < m ; ++ i ) { ans -= ( ( long ) freq [ i ] * ( freq [ i ] - 1 ) ) / 2 ; }   out . println ( ans ) ; }   public static void main ( String args [ ] ) throws Exception { in . init ( System . in ) ; solve ( ) ; out . close ( ) ; }   public static class in { static BufferedReader reader ; static StringTokenizer tokenizer ;   static void init ( InputStream input ) { reader = new BufferedReader ( new InputStreamReader ( input ) ) ; tokenizer = new StringTokenizer ( " " ) ; }   static String next ( ) throws IOException { while ( ! tokenizer . hasMoreTokens ( ) ) tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; return tokenizer . nextToken ( ) ; }   static int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; }   static double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; }   static long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } } }

n , m = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) d = { } for i in set ( l ) : d [ i ] = 0 c = 0 d [ l [ - 1 ] ] = 1 NEW_LINE


import sysimport os . pathfrom collections import * import mathimport bisect   if ( os . path . exists ( ' input . txt ' ) ) : sys . stdin = open ( " input . txt " , " r " ) sys . stdout = open ( " output . txt " , " w " ) else : input = sys . stdin . readline     NEW_LINE


import java . io . * ;    import java . util . * ;      public class Main { public static Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) , 640000 ) ) ; public static PrintWriter out = new PrintWriter ( System . out ) ;        public static void solve ( ) throws Exception { int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int freq [ ] = new int [ m ] ;   for ( int i = 0 ; i < n ; ++ i ) freq [ in . nextInt ( ) - 1 ] ++ ;    long ans = ( ( long ) n * ( n - 1 ) ) / 2 ;   for ( int i = 0 ; i < m ; ++ i ) { ans -= ( ( long ) freq [ i ] * ( freq [ i ] - 1 ) ) / 2 ; }   out . println ( ans ) ; }   public static void main ( String args [ ] ) throws Exception {   solve ( ) ; out . close ( ) ; } }

n , m = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) result = 0 for i in range ( m ) : count = a . count ( i + 1 ) result += count * ( n - count ) print ( result // 2 ) NEW_LINE


import java . io . * ;    import java . util . * ;      public class Main { public static Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) , 640000 ) ) ; public static PrintWriter out = new PrintWriter ( System . out ) ;        public static void solve ( ) throws Exception { int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int freq [ ] = new int [ m ] ;   long totalBooks = 0 ; for ( int i = 0 ; i < n ; ++ i ) { freq [ in . nextInt ( ) - 1 ] ++ ; totalBooks ++ ; }    long ans = ( totalBooks * ( totalBooks - 1 ) ) / 2 ;   for ( int i = 0 ; i < m ; ++ i ) { ans -= ( ( long ) freq [ i ] * ( freq [ i ] - 1 ) ) / 2 ; }   out . println ( ans ) ; }   public static void main ( String args [ ] ) throws Exception {   solve ( ) ; out . close ( ) ; } }


import java . util . Scanner ;   public class ques2 { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int arr [ ] = new int [ n ] ; int gen [ ] = new int [ 11 ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = in . nextInt ( ) ; gen [ arr [ i ] ] ++ ; } long ans = 0 ; for ( int i = 1 ; i <= m ; i ++ ) { for ( int k = 1 ; k <= m ; k ++ ) { if ( i != k ) { ans += ( long ) gen [ i ] * gen [ k ] ; } } } System . out . println ( ans / 2 ) ; } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . HashSet ; import java . util . StringTokenizer ; public class A { public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ; int n = fs . nextInt ( ) ; int x = fs . nextInt ( ) ; int y = fs . nextInt ( ) ; int rem = y % x ; int ans = 0 ; String s = fs . next ( ) ; int i = 0 ; while ( i < n && i < x ) { if ( i < rem && s . charAt ( n - i - 1 ) != '0' ) ans ++ ; else if ( i == rem && s . charAt ( n - i - 1 ) != '1' ) ans ++ ; else if ( i > rem && s . charAt ( n - i - 1 ) != '0' ) ans ++ ; i ++ ; } System . out . println ( ans ) ; } static class FastScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ; String next ( ) { while ( ! st . hasMoreTokens ( ) ) try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } int [ ] readArray ( int n ) { int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextInt ( ) ; return a ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }

n , x , y = [ int ( x ) for x in input ( ) . split ( ) ] s = input ( ) [ : : - 1 ] c = 0 c = sum ( [ 1 for i in s [ 0 : y ] if i == '1' ] ) c += sum ( [ 1 for i in s [ y + 1 : x ] if i == '1' ] ) if s [ y ] == '0' : c += 1 print ( c ) NEW_LINE


def solve ( bin_str , x , y ) : target = ( '0' * ( x - y - 1 ) ) + ( str ( 10 ** y ) ) trimmed = bin_str [ - x : ] return sum ( [ 1 if target_i != trim_i else 0 for target_i , trim_i in zip ( target , trimmed ) ] )   if __name__ == ' _ _ main _ _ ' : n , x , y = list ( map ( int , input ( ) . split ( ) ) ) bin_str = input ( ) print ( solve ( bin_str , x , y ) )   NEW_LINE


from sys import stdin , stdoutstdin . readlinedef mp ( ) : return list ( map ( int , stdin . readline ( ) . strip ( ) . split ( ) ) ) def it ( ) : return int ( stdin . readline ( ) . strip ( ) ) from math import ceilfrom collections import defaultdict as ddfrom collections import Counter as C   n , x , y = mp ( ) l = list ( input ( ) ) ans = 0 NEW_LINE


import mathn , x , y = map ( int , input ( ) . split ( ) ) num = input ( ) num = num [ n - x : ] ans = 0 mid = len ( num ) - y - 1 if num [ mid ] == '0' : ans += 1 ans = ans + num [ 0 : mid ] . count ( '1' ) + num [ mid + 1 : ] . count ( '1' ) print ( ans ) NEW_LINE


n , x , y = map ( int , input ( ) . split ( ) ) s = input ( ) i = 0 ; n = n - 1 ; ans = 0 while i < x : if s [ n - i ] == '1' and i != y : ans += 1 i += 1 if s [ n - y ] == '0' : print ( ans + 1 ) else : print ( ans )   NEW_LINE


import java . util . * ; import java . math . * ; public class Remainder { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; char [ ] arr = sc . next ( ) . toCharArray ( ) ; int out = 0 ; for ( int i = n - x ; i < n ; i ++ ) { if ( i == n - y - 1 ) { if ( arr [ i ] != '1' ) out ++ ; } else { if ( arr [ i ] != '0' ) out ++ ; } } System . out . println ( out ) ; } }


import java . util . Scanner ;   public class A { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; String s = sc . next ( ) ; int xVal = ( int ) Math . pow ( 10 , x ) ; int yVal = ( int ) Math . pow ( 10 , y ) ;


import java . util . Scanner ;   public class Reconnaissance2 { 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 ( ) ; } sc . close ( ) ; int diff = Math . abs ( arr [ n - 1 ] - arr [ 0 ] ) ; int prev = n - 1 , curr = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( diff > Math . abs ( arr [ i ] - arr [ i - 1 ] ) ) { diff = Math . abs ( arr [ i ] - arr [ i - 1 ] ) ; prev = i - 1 ; curr = i ; } } System . out . print ( ( prev + 1 ) + " ▁ " + ( curr + 1 ) ) ; }   }

n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) m = abs ( l [ 0 ] - l [ - 1 ] ) a , b = 1 , nfor i in range ( n - 1 ) : if m > abs ( l [ i ] - l [ i + 1 ] ) : m = abs ( l [ i ] - l [ i + 1 ] ) a , b = i + 1 , i + 2 print ( a , b ) NEW_LINE


n = int ( input ( ) )   min_a = Nonemin_b = Noneminimal = None   arr = [ int ( i ) for i in input ( ) . split ( ) ]   for i in range ( len ( arr ) - 1 ) : if minimal == None or abs ( arr [ i ] - arr [ i + 1 ] ) < minimal : minimal = abs ( arr [ i ] - arr [ i + 1 ] ) min_a = i + 1 min_b = i + 2   if abs ( arr [ - 1 ] - arr [ 0 ] ) < minimal : min_a = 1 min_b = n   print ( min_a , min_b ) NEW_LINE


n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) m = abs ( a [ 0 ] - a [ n - 1 ] ) l = [ 1 , n ] for i in range ( n - 1 ) : if abs ( a [ i ] - a [ i + 1 ] ) < m : m = abs ( a [ i ] - a [ i + 1 ] ) l . append ( i ) if len ( l ) == 2 : print ( * l ) else : print ( l [ len ( l ) - 1 ] + 1 , l [ len ( l ) - 1 ] + 2 ) NEW_LINE


import sysn = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) k , l = 0 , 0 min = sys . maxsizefor i in range ( n ) : for j in range ( i , n + 1 ) : mi1 = abs ( arr [ ( j + 1 ) % n ] - arr [ j % n ] ) if mi1 < min : min = mi1 k , l = j % n , ( j + 1 ) % nprint ( k + 1 , l + 1 ) NEW_LINE


def reconnaissance ( heights ) : l = [ ] m = [ ] for i in range ( len ( heights ) ) : l . append ( abs ( heights [ i ] - heights [ i - 1 ] ) ) minimum = min ( l ) for j in range ( len ( heights ) ) : if ( abs ( heights [ j ] - heights [ j - 1 ] ) == minimum ) : if ( ( j - 1 ) == - 1 ) : m . append ( ( len ( heights ) - 1 ) - ( j - 1 ) ) m . append ( j + 1 ) break else : m . append ( ( j - 1 ) + 1 ) m . append ( j + 1 ) break return ( m )   n = int ( input ( ) ) heights = list ( map ( int , input ( ) . split ( ) ) ) result = reconnaissance ( heights ) for i in result : print ( i , end = " ▁ " ) NEW_LINE


import java . util . Scanner ;   public class Reconnaissance { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int min = Integer . MAX_VALUE ; int [ ] soldiers = new int [ n ] ; for ( int k = 0 ; k < n ; k ++ ) { soldiers [ k ] = scan . nextInt ( ) ; } int man = 0 ; int woman = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int a = soldiers [ i ] ; if ( i == 0 && Math . abs ( a - soldiers [ n - 1 ] ) < min ) { min = Math . abs ( a - soldiers [ n - 1 ] ) ; man = i + 1 ; woman = n ; } if ( i != 0 && Math . abs ( a - soldiers [ i - 1 ] ) < min ) { min = Math . abs ( a - soldiers [ i - 1 ] ) ; man = i + 1 ; woman = i ; } if ( i != 0 && Math . abs ( a - soldiers [ i + 1 ] ) < min ) { min = Math . abs ( a - soldiers [ i + 1 ] ) ; man = i + 1 ; woman = i + 2 ; } } System . out . println ( man + " ▁ " + woman ) ; } }


import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = input . nextInt ( ) ; int minIndex = 0 , min = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { if ( Math . abs ( a [ i ] - a [ ( i + 1 ) % n ] ) < min ) { minIndex = i ; min = Math . abs ( a [ i ] - a [ ( i + 1 ) % n ] ) ; } }   System . out . println ( minIndex + 1 + " ▁ " + ( ( minIndex + 1 ) % n + 1 ) ) ; input . close ( ) ; } }


import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ;   public class Reconnaissance2 { public static int [ ] solve ( int [ ] heights ) { int n = heights . length ; int min = Math . abs ( heights [ n - 1 ] - heights [ 0 ] ) ; int idx1 = 0 ; int idx2 = n - 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( Math . abs ( heights [ i ] - heights [ i + 1 ] ) < min ) { min = Math . abs ( heights [ i ] - heights [ i + 1 ] ) ; idx1 = i ; idx2 = i + 1 ; } } return new int [ ] { idx1 , idx2 } ; }   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 [ ] res = solve ( input ) ; System . out . print ( res [ 0 ] + 1 ) ; System . out . print ( " ▁ " ) ; System . out . println ( res [ 1 ] + 1 ) ; } }


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { int something = intInput ( " " ) ; if ( something == 2 ) { System . out . println ( " NO " ) ; } else if ( something % 2 == 0 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } public static int intInput ( String n1 ) { Scanner something = new Scanner ( System . in ) ; System . out . print ( n1 ) ; int something2 = something . nextInt ( ) ; return something2 ; } }

n = int ( input ( ) ) if n <= 2 or ( ( n - 2 ) % 2 != 0 ) : print ( " NO " ) else : print ( " YES " ) NEW_LINE


kg = int ( input ( ) ) if kg <= 2 : print ( " NO " ) else : for n in range ( 2 , kg , 2 ) : if ( kg - n ) % 2 == 0 : print ( " YES " ) break elif n == kg - 1 or n == kg - 2 : print ( " NO " ) NEW_LINE


kg = int ( input ( ) ) if kg <= 2 : print ( " NO " ) else : for n in range ( 2 , round ( kg / 2 ) + 1 , 2 ) : if ( kg - n ) % 2 == 0 : print ( " YES " ) break elif n == round ( kg / 2 ) or n == round ( kg / 2 ) - 1 : print ( " NO " ) NEW_LINE


n = int ( input ( ) ) if n % 2 == 0 and n != 2 : print ( " YES " ) else : print ( " NO " )   NEW_LINE


import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int w = sc . nextInt ( ) ; if ( w % 2 == 0 && w != 2 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }


import java . util . Scanner ;   public class Watermelon { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int w = sc . nextInt ( ) ; if ( w > 2 ) { if ( w % 2 == 0 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } else System . out . println ( " NO " ) ; sc . close ( ) ; } }


import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; int w = sc . nextInt ( ) ; if ( w % 2 == 0 && w != 2 ) out . println ( " YES " ) ; else out . println ( " NO " ) ;


import java . util . * ;   public class watermelon { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int w = sc . nextInt ( ) ; if ( w > 0 && w <= 100 && w % 2 == 0 && w > 2 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }


import java . math . BigInteger ; import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; BigInteger n1 = sc . nextBigInteger ( ) ; BigInteger n2 = sc . nextBigInteger ( ) ; if ( n2 . subtract ( n1 ) . remainder ( new BigInteger ( "2" ) ) . intValue ( ) == 0 ) { System . out . println ( " NO " ) ; return ; } else { System . out . println ( " YES " ) ; } for ( BigInteger i = n1 ; i . compareTo ( n2 ) == - 1 ; i = i . add ( new BigInteger ( "1" ) ) ) { System . out . print ( i + " ▁ " ) ; i = i . add ( new BigInteger ( "1" ) ) ; System . out . print ( i + " \n " ) ; } }   }

l , r = ( int ( i ) for i in input ( ) . split ( ) ) print ( ' YES ' ) for i in range ( l , r , 2 ) : print ( i , i + 1 ) NEW_LINE


l , r = list ( map ( int , input ( ) . split ( ) ) )   a = [ ] i = lwhile i <= r - 1 : a . append ( [ i , i + 1 ] ) i += 2   if a : print ( ' YES ' ) for i in a : print ( f ' { i [ 0 ] } ▁ { i [ 1 ] } ' ) else : print ( ' NO ' ) NEW_LINE


import itertoolsimport bisectimport mathfrom collections import * import osimport sysfrom io import BytesIO , IOBase   ii = lambda : int ( input ( ) ) lmii = lambda : list ( map ( int , input ( ) . split ( ) ) ) slmii = lambda : sorted ( map ( int , input ( ) . split ( ) ) ) li = lambda : list ( input ( ) ) mii = lambda : map ( int , input ( ) . split ( ) ) msi = lambda : map ( str , input ( ) . split ( ) )     def main ( ) : NEW_LINE


l , r = map ( int , input ( ) . split ( ) ) print ( ' YES ' ) for i in range ( l , r + 1 , 2 ) : print ( i , i + 1 ) NEW_LINE


l , r = map ( int , input ( ) . split ( ) ) print ( ' YES ' ) for i in range ( r - l + 1 ) : if i % 2 == 0 : print ( l + i , l + i + 1 ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; System . out . println ( " YES " ) ; for ( long i = a ; i < b ; i += 2 ) { System . out . println ( Long . toString ( i ) + " ▁ " + Long . toString ( i + 1 ) ) ; }   } }


import java . util . * ; public class Output { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; System . out . println ( " YES " ) ; for ( long i = a ; i < b ; i += 2 ) { System . out . println ( Long . toString ( i ) + " ▁ " + Long . toString ( i + 1 ) ) ; }   } }


import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; long a = scn . nextLong ( ) ; long b = scn . nextLong ( ) ; System . out . println ( " YES " ) ; for ( long i = a ; i <= b ; i += 2 ) { System . out . println ( i + " ▁ " + ( i + 1 ) ) ; } } }


import java . math . BigInteger ; import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; BigInteger l = sc . nextBigInteger ( ) ; BigInteger r = sc . nextBigInteger ( ) ; if ( ( r . add ( l ) . add ( new BigInteger ( "1" ) ) ) . mod ( new BigInteger ( "2" ) ) . equals ( new BigInteger ( "0" ) ) ) { System . out . println ( " YES " ) ; for ( BigInteger i = l ; i . compareTo ( r . add ( new BigInteger ( "1" ) ) ) < 0 ; i = i . add ( new BigInteger ( "2" ) ) ) { System . out . println ( i + " ▁ " + i . add ( new BigInteger ( "1" ) ) ) ; } } else { System . out . println ( " NO " ) ; } } }


import java . io . BufferedReader ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . Scanner ; import java . util . StringTokenizer ;   public class robber {   public static void main ( String [ ] args ) {

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) )   for i in range ( n - 1 , 0 , - 1 ) : for j in range ( i ) : if a [ j ] > a [ j + 1 ] : a [ j ] , a [ j + 1 ] = a [ j + 1 ] , a [ j ] print ( j + 1 , j + 2 ) NEW_LINE


n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) : for j in range ( n - 1 ) : if ( a [ j ] > a [ j + 1 ] ) : a [ j ] , a [ j + 1 ] = a [ j + 1 ] , a [ j ] print ( j + 1 , j + 2 ) NEW_LINE


n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n - 1 , 0 , - 1 ) : for j in range ( i ) : if a [ j + 1 ] < a [ j ] : a [ j ] , a [ j + 1 ] = a [ j + 1 ] , a [ j ] print ( j + 1 , j + 2 ) NEW_LINE


n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) )     for i in reversed ( range ( len ( arr ) ) ) : for j in range ( 1 , i + 1 ) : if arr [ j - 1 ] > arr [ j ] : print ( j , j + 1 ) arr [ j - 1 ] , arr [ j ] = arr [ j ] , arr [ j - 1 ]       NEW_LINE


def solve ( n , seq ) : outer = 0 while outer < n : inner = 0 while inner < n - outer - 1 : if seq [ inner ] > seq [ inner + 1 ] : seq [ inner ] , seq [ inner + 1 ] = seq [ inner + 1 ] , seq [ inner ] print ( inner + 1 , inner + 2 ) inner += 1 outer += 1                               n = int ( input ( ) ) seq = list ( map ( int , input ( ) . split ( ) ) )     solve ( n , seq ) NEW_LINE


import java . util . * ; import java . io . * ;   public class B686 { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) ; int [ ] array = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) array [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n - i - 1 ; j ++ ) if ( array [ j + 1 ] < array [ j ] ) { int temp = array [ j + 1 ] ; array [ j + 1 ] = array [ j ] ; array [ j ] = temp ; pw . println ( ( j + 1 ) + " ▁ " + ( j + 2 ) ) ; } } pw . flush ( ) ; }   public static class Scanner { StringTokenizer st ; BufferedReader br ;   public Scanner ( InputStream system ) { br = new BufferedReader ( new InputStreamReader ( system ) ) ; }   public Scanner ( String file ) throws Exception { br = new BufferedReader ( new FileReader ( file ) ) ; }   public String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return st . nextToken ( ) ; }   public String nextLine ( ) throws IOException { return br . readLine ( ) ; }   public int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; }   public double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; }   public char nextChar ( ) throws IOException { return next ( ) . charAt ( 0 ) ; }   public Long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; }   public boolean ready ( ) throws IOException { return br . ready ( ) ; }   public void waitForInput ( ) throws InterruptedException { Thread . sleep ( 3000 ) ; } } }


import java . util . Scanner ;   public class Contest { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int test = input . nextInt ( ) ; int a [ ] = new int [ test ] ; for ( int i = 0 ; i < test ; i ++ ) { a [ i ] = input . nextInt ( ) ; } boolean swap = true ; while ( swap ) { swap = false ; for ( int i = 0 ; i < test - 1 ; i ++ ) { if ( a [ i ] > a [ i + 1 ] ) { int temp = a [ i ] ; a [ i ] = a [ i + 1 ] ; a [ i + 1 ] = temp ; System . out . println ( ( i + 1 ) + " ▁ " + ( i + 2 ) ) ; swap = true ; } } } } }


import com . sun . org . apache . bcel . internal . generic . AALOAD ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; import java . util . stream . IntStream ; import javafx . util . Pair ;   public class Main {   static void sort ( int a [ ] ) { Random ran = new Random ( ) ; for ( int i = 0 ; i < a . length ; i ++ ) { int r = ran . nextInt ( a . length ) ; int temp = a [ r ] ; a [ r ] = a [ i ] ; a [ i ] = temp ; }   Arrays . sort ( a ) ; }   public static void main ( String [ ] args ) throws IOException { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; } if ( n == 1 ) { System . out . println ( " " ) ; } else if ( check ( a ) ) { System . out . println ( " " ) ; } else { StringBuilder ans = new StringBuilder ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n - 1 ; j ++ ) { if ( a [ j ] > a [ j + 1 ] ) { ans . append ( ( j + 1 ) + " ▁ " + ( j + 2 ) + " \n " ) ; int temp = a [ j ] ; a [ j ] = a [ j + 1 ] ; a [ j + 1 ] = temp ; } } } System . out . println ( ans ) ; } }   private static boolean check ( int [ ] a ) { boolean ok = true ; for ( int i = 0 ; i < a . length - 1 ; i ++ ) { if ( a [ i ] > a [ i + 1 ] ) { ok = false ; break ; } } return ok ; }   }


import java . util . * ; import java . lang . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws java . lang . Exception {

inf = 10 ** 9 NEW_LINE def solve ( ) : l = inf NEW_LINE r = - 1 NEW_LINE for a in aa : l = min ( a , l , a - r ) NEW_LINE r = a - l NEW_LINE if l < 0 or r < 0 : return " NO " NEW_LINE return " YES " NEW_LINE for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE aa = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE print ( solve ( ) ) NEW_LINE


import java . util . Scanner ;   public NEW_LINE class Main {   public static void main ( String [ ] args ) throws Exception { String yes = " YES " ; String no = " NO " ; Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ;   for ( int i = 0 ; i < t ; i + + ) { int n = sc . nextInt ( ) ; int [ ] nums = new int [ n ] ; int max = 0 ;   for ( int j = 0 ; j < n ; j + + ) { nums [ j ] = sc . nextInt ( ) ;   if ( j > 0 ) { max += Math . max ( 0 , nums [ j - 1 ] - nums [ j ] ) ; } }   System . out . println ( ( max <= nums [ 0 ] ) ? yes : no ) ; } } } NEW_LINE


from sys import stdin   t = int ( stdin . readline ( ) )   for case in range ( t ) : n = int ( stdin . readline ( ) ) NEW_LINE a = [ int ( x ) for x in stdin . readline ( ) . split ( ) ]   left = [ a [ 0 ] ] NEW_LINE right = [ a [ - 1 ] ]   for x in range ( 1 , n ) : left . append ( min ( left [ - 1 ] , a [ x ] ) ) NEW_LINE right . append ( min ( right [ - 1 ] , a [ - x - 1 ] ) )   right = right [ : : - 1 ]   NEW_LINE


import sysfrom NEW_LINE bisect NEW_LINE import bisect_left   input = lambda : sys . stdin . readline ( ) . rstrip ( " \n " )     for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE rd = 0 NEW_LINE ld = 0 NEW_LINE for i in range ( 1 , n ) : if NEW_LINE a [ i ] > a [ i - 1 ] : rd += a [ i ] - a [ i - 1 ] else : ld += a [ i - 1 ] - a [ i ] NEW_LINE if ld <= a [ 0 ] and rd <= a [ - 1 ] : print ( ' YES ' )   else : print ( ' NO ' ) NEW_LINE


import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) throws Exception { String yes = " YES " ; String no = " NO " ; Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ;   for ( int i = 0 ; i < t ; i ++ ) { int n = sc . nextInt ( ) ; int [ ] nums = new int [ n ] ; int max = 0 ;   for ( int j = 0 ; j < n ; j ++ ) { nums [ j ] = sc . nextInt ( ) ;   if ( j > 0 ) { max += Math . max ( 0 , nums [ j - 1 ] - nums [ j ] ) ; } }   System . out . println ( ( max <= nums [ 0 ] ) ? yes : no ) ; } } }


import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . util . ArrayList ; import java . util . Random ; import java . util . StringTokenizer ;   public class ExtremeSub { static final int MAXN = 1000_006 ; static final long MOD = ( long ) 1e9 + 7 ; public static void main ( String [ ] args ) throws IOException { MyScanner s = new MyScanner ( ) ; Print p = new Print ( ) ; int t = s . nextInt ( ) ; while ( t -- > 0 ) { int n = s . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = s . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { sum += Math . max ( 0 , arr [ i ] - arr [ i + 1 ] ) ; } if ( sum <= arr [ 0 ] ) p . println ( " YES " ) ; else p . println ( " NO " ) ; } p . close ( ) ; } public static class Pair implements Comparable < Pair > { int first ; int second ; public Pair ( int a , int b ) { this . first = a ; this . second = b ; } @ Override public int hashCode ( ) { final int prime = 31 ; int result = 1 ; result = prime * result + first ; result = prime * result + second ; return result ; } @ Override public boolean equals ( Object obj ) { if ( this == obj ) return true ; if ( obj == null ) return false ; if ( getClass ( ) != obj . getClass ( ) ) return false ; Pair other = ( Pair ) obj ; if ( first != other . first ) return false ; if ( second != other . second ) return false ; return true ; } @ Override public int compareTo ( Pair o ) {


import java . util . * ; import java . util . Scanner ; import java . io . * ; import javax . lang . model . util . ElementScanner6 ; import static java . lang . System . out ; import java . util . Stack ; import java . util . Queue ; import java . util . LinkedList ;   public class B16 {   static int mod = ( int ) ( 1e9 + 7 ) ; static long MOD = ( long ) ( 1e9 + 7 ) ; static FastReader in = new FastReader ( ) ; static PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; public static void main ( String args [ ] ) {   int tc = 1 ;

''' Jana ▁ Goodman 16B ▁ Burglar    ''' SPACE = ' ▁ '   def answer ( n , arr ) : matches , boxes = 0 , n for b , a in arr : if a <= boxes : matches += a * b boxes -= a else : return matches + boxes * b return matches   if __name__ == ' _ _ main _ _ ' : n , m = map ( int , input ( ) . split ( SPACE ) ) containers = [ ] for _ in range ( 0 , m ) : a , b = map ( int , input ( ) . split ( SPACE ) ) containers . append ( ( b , a ) ) containers . sort ( ) containers . reverse ( ) print ( answer ( n , containers ) ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) ) lst = [ ] for i in range ( m ) : lst . append ( list ( map ( int , input ( ) . split ( ) ) ) ) lst . sort ( key = lambda x : x [ 1 ] ) lst . reverse ( ) count = 0 for i in lst : if n <= i [ 0 ] : count += ( n * i [ 1 ] ) break else : count += ( i [ 0 ] * i [ 1 ] ) n -= i [ 0 ] if n == 0 : break print ( count ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) ) ai = [ ] k = 0 v = 0 for i in range ( m ) : a , b = map ( int , input ( ) . split ( ) ) ai . append ( [ b , a ] ) ai = sorted ( ai ) [ : : - 1 ] for i in ai : v = min ( i [ 1 ] , n ) n -= v k += ( v * i [ 0 ] ) print ( k ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) ) arr = [ ] for i in range ( m ) : a , b = map ( int , input ( ) . split ( ) ) arr . append ( ( a , b ) ) arr . sort ( key = lambda x : x [ 1 ] , reverse = True ) rem = nres = 0 for i , j in arr : if rem < 1 : break if i >= rem : res += rem * j rem -= n else : res += i * j rem -= iprint ( res ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . Comparator ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Map ; import java . util . Scanner ; import java . util . StringTokenizer ;   public class newprac { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tt = 1 ;


import java . util . * ;   public class StackBracket { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;


import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ;   public class BurglarAndMatches { public static void main ( String [ ] args ) {


import java . io . * ; import java . math . * ; import java . util . * ;     public class Main {   private static int dx [ ] = { 1 , 0 , - 1 , 0 } ; private static int dy [ ] = { 0 , - 1 , 0 , 1 } ;   private static final long INF = ( long ) Math . pow ( 10 , 16 ) ; private static final int INT_INF = Integer . MAX_VALUE ; private static final long NEG_INF = Long . MIN_VALUE ; private static final int NEG_INT_INF = Integer . MIN_VALUE ; private static final double EPSILON = 1e-10 ;   private static final long MAX = ( long ) 1e12 ; private static final long MOD = 100000007 ;   private static final int MAXN = 300005 ; private static final int MAXA = 1000007 ; private static final int MAXLOG = 22 ; private static final double PI = Math . acos ( - 1 ) ; public static void main ( String [ ] args ) throws IOException {   InputReader in = new InputReader ( System . in ) ;

n = int ( input ( ) ) dic = { } for i in range ( n ) : ( a , b ) = [ int ( j ) for j in input ( ) . split ( ' ▁ ' ) ] dic [ a ] = b ans = [ ] ans . append ( 0 ) val = set ( dic . values ( ) ) NEW_LINE


n = int ( input ( ) ) s = dict ( ) for i in range ( n ) : ( a , b ) = [ int ( element ) for element in input ( ) . split ( ' ▁ ' ) ] s [ a ] = b v = [ ] v . append ( 0 ) t = set ( s . values ( ) ) for key in s . keys ( ) : if ( key not in t ) : v . append ( key ) breakfor i in range ( n - 1 ) : v . append ( s [ v [ - 2 ] ] ) v = [ str ( elem ) for elem in v ] print ( ' ▁ ' . join ( v [ 1 : ] ) ) NEW_LINE


import sys , os , ioinput = io . BytesIO ( os . read ( 0 , os . fstat ( 0 ) . st_size ) ) . readlinen = int ( input ( ) ) d = { } ddd = { } dd = { } for i in range ( n ) : a , b = map ( int , input ( ) . split ( ) ) d [ a ] = b dd [ b ] = a if ( a in ddd ) : ddd . pop ( a ) else : ddd [ a ] = 1 if ( b in ddd ) : ddd . pop ( b ) else : ddd [ b ] = - 1   temp = 0 ind = 1 a = [ 0 ] * nwhile ( temp in d ) : temp = d [ temp ] if ( temp == 0 ) : break a [ ind ] = temp ind += 2 if ( len ( a ) & 1 ) : ind = len ( a ) - 1 temp = 0 tempp = 0 for x in ddd : if ( ddd [ x ] == - 1 ) : temp = x else : tempp = x NEW_LINE


import java . util . Arrays ; import java . util . Scanner ;   import java . util . Hashtable ; import java . util . List ; import java . util . Map ;   public class Queue_B {   public static void main ( String [ ] args ) {   Scanner console = new Scanner ( System . in ) ;   int n = console . nextInt ( ) ; int [ ] pArr = new int [ n ] ;   int secN = 1 , lsecN = 0 , beforeN = 0 , lbeforeN = 0 , i , j ; Hashtable < Integer , Integer > hashtableF = new Hashtable < > ( ) ; Hashtable < Integer , Integer > hashtableB = new Hashtable < > ( ) ;   while ( n -- > 0 ) { i = console . nextInt ( ) ; j = console . nextInt ( ) ; hashtableF . put ( i , j ) ; hashtableB . put ( j , i ) ; } for ( Map . Entry < Integer , Integer > entry : hashtableF . entrySet ( ) ) { if ( ! hashtableB . containsKey ( entry . getKey ( ) ) ) { lbeforeN = entry . getKey ( ) ; pArr [ lsecN ] = lbeforeN ; lsecN += 2 ; break ; } } for ( int x = 0 ; x <= pArr . length - 1 ; x += 2 ) { if ( lsecN <= pArr . length - 1 ) { pArr [ lsecN ] = hashtableF . get ( lbeforeN ) ; lbeforeN = pArr [ lsecN ] ; } if ( secN <= pArr . length - 1 ) { pArr [ secN ] = hashtableF . get ( beforeN ) ; beforeN = pArr [ secN ] ; }   secN += 2 ; lsecN += 2 ; System . out . print ( pArr [ x ] ) ; if ( x + 1 <= pArr . length - 1 ) { System . out . print ( " ▁ " + pArr [ x + 1 ] ) ; } if ( x != pArr . length - 1 ) { System . out . print ( " ▁ " ) ; } } } }


import java . awt . * ; import java . io . * ; import java . util . * ;   public class Abc { public static void main ( String [ ] args ) throws Exception { FastReader sc = new FastReader ( ) ; String a = sc . next ( ) , b = sc . next ( ) , c = sc . next ( ) ; int cnta [ ] = new int [ 26 ] , cntb [ ] = new int [ 26 ] , cntc [ ] = new int [ 26 ] ; for ( int i = 0 ; i < a . length ( ) ; i ++ ) { cnta [ a . charAt ( i ) - ' a ' ] ++ ; } for ( int i = 0 ; i < b . length ( ) ; i ++ ) { cntb [ b . charAt ( i ) - ' a ' ] ++ ; } for ( int i = 0 ; i < c . length ( ) ; i ++ ) { cntc [ c . charAt ( i ) - ' a ' ] ++ ; } int maxb = Integer . MAX_VALUE ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( cntb [ i ] == 0 ) continue ; maxb = Math . min ( cnta [ i ] / cntb [ i ] , maxb ) ; } int ansb = 0 , ansc = 0 ; for ( int i = 0 ; i <= maxb ; i ++ ) { int cc = Integer . MAX_VALUE ; for ( int j = 0 ; j < 26 ; j ++ ) { if ( cntc [ j ] > 0 ) { cc = Math . min ( cc , ( cnta [ j ] - i * cntb [ j ] ) / cntc [ j ] ) ; } } if ( ansb + ansc < i + cc ) { ansb = i ; ansc = cc ; } } StringBuilder sb = new StringBuilder ( ) ;

from collections import defaultdict     def find_max_possible_substring ( a , a_char_counts , char_counts ) : max_count_of_sub = len ( a ) for char , count in char_counts . items ( ) : max_count_of_sub = min ( max_count_of_sub , a_char_counts [ char ] // char_counts [ char ] )   return max_count_of_sub     def get_optimal_count ( a , a_orig_char_counts , max_count_of_first , first_char_counts , second_char_counts ) : max = 0 count_of_first = 0 count_of_second = 0 for i in range ( max_count_of_first + 1 ) : a_char_counts = a_orig_char_counts . copy ( ) for char , count in first_char_counts . items ( ) : a_char_counts [ char ] -= count * i   remaining_count_of_second = find_max_possible_substring ( a , a_char_counts , second_char_counts )   count = remaining_count_of_second + i if max < count : max = count count_of_first = i count_of_second = remaining_count_of_second   return count_of_first , count_of_second     def get_result ( a , a_char_counts , first , max_count_of_first , first_char_counts , second , second_char_counts ) : optimal_count_of_first , optimal_count_of_second = get_optimal_count ( a , a_char_counts , max_count_of_first , first_char_counts , second_char_counts ) result = " " result += first * optimal_count_of_first   for char , count in first_char_counts . items ( ) : a_char_counts [ char ] -= count * optimal_count_of_first   if optimal_count_of_second : result += second * optimal_count_of_second for char , count in second_char_counts . items ( ) : a_char_counts [ char ] -= count * optimal_count_of_second   for char , count in a_char_counts . items ( ) : result += char * count   return result     def find_k ( a , b , c ) : a_char_counts = defaultdict ( lambda : 0 ) b_char_counts = defaultdict ( lambda : 0 ) c_char_counts = defaultdict ( lambda : 0 )   for char in a : a_char_counts [ char ] += 1   for char in b : b_char_counts [ char ] += 1   for char in c : c_char_counts [ char ] += 1   max_count_of_b = find_max_possible_substring ( a , a_char_counts , b_char_counts )   max_count_of_c = find_max_possible_substring ( a , a_char_counts , c_char_counts )   if max_count_of_b >= max_count_of_c : result = get_result ( a , a_char_counts , b , max_count_of_b , b_char_counts , c , c_char_counts ) else : result = get_result ( a , a_char_counts , c , max_count_of_c , c_char_counts , b , b_char_counts )   return result     if __name__ == ' _ _ main _ _ ' : a_in = input ( ) b_in = input ( ) c_in = input ( )   print ( find_k ( a_in , b_in , c_in ) ) NEW_LINE


contest = Trueif not contest : fin = open ( " in " , " r " ) inp = input if contest else lambda : fin . readline ( ) [ : - 1 ] read = lambda : tuple ( map ( int , inp ( ) . split ( ) ) )   cstr = lambda s : dict ( [ [ v , s . count ( v ) ] for v in set ( s ) ] )   s , a , b = inp ( ) , inp ( ) , inp ( ) ks , ka , kb = cstr ( s ) , cstr ( a ) , cstr ( b )   def suka ( ks , kx , minusV , minusK ) : ans = " " d = 10 ** 10 for k in kx : if not k in ks : return 0 c = ks [ k ] if k in minusV : c -= minusV [ k ] * minusK d = min ( max ( c , 0 ) // kx [ k ] , d ) return d   da = suka ( ks , ka , { } , 0 ) mx = 0 ans = ( - 1 , - 1 ) for dai in range ( 0 , da + 1 ) : db = suka ( ks , kb , ka , dai ) if dai + db >= mx : ans = ( dai , db ) mx = dai + dbfor k in ks : if k in ka : ks [ k ] -= ans [ 0 ] * ka [ k ] if k in kb : ks [ k ] -= ans [ 1 ] * kb [ k ] print ( ans [ 0 ] * a + ans [ 1 ] * b + " " . join ( [ str ( k * ks [ k ] ) for k in ks ] ) ) NEW_LINE


from collections import Counterfrom copy import deepcopy   def getMax ( c1 , c2 ) : ret = 1 << 32 for k in c2 . keys ( ) : ret = min ( ret , c1 [ k ] // c2 [ k ] ) return ret   a , b , c = input ( ) , input ( ) , input ( ) counterA , counterB , counterC = Counter ( a ) , Counter ( b ) , Counter ( c )   cntB , cntC = 0 , getMax ( counterA , counterC ) counterAA = deepcopy ( counterA ) cntBB = 0 while counterAA & counterB == counterB : cntBB += 1 counterAA -= counterB cntCC = getMax ( counterAA , counterC ) if cntB + cntC < cntBB + cntCC : cntB , cntC = cntBB , cntCC   ans = b * cntB + c * cntCans += ' ' . join ( ( counterA - Counter ( ans ) ) . elements ( ) ) print ( ans )         NEW_LINE


alpha = " abcdefghijklmnopqrstuvwxyz " dict_alpha = { j : i for i , j in enumerate ( alpha ) }   def freq ( s ) : d = [ 0 ] * len ( alpha ) for c in s : d [ dict_alpha [ c ] ] += 1 return d   sa = input ( ) sb = input ( ) sc = input ( )   cntA = freq ( sa ) cpy_cntA = cntA . copy ( ) cntB = freq ( sb ) cntC = freq ( sc )   def highest ( d ) : m = len ( sa ) for i in range ( 26 ) : if d [ i ] == 0 : continue m = min ( m , cntA [ i ] // d [ i ] ) return m   m = ( 0 , 0 ) n = highest ( cntB ) for i in range ( n + 1 ) : add = highest ( cntC ) if i + add > sum ( m ) : m = ( i , add ) for j in range ( 26 ) : cntA [ j ] -= cntB [ j ]   res = [ sb * m [ 0 ] ] + [ sc * m [ 1 ] ] for i in range ( 26 ) : cpy_cntA [ i ] -= cntB [ i ] * m [ 0 ] + cntC [ i ] * m [ 1 ] res . append ( alpha [ i ] * cpy_cntA [ i ] ) print ( " " . join ( res ) ) NEW_LINE


from collections import Counterfrom collections import defaultdictimport randomimport string     a = input ( ) b = input ( ) c = input ( )   NEW_LINE


import java . util . ArrayList ; import java . util . Scanner ;   public class twentyone {   public static void main ( String [ ] args ) {

n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) i = 0j = n - 1 c = 0 while ( i <= j and ( a [ i ] <= k or a [ j ] <= k ) ) : if ( a [ i ] <= k ) : i += 1 c += 1 if ( a [ j ] <= k and i < j ) : j -= 1 c += 1 print ( c ) NEW_LINE


n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) solved = 0   while a [ 0 ] <= k or a [ len ( a ) - 1 ] <= k : if a [ 0 ] <= k : solved += 1 a = a [ 1 : len ( a ) ] elif a [ - 1 ] <= k : solved += 1 a = a [ 0 : len ( a ) - 1 ] if len ( a ) == 0 : a = [ k + 1 ] print ( solved ) NEW_LINE


N , S = map ( int , input ( ) . split ( ) ) A = list ( map ( int , input ( ) . split ( ) ) ) Score = 0 while ( len ( A ) > 0 and ( A [ 0 ] <= S or A [ len ( A ) - 1 ] <= S ) ) : if A [ 0 ] <= S : Score += 1 A . pop ( 0 ) else : Score += 1 A . pop ( ) print ( Score ) NEW_LINE


n , k = ( int ( x ) for x in input ( ) . strip ( ) . split ( ' ▁ ' ) ) weight = [ int ( x ) for x in input ( ) . strip ( ) . split ( ' ▁ ' ) ] sum = 0 for i in range ( 0 , n ) : if weight [ i ] <= k : sum = sum + 1 else : breakif sum == n : print ( sum ) else : for i in range ( n - 1 , 0 , - 1 ) : if weight [ i ] <= k : sum = sum + 1 else : break print ( sum )   NEW_LINE


import renumber1 = str ( input ( ) ) arr = str ( input ( ) ) z = re . findall ( r " \d + " , number1 ) c = [ int ( b ) for b in z ] x = re . findall ( r " \d + " , arr ) y = [ int ( a ) for a in x ] lr = 0 rl = 0 for i in range ( len ( y ) ) : if y [ i ] <= c [ 1 ] : lr += 1 else : breakfor i in reversed ( range ( len ( y ) ) ) : if y [ i ] <= c [ 1 ] : rl += 1 else : break   print ( min ( lr + rl , c [ 0 ] ) ) NEW_LINE


import java . util . * ; public class cc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; int p1 = 0 , p2 = n - 1 , c = 0 ; while ( p1 <= p2 ) { if ( p1 == n || p2 == - 1 || ( a [ p1 ] > k && a [ p2 ] > k ) ) break ; if ( p1 < n && a [ p1 ] <= k ) { c ++ ; p1 ++ ; } else if ( p2 > 0 && a [ p2 ] <= k ) { c ++ ; p2 -- ; } } System . out . println ( c ) ; } }


import java . util . * ; public class MyClass { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } if ( arr [ 0 ] > k && arr [ n - 1 ] > k ) System . out . println ( "0" ) ; else { int i = 0 , j = n - 1 ; while ( i < j ) { if ( arr [ i ] > k && arr [ j ] > k ) { break ; } if ( arr [ i ] <= k ) { i ++ ; count ++ ; } else if ( arr [ j ] <= k ) { j -- ; count ++ ; } } if ( arr [ i ] <= k || arr [ j ] <= k ) count ++ ; System . out . println ( count ) ; } } }


import java . util . Scanner ;   public class Manisha {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int count1 = 0 ; int count2 = 0 ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int low = 0 ; int high = n - 1 ; while ( low <= high ) { if ( a [ low ] <= k ) { count1 ++ ; low ++ ; } else if ( a [ high ] <= k ) { count2 ++ ; high -- ; } else { break ; } } System . out . println ( count1 + count2 ) ; } }


import java . util . * ;   public class Solve {   static Scanner scan = new Scanner ( System . in ) ;   public static void solve ( long a , long b , long n , long s ) {   if ( ( a * n ) + b >= s ) { if ( s % n <= b ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } else { System . out . println ( " NO " ) ; } }   public static void main ( String [ ] args ) {   int t = scan . nextInt ( ) ;   while ( t -- > 0 ) {   long n = scan . nextLong ( ) ; long a = scan . nextLong ( ) ; long b = scan . nextLong ( ) ; long s = scan . nextLong ( ) ;   solve ( n , a , b , s ) ; } } }

for _ in range ( int ( input ( ) ) ) : L = list ( map ( int , input ( ) . split ( ) ) ) x = L [ - 1 ] y = L [ - 2 ] if ( x // y ) <= L [ 0 ] : if ( x % y ) <= L [ 1 ] : print ( " YES " ) else : print ( " NO " ) else : if ( y * ( ( x // y ) - L [ 0 ] ) ) + ( x % y ) > L [ 1 ] : print ( " NO " ) else : print ( " YES " ) NEW_LINE


for i in range ( int ( input ( ) ) ) : a , b , n , s = map ( int , input ( ) . split ( ) ) if ( s <= a * n + b and s % n <= b ) : print ( " YES " ) else : print ( " NO " ) NEW_LINE


for _ in range ( int ( input ( ) ) ) : a , b , n , s = map ( int , input ( ) . split ( ) ) if s <= b : print ( " YES " ) else : if ( n * a ) >= s : if s % n <= b : print ( " YES " ) else : print ( " NO " ) else : if ( s - n * a ) <= b : print ( " YES " ) else : print ( " NO " ) NEW_LINE


q = int ( input ( ) ) for line in range ( q ) : a , b , n , s = list ( map ( int , input ( ) . split ( ) ) ) ans = s // n if ans <= a : s -= ans * n else : s -= a * n if s <= b : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE


import java . util . * ; public class MyClass { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int q = sc . nextInt ( ) ; while ( q -- > 0 ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int k = Math . min ( s / n , a ) ; k = s - k * n ; if ( k <= b ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } }


import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class cf908b {

n , m = map ( int , input ( ) . split ( ) ) p = [ list ( input ( ) ) for _ in range ( n ) ] x , y = 0 , 0 for i in range ( n ) : for j in range ( m ) : if p [ i ] [ j ] == ' S ' : x = i y = j   st = input ( ) command = ( ' D ' , ' L ' , ' U ' , ' R ' ) d_x = { ' D ' : lambda x : x , ' L ' : lambda x : x - 1 , ' R ' : lambda x : x + 1 , ' U ' : lambda x : x , }   d_y = { ' D ' : lambda y : y + 1 , ' L ' : lambda y : y , ' R ' : lambda y : y , ' U ' : lambda y : y - 1 , } count = 0 for el1 in command : NEW_LINE


def STR ( ) : return list ( input ( ) ) def INT ( ) : return int ( input ( ) ) def MAP ( ) : return map ( int , input ( ) . split ( ) ) def LIST ( ) : return list ( map ( int , input ( ) . split ( ) ) ) def STRING ( ) : return input ( )   from heapq import heappop , heappushfrom bisect import * from collections import dequefrom math import * from itertools import permutationsdx = [ - 1 , 1 , 0 , 0 ] dy = [ 0 , 0 , 1 , - 1 ] NEW_LINE


def STR ( ) : return list ( input ( ) ) def INT ( ) : return int ( input ( ) ) def MAP ( ) : return map ( int , input ( ) . split ( ) ) def LIST ( ) : return list ( map ( int , input ( ) . split ( ) ) ) def STRING ( ) : return input ( ) from heapq import heappop , heappushfrom bisect import * from collections import dequefrom math import * from itertools import permutationsdx = [ - 1 , 1 , 0 , 0 ] dy = [ 0 , 0 , 1 , - 1 ] NEW_LINE


def Diff ( li1 , li2 ) : li_dif = [ i for i in li1 + li2 if i not in li1 or i not in li2 ] return li_difn , m = list ( map ( int , input ( ) . split ( ) ) ) g = [ ] for i in range ( n ) : g . append ( input ( ) ) p = input ( ) x , y , f = 0 , 0 , 0 for i in range ( n ) : for j in range ( m ) : if g [ i ] [ j ] == ' S ' : x , y = i , j f = 1 break if f : breakans = 0 d = { } l = [ ' l ' , ' r ' , ' u ' , ' d ' ] for i in l : d [ '0' ] = i l1 = Diff ( l , [ i ] ) for j in l1 : d [ '1' ] = j l2 = Diff ( l , [ i , j ] ) for k in l2 : d [ '2' ] = k l3 = Diff ( l , [ i , j , k ] ) for t in l3 : d [ '3' ] = t f = 0 a , b = x , y for pt in p : if d [ pt ] == ' l ' : a = a - 1 elif d [ pt ] == ' r ' : a = a + 1 elif d [ pt ] == ' u ' : b = b + 1 elif d [ pt ] == ' d ' : b = b - 1 if ( a < 0 ) or ( a >= n ) or ( b < 0 ) or ( b >= m ) : break elif g [ a ] [ b ] == ' # ' : break elif g [ a ] [ b ] == ' E ' : f = 1 break if f : ans = ans + 1 print ( ans ) NEW_LINE


from itertools import * n , m = map ( int , input ( ) . split ( ) ) p = [ [ 0 ] * ( m + 1 ) for i in range ( n ) ] + [ [ 0 ] * m ] for i in range ( n ) : for j , q in enumerate ( input ( ) ) : if q == ' S ' : a , b = i , j p [ i ] [ j ] = ' # E ' . find ( q ) s = list ( map ( int , input ( ) ) ) def f ( d ) : x , y = a , b for k in s : i , j = d [ k ] x += i y += j if p [ x ] [ y ] + 1 : return p [ x ] [ y ] return 0 t = [ ( 1 , 0 ) , ( - 1 , 0 ) , ( 0 , 1 ) , ( 0 , - 1 ) ] print ( sum ( f ( d ) for d in permutations ( t ) ) ) NEW_LINE


import java . util . * ; import java . io . * ; import java . math . * ;   public class B { public static void main ( String omkar [ ] ) throws Exception { BufferedReader infile = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( infile . readLine ( ) ) ; int N = Integer . parseInt ( st . nextToken ( ) ) ; int M = Integer . parseInt ( st . nextToken ( ) ) ; char [ ] [ ] grid = new char [ N ] [ M ] ; for ( int i = 0 ; i < N ; i ++ ) grid [ i ] = infile . readLine ( ) . toCharArray ( ) ; String input = infile . readLine ( ) ; int [ ] arr = new int [ input . length ( ) ] ; int Nn = arr . length ; for ( int i = 0 ; i < Nn ; i ++ ) arr [ i ] = Integer . parseInt ( input . substring ( i , i + 1 ) ) ;


import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;


import java . lang . reflect . Array ; import java . text . CollationElementIterator ; import java . util . * ; import java . util . Map . Entry ; import java . io . * ; import java . lang . Math . * ; import java . math . BigInteger ;   import static java . lang . Math . * ; import static java . lang . System . * ; import static java . util . Arrays . fill ; import static java . util . Arrays . spliterator ; public class ContestMain implements Runnable { private static Reader in = new Reader ( ) ; private static StringBuilder ans = new StringBuilder ( ) ; private static long MOD = ( long ) ( 1e9 + 7 ) ; private static final int N = ( int ) ( 2e5 + 7 ) ;

from sys import stdininput = stdin . readlinen = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) e , z , ans , o = 1 , 0 , 0 , 0 for i in range ( n ) : z += ( a [ i ] < 0 ) if z % 2 : ans += e else : ans += o e += z % 2 == 0 o += z % 2 print ( ans , n * ( n + 1 ) // 2 - ans ) NEW_LINE


import sysinput = sys . stdin . readline   '''   '''   n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a = [ 1 if ai > 0 else - 1 for ai in a ]   pre_prod = [ 1 if a [ 0 ] > 0 else - 1 ] pre_sum_pos = [ 1 if a [ 0 ] > 0 else 0 ] for i in range ( 1 , n ) : pre_prod . append ( pre_prod [ - 1 ] * a [ i ] ) if pre_prod [ - 1 ] > 0 : pre_sum_pos . append ( pre_sum_pos [ - 1 ] + 1 ) else : pre_sum_pos . append ( pre_sum_pos [ - 1 ] )   count_neg = n - pre_sum_pos [ - 1 ] count_pos = pre_sum_pos [ - 1 ]   for l in range ( 1 , n ) : if a [ l ] == pre_prod [ l ] : x = pre_sum_pos [ - 1 ] - pre_sum_pos [ l - 1 ] count_pos += x count_neg += n - l - x else : x = pre_sum_pos [ - 1 ] - pre_sum_pos [ l - 1 ] count_neg += x count_pos += n - l - x   print ( count_neg , count_pos )     NEW_LINE


n = int ( input ( ) ) pos = 1 neg = 0 k = 1 l = list ( map ( int , input ( ) . split ( ) ) ) for t in l : if ( t < 0 ) : k *= - 1 if ( k < 0 ) : neg += 1 else : pos += 1 print ( pos * neg , ( n * ( n + 1 ) // 2 ) - ( pos * neg ) ) NEW_LINE


from sys import stdin , stdout   input = stdin . readline   n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) p = 1 l = 0 pr = 1 for i in range ( n ) : if a [ i ] < 0 : pr *= - 1 if pr > 0 : p += 1 else : l += 1 print ( l * p , ( n * ( n + 1 ) ) // 2 - ( l * p ) ) NEW_LINE


n , a , b = int ( input ( ) ) , 0 , 0 d = { - 1 : 0 , 1 : 1 } s = 1 arr = list ( map ( int , input ( ) . split ( ) ) ) for c in arr : c //= abs ( c ) s *= c a += d [ s ] b += d [ - s ] d [ s ] += 1 print ( b , a ) NEW_LINE


import java . util . * ; import java . io . * ; import java . math . * ;   public class First {   public static void process ( ) throws IOException { int n = ni ( ) ; int dp [ ] [ ] = new int [ n + 1 ] [ 2 ] ; long pp = 0l ; long np = 0l ; for ( int i = 1 ; i <= n ; i ++ ) { int a = ni ( ) ; if ( a > 0 ) { dp [ i ] [ 0 ] = 1 + dp [ i - 1 ] [ 0 ] ; dp [ i ] [ 1 ] = dp [ i - 1 ] [ 1 ] ;   } else { dp [ i ] [ 0 ] = dp [ i - 1 ] [ 1 ] ; dp [ i ] [ 1 ] = 1 + dp [ i - 1 ] [ 0 ] ; } pp += dp [ i ] [ 0 ] ; np += dp [ i ] [ 1 ] ; } pn ( np + " ▁ " + pp ) ;    }     static AnotherReader sc ; static PrintWriter out ; public static void main ( String [ ] args ) throws IOException { out = new PrintWriter ( System . out ) ; sc = new AnotherReader ( ) ; boolean oj = true ;


import java . util . Scanner ;   public class TheNumberOfProducts { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int [ ] nums = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { nums [ i ] = scanner . nextInt ( ) ; } scanner . close ( ) ; long totalCount = 0 ; for ( int i = 1 ; i <= nums . length ; i ++ ) { totalCount += i ; } long negativeCount = findSolution ( nums ) ; long positiveCount = totalCount - negativeCount ; System . out . print ( negativeCount + " ▁ " + positiveCount ) ; } private static long findSolution ( int [ ] nums ) { long [ ] prevValues = new long [ 2 ] ; int prevPointer = 0 ; long count = 0 ; int precedingCount = 0 ; for ( int i = 0 ; i < nums . length ; i ++ ) { int val = nums [ i ] ; if ( val > 0 ) { precedingCount ++ ; count += prevValues [ prevPointer ] ; continue ; } long thisCount = 1 + precedingCount + prevValues [ ( prevPointer + 1 ) % 2 ] ; count += thisCount ; precedingCount = 0 ; prevValues [ ( prevPointer + 1 ) % 2 ] = thisCount ; prevPointer = ( prevPointer + 1 ) % 2 ; } return count ; } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   import java . util . * ;   public class Main {   public static void main ( String args [ ] ) { FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; long a [ ] = new long [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { long value = input . nextLong ( ) ; a [ i ] = ( value < 0 ) ? 1L : 0 ; } for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] += a [ i - 1 ] ; }


import java . io . * ; import java . lang . reflect . Array ; import java . nio . Buffer ; import java . util . * ;   public class Pair {   static class FastReader { private BufferedReader br ; private StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   public String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException 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 str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } }    public static void main ( String [ ] args ) throws Exception { try { FastReader sc = new FastReader ( ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int n = sc . nextInt ( ) ; System . out . println ( a + " ▁ " + b ) ; while ( n != 0 ) { String c = sc . next ( ) ; String d = sc . next ( ) ; if ( c . equals ( a ) ) { a = d ; } else { b = d ; } System . out . println ( a + " ▁ " + b ) ; }   } catch ( Exception e ) { } } }

v1 , v2 = map ( str , input ( ) . split ( ) ) days = int ( input ( ) ) victims = [ [ v1 , v2 ] ]   while days > 0 : killed , new = map ( str , input ( ) . split ( ) ) if killed == v1 : v1 = new else : v2 = new victims . append ( [ v1 , v2 ] )   days -= 1     for i in victims : print ( ' ▁ ' . join ( i ) ) NEW_LINE


initial = input ( ) . split ( ) n = int ( input ( ) )   victims = [ ] m = nwhile m > 0 : s , t = input ( ) . split ( ) victims . append ( [ s , t ] ) m -= 1   answer = initial [ 0 ] + " ▁ " + initial [ 1 ]   for i in range ( len ( victims ) ) : if initial [ 0 ] == victims [ i ] [ 0 ] : initial [ 0 ] = victims [ i ] [ 1 ] answer += " \n " + initial [ 0 ] + " ▁ " + initial [ 1 ] elif initial [ 1 ] == victims [ i ] [ 0 ] : initial [ 1 ] = victims [ i ] [ 1 ] answer += " \n " + initial [ 0 ] + " ▁ " + initial [ 1 ]   print ( answer ) NEW_LINE


a = input ( ) . split ( ) n = int ( input ( ) ) print ( * a ) for _ in range ( n ) : b = input ( ) . split ( ) a . remove ( b [ 0 ] ) a . append ( b [ 1 ] ) print ( * a ) NEW_LINE


one , other = [ str ( x ) for x in input ( ) . split ( ) ]   murders = int ( input ( ) )   for i in range ( murders ) : killed , replaced_by = [ str ( x ) for x in input ( ) . split ( ) ]   print ( f ' { one } ▁ { other } ' ) if ( killed == one ) : one = replaced_by else : other = replaced_byprint ( f ' { one } ▁ { other } ' ) NEW_LINE


one , two = input ( ) . split ( ) n = int ( input ( ) ) L = [ ] for _ in range ( n ) : kill , new = input ( ) . split ( ) L . append ( ( kill , new ) ) NEW_LINE


import java . util . HashSet ; import java . util . Scanner ;   public class AserialKiller {   public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; HashSet < String > set = new HashSet < String > ( ) ; set . add ( reader . next ( ) ) ; set . add ( reader . next ( ) ) ; String print = " " ; for ( String i : set ) print += i + " ▁ " ; System . out . println ( print ) ; int t = reader . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { print = " " ; set . remove ( reader . next ( ) ) ; set . add ( reader . next ( ) ) ; for ( String j : set ) print += j + " ▁ " ; System . out . println ( print ) ; }   }   }


import java . util . Scanner ; public class Reconnaissance2 { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String a = s . next ( ) , b = s . next ( ) , c , d ; int loop = s . nextInt ( ) ; System . out . println ( a + " ▁ " + b ) ; for ( int i = 0 ; i < loop ; i ++ ) { c = s . next ( ) ; d = s . next ( ) ; if ( a . equalsIgnoreCase ( c ) ) a = d ; else b = d ; System . out . println ( a + " ▁ " + b ) ; } } }


import java . util . Scanner ;   public class ASerialKiller_776A { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String a = input . next ( ) ; String b = input . next ( ) ; int n = input . nextInt ( ) ; System . out . println ( a + " ▁ " + b ) ; for ( int i = 0 ; i < n ; i ++ ) { String c = input . next ( ) ; if ( a . equals ( c ) ) a = input . next ( ) ; else b = input . next ( ) ; System . out . println ( a + " ▁ " + b ) ; } input . close ( ) ; } }


import java . io . * ; import java . util . * ; import java . util . StringTokenizer ;   public class SerialKiller implements Runnable { public static void main ( String [ ] args ) { new Thread ( null , new SerialKiller ( ) , " whatever " , 1 << 26 ) . start ( ) ; }   public void run ( ) { Scanner scanner = new Scanner ( System . in ) ; StringBuilder answers = new StringBuilder ( ) ; ArrayList < String > currentPair = new ArrayList < > ( ) ; String start = scanner . nextLine ( ) ; answers . append ( start + " \n " ) ; for ( String name : start . split ( " ▁ " ) ) { currentPair . add ( name ) ; } int n = scanner . nextInt ( ) ; scanner . nextLine ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String line = scanner . nextLine ( ) ; String [ ] names = line . split ( " ▁ " ) ; currentPair . remove ( currentPair . indexOf ( names [ 0 ] ) ) ; currentPair . add ( names [ 1 ] ) ; answers . append ( currentPair . get ( 0 ) + " ▁ " + currentPair . get ( 1 ) + " \n " ) ; } System . out . println ( answers ) ; }   }


import java . math . * ; import java . util . * ; public class Main { static long a [ ] = new long [ 500 ] ; public static int n ; public static BigDecimal f ( int index ) { if ( index == n ) return BigDecimal . valueOf ( a [ index ] ) . divide ( BigDecimal . ONE , 45 , BigDecimal . ROUND_HALF_DOWN ) ; else return BigDecimal . valueOf ( a [ index ] ) . add ( BigDecimal . ONE . divide ( f ( index + 1 ) , 45 , BigDecimal . ROUND_HALF_DOWN ) ) ; } public static void main ( final String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; BigDecimal p , q ; p = cin . nextBigDecimal ( ) ; q = cin . nextBigDecimal ( ) ; n = cin . nextInt ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = cin . nextLong ( ) ; } BigDecimal s1 = p . divide ( q , 45 , BigDecimal . ROUND_HALF_DOWN ) ; BigDecimal s2 = f ( 1 ) ; if ( s1 . equals ( s2 ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } }   }

def solve ( p , q , a , st , n ) : if st == n - 1 : return p == q * a [ st ] return solve ( q , p - a [ st ] * q , a , st + 1 , n ) ;     p , q = map ( int , input ( ) . split ( ) ) n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) )   if solve ( p , q , a , 0 , n ) : print ( " YES " ) else : print ( " NO " ) NEW_LINE


from math import gcdq , p = map ( int , input ( ) . split ( ) ) n = int ( input ( ) ) a = [ * map ( int , input ( ) . split ( ) ) ] d = gcd ( p , q ) p //= dq //= dm , b = 1 , a [ - 1 ] i = n - 2 while ( i >= 0 ) : m = b * a [ i ] + m d = gcd ( m , b ) m //= d b //= d i -= 1 m , b = b , mprint ( " YES " if ( m == p and b == q ) else " NO " ) NEW_LINE


from math import gcdq , p = map ( int , input ( ) . split ( ) ) n = int ( input ( ) ) t = [ * map ( int , input ( ) . split ( ) ) ] d = gcd ( p , q ) p //= dq //= da = int ( 1 ) b = int ( t [ n - 1 ] ) i = n - 2 while i >= 0 : a = b * t [ i ] + a d = gcd ( a , b ) a //= d b //= d i -= 1 c = a a = b b = cif a == p and q == b : print ( " YES " ) else : print ( " NO " )   NEW_LINE


P , Q = map ( int , input ( ) . split ( ) ) n = int ( input ( ) ) a = [ int ( i ) for i in input ( ) . split ( ) ] p = [ ] q = [ ] p . append ( a [ 0 ] ) q . append ( 1 ) if ( n == 1 ) : if ( p [ 0 ] * Q == q [ 0 ] * P ) : print ( " YES " ) else : print ( " NO " ) else : p . append ( a [ 1 ] * a [ 0 ] + 1 ) q . append ( a [ 1 ] ) for i in range ( 2 , n ) : p . append ( a [ i ] * p [ i - 1 ] + p [ i - 2 ] ) q . append ( a [ i ] * q [ i - 1 ] + q [ i - 2 ] ) if ( p [ n - 1 ] * Q == q [ n - 1 ] * P ) : print ( " YES " ) else : print ( " NO " ) NEW_LINE


import java . math . BigDecimal ; import java . util . * ; public class Main { static long a [ ] = new long [ 500 ] ; public static int n ; public static BigDecimal f ( int index ) { if ( index == n ) return BigDecimal . valueOf ( a [ index ] ) . divide ( BigDecimal . ONE , 45 , BigDecimal . ROUND_HALF_DOWN ) ; else return BigDecimal . valueOf ( a [ index ] ) . add ( BigDecimal . ONE . divide ( f ( index + 1 ) , 45 , BigDecimal . ROUND_HALF_DOWN ) ) ; } public static void main ( final String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; BigDecimal p , q ; p = cin . nextBigDecimal ( ) ; q = cin . nextBigDecimal ( ) ; n = cin . nextInt ( ) ; for ( int i = 1 ; i <= n ; i ++ ) a [ i ] = cin . nextLong ( ) ; BigDecimal s1 = p . divide ( q , 45 , BigDecimal . ROUND_HALF_DOWN ) ; BigDecimal s2 = f ( 1 ) ; if ( s1 . equals ( s2 ) ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; cin . close ( ) ; } }


import java . math . * ; import java . util . Scanner ; public class Main { static long a [ ] = new long [ 500 ] ; public static int n ; public static BigDecimal f ( int index ) { if ( index == n ) return BigDecimal . valueOf ( a [ index ] ) . divide ( BigDecimal . ONE , 45 , BigDecimal . ROUND_HALF_DOWN ) ; else return BigDecimal . valueOf ( a [ index ] ) . add ( BigDecimal . ONE . divide ( f ( index + 1 ) , 45 , BigDecimal . ROUND_HALF_DOWN ) ) ; } public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; BigDecimal p , q ; p = cin . nextBigDecimal ( ) ; q = cin . nextBigDecimal ( ) ; n = cin . nextInt ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = cin . nextLong ( ) ; } BigDecimal s1 = p . divide ( q , 45 , BigDecimal . ROUND_HALF_DOWN ) ; BigDecimal s2 = f ( 1 ) ; if ( s1 . equals ( s2 ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } }   }


import java . math . BigDecimal ; import java . util . Scanner ; public class Main { static long a [ ] = new long [ 500 ] ; public static int n ; public static BigDecimal f ( int index ) { if ( index == n ) return BigDecimal . valueOf ( a [ index ] ) . divide ( BigDecimal . ONE , 45 , BigDecimal . ROUND_HALF_DOWN ) ; else return BigDecimal . valueOf ( a [ index ] ) . add ( BigDecimal . ONE . divide ( f ( index + 1 ) , 45 , BigDecimal . ROUND_HALF_DOWN ) ) ; } public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; BigDecimal p , q ; p = cin . nextBigDecimal ( ) ; q = cin . nextBigDecimal ( ) ; n = cin . nextInt ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = cin . nextLong ( ) ; } BigDecimal s1 = p . divide ( q , 45 , BigDecimal . ROUND_HALF_DOWN ) ; BigDecimal s2 = f ( 1 ) ;


import java . io . BufferedReader ; import java . io . FileReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; import java . io . * ; public class codeforces { static class Student { int x , y ;


import sys   input = sys . stdin . readlinefrom collections import deque    def bfs ( root ) : visit = [ 0 ] * ( n + 1 ) queue = [ root , - 1 ] queue = deque ( queue ) visit [ root ] = 1 d = 0 while len ( queue ) != 1 : element = queue . popleft ( ) if element == - 1 : queue . append ( - 1 ) d += 1 continue visit [ element ] = 1 store [ element ] = d for i in r_graph [ element ] : if not visit [ i ] : queue . append ( i ) visit [ i ] = 1    n , m = map ( int , input ( ) . split ( ) ) r_graph = [ [ ] for i in range ( n + 1 ) ] graph = [ [ ] for i in range ( n + 1 ) ] for i in range ( m ) : a , b = map ( int , input ( ) . split ( ) ) graph [ a ] . append ( b ) r_graph [ b ] . append ( a ) k = int ( input ( ) ) c = list ( map ( int , input ( ) . split ( ) ) ) store = [ 0 ] * ( n + 1 ) bfs ( c [ - 1 ] ) maxi , mini , count = 0 , 0 , 0f or i in range ( k - 1 ) : if ( store [ c [ i ] ] < store [ c [ i + 1 ] ] + 1 ) : maxi += 1 mini += 1 else : count = 0 for j in graph [ c [ i ] ] : if ( store [ c [ i ] ] == store [ j ] + 1 ) : count += 1 if ( count >= 2 ) : maxi += 1 print ( mini , maxi )

import sys   input = sys . stdin . readlinefrom collections import deque     def bfs ( root ) : visit = [ 0 ] * ( n + 1 ) queue = [ root , - 1 ] queue = deque ( queue ) visit [ root ] = 1 d = 0 while len ( queue ) != 1 : element = queue . popleft ( ) if element == - 1 : queue . append ( - 1 ) d += 1 continue visit [ element ] = 1 store [ element ] = d for i in r_graph [ element ] : if not visit [ i ] : queue . append ( i ) visit [ i ] = 1     n , m = map ( int , input ( ) . split ( ) ) r_graph = [ [ ] for i in range ( n + 1 ) ] graph = [ [ ] for i in range ( n + 1 ) ] for i in range ( m ) : a , b = map ( int , input ( ) . split ( ) ) graph [ a ] . append ( b ) r_graph [ b ] . append ( a ) k = int ( input ( ) ) c = list ( map ( int , input ( ) . split ( ) ) ) store = [ 0 ] * ( n + 1 ) bfs ( c [ - 1 ] ) maxi , mini , count = 0 , 0 , 0 for i in range ( k - 1 ) : if ( store [ c [ i ] ] < store [ c [ i + 1 ] ] + 1 ) : maxi += 1 mini += 1 else : count = 0 for j in graph [ c [ i ] ] : if ( store [ c [ i ] ] == store [ j ] + 1 ) : count += 1 if ( count >= 2 ) : maxi += 1 print ( mini , maxi ) NEW_LINE


from collections import defaultdictfrom collections import deque   n , m = map ( int , input ( ) . split ( ) ) adj = defaultdict ( list ) rev = defaultdict ( list ) dist = { } for _ in range ( m ) : u , v = map ( int , input ( ) . split ( ) ) adj [ u ] . append ( v ) rev [ v ] . append ( u )   k = int ( input ( ) ) path = list ( map ( int , input ( ) . split ( ) ) )   dt = { }     def bfs ( t ) : q = deque ( [ t ] ) dt [ t ] = 0   while q : c = q . popleft ( ) for y in rev [ c ] : if y not in dt : dt [ y ] = dt [ c ] + 1 q . append ( y )     min_rebuild = 0 max_rebuild = 0 bfs ( path [ k - 1 ] )   for i in range ( 1 , k - 1 ) : v = path [ i - 1 ] u = path [ i ]   if dt [ u ] + 1 > dt [ v ] : min_rebuild += 1 max_rebuild += 1   elif dt [ u ] + 1 == dt [ v ] : for w in adj [ v ] : if u != w and dt [ u ] == dt [ w ] : max_rebuild += 1 break     print ( min_rebuild , max_rebuild ) NEW_LINE


import sysinput = sys . stdin . buffer . readline NEW_LINE


from types import GeneratorType   INF = 1e10     def bootstrap ( f , stack = [ ] ) : def wrappedfunc ( * args , ** kwargs ) : if stack : return f ( * args , ** kwargs ) else : to = f ( * args , ** kwargs ) while True : if type ( to ) is GeneratorType : stack . append ( to ) to = next ( to ) else : stack . pop ( ) if not stack : break to = stack [ - 1 ] . send ( to ) return to   return wrappedfunc     class Graph :   def __init__ ( self , V ) : self . V = V self . adj = [ [ ] for i in range ( V ) ]   def addEdge ( self , v , w ) : self . adj [ v ] . append ( w )     import sys   input = sys . stdin . readlinen , m = list ( map ( int , input ( ) . split ( ) ) ) G = Graph ( n ) G_transpose = Graph ( n ) for _ in range ( m ) : u , v = list ( map ( int , input ( ) . split ( ) ) ) G . addEdge ( u - 1 , v - 1 ) G_transpose . addEdge ( v - 1 , u - 1 ) minimums = [ 0 for _ in range ( n ) ] mini = [ 0 for _ in range ( n ) ]   from collections import dequedef BFS_SP ( graph , start ) : explored = set ( ) queue = deque ( [ start ] ) dz = set ( )   while queue : node = queue . popleft ( )   if node not in explored : neighbours = graph . adj [ node ] NEW_LINE


import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; }   int N ; List < Integer > [ ] adj ; List < Integer > [ ] radj ; int M ; int [ ] dist ; int [ ] distCount ;   int K ; int [ ] path ; void run ( FastScanner in , PrintWriter out ) {   N = in . nextInt ( ) ; adj = new List [ N + 1 ] ; radj = new List [ N + 1 ] ; dist = new int [ N + 1 ] ; multipleOptionsForShortestPath = new boolean [ N + 1 ] ; distCount = new int [ N + 1 ] ; for ( int i = 0 ; i <= N ; i ++ ) { adj [ i ] = new ArrayList < > ( ) ; radj [ i ] = new ArrayList < > ( ) ; }   M = in . nextInt ( ) ; for ( int i = 0 ; i < M ; i ++ ) { int u = in . nextInt ( ) ; int v = in . nextInt ( ) ;   adj [ u ] . add ( v ) ; radj [ v ] . add ( u ) ; }   K = in . nextInt ( ) ; path = new int [ K ] ; for ( int i = 0 ; i < K ; i ++ ) path [ i ] = in . nextInt ( ) ;    bfs ( path [ K - 1 ] ) ;   int min = 0 ; int max = 0 ;   for ( int i = 1 ; i < K ; i ++ ) { int prevDist = dist [ path [ i - 1 ] ] ; int currDist = dist [ path [ i ] ] ; if ( prevDist - 1 != currDist ) { min ++ ; max ++ ; } else {


import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; }   int N ; List < Integer > [ ] adj ; List < Integer > [ ] radj ; int M ; int [ ] dist ; int [ ] distCount ;   int K ; int [ ] path ; void run ( FastScanner in , PrintWriter out ) {   N = in . nextInt ( ) ; adj = new List [ N + 1 ] ; radj = new List [ N + 1 ] ; dist = new int [ N + 1 ] ; distCount = new int [ N + 1 ] ; for ( int i = 0 ; i <= N ; i ++ ) { adj [ i ] = new ArrayList < > ( ) ; radj [ i ] = new ArrayList < > ( ) ; }   M = in . nextInt ( ) ; for ( int i = 0 ; i < M ; i ++ ) { int u = in . nextInt ( ) ; int v = in . nextInt ( ) ;   adj [ u ] . add ( v ) ; radj [ v ] . add ( u ) ; }   K = in . nextInt ( ) ; path = new int [ K ] ; for ( int i = 0 ; i < K ; i ++ ) path [ i ] = in . nextInt ( ) ;    bfs ( path [ K - 1 ] ) ;   int min = 0 ; int max = 0 ;   for ( int i = 1 ; i < K ; i ++ ) { int prevDist = dist [ path [ i - 1 ] ] ; int currDist = dist [ path [ i ] ] ; if ( prevDist - 1 != currDist ) { min ++ ; max ++ ; } else {


import java . io . * ; import java . util . * ;   public class Main { public static void main ( String [ ] args ) throws IOException {


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class A { public static void main ( String [ ] args ) { FastReader ( ) ; int t = 1 ; while ( t > 0 ) { solve ( ) ; -- t ; } write . flush ( ) ; write . close ( ) ; } static void solve ( ) { int n = ni ( ) , k = ni ( ) ; int f [ ] = new int [ n ] ; int t [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { f [ i ] = ni ( ) ; t [ i ] = ni ( ) ; } long max = 0 ; if ( t [ 0 ] > k ) { max = f [ 0 ] - t [ 0 ] + k ; } else { max = f [ 0 ] ; } for ( int i = 0 ; i < n ; ++ i ) { if ( t [ i ] > k ) { long p = f [ i ] - t [ i ] + k ; if ( p > max ) { max = p ; } } else { long p = f [ i ] ; if ( p > max ) { max = p ; } } } out ( max ) ; }

import sysinput = sys . stdin . readlinerr = lambda : sys . stdin . readline ( ) . strip ( ) restaurants , givenTime = map ( int , rr ( ) . split ( ) ) restDetails = [ tuple ( map ( int , rr ( ) . split ( ) ) ) for _ in range ( restaurants ) ] restDetails . sort ( )   ans = - 10 ** 69 for f , t in restDetails : cur = f if t > givenTime : cur = f - ( t - givenTime ) ans = max ( cur , ans ) print ( ans ) NEW_LINE


cases , k = map ( int , input ( ) . split ( ) ) mx = float ( " - inf " ) while cases : cases -= 1 fi , ti = map ( int , input ( ) . split ( ) ) if ti > k : mx = max ( fi + k - ti , mx ) else : mx = max ( mx , fi )   print ( mx ) NEW_LINE


import sysfrom os import pathif ( path . exists ( ' input . txt ' ) and path . exists ( ' output . txt ' ) ) : sys . stdout = open ( ' output . txt ' , ' w ' ) sys . stdin = open ( ' input . txt ' , ' r ' )   NEW_LINE


n = [ int ( x ) for x in input ( ) . split ( ) ] t = n [ 1 ] j = [ ] for i in range ( n [ 0 ] ) : x = [ int ( x ) for x in input ( ) . split ( ) ] if x [ 1 ] > t : j . append ( ( x [ 0 ] - ( x [ 1 ] - t ) ) ) else : j . append ( x [ 0 ] )   print ( max ( j ) ) NEW_LINE


n , k = map ( int , input ( ) . split ( ) )   joy = int ( )   for i in range ( n ) :   f , t = map ( int , input ( ) . split ( ) )   if i == 0 : if t > k : joy = f - t + k   else : joy = f   else : if t > k : joy = max ( joy , f - t + k )   else : joy = max ( joy , f )   print ( joy ) NEW_LINE


import java . lang . * ; import java . util . * ; import java . io . * ;   public class _temp2 { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] st = br . readLine ( ) . split ( " ▁ " ) ; int n = Integer . parseInt ( st [ 0 ] ) ; int k = Integer . parseInt ( st [ 1 ] ) ; int [ ] a = new int [ n ] ; int [ ] b = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { st = br . readLine ( ) . split ( " ▁ " ) ; a [ i ] = Integer . parseInt ( st [ 0 ] ) ; b [ i ] = Integer . parseInt ( st [ 1 ] ) ; } int count = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { if ( b [ i ] > k ) { count = Math . max ( count , a [ i ] - b [ i ] + k ) ; } else { count = Math . max ( count , a [ i ] ) ; } } System . out . println ( count ) ; } }


import java . util . * ; import java . math . * ;   public class gfg { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int maxJoy = - 1000000000 ; for ( int i = 0 ; i < n ; i ++ ) { int f = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; if ( t < k ) { if ( maxJoy < f ) maxJoy = f ; } else { if ( maxJoy < ( f - ( t - k ) ) ) maxJoy = f - ( t - k ) ; } } System . out . println ( maxJoy ) ; } }


import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ; public class Cat_Furrier { public static void main ( String [ ] args ) {

n , m = map ( int , input ( ) . split ( ) ) a = { input ( ) for _ in range ( n ) } b = { input ( ) for _ in range ( m ) } u = len ( a . intersection ( b ) ) print ( " NO " ) if m - u + u // 2 >= n - u + ( u + 1 ) // 2 else print ( " YES " ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) ) a = { input ( ) for x in range ( n ) } b = { input ( ) for y in range ( m ) } t = n + m - len ( a | b ) print ( ' YES ' if n + t % 2 > m else ' NO ' )   NEW_LINE


temp = input ( ) . split ( " ▁ " ) n = int ( temp [ 0 ] ) m = int ( temp [ 1 ] )   nli = [ ] mli = [ ]   for _ in range ( n ) : nli . append ( input ( ) )   for _ in range ( m ) : mli . append ( input ( ) )   res = n - mcount = 0 for x in mli : if x in nli : count += 1   res = res + ( count % 2 ) if res > 0 : print ( " YES " )   else : print ( " NO " ) NEW_LINE


def solve ( ) : n , m = [ int ( x ) for x in input ( ) . split ( ) ] if m > n : print ( " NO " ) return elif n > m : print ( " YES " ) return a = [ ] for _ in range ( n ) : a . append ( input ( ) ) a . sort ( ) counter = 0 for _ in range ( m ) : if input ( ) in a : counter += 1 if counter & 1 : if n + 1 > m : print ( " YES " ) else : print ( " NO " )   else : if m >= n : print ( " NO " ) else : print ( " YES " )     solve ( ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) ) a = { input ( ) for x in range ( n ) } b = { input ( ) for y in range ( m ) } t = n + m - len ( a | b ) print ( ' YES ' if n + t % 2 > m else ' NO ' ) NEW_LINE


import java . util . * ; import java . io . * ; import java . math . * ;   public class Practice   { static FastReader sc = new FastReader ( ) ; static int mod = ( int ) Math . pow ( 10 , 9 ) + 7 ; public static void main ( String [ ] args ) {


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; public class b755 {


import java . util . * ; import java . io . * ; import java . math . BigInteger ; import java . text . * ; public class Main { static long mod = 1000_000_007 ; static long mod1 = 998244353 ; static boolean fileIO = false ; static boolean memory = true ; static FastScanner f ; static PrintWriter pw ; static double eps = ( double ) 1e-6 ; static int maxN = ( int ) 1e6 ;

from sys import stdin , stdoutnmbr = lambda : int ( stdin . readline ( ) ) lst = lambda : list ( map ( int , stdin . readline ( ) . split ( ) ) ) for _ in range ( 1 ) : NEW_LINE


x , y = [ ] , [ ] xx , yy = { } , { } for i in range ( 8 ) : a , b = map ( int , input ( ) . split ( ) ) x . append ( a ) y . append ( b ) if a not in xx : xx [ a ] = [ b ] else : xx [ a ] . append ( b ) if b not in yy : yy [ b ] = [ a ] else : yy [ b ] . append ( a ) if len ( set ( x ) ) != 3 or len ( set ( y ) ) != 3 : print ( ' ugly ' ) exit ( ) xxx , yyy = sorted ( set ( x ) ) , sorted ( set ( y ) ) if set ( xx [ xxx [ 1 ] ] ) != { yyy [ 0 ] , yyy [ 2 ] } : print ( ' ugly ' ) exit ( ) if set ( yy [ yyy [ 1 ] ] ) != { xxx [ 0 ] , xxx [ 2 ] } : print ( ' ugly ' ) exit ( ) if len ( set ( xx [ xxx [ 0 ] ] ) ) != 3 or 3 != len ( set ( xx [ xxx [ 2 ] ] ) ) or len ( set ( yy [ yyy [ 0 ] ] ) ) != 3 or 3 != len ( set ( yy [ yyy [ 2 ] ] ) ) : print ( ' ugly ' ) exit ( ) print ( ' respectable ' ) NEW_LINE


a = [ ] xDistinct = [ ] yDistinct = [ ]   for i in range ( 0 , 8 ) : [ n1 , n2 ] = map ( int , input ( ) . split ( ) ) a . append ( [ n1 , n2 ] )   if ( n1 not in xDistinct ) : xDistinct . append ( n1 )   if ( n2 not in yDistinct ) : yDistinct . append ( n2 )     countDistinctX = len ( xDistinct ) countDistinctY = len ( yDistinct )   if ( countDistinctX != 3 and countDistinctY != 3 ) : print ( " ugly " ) exit ( )   xDistinct . sort ( ) yDistinct . sort ( ) a . sort ( )   index = 0   for i in range ( 3 ) : for j in range ( 3 ) : if i == j == 1 : continue   if xDistinct [ i ] != a [ index ] [ 0 ] or yDistinct [ j ] != a [ index ] [ 1 ] : print ( ' ugly ' ) exit ( )   index = index + 1   print ( ' respectable ' ) NEW_LINE


class coor : def __init__ ( self , x , y ) : self . x = x self . y = y def __lt__ ( self , other ) : if ( self . x < other . x ) : return True elif ( self . x > other . x ) : return False else : if ( self . y < other . y ) : return True else : return Falsea = [ ] first = set ( ) second = set ( ) for i in range ( 0 , 8 ) : x , y = ( map ( int , input ( ) . split ( ) ) ) first . add ( x ) second . add ( y ) a . append ( coor ( x , y ) )   NEW_LINE


import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . * ;   public class main {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x [ ] = new int [ 8 ] ; int y [ ] = new int [ 8 ] ; for ( int i = 0 ; i < 8 ; ++ i ) { x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; }   TreeSet < Integer > setX = new TreeSet < > ( ) ; TreeSet < Integer > setY = new TreeSet < > ( ) ; for ( int i = 0 ; i < 8 ; ++ i ) { setX . add ( x [ i ] ) ; setY . add ( y [ i ] ) ; }   if ( setX . size ( ) != 3 || setY . size ( ) != 3 ) { System . out . println ( " ugly " ) ; return ; }   Integer [ ] arrX = setX . toArray ( new Integer [ 3 ] ) ; Integer [ ] arrY = setY . toArray ( new Integer [ 3 ] ) ;   for ( int i = 0 ; i < 3 ; ++ i ) { for ( int j = 0 ; j < 3 ; ++ j ) { boolean found = false ; for ( int k = 0 ; k < 8 ; ++ k ) { if ( arrX [ i ] == x [ k ] && arrY [ j ] == y [ k ] ) { found = true ; break ; } }   if ( found == ( i == 1 && j == 1 ) ) { System . out . println ( " ugly " ) ; return ; } } }   System . out . println ( " respectable " ) ; } }


import java . util . Arrays ; import java . util . Scanner ;   public class EightPointSets { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] x = new int [ 8 ] ; int [ ] y = new int [ 8 ] ; for ( int i = 0 ; i < 8 ; i ++ ) { x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < 8 ; i ++ ) { for ( int j = i + 1 ; j < 8 ; j ++ ) { if ( x [ i ] == x [ j ] && y [ i ] == y [ j ] ) { System . out . println ( " ugly " ) ; return ; } } } int [ ] cntx = new int [ 1000000 + 1 ] ; int [ ] cnty = new int [ 1000000 + 1 ] ; for ( int i = 0 ; i < 8 ; i ++ ) { cntx [ x [ i ] ] ++ ; cnty [ y [ i ] ] ++ ; } boolean isRespectable = false ; Arrays . sort ( x ) ; Arrays . sort ( y ) ; if ( cntx [ x [ 0 ] ] == 3 && cntx [ x [ 3 ] ] == 2 && cntx [ x [ 5 ] ] == 3 && cnty [ y [ 0 ] ] == 3 && cnty [ y [ 3 ] ] == 2 && cnty [ y [ 5 ] ] == 3 ) { isRespectable = true ; } System . out . println ( isRespectable ? " respectable " : " ugly " ) ; } }


import java . io . * ; import java . util . * ;   public class prog { static class pr { int id , w ;   pr ( int id , int w ) { this . id = id ; this . w = w ; } }   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = in . nextInt ( ) ; pr mas [ ] = new pr [ n ] ; for ( int i = 0 ; i < n ; i ++ ) mas [ i ] = new pr ( i + 1 , in . nextInt ( ) ) ; Arrays . sort ( mas , new Comparator < pr > ( ) { public int compare ( pr a , pr b ) { return a . w - b . w ; } } ) ; String s = in . next ( ) ; Stack < Integer > order = new Stack < > ( ) ; int id = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '1' ) out . print ( order . pop ( ) + " ▁ " ) ; else { out . print ( mas [ id ] . id + " ▁ " ) ; order . push ( mas [ id ++ ] . id ) ; } } in . close ( ) ; out . close ( ) ; } }

n = int ( input ( ) ) a = [ int ( a ) for a in input ( ) . split ( ) ]   code = [ ]   for i in range ( 1 , n + 1 ) : d = dict ( x = a [ i - 1 ] , y = i ) code . append ( d ) code = sorted ( code , key = lambda i : i [ " x " ] , reverse = True ) intro = [ ] extro = [ ]   for i in range ( 1 , n + 1 ) : intro . append ( code [ i - 1 ] [ ' y ' ] )   inp = input ( )   for i in inp : if i == '0' : intro_seat = intro . pop ( ) print ( intro_seat , end = ' ▁ ' ) extro . append ( intro_seat )   else : print ( extro . pop ( ) , end = ' ▁ ' )   print ( ) NEW_LINE


z , zz = input , lambda : list ( map ( int , z ( ) . split ( ) ) ) fast = lambda : stdin . readline ( ) . strip ( ) zzz = lambda : [ int ( i ) for i in fast ( ) . split ( ) ] szz , graph , mod , szzz = lambda : sorted ( zz ( ) ) , { } , 10 ** 9 + 7 , lambda : sorted ( zzz ( ) ) from string import * from re import * from collections import * from queue import * from sys import * from collections import * from math import * from heapq import * from itertools import * from bisect import * from collections import Counter as ccfrom math import factorial as ffrom bisect import bisect as bsfrom bisect import bisect_left as bslfrom itertools import accumulate as acdef lcd ( xnum1 , xnum2 ) : return ( xnum1 * xnum2 // gcd ( xnum1 , xnum2 ) ) def prime ( x ) : p = ceil ( x ** .5 ) + 1 for i in range ( 2 , p ) : if ( x % i == 0 and x != 2 ) or x == 0 : return 0 return 1 def dfs ( u , visit , graph ) : visit [ u ] = 1 for i in graph [ u ] : if not visit [ i ] : dfs ( i , visit , graph ) def output ( answer ) : stdout . write ( str ( answer ) ) NEW_LINE


from _collections import dequen = int ( input ( ) ) m = list ( map ( int , input ( ) . split ( ) ) ) a = [ ] b = deque ( ) i = 1 for x in m : a . append ( ( x , i ) ) i += 1 a . sort ( key = lambda p : - p [ 0 ] ) s = input ( ) ans = [ ] for x in s : if x == "1" : v = b . pop ( ) ans . append ( v [ 1 ] ) else : v = a . pop ( ) ans . append ( v [ 1 ] ) b . append ( v ) print ( * ans ) NEW_LINE


from sys import stdin , stdoutnmbr = lambda : int ( stdin . readline ( ) ) lst = lambda : list ( map ( int , stdin . readline ( ) . split ( ) ) ) for _ in range ( 1 ) : n = nmbr ( ) l = sorted ( zip ( lst ( ) , range ( n ) ) ) p = 0 ; ans = [ 0 ] * ( 2 * n ) st = [ 0 ] * n ; ln = 0 s = input ( ) for i in range ( 2 * n ) : ch = s [ i ] if ch == '0' : st [ ln ] = p ans [ i ] = l [ p ] [ 1 ] + 1 ln += 1 p += 1 else : ans [ i ] = l [ st [ ln - 1 ] ] [ 1 ] + 1 ln -= 1 print ( * ans ) NEW_LINE


from collections import dequen = int ( input ( ) ) orderedli = list ( map ( int , input ( ) . split ( " ▁ " ) ) )     indexof = { } for i , x in enumerate ( orderedli ) : indexof [ x ] = i + 1   sortedli = list ( sorted ( orderedli ) ) i = 0   s = input ( )   st = deque ( )   for x in s : if x == "0" : st . append ( sortedli [ i ] ) print ( indexof [ sortedli [ i ] ] , end = " ▁ " ) i += 1 else : NEW_LINE


import java . io . * ; import java . math . * ; import java . security . * ; import java . text . * ; import java . util . * ; import javafx . util . Pair ;   public class CodeForce { static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static StringBuilder sb = new StringBuilder ( ) ;   static boolean flag = false ; static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static int next ( String [ ] sr , int ind ) { return Integer . parseInt ( sr [ ind ] ) ; }   public static void main ( String [ ] args ) throws IOException {


import java . util . * ; import java . io . * ;   public class Div688A {


# include < bits / stdc ++ . h > using namespace std ;  # define ll long long

n = int ( input ( ) )   x = sorted ( list ( map ( int , input ( ) . split ( ) ) ) )   print ( min ( [ x [ i + n // 2 ] - x [ i ] for i in range ( n // 2 ) ] ) )             NEW_LINE


n = int ( input ( ) ) x = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) print ( min ( [ x [ i + n // 2 ] - x [ i ] for i in range ( n // 2 ) ] ) )   NEW_LINE


import java . util . * ;   public class WarriorAndArcher {   public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = scan . nextInt ( ) ; Arrays . sort ( arr ) ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i + n / 2 < n ; i ++ ) { ans = Math . min ( arr [ i + n / 2 ] - arr [ i ] , ans ) ; } 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 . 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 n = in . nextInt ( ) ; Integer [ ] x = new Integer [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = in . nextInt ( ) ; } Arrays . sort ( x ) ; int m = n / 2 ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < m ; i ++ ) { ans = Math . min ( ans , x [ i + m ] - x [ i ] ) ; } out . println ( ans ) ; }   }   static class InputReader { private StringTokenizer tokenizer ; private BufferedReader reader ;   public InputReader ( InputStream inputStream ) { reader = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; }   private void fillTokenizer ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } }   public String next ( ) { fillTokenizer ( ) ; return tokenizer . nextToken ( ) ; }   public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   } }


import java . io . * ; import java . util . * ;   public class Main {    public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ;   int N = in . nextInt ( ) ;   int [ ] vals = new int [ N ] ;   for ( int i = 0 ; i < N ; i ++ ) vals [ i ] = in . nextInt ( ) ;   Arrays . sort ( vals ) ;   if ( N == 2 ) { System . out . println ( vals [ 1 ] - vals [ 0 ] ) ; return ; }   int interval = N / 2 ;   int min1 = 0 ; int min2 = 0 ; int min = 0 ;   for ( int i = 0 ; i + interval < N ; i ++ ) { if ( min == 0 || vals [ i + interval ] - vals [ i ] < min ) { min1 = i ; min2 = i + interval ; min = vals [ i + interval ] - vals [ i ] ;   } }    System . out . println ( min ) ;    } }


import java . io . * ;   public class Main { static final int N = 110 ; static int n , m ; static String [ ] input ; static char [ ] [ ] g = new char [ N ] [ N ] ; static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ;   public static void main ( String [ ] args ) throws IOException { input = br . readLine ( ) . split ( " ▁ " ) ; n = Integer . parseInt ( input [ 0 ] ) ; m = Integer . parseInt ( input [ 1 ] ) ; for ( int i = 0 ; i < n ; ++ i ) { g [ i ] = br . readLine ( ) . toCharArray ( ) ; } char t = ' ▁ ' ; boolean flag = true ; for ( int i = 0 ; i < n ; ++ i ) { if ( i != 0 && t == g [ i ] [ 0 ] ) { flag = false ; break ; } t = g [ i ] [ 0 ] ; for ( int j = 1 ; j < m ; ++ j ) { if ( t != g [ i ] [ j ] ) { flag = false ; break ; } } if ( ! flag ) { break ; } } bw . write ( flag ? " YES " : " NO " ) ; bw . close ( ) ; } }

''' Jana ▁ Goodman6 16A ▁ Flag n ▁ x ▁ m ▁ squares ▁ ( 1 . . 100)10 ▁ colors horizontal ▁ rows ▁ all ▁ same ▁ coloradjacent ▁ rows ▁ different ▁ colors   ''' SPACE = ' ▁ '   def all_same ( s ) : return s . count ( s [ 0 ] ) == len ( s )   def answer ( stripes , height , width ) : prev = ' x ' for s in stripes : if s [ 0 ] == prev or not all_same ( s ) : return ' NO ' prev = s [ 0 ] return ' YES '   if __name__ == ' _ _ main _ _ ' : rows , cols = map ( int , input ( ) . split ( SPACE ) ) stripes = [ ] for _ in range ( 0 , rows ) : stripes . append ( input ( ) . strip ( ) )   print ( answer ( stripes , rows , cols ) ) NEW_LINE


n , m = [ int ( j ) for j in input ( ) . split ( ) ] output = " YES " prev = str ( input ( ) ) if prev . count ( prev [ 0 ] ) != m : output = " NO " for j in range ( n - 1 ) : s = str ( input ( ) ) if s . count ( s [ 0 ] ) != m or s [ 0 ] == prev [ 0 ] : output = " NO " prev = sprint ( output ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) ) li = [ ] for i in range ( n ) : li . append ( list ( map ( int , input ( ) ) ) )   if li [ 0 ] . count ( li [ 0 ] [ 0 ] ) != m : print ( ' NO ' ) else : for row in range ( 1 , len ( li ) ) :   if li [ row ] . count ( li [ row ] [ 0 ] ) != m : print ( ' NO ' ) break if li [ row - 1 ] == li [ row ] : print ( ' NO ' ) break else : print ( ' YES ' ) NEW_LINE


''' n , ▁ m ▁ = ▁ [ int ( item ) ▁ for ▁ item ▁ in ▁ input ( ) . split ( ' ▁ ' ) ] ans ▁ = ▁ ' YES ' cont ▁ = ▁ [ ]   def ▁ check ( s ) : ▁ ▁ ▁ ▁ for ▁ i ▁ in ▁ range ( len ( s ) ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ if ▁ s [ 0 ] ▁ ! = ▁ s [ i ] : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ return ▁ False ▁ ▁ ▁ ▁ return ▁ True  for ▁ i ▁ in ▁ range ( n ) : ▁ ▁ ▁ ▁ cont . append ( input ( ) ) ▁ ▁ ▁ ▁ if ▁ not ▁ check ( cont [ i ] ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ans ▁ = ▁ ' NO ' ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ break if ▁ ans ▁ ! = ▁ ' NO ' : ▁ ▁ ▁ ▁ for ▁ j ▁ in ▁ range ( n ▁ - ▁ 1 ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ s1 ▁ = ▁ cont [ j ] ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ s2 ▁ = ▁ cont [ j ▁ + ▁ 1 ] ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ if ▁ s1[0:1 ] ▁ = = ▁ s2[0:1 ] : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ans ▁ = ▁ ' NO ' ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ break print ( ans ) ''' n , m = [ int ( item ) for item in input ( ) . split ( ' ▁ ' ) ] prev , ans = ' ' , ' YES ' for i in range ( n ) : current = input ( ) if current == prev or current . count ( current [ 0 ] ) != m : ans = ' NO ' break prev = current   print ( ans ) NEW_LINE


def all_same ( s ) : return len ( set ( s ) ) == 1     def solve ( flag ) :   for row in flag : if not all_same ( row ) : return " NO " for i in range ( len ( flag ) - 2 ) : if flag [ i ] == flag [ i + 1 ] : return " NO " return " YES "   rows , cols = map ( int , input ( ) . split ( ) ) flag = [ ] for row in range ( rows ) : row = input ( ) flag . append ( row )     print ( solve ( flag ) ) NEW_LINE


import java . io . FileInputStream ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Collection ; import java . util . List ; import java . util . Scanner ; import java . util . TreeSet ; import java . util . function . Function ; import java . util . stream . Collectors ; public class _p000016A { static public void main ( final String [ ] args ) throws IOException { p000016A . _main ( args ) ; }


public class Flag { public static void main ( String [ ] args ) { try ( java . util . Scanner sc = new java . util . Scanner ( System . in ) ) { int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ;   int [ ] [ ] mm = new int [ n ] [ m ] ;   for ( int i = 0 ; i < n ; i ++ ) { String [ ] aa = sc . next ( ) . split ( " " ) ; for ( int j = 0 ; j < aa . length ; j ++ ) { mm [ i ] [ j ] = Integer . parseInt ( aa [ j ] ) ; } }   boolean isOK = true ;   for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 1 ; j < m ; j ++ ) { if ( mm [ i - 1 ] [ j ] == mm [ i ] [ j ] ) { isOK = false ; } } }   if ( isOK ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 1 ; j < m ; j ++ ) { if ( mm [ i ] [ j - 1 ] != mm [ i ] [ j ] ) { isOK = false ; } } } } System . out . println ( isOK ? " YES " : " NO " ) ; } } }


import java . awt . Label ; import java . util . * ;   public class JavaApplication23 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ;   boolean check = true ; int n , m , index = 0 ; n = in . nextInt ( ) ; m = in . nextInt ( ) ;   String [ ] a = new String [ n ] ; int integer [ ] = new int [ n ] ;   while ( n != 0 ) { a [ index ] = in . next ( ) ; for ( int i = 0 ; i < a [ index ] . length ( ) - 1 ; i ++ ) { if ( a [ index ] . charAt ( i ) != a [ index ] . charAt ( i + 1 ) ) { check = false ; break ; } } index ++ ; n -- ; } if ( check ) { ConvertStringToInteger ( a , integer ) ; for ( int i = 1 ; i < integer . length - 1 ; i ++ ) { if ( ! ( integer [ i - 1 ] != integer [ i ] && integer [ i ] != integer [ i + 1 ] ) ) { check = false ; break ; } }   }   if ( check ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } }   public static void ConvertStringToInteger ( String [ ] a , int [ ] num ) { for ( int i = 0 ; i < a . length ; i ++ ) { for ( int j = 0 ; j < a [ i ] . length ( ) ; j ++ ) { num [ i ] += ( int ) a [ i ] . charAt ( j ) ; } } } }