from collections import defaultdictn , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) d = defaultdict ( int ) for i in range ( n ) : d [ a [ i ] ] += 1 if d [ a [ i ] ] > k : print ( ' NO ' ) exit ( ) ans = [ - 1 for i in range ( n ) ] d = defaultdict ( int ) for j in range ( n ) : y = a [ j ] d [ y ] += 1   t = [ ] for i in range ( n ) : t . append ( [ d [ a [ i ] ] , a [ i ] , i ] ) t . sort ( key = lambda x : x [ 1 ] , reverse = True ) t . sort ( key = lambda x : x [ 0 ] , reverse = True ) c = 0 for i in range ( n ) : c += 1 x = t [ i ] [ 2 ] ans [ x ] = c if c == k : c = 0   print ( ' YES ' ) print ( * ans ) NEW_LINE


import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class temp4 { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } static class Print { private final BufferedWriter bw ; public Print ( ) { bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; } public void print ( String str ) throws IOException { bw . append ( str ) ; } public void println ( String str ) throws IOException { print ( str ) ; bw . append ( " \n " ) ; } public void close ( ) throws IOException { bw . close ( ) ; } } public static void main ( String [ ] args ) throws IOException { FastReader scn = new FastReader ( ) ;

from sys import stdin , stdoutinput = stdin . readline def main ( ) : n , k = map ( int , input ( ) . split ( ) ) ar = [ 1 ] * 5001 ai = list ( map ( int , input ( ) . split ( ) ) ) ans = [ 0 ] * n for i in range ( n ) : ans [ i ] = ar [ ai [ i ] ] ar [ ai [ i ] ] += 1 if ans [ i ] > k : print ( " NO " ) return temp = max ( ans ) if temp < k : ar = [ 0 ] * 5000 ar2 = [ ] for i in range ( n ) : if ar [ ans [ i ] - 1 ] : ar2 += [ i ] ar [ ans [ i ] - 1 ] = 1 z = 1 for j in range ( temp + 1 , k + 1 ) : ans [ ar2 [ z - 1 ] ] = j z += 1 print ( " YES " ) print ( * ans ) main ( )   NEW_LINE


n , k = [ * map ( int , input ( ) . split ( ) ) ] l = [ * map ( int , input ( ) . split ( ) ) ] d = { } for i in range ( n ) : if l [ i ] in d : d [ l [ i ] ] = d [ l [ i ] ] + 1 else : d [ l [ i ] ] = 1 if max ( d . values ( ) ) > k or k > n : print ( ' NO ' ) else : print ( ' YES ' ) li = [ ] for i in range ( n ) : li . append ( [ l [ i ] , i ] ) li . sort ( key = lambda x : x [ 0 ] ) la = [ ] for i in range ( n ) : la . append ( [ i % k + 1 , li [ i ] [ 1 ] ] ) la . sort ( key = lambda x : x [ 1 ] ) for i in range ( n ) : print ( la [ i ] [ 0 ] , end = ' ▁ ' ) NEW_LINE


from collections import Countern , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) d = Counter ( a ) if max ( d . values ( ) ) > k : print ( " NO " ) else : print ( " YES " ) b = sorted ( ( x , i ) for ( i , x ) in enumerate ( a ) ) count = 0 ans = [ 0 ] * n for x , i in b : count = count % k + 1 ans [ i ] = count print ( * ans ) NEW_LINE


from collections import defaultdictn , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) d = defaultdict ( int ) for i in range ( n ) : d [ a [ i ] ] += 1 if d [ a [ i ] ] > k : print ( ' NO ' ) exit ( ) ''' m = max ( a )  for ▁ i ▁ in ▁ range ( 1 , m + 1 ) : ▁ ▁ ▁ ▁ if ▁ d [ i ] = = 0 : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( ' NO ' ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ exit ( ) ''' ans = [ - 1 for i in range ( n ) ] d = defaultdict ( int ) for j in range ( n ) : y = a [ j ] d [ y ] += 1   t = [ ] for i in range ( n ) : t . append ( [ d [ a [ i ] ] , a [ i ] , i ] ) t . sort ( key = lambda x : x [ 1 ] , reverse = True ) t . sort ( key = lambda x : x [ 0 ] , reverse = True ) c = 0 for i in range ( n ) : c += 1 x = t [ i ] [ 2 ] ans [ x ] = c if c == k : c = 0   print ( ' YES ' ) print ( * ans ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import static java . lang . Math . * ; import static java . lang . System . out ; import java . util . * ; import java . io . PrintStream ; import java . io . PrintWriter ; public class A { static final int N = ( int ) ( 1e5 + 100 ) ; static final int mod = 1000000007 ; static final long temp = 998244353 ; static final long MOD = 1000000007 ; static final long M = ( long ) 1e9 + 7 ; static class Pair implements Comparable < Pair > { int first , second ; public Pair ( int aa , int bb ) { first = aa ; second = bb ; } public int compareTo ( Pair o ) { return o . first - this . first ; } } static class Tuple implements Comparable < Tuple > { long first , second , third ; public Tuple ( long first , long second , long third ) { this . first = first ; this . second = second ; this . third = third ; } public int compareTo ( Tuple o ) { return ( int ) ( o . third - this . third ) ; } } public static class DSU { int [ ] parent ; int [ ] rank ;


import java . util . * ;    public class l700 {   public static void main ( String [ ] args ) {

n , m = input ( ) . split ( ) n , m = int ( n ) , int ( m ) string = input ( ) iterator = [ ] for i in range ( m ) : l , r , c1 , c2 = input ( ) . split ( ) l , r = int ( l ) - 1 , int ( r ) - 1 iterator . append ( ( l , r , c1 , c2 ) ) for step in iterator : l , r , c1 , c2 = step [ 0 ] , step [ 1 ] , step [ 2 ] , step [ 3 ] for k in range ( l , r + 1 ) : if string [ k ] == c1 : string = string [ 0 : k ] + c2 + string [ k + 1 : len ( string ) ] print ( string ) NEW_LINE


string_length , test_case = map ( int , input ( ) . split ( ) ) st = list ( input ( ) )     for x in range ( test_case ) : start , end , frm , to = map ( str , input ( ) . split ( ) ) for y in range ( int ( start ) - 1 , int ( end ) ) : if st [ y ] == frm : st [ y ] = toprint ( " " . join ( st ) ) NEW_LINE


import sys   def main ( ) : inp = sys . stdin . read ( ) . strip ( ) . split ( ' \n ' ) s = inp [ 1 ] for i in inp [ 2 : ] : r , l , c , d = i . split ( ) r , l = int ( r ) - 1 , int ( l ) - 1 s = s [ : r ] + s [ r : l + 1 ] . replace ( c , d ) + s [ l + 1 : ] return s print ( main ( ) ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) ) str1 = input ( ) . lower ( ) for j in range ( m ) : l , r , c1 , c2 = input ( ) . split ( ) l , r = ( int ( l ) - 1 ) , int ( r ) l1 = [ i for i in str1 ] for p in range ( l , r ) : if l1 [ p ] == c1 : l1 [ p ] = c2 s = " " str1 = s . join ( l1 ) print ( str1 ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) ) s = list ( input ( ) ) for i in range ( m ) : a , b , c , d = map ( str , input ( ) . split ( ) ) a = int ( a ) b = int ( b ) if a == b : if s [ a - 1 ] == c : s [ a - 1 ] = d else : for j in range ( a - 1 , b ) : if s [ j ] == c : s [ j ] = dfor i in s : print ( i , end = ' ' ) NEW_LINE


import java . util . * ; public class problem { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; String s = sc . next ( ) ; char [ ] a = new char [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = s . charAt ( i ) ; } int l , r ; char c1 , c2 ; for ( int i = 0 ; i < m ; i ++ ) { l = sc . nextInt ( ) ; r = sc . nextInt ( ) ; c1 = sc . next ( ) . charAt ( 0 ) ; c2 = sc . next ( ) . charAt ( 0 ) ; for ( int j = l - 1 ; j <= r - 1 ; j ++ ) { if ( a [ j ] == c1 ) { a [ j ] = c2 ; } } } for ( int j = 0 ; j < n ; j ++ ) { System . out . print ( a [ j ] ) ; } } }


import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int m = s . nextInt ( ) ; s . nextLine ( ) ; String input = s . nextLine ( ) ; String result = " " , result1 = " " ; for ( int i = 0 ; i < m ; i ++ ) { int l = s . nextInt ( ) ; int r = s . nextInt ( ) ; l = l - 1 ; r = r - 1 ; result = " " ; char c1 = s . next ( ) . charAt ( 0 ) ; char c2 = s . next ( ) . charAt ( 0 ) ; for ( int y = 0 ; y < input . length ( ) ; y ++ ) { if ( y >= l && y <= r ) { if ( input . charAt ( y ) == c1 ) { result = result + c2 ; } else result = result + input . charAt ( y ) ; } else result = result + input . charAt ( y ) ; } input = result ; } System . out . println ( result ) ; } }


import java . io . * ; import java . util . * ;   public class GFG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int t = sc . nextInt ( ) ;


import java . util . Scanner ;   public class Singleton_Pattern { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; sc . nextLine ( ) ; String s = sc . nextLine ( ) ; StringBuilder string = new StringBuilder ( s ) ; for ( int i = 0 ; i < m ; i ++ ) { int l = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; char c1 = sc . next ( ) . charAt ( 0 ) ; char c2 = sc . next ( ) . charAt ( 0 ) ; sc . nextLine ( ) ; Character c3 = Character . valueOf ( c1 ) ; Character c4 = Character . valueOf ( c2 ) ;    for ( int j = l - 1 ; j <= r - 1 ; j ++ ) { Character c5 = Character . valueOf ( string . charAt ( j ) ) ; boolean res = c3 . equals ( c5 ) ; if ( res == true ) string . setCharAt ( j , c2 ) ; }   } System . out . println ( string ) ;   } }


import java . util . Scanner ; public class Word { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String ch = s . next ( ) ; String ch1 = " " ; String ch2 = " " ; boolean aux = true ; if ( Character . isLowerCase ( ch . charAt ( 0 ) ) ) { for ( int i = 1 ; i < ch . length ( ) ; i ++ ) { if ( Character . isLowerCase ( ch . charAt ( i ) ) ) { aux = false ; break ; } } if ( aux == false ) { System . out . println ( ch ) ; } else { ch1 = ch1 + Character . toUpperCase ( ch . charAt ( 0 ) ) ; for ( int i = 1 ; i < ch . length ( ) ; i ++ ) { ch1 = ch1 + Character . toLowerCase ( ch . charAt ( i ) ) ; } System . out . println ( ch1 ) ; } } else { for ( int i = 1 ; i < ch . length ( ) ; i ++ ) { if ( Character . isLowerCase ( ch . charAt ( i ) ) ) { aux = false ; break ; } } if ( aux == false ) { System . out . println ( ch ) ; } else { ch2 = ch2 + Character . toLowerCase ( ch . charAt ( 0 ) ) ; for ( int i = 1 ; i < ch . length ( ) ; i ++ ) { ch2 = ch2 + Character . toLowerCase ( ch . charAt ( i ) ) ; } System . out . println ( ch2 ) ; } } } }

s = input ( ) x , up , low , st = len ( s ) , 0 , 0 , " " for i in range ( 1 , x ) : if ( ord ( s [ i ] ) > 90 ) : low += 1 else : up += 1 if ( up == ( len ( s ) - 1 ) or len ( s ) == 1 ) : st += s . swapcase ( ) print ( st ) else : print ( s ) NEW_LINE


def compute ( string ) :   if string . isupper ( ) or string [ 1 : ] . isupper ( ) or len ( string ) == 1 : answer = " " for character in string : if character . isupper ( ) : answer += character . lower ( ) else : answer += character . upper ( ) return answer else : return string   if __name__ == ' _ _ main _ _ ' : string = input ( ) print ( compute ( string ) ) NEW_LINE


s = input ( ) ans = sif len ( s ) == 1 or s [ 1 : ] . isupper ( ) : ans = ' ' for c in s : ans += ( c . upper ( ) if c . islower ( ) else c . lower ( ) )   print ( ans ) NEW_LINE


s = input ( ) ; print ( [ s , s . swapcase ( ) ] [ s [ 1 : ] == s [ 1 : ] . upper ( ) ] ) NEW_LINE


s = input ( ) x , up , low , st = len ( s ) , 0 , 0 , " " for i in range ( 1 , x ) : if ( ord ( s [ i ] ) > 90 ) : low += 1 else : up += 1 if ( up == ( len ( s ) - 1 ) or len ( s ) == 1 ) : st += s [ 0 ] . swapcase ( ) i = 1 for i in range ( x ) : if ( i > 0 ) : st += s [ i ] . swapcase ( ) print ( st ) else : print ( s ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String ch ; do { ch = s . next ( ) ; } while ( ( ch . length ( ) < 1 ) && ( ch . length ( ) > 100 ) ) ; if ( ch . equals ( ch . toUpperCase ( ) ) ) { System . out . println ( ch . toLowerCase ( ) ) ; } else if ( Character . isLowerCase ( ch . charAt ( 0 ) ) && ( ch . substring ( 1 ) ) . equals ( ( ch . substring ( 1 ) ) . toUpperCase ( ) ) ) { System . out . println ( Character . toUpperCase ( ch . charAt ( 0 ) ) + ( ch . substring ( 1 ) ) . toLowerCase ( ) ) ; } else { System . out . println ( ch ) ; } } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class cAPS_lOCK { static class RealScanner { 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 ( ) ) ; } }   public static void main ( String [ ] args ) { RealScanner sc = new RealScanner ( ) ; String s = sc . next ( ) ; boolean check = true ; char ch ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( Character . isLowerCase ( s . charAt ( i ) ) ) { check = false ; } } if ( check ) { for ( int j = 0 ; j < s . length ( ) ; j ++ ) { if ( Character . isLowerCase ( s . charAt ( j ) ) ) { ch = Character . toUpperCase ( s . charAt ( j ) ) ; } else { ch = Character . toLowerCase ( s . charAt ( j ) ) ; } System . out . print ( ch ) ; } } else { System . out . print ( s ) ; } } }


import java . util . Scanner ;   public class CapsLock { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; boolean flag = true ; if ( str . length ( ) == 1 ) { char ch [ ] = str . toCharArray ( ) ;


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


import java . io . * ; import java . math . * ; import java . util . * ; import java . text . * ;   public class Main { private static FastIO sc ;   public static void main ( String [ ] args ) { sc = new FastIO ( System . in , System . out ) ; int n = sc . readInt ( ) , k = sc . readInt ( ) ; ArrayList < IntIntPair > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( IntIntPair . makePair ( sc . readInt ( ) , i + 1 ) ) ; } Collections . sort ( list ) ; List < Integer > indexes = new ArrayList < > ( ) ; for ( IntIntPair c : list ) { if ( c . first <= k ) { indexes . add ( c . second ) ; k -= c . first ; } } sc . println ( indexes . size ( ) ) ; for ( Integer c : indexes ) sc . printls ( c ) ; sc . close ( ) ; }   static void printPrecision ( double d ) { DecimalFormat ft = new DecimalFormat ( "0.00000000000" ) ;

n , k = map ( int , input ( ) . split ( ) ) arr = sorted ( list ( zip ( range ( n ) , ( map ( int , input ( ) . split ( ) ) ) ) ) , key = lambda x : x [ 1 ] ) ans = [ ] i = 0 while k - arr [ i ] [ 1 ] >= 0 : k -= arr [ i ] [ 1 ] ans . append ( arr [ i ] [ 0 ] + 1 ) i += 1 if i == n : breakprint ( len ( ans ) ) print ( * ans ) NEW_LINE


import sysfrom os import pathif ( path . exists ( ' input . txt ' ) ) : sys . stdin = open ( " input . txt " , " r " ) sys . stdout = open ( " output . txt " , " w " )       n , k = [ int ( x ) for x in input ( ) . split ( ) ] a = [ int ( x ) for x in input ( ) . split ( ) ]   d = { } for i in range ( n ) : d [ i ] = a [ i ]   dict ( sorted ( d . items ( ) , key = lambda item : item [ 1 ] ) )   a . sort ( ) ; sum = 0 ; res = [ ] for i in a : sum += i if sum > k : break res . append ( i ) print ( len ( res ) ) ; for i in res : print ( list ( d . keys ( ) ) [ list ( d . values ( ) ) . index ( i ) ] + 1 , end = " ▁ " ) d [ ( list ( d . keys ( ) ) [ list ( d . values ( ) ) . index ( i ) ] ) ] = 0 NEW_LINE


n , k = list ( map ( int , input ( ) . split ( ) ) ) a = list ( map ( int , input ( ) . split ( ) ) ) d = { } ans = [ ]   for i in range ( len ( a ) ) : d [ i + 1 ] = a [ i ]   x = list ( d . values ( ) ) x . sort ( )   for i in x : k -= i if k >= 0 : ans . append ( list ( d . values ( ) ) . index ( i ) + 1 ) d [ list ( d . values ( ) ) . index ( i ) + 1 ] = 0 else : break 	 	   print ( len ( ans ) ) for i in ans : print ( i , end = ' ▁ ' ) NEW_LINE


from __future__ import division , print_functionfrom collections import * from math import * from itertools import * import osimport sysfrom io import BytesIO , IOBaseimport math   if sys . version_info [ 0 ] < 3 : from __builtin__ import xrange as range from future_builtins import ascii , filter , hex , map , oct , zip       def main ( ) : n , k = map ( int , input ( ) . split ( ) ) t = list ( map ( int , input ( ) . split ( ) ) ) arr = [ ] s = 0 while ( k >= 0 ) : try : k -= min ( t ) except : break if k < 0 : break arr . append ( t . index ( min ( t ) ) + 1 ) t . insert ( t . index ( min ( t ) ) + 1 , 123321 ) t . pop ( t . index ( min ( t ) ) ) s += 1 print ( s ) arr . sort ( ) arr = list ( map ( str , arr ) ) print ( " ▁ " . join ( arr ) )                     NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int k = in . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = in . nextInt ( ) ; StringBuffer sb = new StringBuffer ( ) ; int c = 0 ; while ( k > 0 ) { int min = Integer . MAX_VALUE , p = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] < min ) { min = a [ i ] ; p = i ; } } k -= min ; if ( k >= 0 ) { c ++ ; a [ p ] = Integer . MAX_VALUE ; p = p + 1 ; sb . append ( p + " ▁ " ) ; } } System . out . println ( c ) ; System . out . println ( sb ) ; } }


import java . util . Arrays ; import java . util . Scanner ;   public class AmrMusic { public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) , k = in . nextInt ( ) , i , a [ ] [ ] = new int [ n ] [ 2 ] , c = 0 , d = 0 ; String s = " " ;   for ( i = 0 ; i < n ; i ++ ) { a [ i ] [ 0 ] = in . nextInt ( ) ; a [ i ] [ 1 ] = i + 1 ; } in . close ( ) ; Arrays . sort ( a , ( x , y ) -> Integer . compare ( x [ 0 ] , y [ 0 ] ) ) ;   for ( i = 0 ; i < n ; i ++ ) { if ( c + a [ i ] [ 0 ] <= k ) { c += a [ i ] [ 0 ] ; d ++ ; s += a [ i ] [ 1 ] + " ▁ " ; } } System . out . println ( d + " \n " + s ) ; } }


import java . util . * ; import java . io . * ; import java . lang . * ; import java . math . * ;   public class cp { static BufferedReader br ; static StringTokenizer st ;   public static void main ( String [ ] args ) throws IOException {   br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; List < Integer > answer = new ArrayList < Integer > ( ) ;


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

print ( max ( abs ( a - b ) for a , b in zip ( * [ map ( int , input ( ) . split ( ) ) for _ in ( 1 , 2 ) ] ) ) ) NEW_LINE


x , y = map ( int , input ( ) . split ( ) ) xx , yy = map ( int , input ( ) . split ( ) ) dx = abs ( xx - x ) dy = abs ( yy - y ) print ( max ( dx , dy ) ) NEW_LINE


x1 , y1 = map ( int , input ( ) . split ( ) ) x2 , y2 = map ( int , input ( ) . split ( ) ) print ( max ( abs ( x1 - x2 ) , abs ( y1 - y2 ) ) ) NEW_LINE


x1 , y1 = map ( int , input ( ) . split ( ) ) x2 , y2 = map ( int , input ( ) . split ( ) )   print ( max ( abs ( x1 - x2 ) , abs ( y1 - y2 ) ) ) NEW_LINE


x , y = map ( int , input ( ) . split ( ' ▁ ' ) ) a , b = map ( int , input ( ) . split ( ' ▁ ' ) ) print ( max ( abs ( x - a ) , abs ( b - y ) ) ) NEW_LINE


import java . util . * ; import java . util . Scanner ; import java . io . * ; import javax . lang . model . util . ElementScanner6 ; import static java . lang . System . out ;    public class A620 {   public static void main ( String args [ ] ) {   FastReader in = new FastReader ( ) ; PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; int tc = 1 ;


import java . io . File ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . PrintWriter ; import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int x1 = input . nextInt ( ) ; int y1 = input . nextInt ( ) ; int x2 = input . nextInt ( ) ; int y2 = input . nextInt ( ) ; System . out . println ( Math . max ( Math . abs ( x1 - x2 ) , Math . abs ( y2 - y1 ) ) ) ; } }


import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long x1 , y1 , x2 , y2 , m , x3 , y3 ; x1 = in . nextLong ( ) ; y1 = in . nextLong ( ) ; x2 = in . nextLong ( ) ; y2 = in . nextLong ( ) ; x3 = Math . abs ( x2 - x1 ) ; y3 = Math . abs ( y2 - y1 ) ; if ( y3 >= x3 ) { m = y3 ; System . out . println ( m ) ; } else { m = x3 ; System . out . println ( m ) ; } } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . PriorityQueue ; import java . util . Random ; import java . util . StringTokenizer ;   public class Solution { static FastScanner fs = new FastScanner ( ) ; static PrintWriter out = new PrintWriter ( System . out ) ; static int n , d ; public static void main ( String [ ] args ) throws IOException {

import sys   def ask ( x ) : print ( ' ? ▁ % d ' % x ) sys . stdout . flush ( ) x = int ( input ( ) ) return x   n = int ( input ( ) ) t = n // 2 if t & 1 : print ( ' ! ▁ - 1' ) sys . stdout . flush ( ) sys . exit ( ) l = 1 r = nwhile l < r : mid = ( l + r ) >> 1 if ask ( mid ) >= ask ( ( mid + t - 1 ) % n + 1 ) : r = mid else : l = mid + 1 print ( ' ! ▁ % d ' % l ) sys . stdout . flush ( ) NEW_LINE


from sys import stdout       n = int ( input ( ) )   if n % 4 == 2 :   print ( " ! ▁ - 1" )   exit ( 0 )   print ( " ? " , 1 )   stdout . flush ( )   a = int ( input ( ) )   print ( " ? " , 1 + n // 2 )   stdout . flush ( )   b = int ( input ( ) )   if a == b :   print ( " ! " , 1 )   exit ( 0 )   l = 1   r = 1 + n // 2   while ( l != r ) :   mid = ( l + r ) // 2   print ( " ? " , mid )   stdout . flush ( )   c = int ( input ( ) )   print ( " ? " , mid + n // 2 )   stdout . flush ( )   d = int ( input ( ) )   if c == d :   print ( " ! " , mid )   exit ( 0 )   if a < b :   if c < d :   l = mid + 1   else :   r = mid   else :   if c > d :   l = mid + 1   else :   r = mid   print ( " ! " , l )       NEW_LINE


class Solver : def solve ( self ) : self . num_people = int ( input ( ) )   if self . num_people % 4 == 2 : return - 1   return self . find_zero_pair ( )   def find_zero_pair ( self ) : begin = 1 end = self . num_people // 2 + 1   begin_value = self . func ( begin ) if begin_value == 0 : return begin   while begin < end : mid = ( begin + end ) // 2 mid_value = self . func ( mid ) if mid_value == 0 : return mid elif begin_value * mid_value > 0 : begin = mid + 1 else : end = mid - 1   return begin   def func ( self , pos ) : opposite = ( pos - 1 + self . num_people // 2 ) % self . num_people + 1 return self . get_value ( pos ) - self . get_value ( opposite )   def get_value ( self , pos ) : print ( ' ? ▁ { } ' . format ( pos ) ) value = int ( input ( ) ) return value   solver = Solver ( ) pair = solver . solve ( ) print ( ' ! ▁ { } ' . format ( pair ) ) NEW_LINE


import java . util . * ; import java . util . stream . * ; public class Solution { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; List < String > rat = new ArrayList < > ( ) ; List < String > womanChild = new ArrayList < > ( ) ; List < String > man = new ArrayList < > ( ) ; String captain = " " ; int n = scan . nextInt ( ) ; scan . nextLine ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] info = scan . nextLine ( ) . split ( " ▁ " ) ; if ( info [ 1 ] . equals ( " rat " ) ) { rat . add ( info [ 0 ] ) ; } if ( info [ 1 ] . equals ( " woman " ) || info [ 1 ] . equals ( " child " ) ) { womanChild . add ( info [ 0 ] ) ; } if ( info [ 1 ] . equals ( " man " ) ) { man . add ( info [ 0 ] ) ; } if ( info [ 1 ] . equals ( " captain " ) ) { captain = info [ 0 ] ; } } for ( String elem : rat ) { System . out . println ( elem ) ; } for ( String elem : womanChild ) { System . out . println ( elem ) ; } for ( String elem : man ) { System . out . println ( elem ) ; } System . out . println ( captain ) ; } }

import sysfrom NEW_LINE functools NEW_LINE import lru_cache , cmp_to_keyfrom NEW_LINE heapq NEW_LINE import merge , heapify , heappop , heappushfrom NEW_LINE math NEW_LINE import * from collections NEW_LINE import defaultdict as dd , deque , Counter as Cfrom NEW_LINE itertools NEW_LINE import combinations as comb , permutations as permfrom NEW_LINE bisect NEW_LINE import bisect_left as bl , bisect_right as br , bisect , insortfrom NEW_LINE time NEW_LINE import perf_counterfrom NEW_LINE fractions NEW_LINE import Fractionimport NEW_LINE copyfrom NEW_LINE copy NEW_LINE import deepcopyimport NEW_LINE timestarttime = time . time ( ) NEW_LINE mod = int ( pow ( 10 , 9 ) + 7 ) NEW_LINE mod2 = 998244353   NEW_LINE def data ( ) : return sys . stdin . readline ( ) . strip ( ) NEW_LINE def out ( * var , end = " \n " ) : sys . stdout . write ( ' ▁ ' . join ( map ( str , var ) ) + end ) NEW_LINE def L ( ) : return list ( sp ( ) ) NEW_LINE def sl ( ) : return list ( ssp ( ) ) NEW_LINE def sp ( ) : return map ( int , data ( ) . split ( ) ) NEW_LINE def ssp ( ) : return map ( str , data ( ) . split ( ) ) NEW_LINE def l1d ( n , val = 0 ) : return [ val for i in range ( n ) ] NEW_LINE def l2d ( n , m , val = 0 ) : return [ l1d ( n , val ) for j in range ( m ) ] NEW_LINE try : NEW_LINE


prioridades = [ ] NEW_LINE tipos = [ ]   nombres = [ ]   n = int ( input ( ) ) NEW_LINE for i in range ( n ) : nombre , tipo = input ( ) . split ( ) NEW_LINE prioridad = 5 NEW_LINE if tipo == ' rat ' : NEW_LINE INDENT prioridad = 1 elif tipo == ' woman ' or tipo == ' child ' : NEW_LINE prioridad = 2 elif tipo == ' man ' : NEW_LINE prioridad = 3 else : NEW_LINE prioridad = 4 NEW_LINE DEDENT j = 0 NEW_LINE while j < len ( prioridades ) : if NEW_LINE prioridad < prioridades [ j ] : NEW_LINE break NEW_LINE j = j + 1 NEW_LINE prioridades . insert ( j , prioridad ) NEW_LINE nombres . insert ( j , nombre ) NEW_LINE for k in range ( n ) : print ( nombres [ k ] ) NEW_LINE


def solve ( arr , n ) : d = { ' rat ' : 0 , ' woman ' : 1 , ' child ' : 1 , ' man ' : 2 , ' captain ' : 3 } NEW_LINE for i in range ( 1 , n ) : j = i - 1 NEW_LINE key = arr [ i ] [ : ] NEW_LINE while j >= 0 and d [ arr [ j ] [ 1 ] ] > d [ key [ 1 ] ] : arr [ j + 1 ] = arr [ j ] NEW_LINE j -= 1 NEW_LINE arr [ j + 1 ] = key NEW_LINE for i in arr : print ( i [ 0 ] )                                 NEW_LINE def main ( ) : NEW_LINE


n = int ( input ( ) ) NEW_LINE rat = [ ] NEW_LINE men = [ ] NEW_LINE child = [ ] NEW_LINE captain = [ ] NEW_LINE for i in range ( n ) : a , b = input ( ) . split ( ) NEW_LINE if b == ' rat ' : NEW_LINE INDENT rat . append ( a ) elif b == ' child ' : NEW_LINE child . append ( a ) elif b == ' woman ' : NEW_LINE child . append ( a ) elif b == ' man ' : NEW_LINE men . append ( a ) else : NEW_LINE captain . append ( a ) NEW_LINE DEDENT ans = rat + child + men + captainfor NEW_LINE i in ans : print ( i ) NEW_LINE


n = int ( input ( ) ) NEW_LINE crew = [ ] NEW_LINE status = [ " rat " , [ " woman " , " child " ] , " man " , " captain " ] NEW_LINE leave_first = [ ]   for i in range ( n ) : crew . append ( input ( ) )   for i in range ( len ( status ) ) : for NEW_LINE j in range ( n ) : NEW_LINE if ( i == 1 ) : if NEW_LINE INDENT ( crew [ j ] . split ( " ▁ " ) [ 1 ] == status [ 1 ] [ 0 ] ) : leave_first . append ( crew [ j ] . split ( " ▁ " ) [ 0 ] ) elif ( crew [ j ] . split ( " ▁ " ) [ 1 ] == status [ 1 ] [ 1 ] ) : leave_first . append ( crew [ j ] . split ( " ▁ " ) [ 0 ] ) elif ( crew [ j ] . split ( " ▁ " ) [ 1 ] == status [ i ] ) : leave_first . append ( crew [ j ] . split ( " ▁ " ) [ 0 ] )   for i in leave_first : print ( i ) NEW_LINE DEDENT


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   import static java . lang . Integer . lowestOneBit ; import static java . lang . Integer . parseInt ;   public class Example {   public static void main ( String [ ] args ) {    Scanner sc = new Scanner ( System . in ) ;   int n = sc . nextInt ( ) ; String sdsd = sc . nextLine ( ) ; String [ ] [ ] list = new String [ n ] [ 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { String ss = sc . nextLine ( ) ; list [ i ] = ss . split ( " ▁ " ) ; } String s = " rat " ;   for ( int i = 0 ; i < n ; i ++ ) {   if ( list [ i ] [ 1 ] . equals ( s ) ) { System . out . println ( list [ i ] [ 0 ] ) ; }    } String ss = " child " ; for ( int i = 0 ; i < n ; i ++ ) { if ( list [ i ] [ 1 ] . equals ( ss ) || list [ i ] [ 1 ] . equals ( " woman " ) ) { System . out . println ( list [ i ] [ 0 ] ) ; } }    for ( int i = 0 ; i < n ; i ++ ) { if ( list [ i ] [ 1 ] . equals ( " man " ) ) { System . out . println ( list [ i ] [ 0 ] ) ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( list [ i ] [ 1 ] . equals ( " captain " ) ) { System . out . println ( list [ i ] [ 0 ] ) ; } }   }   }


import java . util . * ;   public class CF102 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; List < String > rat = new ArrayList < > ( ) ; List < String > womenc = new ArrayList < > ( ) ; List < String > men = new ArrayList < > ( ) ; List < String > capt = new ArrayList < > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { String name = sc . next ( ) ; String status = sc . next ( ) ; if ( status . equals ( " rat " ) ) { rat . add ( name ) ; } else if ( ( status . equals ( " woman " ) || status . equals ( " child " ) ) ) { womenc . add ( name ) ; } else if ( ( status . equals ( " man " ) ) ) { men . add ( name ) ; } else if ( ( status . equals ( " captain " ) ) ) { capt . add ( name ) ; } }   for ( String ss : rat ) { System . out . println ( ss ) ; } for ( String ss : womenc ) { System . out . println ( ss ) ; } for ( String ss : men ) { System . out . println ( ss ) ; } for ( String ss : capt ) { System . out . println ( ss ) ; }   } }


import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . BufferedWriter ; import java . io . OutputStreamWriter ; import java . io . IOException ; import java . util . ArrayList ; import java . util . Collections ;   public class ObjectSortning_CF_63A { public static class Tripulant implements Comparable < Tripulant > { private String name ; private String type ; public Tripulant ( String name , String type ) { this . name = name ; this . type = type ; } public void setName ( String name ) { this . name = name ; } public void setType ( String type ) { this . type = type ; }   public void convertToNumbers ( Tripulant tripulant ) { if ( tripulant . type . equalsIgnoreCase ( " rat " ) ) { tripulant . setType ( "1" ) ; } else if ( tripulant . type . equalsIgnoreCase ( " woman " ) ) { tripulant . setType ( "2" ) ; } else if ( tripulant . type . equalsIgnoreCase ( " child " ) ) { tripulant . setType ( "2" ) ; } else if ( tripulant . type . equalsIgnoreCase ( " man " ) ) { tripulant . setType ( "3" ) ; } else if ( tripulant . type . equalsIgnoreCase ( " captain " ) ) { tripulant . setType ( "4" ) ; } } @ Override public int compareTo ( Tripulant otherTripulant ) { int ret ; int num1 = Integer . parseInt ( type ) ; int num2 = Integer . parseInt ( otherTripulant . type ) ; if ( num1 < num2 ) { ret = - 1 ; } else if ( num1 > num2 ) { ret = 1 ; } else { ret = 0 ; } return ret ; } } public static void main ( String args [ ] ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ;


import java . util . * ;   public class question { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; if ( s . length ( ) == 1 ) { System . out . println ( s ) ; System . exit ( 0 ) ; } StringBuilder ans = new StringBuilder ( ) ; int i = s . length ( ) - 1 , j = 0 ; if ( ( s . length ( ) & 1 ) == 0 ) { for ( int l = 0 ; l < s . length ( ) / 2 ; l ++ ) { if ( i == j ) { ans . append ( s . charAt ( i ) ) ; break ; } ans . append ( s . charAt ( i ) ) ; i -- ; ans . append ( s . charAt ( j ) ) ; j ++ ; } System . out . println ( ans . reverse ( ) ) ; } else { int mid = s . length ( ) / 2 ; int x = mid , y = mid ; System . out . print ( s . charAt ( mid ) ) ; for ( int l = 0 ; l < mid ; l ++ ) { x ++ ; System . out . print ( s . charAt ( x ) ) ; y -- ; System . out . print ( s . charAt ( y ) ) ; } }   } }

import sysfrom itertools import zip_longestfrom math import ceil   def main ( ) : s = sys . stdin . read ( ) . strip ( ) t = int ( ceil ( len ( s ) / 2 ) ) return ' ' . join ( i + j for i , j in zip_longest ( s [ : t ] [ : : - 1 ] , s [ t : ] , fillvalue = ' ' ) )   print ( main ( ) ) NEW_LINE


n = input ( ) if ( len ( n ) % 2 == 0 ) : c = n [ len ( n ) // 2 - 1 ] s = n [ : len ( n ) // 2 - 1 : ] s = s [ : : - 1 ] t = n [ len ( n ) // 2 : : ] x = min ( len ( s ) , len ( t ) ) for i in range ( x ) : c = c + t [ i ] + s [ i ] if ( x == len ( s ) ) : c = c + t [ - 1 ] else : c = c + s [ - 1 ] print ( c ) else : c = n [ len ( n ) // 2 ] s = n [ : len ( n ) // 2 : ] s = s [ : : - 1 ] t = n [ len ( n ) // 2 + 1 : : ] x = min ( len ( s ) , len ( t ) ) for i in range ( x ) : c = c + t [ i ] + s [ i ] print ( c ) NEW_LINE


import java . lang . * ; import java . util . * ;   public class Main {   public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; StringBuilder t = new StringBuilder ( sc . nextLine ( ) ) ; int n = t . length ( ) ; StringBuilder sb = new StringBuilder ( " " ) ; while ( n != 0 ) { if ( n % 2 == 0 ) { sb . append ( t . charAt ( t . length ( ) - 1 ) ) ; t . deleteCharAt ( t . length ( ) - 1 ) ; } else { sb . append ( t . charAt ( 0 ) ) ; t . deleteCharAt ( 0 ) ; } n -- ;   } System . out . println ( sb . reverse ( ) ) ;   } }


import java . util . * ; public class P2 {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int len = s . length ( ) ; StringBuilder sb = new StringBuilder ( ) ; int p = 0 ; int m = len ; if ( ( s . length ( ) & 1 ) == 0 ) { while ( len > 0 ) { sb . append ( s . charAt ( m - p - 1 ) ) ; sb . append ( s . charAt ( p ) ) ; p ++ ; len -= 2 ; } sb . reverse ( ) ; System . out . println ( sb ) ; } else { while ( len > 0 ) { sb . append ( s . charAt ( p ) ) ; sb . append ( s . charAt ( m - p - 1 ) ) ; p ++ ; len -= 2 ; } sb . reverse ( ) ; sb . deleteCharAt ( 0 ) ; System . out . println ( sb ) ; }   } }


import java . io . * ; import java . lang . * ; import java . util . * ; import java . util . concurrent . * ; import java . util . function . * ;   public class B { public static void main ( String [ ] args ) { int n = in . nextInt ( ) ; long [ ] a = in . nextLongs ( n ) ;


n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) arr = [ 0 ] + arr + [ 0 ] suffmin = [ n + 1 ] * ( n + 2 ) premin = [ 0 ] * ( n + 1 ) st = [ n + 1 ] for i in range ( 1 , n + 1 ) : while arr [ i ] < arr [ st [ - 1 ] ] : suffmin [ st [ - 1 ] ] = i st . pop ( ) st += [ i ] st = [ 0 ] for i in range ( n , 0 , - 1 ) : while arr [ i ] < arr [ st [ - 1 ] ] : premin [ st [ - 1 ] ] = i st . pop ( ) st += [ i ] maxans = [ 0 ] * ( n + 2 ) for i in range ( 1 , n + 1 ) : if maxans [ suffmin [ i ] - premin [ i ] - 1 ] < arr [ i ] : maxans [ suffmin [ i ] - premin [ i ] - 1 ] = arr [ i ] m = arr [ 1 ] for i in range ( 1 , n + 1 ) : if arr [ i ] < m : m = arr [ i ] maxans [ n ] = mfor i in range ( n - 1 , 0 , - 1 ) : if maxans [ i + 1 ] > maxans [ i ] : maxans [ i ] = maxans [ i + 1 ]   print ( * maxans [ 1 : n + 1 ] ) NEW_LINE


n = int ( input ( ) ) ar = list ( map ( int , input ( ) . split ( ) ) ) prev_smaller = [ i + 1 for i in range ( n ) ] next_smaller = [ n + 1 ] * nstack = [ ] for index , value in enumerate ( ar ) : while stack and ar [ stack [ - 1 ] ] >= value : stack . pop ( ) if stack : prev_smaller [ index ] = stack [ - 1 ] + 1 else : prev_smaller [ index ] = 0 stack . append ( index ) NEW_LINE


numFeet = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) stack = [ ] r_arr = [ numFeet ] * ( numFeet + 1 ) l_arr = [ - 1 ] * ( numFeet + 1 ) ans = [ 0 ] * ( numFeet + 1 )   for i in range ( numFeet ) : while stack and arr [ stack [ - 1 ] ] >= arr [ i ] : stack . pop ( ) if stack : l_arr [ i ] = stack [ - 1 ] stack . append ( i ) NEW_LINE


n = int ( input ( ) ) maxn = n + 10 dpl , dpr , ans = [ 0 ] * maxn , [ n + 1 ] * maxn , [ 0 ] * maxna = [ 0 ] a . extend ( list ( map ( int , input ( ) . split ( ) ) ) ) a . append ( 0 )   for i in range ( 1 , n + 1 ) : tmp = i - 1 while ( a [ tmp ] >= a [ i ] ) : tmp = dpl [ tmp ] dpl [ i ] = tmp   for i in range ( n , 0 , - 1 ) : tmp = i + 1 while ( a [ tmp ] >= a [ i ] ) : tmp = dpr [ tmp ] dpr [ i ] = tmp ans [ dpr [ i ] - dpl [ i ] - 1 ] = max ( ans [ dpr [ i ] - dpl [ i ] - 1 ] , a [ i ] )   for i in range ( n , 0 , - 1 ) : ans [ i ] = max ( ans [ i + 1 ] , ans [ i ] )   print ( ' ▁ ' . join ( map ( str , ans [ 1 : n + 1 ] ) ) ) NEW_LINE


import java . io . * ; import java . util . * ; import java . lang . * ; import java . math . * ; import java . text . DecimalFormat ; import java . lang . reflect . Array ; import java . io . BufferedOutputStream ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigDecimal ; public class B { public static PrintWriter out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; static long MOD = ( long ) ( 1e9 + 7 ) ; static long MOD2 = MOD * MOD ;

n , a = map ( int , input ( ) . split ( ) ) x = list ( map ( int , input ( ) . split ( ) ) ) x . sort ( ) print ( 0 if n == 1 else min ( abs ( a - x [ 1 ] ) + x [ n - 1 ] - x [ 1 ] , abs ( a - x [ n - 1 ] ) + x [ n - 1 ] - x [ 1 ] , abs ( a - x [ 0 ] ) + x [ n - 2 ] - x [ 0 ] , abs ( a - x [ n - 2 ] ) + x [ n - 2 ] - x [ 0 ] ) ) NEW_LINE


import osimport sysimport mathimport heapqfrom decimal import * from io import BytesIO , IOBasefrom collections import defaultdict , deque   def r ( ) : return int ( input ( ) ) def rm ( ) : return map ( int , input ( ) . split ( ) ) def rl ( ) : return list ( map ( int , input ( ) . split ( ) ) )   n , a = rm ( ) b = rl ( ) b . sort ( ) if n == 1 : print ( 0 ) elif n == 2 : print ( min ( abs ( a - b [ 0 ] ) , abs ( a - b [ 1 ] ) ) ) elif b [ 0 ] >= a : print ( abs ( a - b [ - 2 ] ) ) elif b [ - 1 ] <= a : print ( abs ( a - b [ 1 ] ) ) else : cal = 0 for i in b : if i <= a : cal += 1 else : break s = abs ( a - b [ 0 ] ) e = abs ( b [ - 1 ] - a ) if cal == 1 : es = abs ( b [ - 2 ] - a ) print ( min ( e , s + es + min ( s , es ) ) ) elif n - cal == 1 : se = abs ( a - b [ 1 ] ) print ( min ( s , e + se + min ( e , se ) ) ) else : es = abs ( b [ - 2 ] - a ) se = abs ( a - b [ 1 ] ) print ( min ( s + es + min ( s , es ) , e + se + min ( e , se ) ) ) NEW_LINE


n , a = map ( int , input ( ) . split ( ) ) x = [ * map ( int , input ( ) . split ( ) ) ] x . sort ( ) if ( n == 1 ) : print ( 0 ) exit ( 0 ) ind = 0 dist1 = min ( abs ( a - x [ n - 1 ] ) , abs ( a - x [ 1 ] ) ) + abs ( x [ n - 1 ] - x [ 1 ] ) dist2 = min ( abs ( a - x [ 0 ] ) , abs ( a - x [ n - 2 ] ) ) + abs ( x [ 0 ] - x [ n - 2 ] ) print ( min ( dist1 , dist2 ) )   NEW_LINE


n , a = map ( int , input ( ) . split ( ) ) l = [ int ( x ) for x in input ( ) . split ( ) ] if n == 1 : print ( 0 ) exit ( ) l . sort ( ) ans1 = l [ - 2 ] - l [ 0 ] + min ( abs ( a - l [ - 2 ] ) , abs ( a - l [ 0 ] ) ) ans2 = l [ - 1 ] - l [ 1 ] + min ( abs ( a - l [ - 1 ] ) , abs ( a - l [ 1 ] ) ) print ( min ( ans1 , ans2 ) ) NEW_LINE


import sysinput = sys . stdin . readline   n , m = map ( int , input ( ) . split ( ) )     t = list ( map ( int , input ( ) . split ( ) ) )       t . sort ( )     if n <= 1 : print ( 0 ) else :             ans = 9999999999999999 for j in range ( n ) :     if j + ( n - 2 ) < n : NEW_LINE


import java . util . * ; public class Main {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; if ( n == 1 ) { System . out . println ( 0 ) ; return ; } int a = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( arr ) ; int min = Integer . MAX_VALUE ; min = Math . min ( min , Math . abs ( arr [ n - 2 ] - arr [ 0 ] ) + Math . min ( Math . abs ( a - arr [ 0 ] ) , Math . abs ( a - arr [ n - 2 ] ) ) ) ; min = Math . min ( min , Math . abs ( arr [ n - 1 ] - arr [ 1 ] ) + Math . min ( Math . abs ( a - arr [ 1 ] ) , Math . abs ( a - arr [ n - 1 ] ) ) ) ; System . out . println ( min ) ; } }


import java . util . Arrays ; import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n , a , temp = 2000000222 ; n = in . nextInt ( ) ; a = in . nextInt ( ) ; if ( n == 1 ) { System . out . println ( 0 ) ; return ; } int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = in . nextInt ( ) ; Arrays . sort ( arr ) ; int temp2 ; temp = arr [ n - 2 ] - arr [ 0 ] + Math . min ( Math . abs ( arr [ 0 ] - a ) , Math . abs ( arr [ n - 2 ] - a ) ) ; temp2 = arr [ n - 1 ] - arr [ 1 ] + Math . min ( Math . abs ( arr [ 1 ] - a ) , Math . abs ( arr [ n - 1 ] - a ) ) ; System . out . println ( Math . min ( temp , temp2 ) ) ; } }


import java . util . * ; import java . io . * ;   public class Game_With_Stricks {   static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; }   }   public static void shuffle ( int [ ] a ) { Random r = new Random ( ) ;   for ( int i = 0 ; i <= a . length - 2 ; i ++ ) { int j = i + r . nextInt ( a . length - i ) ;   swap ( a , i , j ) ; }   Arrays . sort ( a ) ; }   public static void swap ( int [ ] a , int i , int j ) { int temp = a [ i ] ; a [ i ] = a [ j ] ; a [ j ] = temp ; }   public static void main ( String [ ] args ) {

n , m = map ( int , input ( ) . split ( ) )   inters = n * m   moves = inters // max ( n , m )   if moves % 2 == 0 : print ( ' Malvika ' ) else : print ( ' Akshat ' ) NEW_LINE


k = 0 n = input ( ) a = list ( n . split ( ) ) if int ( a [ 0 ] ) > int ( a [ 1 ] ) : k = int ( a [ 1 ] ) elif int ( a [ 1 ] ) > int ( a [ 0 ] ) : k = int ( a [ 0 ] ) else : k = int ( a [ 0 ] ) if k % 2 == 0 : print ( " Malvika " ) else : print ( " Akshat " ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) ) points = 0 if n < m : points = nelse : points = mif ( points % 2 ) != 0 : print ( " Akshat " ) else : print ( " Malvika " ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) ) if min ( n , m ) % 2 == 0 : print ( ' Malvika ' ) else : print ( ' Akshat ' ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) )   n = min ( n , m ) if n % 2 == 0 : print ( ' Malvika ' ) else : print ( ' Akshat ' ) NEW_LINE


import java . util . Scanner ; public class GameOfSticks { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int total = n * m ; int res = - 1 ; int inter = total ; while ( inter != 0 ) { res ++ ; n -- ; m -- ; inter = n * m ; } if ( res % 2 != 0 ) { System . out . println ( " Malvika " ) ; } else { System . out . println ( " Akshat " ) ; } } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . PriorityQueue ;   public class Template { private static BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ;   static String readln ( ) throws IOException { return input . readLine ( ) ; }   public static void main ( String [ ] args ) throws IOException { solution ( ) ; }   public static void solution ( ) throws IOException {


import java . io . * ; import java . util . StringTokenizer ;   public class A451 { public static void main ( String [ ] args ) throws IOException { PrintWriter out = new PrintWriter ( System . out ) ; FastScanner fs = new FastScanner ( ) ; int N , M ; N = fs . nextInt ( ) ; M = fs . nextInt ( ) ; int mini = Math . min ( N , M ) ; if ( mini % 2 == 0 ) { out . println ( " Malvika " ) ; } else { out . println ( " Akshat " ) ; } out . close ( ) ; }   static class FastScanner { BufferedReader br ; StringTokenizer st ;   public FastScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   public FastScanner ( String filePath ) throws FileNotFoundException { try { br = new BufferedReader ( new FileReader ( filePath ) ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } }   String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; throw e ; } } return st . nextToken ( ) ; }   String nextLine ( ) throws IOException { String str ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; throw e ; } return str ; }   int nextInt ( ) throws IOException { return Integer . parseInt ( this . next ( ) ) ; }   long nextLong ( ) throws IOException { return Long . parseLong ( this . next ( ) ) ; } } }


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

from math import combdef minp ( arr ) : arr = sorted ( arr ) st = arr [ : 3 ] ans = 1 for i in set ( st ) : ans *= comb ( arr . count ( i ) , st . count ( i ) ) return ans   a = input ( ) lst = list ( map ( int , input ( ) . strip ( ) . split ( ) ) ) print ( minp ( lst ) ) NEW_LINE


n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) l . sort ( ) g = [ ] def combi ( n , r ) : p = 1 for i in range ( min ( r , n - r ) ) : p = p * ( n - i ) // ( i + 1 ) return p d = 1 if l [ 0 ] == l [ 1 ] == l [ 2 ] :   d = d * combi ( l . count ( l [ 0 ] ) , 3 ) elif l [ 0 ] != l [ 1 ] == l [ 2 ] : d = d * combi ( l . count ( l [ 2 ] ) , 2 ) * l . count ( l [ 0 ] ) elif l [ 0 ] == l [ 1 ] != l [ 2 ] : d = d * combi ( l . count ( l [ 0 ] ) , 2 ) * l . count ( l [ 2 ] ) elif l [ 0 ] != l [ 1 ] != l [ 2 ] : d = d * l . count ( l [ 0 ] ) * l . count ( l [ 1 ] ) * l . count ( l [ 2 ] ) print ( d ) NEW_LINE


import sysfrom collections import defaultdictinput = sys . stdin . readline   d , n = defaultdict ( int ) , int ( input ( ) ) s = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in s : d [ i ] += 1 if s [ 2 ] != s [ 1 ] : print ( d [ s [ 2 ] ] ) elif s [ 2 ] == s [ 1 ] and s [ 1 ] != s [ 0 ] : print ( d [ s [ 2 ] ] * ( d [ s [ 2 ] ] - 1 ) // 2 ) else : print ( d [ s [ 0 ] ] * ( d [ s [ 0 ] ] - 1 ) * ( d [ s [ 0 ] ] - 2 ) // 6 ) NEW_LINE


num = int ( input ( ) ) arr = [ 0 ] * numarr = input ( ) . split ( ) for i in range ( num ) : arr [ i ] = int ( arr [ i ] ) arr . sort ( ) a = arr [ 0 ] b = arr [ 1 ] c = arr [ 2 ] ans = 1 ca = arr . count ( a ) cb = arr . count ( b ) cc = arr . count ( c ) if c != b and b != a : ans = ca * cb * ccelif b == c and b != a : ans = ca * ( cb * ( cb - 1 ) // 2 ) elif a == b and b != c : ans = ( ca * ( ca - 1 ) ) // 2 * ccelif a == b and b == c : ans = ( ca * ( ca - 1 ) * ( ca - 2 ) ) // 6 print ( ans ) NEW_LINE


n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) l . sort ( ) x , y , z = l . count ( l [ 0 ] ) , l . count ( l [ 1 ] ) , l . count ( l [ 2 ] ) if ( x > 2 ) : print ( x * ( x - 1 ) * ( x - 2 ) // 6 ) elif ( x == 1 and y >= 2 ) : print ( y * ( y - 1 ) // 2 ) else : print ( z ) NEW_LINE


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 B817 {   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 ;


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; char [ ] [ ] c = new char [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) c [ i ] = sc . next ( ) . toCharArray ( ) ; for ( int i = 1 ; i < n - 1 ; i ++ ) { for ( int j = 1 ; j < n - 1 ; j ++ ) { if ( c [ i ] [ j ] == ' # ' && c [ i - 1 ] [ j ] == ' # ' && c [ i + 1 ] [ j ] == ' # ' && c [ i ] [ j + 1 ] == ' # ' && c [ i ] [ j - 1 ] == ' # ' ) { c [ i ] [ j ] = c [ i - 1 ] [ j ] = c [ i + 1 ] [ j ] = c [ i ] [ j - 1 ] = c [ i ] [ j + 1 ] = ' . ' ; } } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( c [ i ] [ j ] == ' # ' ) { System . out . println ( " NO " ) ; return ; } } } System . out . println ( " YES " ) ; } }

from itertools import chain   if __name__ == ' _ _ main _ _ ' : n = int ( input ( ) ) tab = [ list ( c == ' # ' for c in input ( ) ) for _ in range ( n ) ] flag = { True } . issubset ( chain . from_iterable ( tab ) ) if ( flag ) : for i in range ( 1 , n - 1 ) : for j in range ( 1 , n - 1 ) : if tab [ i - 1 ] [ j ] and tab [ i ] [ j - 1 ] and tab [ i ] [ j ] and tab [ i ] [ j + 1 ] and tab [ i + 1 ] [ j ] : tab [ i - 1 ] [ j ] = False tab [ i ] [ j - 1 ] = False tab [ i ] [ j ] = False tab [ i ] [ j + 1 ] = False tab [ i + 1 ] [ j ] = False flag = { True } . issubset ( chain . from_iterable ( tab ) ) if ( flag ) : print ( ' NO ' ) else : print ( ' YES ' )   NEW_LINE


if __name__ == ' _ _ main _ _ ' : n = int ( input ( ) ) x = [ list ( input ( ) ) for i in range ( n ) ] y = [ [ ' . ' for j in range ( n ) ] for i in range ( n ) ]   error = False for i in range ( n ) : for j in range ( n ) : if x [ i ] [ j ] == ' . ' and y [ i ] [ j ] == ' . ' : continue elif x [ i ] [ j ] == ' . ' and y [ i ] [ j ] == ' # ' : error = True break elif x [ i ] [ j ] == ' # ' and y [ i ] [ j ] == ' . ' : if j == 0 or j == n - 1 or i > n - 3 or ( y [ i ] [ j ] == ' # ' or y [ i + 1 ] [ j - 1 ] == ' # ' or y [ i + 1 ] [ j ] == ' # ' or y [ i + 1 ] [ j + 1 ] == ' # ' or y [ i + 2 ] [ j ] == ' # ' ) : error = True break else : y [ i ] [ j ] = ' # ' y [ i + 1 ] [ j - 1 ] = ' # ' y [ i + 1 ] [ j ] = ' # ' y [ i + 1 ] [ j + 1 ] = ' # ' y [ i + 2 ] [ j ] = ' # '   if not error : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE


def canDraw ( n , matrix ) : can = True for i in range ( n ) : for j in range ( n ) : if matrix [ i ] [ j ] == " # " : if matrix [ i + 1 ] [ j ] == " # " and matrix [ i + 2 ] [ j ] == " # " and matrix [ i + 1 ] [ j - 1 ] == " # " and matrix [ i + 1 ] [ j + 1 ] == " # " : matrix [ i ] [ j ] = " . " matrix [ i + 1 ] [ j ] = " . " matrix [ i + 2 ] [ j ] = " . " matrix [ i + 1 ] [ j - 1 ] = " . " matrix [ i + 1 ] [ j + 1 ] = " . " else : can = False break if not can : break return can         NEW_LINE


import java . util . * ;   public class ICPC {    public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; List < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( sc . next ( ) ) ; } for ( int i = 1 ; i < n - 1 ; i ++ ) { for ( int j = 1 ; j < n - 1 ; j ++ ) { String s1 = list . get ( i ) ; String s2 = list . get ( i - 1 ) ; String s3 = list . get ( i + 1 ) ; char ch = list . get ( i ) . charAt ( j ) ; char ch1 = list . get ( i ) . charAt ( j + 1 ) ; char ch2 = list . get ( i ) . charAt ( j - 1 ) ; char ch3 = list . get ( i - 1 ) . charAt ( j ) ; char ch4 = list . get ( i + 1 ) . charAt ( j ) ;   if ( ch == ' # ' && ch1 == ' # ' && ch2 == ' # ' && ch3 == ' # ' && ch4 == ' # ' ) { String s11 = s1 . substring ( 0 , j - 1 ) + " . . . " + s1 . substring ( j + 2 ) ; list . set ( i , s11 ) ; String s12 = s2 . substring ( 0 , j ) + " . " + s2 . substring ( j + 1 ) ; list . set ( i - 1 , s12 ) ; String s13 = s3 . substring ( 0 , j ) + " . " + s3 . substring ( j + 1 ) ; list . set ( i + 1 , s13 ) ;


import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; char arr [ ] [ ] = new char [ n ] [ n ] ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String str = s . next ( ) ; for ( int j = 0 ; j < n ; j ++ ) { arr [ i ] [ j ] = str . charAt ( j ) ; if ( arr [ i ] [ j ] == ' # ' ) { count ++ ; } } } if ( count % 5 > 0 ) { System . out . println ( " NO " ) ; return ; } for ( int i = 1 ; i < n - 1 ; i ++ ) { for ( int j = 1 ; j < n - 1 ; j ++ ) { if ( arr [ i ] [ j ] == ' # ' ) { if ( arr [ i - 1 ] [ j ] == ' # ' && arr [ i ] [ j + 1 ] == ' # ' && arr [ i + 1 ] [ j ] == ' # ' && arr [ i ] [ j - 1 ] == ' # ' ) { arr [ i ] [ j ] = ' . ' ; arr [ i - 1 ] [ j ] = ' . ' ; arr [ i ] [ j + 1 ] = ' . ' ; arr [ i ] [ j - 1 ] = ' . ' ; arr [ i + 1 ] [ j ] = ' . ' ; } }   } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( arr [ i ] [ j ] == ' # ' ) { System . out . println ( " NO " ) ; return ; } } } System . out . println ( " YES " ) ; } }


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 B6 {   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 ) ) ) ; static HashSet < Character > hs ; static int n , m ; static char ch [ ] [ ] ; public static void main ( String args [ ] ) {   int tc = 1 ;

n , m , c = input ( ) . split ( ) lst = [ [ 1 ] * ( int ( m ) + 2 ) ] temp = [ ] for i in range ( int ( n ) ) : f = list ( input ( ) . strip ( ) ) f . insert ( 0 , 1 ) f . append ( 1 ) lst . append ( f ) lst . append ( [ 1 ] * ( int ( m ) + 2 ) ) for i in range ( 1 , int ( n ) + 1 ) : for j in range ( 1 , int ( m ) + 1 ) : if lst [ i ] [ j ] == c : temp . append ( lst [ i - 1 ] [ j ] ) temp . append ( lst [ i + 1 ] [ j ] ) temp . append ( lst [ i ] [ j + 1 ] ) temp . append ( lst [ i ] [ j - 1 ] ) temp = set ( temp ) st = " " for i in temp : st += str ( i ) st = st . replace ( "1" , " " ) st = st . replace ( " . " , " " ) st = st . replace ( c , " " ) print ( len ( st ) ) NEW_LINE


def indices ( n , m , room , c ) : res = [ ] for i in range ( n ) : for j in range ( m ) : if room [ i ] [ j ] == c : res . append ( ( i , j ) ) return res           def solve ( n , m , room , c ) : president_pos = indices ( n , m , room , c ) diputies = set ( ) for i , j in president_pos : if i > 0 and room [ i - 1 ] [ j ] not in c + ' . ' : diputies . add ( room [ i - 1 ] [ j ] ) if j > 0 and room [ i ] [ j - 1 ] not in c + ' . ' : diputies . add ( room [ i ] [ j - 1 ] ) if i < n - 1 and room [ i + 1 ] [ j ] not in c + ' . ' : diputies . add ( room [ i + 1 ] [ j ] ) if j < m - 1 and room [ i ] [ j + 1 ] not in c + ' . ' : diputies . add ( room [ i ] [ j + 1 ] ) print ( len ( diputies ) )           def main ( ) : n , m , c = input ( ) . split ( ) n , m = int ( n ) , int ( m ) room = [ ] for _ in range ( n ) : room . append ( input ( ) ) solve ( n , m , room , c )   if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE


r = lambda : list ( map ( int , input ( ) . split ( ) ) ) a , b , x = input ( ) . split ( ) a = int ( a ) b = int ( b )   ans = set ( )   arr = [ input ( ) for _ in range ( a ) ]   for i in range ( a ) : for j in range ( b ) : if arr [ i ] [ j ] == x : if i > 0 : ans . add ( arr [ i - 1 ] [ j ] ) if i < a - 1 : ans . add ( arr [ i + 1 ] [ j ] ) if j > 0 : ans . add ( arr [ i ] [ j - 1 ] ) if j < b - 1 : ans . add ( arr [ i ] [ j + 1 ] )   try : ans . remove ( ' . ' ) except : passtry : ans . remove ( x ) except : passprint ( len ( ans ) )     NEW_LINE


n , m , c = input ( ) . split ( ) n = int ( n ) m = int ( m ) string = " . " * mfor i in range ( n ) : string = string + " . " + input ( ) + " . " string = string + ( " . " * m ) for i in range ( n * m ) : this = string [ i ] next = string [ i + 1 ] previous = string [ i - 1 ] res = [ ] for i in range ( len ( string ) ) : try : val = string [ i ] if val == c : next = string [ i + 1 ] if next != c and next != " . " : if next not in res : res . append ( next ) pre = string [ i - 1 ] if pre != c and pre != " . " : if pre not in res : res . append ( pre ) up = string [ i - ( m + 2 ) ] if up != c and up != " . " : if up not in res : res . append ( up ) down = string [ i + ( m + 2 ) ] if down != c and down != " . " : if down not in res : res . append ( down ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; import java . util . TreeSet ;   public class B6_Presidents_Office {   public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer stt = new StringTokenizer ( br . readLine ( ) ) ; int h = Integer . parseInt ( stt . nextToken ( ) ) ; int w = Integer . parseInt ( stt . nextToken ( ) ) ; char c = stt . nextToken ( ) . charAt ( 0 ) ; char [ ] [ ] arr = new char [ h ] [ w ] ; for ( int i = 0 ; i < h ; i ++ ) { arr [ i ] = br . readLine ( ) . toCharArray ( ) ; } TreeSet < Character > set = new TreeSet < > ( ) ; for ( int i = 0 ; i < h ; ++ i ) { int index = String . valueOf ( arr [ i ] ) . indexOf ( c ) ; if ( index >= 0 ) { for ( int j = index ; j < w ; ++ j ) { if ( arr [ i ] [ j ] == c ) { if ( i > 0 ) { set . add ( arr [ i - 1 ] [ j ] ) ; } if ( i < h - 1 ) { set . add ( arr [ i + 1 ] [ j ] ) ; } if ( j > 0 ) { set . add ( arr [ i ] [ j - 1 ] ) ; } if ( j < w - 1 ) { set . add ( arr [ i ] [ j + 1 ] ) ; } } else { break ; } } } } set . remove ( ' . ' ) ; set . remove ( c ) ; System . out . println ( set . size ( ) ) ;    }   }


import java . io . BufferedInputStream ; import java . util . HashSet ; import java . util . Scanner ;   import javax . jws . WebParam . Mode ;   public class Main { public static char [ ] [ ] s ; static int n , m , sum ; static int [ ] a = new int [ 1000 ] ; static char c ; static int [ ] [ ] ans = { { 0 , 1 } , { 1 , 0 } , { - 1 , 0 } , { 0 , - 1 } } ; static int [ ] [ ] cnt ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( new BufferedInputStream ( System . in ) ) ; n = sc . nextInt ( ) ; m = sc . nextInt ( ) ; c = sc . next ( ) . charAt ( 0 ) ; s = new char [ n ] [ m ] ; cnt = new int [ n ] [ m ] ; String string ; for ( int i = 0 ; i < n ; i ++ ) { string = sc . next ( ) ; for ( int j = 0 ; j <= string . length ( ) - 1 ; j ++ ) { s [ i ] [ j ] = string . charAt ( j ) ; } } sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( s [ i ] [ j ] == c ) { dfs ( i , j ) ; } } } System . out . println ( sum ) ; } private static void dfs ( int i , int j ) {


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class FootBallFouls { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ;   String h = reader . readLine ( ) ; String a = reader . readLine ( ) ; int n = Integer . parseInt ( reader . readLine ( ) ) ;   int [ ] [ ] store = new int [ 2 ] [ 100 ] ;   for ( int i = 0 ; i < n ; i ++ ) { StringTokenizer st = new StringTokenizer ( reader . readLine ( ) ) ;   int minute = Integer . parseInt ( st . nextToken ( ) ) ;   int k = 0 ; if ( st . nextToken ( ) . equals ( " a " ) ) k = 1 ;   int player = Integer . parseInt ( st . nextToken ( ) ) ;   if ( st . nextToken ( ) . equals ( " y " ) ) store [ k ] [ player ] ++ ; else if ( store [ k ] [ player ] < 2 ) { store [ k ] [ player ] = 1000 ; System . out . println ( ( k == 0 ? h : a ) + " ▁ " + player + " ▁ " + minute ) ; }   if ( store [ k ] [ player ] == 2 ) { store [ k ] [ player ] = 1000 ; System . out . println ( ( k == 0 ? h : a ) + " ▁ " + player + " ▁ " + minute ) ; } } } }

if __name__ == ' _ _ main _ _ ' : h , a = input ( ) , input ( ) s = lambda x , n , m : " % s ▁ % s ▁ % s " % ( x , n , m ) t = int ( input ( ) ) b , c = dict ( ) , dict ( )   def is_red ( d , key , name , m , func ) : if d [ key ] in ( 2 , 3 ) : print ( func ( name , key , m ) )   while t > 0 : d = input ( ) . split ( ) cnt = 1 if d [ 3 ] == " y " else 2 if d [ 1 ] == " h " : if b . get ( d [ 2 ] , 0 ) < 2 and 1 < b . get ( d [ 2 ] , 0 ) + cnt < 4 : print ( s ( h , d [ 2 ] , d [ 0 ] ) ) b [ d [ 2 ] ] = b . get ( d [ 2 ] , 0 ) + cnt else : if c . get ( d [ 2 ] , 0 ) < 2 and 1 < c . get ( d [ 2 ] , 0 ) + cnt < 4 : print ( s ( a , d [ 2 ] , d [ 0 ] ) ) c [ d [ 2 ] ] = c . get ( d [ 2 ] , 0 ) + cnt t -= 1 NEW_LINE


team_1 = input ( ) team_2 = input ( ) n = int ( input ( ) ) ll = [ ] for i in range ( n ) : mi , te , num , card = map ( str , input ( ) . split ( ) ) ll . append ( ( int ( mi ) , te , int ( num ) , card ) ) ll . sort ( key = lambda x : x [ 0 ] )   team_1_p = [ 0 for x in range ( 101 ) ] team_2_p = [ 0 for x in range ( 101 ) ] d_1 , d_2 = { } , { } sol = [ ] for l in ll : if l [ 1 ] == ' h ' : if l [ 3 ] == ' r ' : if l [ 2 ] not in d_1 : sol . append ( ( team_1 , l [ 2 ] , l [ 0 ] ) ) d_1 [ l [ 2 ] ] = True elif l [ 3 ] == ' y ' : if team_1_p [ l [ 2 ] ] == 0 : team_1_p [ l [ 2 ] ] += 1 else : if l [ 2 ] not in d_1 : sol . append ( ( team_1 , l [ 2 ] , l [ 0 ] ) ) d_1 [ l [ 2 ] ] = True if l [ 1 ] == ' a ' : if l [ 3 ] == ' r ' : if l [ 2 ] not in d_2 : sol . append ( ( team_2 , l [ 2 ] , l [ 0 ] ) ) d_2 [ l [ 2 ] ] = True elif l [ 3 ] == ' y ' : if team_2_p [ l [ 2 ] ] == 0 : team_2_p [ l [ 2 ] ] += 1 else : if l [ 2 ] not in d_2 : sol . append ( ( team_2 , l [ 2 ] , l [ 0 ] ) ) d_2 [ l [ 2 ] ] = True   for x in sol : print ( * x ) NEW_LINE


from math import * t1 = input ( ) t2 = input ( ) m1 , m2 = { } , { } for i in range ( int ( input ( ) ) ) : t , time , n , cor = input ( ) . split ( ) n = int ( n ) if ( time == ' h ' and ( n not in m1 or m1 [ n ] != ' r ' ) ) or ( time == ' a ' and ( n not in m2 or m2 [ n ] != ' r ' ) ) : if ( time == ' h ' and ( n in m1 and m1 [ n ] == ' y ' or cor == ' r ' ) ) or ( time == ' a ' and ( n in m2 and m2 [ n ] == ' y ' or cor == ' r ' ) ) : if time == " h " : m1 [ n ] = ' r ' else : m2 [ n ] = ' r ' print ( ( t1 if time == ' h ' else t2 ) , n , t ) else : if time == " h " : m1 [ n ] = ' y ' else : m2 [ n ] = ' y ' NEW_LINE


from collections import *   home = input ( ) away = input ( ) n = int ( input ( ) ) hd = defaultdict ( int ) ad = defaultdict ( int ) for i in range ( n ) : a = list ( map ( str , input ( ) . split ( ) ) ) if a [ 1 ] == " h " : if hd [ a [ 2 ] ] != - 1 : if a [ - 1 ] == " r " : hd [ a [ 2 ] ] = - 1 print ( home , a [ 2 ] , a [ 0 ] ) else : hd [ a [ 2 ] ] += 1 if hd [ a [ 2 ] ] == 2 : hd [ a [ 2 ] ] = - 1 print ( home , a [ 2 ] , a [ 0 ] ) else : if ad [ a [ 2 ] ] != - 1 : if a [ - 1 ] == " r " : ad [ a [ 2 ] ] = - 1 print ( away , a [ 2 ] , a [ 0 ] ) else : ad [ a [ 2 ] ] += 1 if ad [ a [ 2 ] ] == 2 : ad [ a [ 2 ] ] = - 1 print ( away , a [ 2 ] , a [ 0 ] ) NEW_LINE


def STR ( ) : return list ( input ( ) ) def INT ( ) : return int ( input ( ) ) def MAP ( ) : return map ( int , input ( ) . split ( ) ) def MAP2 ( ) : return map ( float , input ( ) . split ( ) ) def LIST ( ) : return list ( map ( int , input ( ) . split ( ) ) ) def STRING ( ) : return input ( ) import stringimport sysfrom heapq import heappop , heappushfrom bisect import * from collections import deque , Counter , defaultdictfrom math import * from itertools import permutations , accumulatedx = [ - 1 , 1 , 0 , 0 ] dy = [ 0 , 0 , 1 , - 1 ] NEW_LINE


import java . math . BigInteger ; import java . util . * ;   public class Main {   static Scanner input = new Scanner ( System . in ) ;   public static void main ( String [ ] args ) { String h [ ] = new String [ 2 ] ; h [ 0 ] = input . next ( ) ; h [ 1 ] = input . next ( ) ; int homecards [ ] = new int [ 100 ] ; int awaycards [ ] = new int [ 100 ] ; int redcards [ ] [ ] = new int [ 100 ] [ 3 ] ; int n = input . nextInt ( ) ; int ri = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int minute = input . nextInt ( ) ; String TeamName = input . next ( ) ; int Number = input . nextInt ( ) ; String color = input . next ( ) ; if ( TeamName . equals ( " h " ) && homecards [ Number ] != 2 ) { if ( color . equals ( " y " ) ) homecards [ Number ] ++ ; else homecards [ Number ] = 2 ; if ( homecards [ Number ] == 2 ) { redcards [ ri ] [ 0 ] = 0 ; redcards [ ri ] [ 1 ] = Number ; redcards [ ri ] [ 2 ] = minute ; ri ++ ; } } else if ( TeamName . equals ( " a " ) && awaycards [ Number ] != 2 ) { if ( color . equals ( " y " ) ) awaycards [ Number ] ++ ; else awaycards [ Number ] = 2 ; if ( awaycards [ Number ] == 2 ) { redcards [ ri ] [ 0 ] = 1 ; redcards [ ri ] [ 1 ] = Number ; redcards [ ri ] [ 2 ] = minute ; ri ++ ; } } } for ( int i = 0 ; i < ri ; i ++ ) { System . out . println ( h [ redcards [ i ] [ 0 ] ] + " ▁ " + redcards [ i ] [ 1 ] + " ▁ " + redcards [ i ] [ 2 ] ) ; } }      }


import java . util . * ; public class sheets { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int n = sc . nextInt ( ) ; int low = 0 ; int high = 100000 ; TreeMap < Character , Integer > map = new TreeMap < > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { map . put ( s . charAt ( i ) , map . getOrDefault ( s . charAt ( i ) , 0 ) + 1 ) ; } int size = map . size ( ) ; if ( n < size ) { System . out . println ( " - 1" ) ; return ; } while ( low < high ) { int mid = ( low + high ) / 2 ; int sum = 0 ; for ( Map . Entry < Character , Integer > entry : map . entrySet ( ) ) { sum += Math . ceil ( ( double ) entry . getValue ( ) / mid ) ; } if ( sum > n ) { low = mid + 1 ; } else { high = mid ; } } System . out . println ( high ) ; String ans = " " ; for ( Map . Entry < Character , Integer > entry : map . entrySet ( ) ) { char [ ] t = new char [ ( int ) Math . ceil ( ( double ) entry . getValue ( ) / high ) ] ; Arrays . fill ( t , entry . getKey ( ) ) ; String k = new String ( t ) ; ans += k ; } if ( ans . length ( ) < n ) { while ( ans . length ( ) < n ) { ans = ans + " a " ; } } System . out . println ( ans ) ; } }


s = input ( ) n = int ( input ( ) ) d = { } r = 0 for a in s : d . setdefault ( a , 0 ) d [ a ] += 1 if ( d [ a ] > r ) : r = d [ a ] if ( len ( d ) > n ) : print ( - 1 ) else : l = 0 while r - l > 1 : k = ( l + r ) // 2 cur = 0 for x in d . values ( ) : cur += ( x + k - 1 ) // k if cur > n : l = k else : r = k print ( r ) s = ' ' for a in d . keys ( ) : s += a * ( ( d [ a ] + r - 1 ) // r ) l = len ( s ) s += ' a ' * ( n - len ( s ) ) print ( s ) NEW_LINE


from collections import Counter     def main ( ) : s = input ( ) l = int ( input ( ) ) d = Counter ( s ) if len ( d ) > l : print ( - 1 ) return lo = 0 hi = 10000 while lo + 1 < hi : mid = ( lo + hi ) // 2 c = 0 for x in iter ( d . values ( ) ) : c += ( x + mid - 1 ) // mid if c > l : lo = mid else : hi = mid print ( hi ) ans = [ ] for x in iter ( d . items ( ) ) : ans . append ( x [ 0 ] * int ( ( ( x [ 1 ] + hi - 1 ) / hi ) ) ) t = ' ' . join ( ans ) if len ( t ) < l : t += ' a ' * ( l - len ( t ) ) print ( t )     main ( ) NEW_LINE


from collections import defaultdict   s = input ( ) n = int ( input ( ) )   if len ( set ( s ) ) > n : print ( - 1 ) else : hist = defaultdict ( int ) for c in s : hist [ c ] += 1 for ans in range ( 1 , 2000 ) : cur_need = 0 for c in hist : NEW_LINE


s , n , q , a = input ( ) , int ( input ( ) ) , { } , " " for i in s : q [ i ] = [ q [ i ] [ 0 ] + 1 , 1 ] if i in q else [ 1 , 1 ] if len ( q ) > n : print ( - 1 ) else : for i in range ( n - len ( q ) ) : o = 0 for j in q : m = ( q [ j ] [ 0 ] + q [ j ] [ 1 ] - 1 ) // q [ j ] [ 1 ] if m > o : o , w = m , j q [ w ] [ 1 ] = q [ w ] [ 1 ] + 1 for i in q : a += i * q [ i ] [ 1 ] o = 0 for i in q : m = ( q [ i ] [ 0 ] + q [ i ] [ 1 ] - 1 ) // q [ i ] [ 1 ] if m > o : o = m print ( o , " \n " , a ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class CF335A { static final int CHARS = 26 ;   public static void main ( String [ ] args ) throws IOException { FastScanner sc = new FastScanner ( ) ; PrintWriter pw = new PrintWriter ( System . out ) ;   char [ ] s = sc . nextToken ( ) . toCharArray ( ) ; int n = sc . nextInt ( ) ;   int [ ] occs = new int [ CHARS ] ; int distinct = 0 ; for ( char ch : s ) { if ( occs [ ch - ' a ' ] == 0 ) distinct ++ ; occs [ ch - ' a ' ] ++ ; } if ( distinct > n ) { pw . println ( - 1 ) ; pw . flush ( ) ; return ; }   int lo = 1 , hi = 1000 ; while ( lo <= hi ) { int mid = ( lo + hi ) / 2 ; int n1 = 0 ; for ( int occ : occs ) if ( occ > 0 ) n1 += ( occ + mid - 1 ) / mid ;


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

t = int ( input ( ) ) NEW_LINE for _ in range ( t ) : q , d = map ( int , input ( ) . split ( ) ) NEW_LINE ali = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for j in ali : while NEW_LINE str ( d ) not in str ( j ) : NEW_LINE if ( j < 0 ) : NEW_LINE INDENT break else : NEW_LINE j -= d NEW_LINE DEDENT


t = int ( input ( ) ) NEW_LINE for i in range ( t ) : q , d = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE s = str ( d ) NEW_LINE l = [ 0 for j in range ( d * 10 - 1 ) ] NEW_LINE for j in range ( d * 10 - 1 ) : if NEW_LINE str ( j + 1 ) . count ( s ) : l [ j ] = 1 else : for k in range ( 0 , j ) : if NEW_LINE l [ k ] : NEW_LINE if str ( j - k ) . count ( s ) : l [ j ] = 1 NEW_LINE break NEW_LINE m = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for i in m : if NEW_LINE i >= d * 10 : print ( " YES " ) elif l [ i - 1 ] : print ( " YES " ) else : print ( " NO " ) NEW_LINE


t = int ( input ( ) ) NEW_LINE for _ in range ( t ) : q , d = map ( int , input ( ) . split ( ) ) NEW_LINE arr = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for i in arr : if NEW_LINE str ( d ) in str ( i ) : print ( " YES " ) NEW_LINE continue NEW_LINE if i >= 10 * d or i % d == 0 : print ( " YES " ) NEW_LINE continue NEW_LINE temp = i NEW_LINE while temp > 0 : if NEW_LINE str ( d ) in str ( temp ) : print ( " YES " ) NEW_LINE break else : temp -= d NEW_LINE continue NEW_LINE if temp <= 0 : print ( " NO " )                                                                                NEW_LINE


import osimport NEW_LINE sysfrom NEW_LINE io NEW_LINE import BytesIO , IOBase     NEW_LINE def main ( ) : import bisect NEW_LINE import NEW_LINE INDENT math   NEW_LINE DEDENT


import java . util . Scanner ;   public class B1478 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; StringBuilder output = new StringBuilder ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int Q = in . nextInt ( ) ; int D = in . nextInt ( ) ; boolean [ ] possible = new boolean [ 100 ] ; possible [ 0 ] = true ; for ( int n = 1 ; n < 100 ; n ++ ) { if ( isLucky ( n , D ) ) { for ( int i = 0 ; i < 100 - n ; i ++ ) { if ( possible [ i ] ) { possible [ i + n ] = true ; } } } } for ( int q = 0 ; q < Q ; q ++ ) { int a = in . nextInt ( ) ; if ( a >= 100 ) { output . append ( " YES " ) ; } else { output . append ( possible [ a ] ? " YES " : " NO " ) ; } output . append ( ' \n ' ) ; } } System . out . print ( output ) ; }   static boolean isLucky ( int N , int D ) { while ( N > 0 ) { if ( N % 10 == D ) { return true ; } N /= 10 ; } return false ; }   }


import java . util . Scanner ;   public class CommandLineArguments {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; boolean quote = false ; boolean closed = true ; int cur = 0 ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( c == ' " ' ) { if ( ! quote ) { quote = true ; sb . append ( ' < ' ) ; cur = 1 ; closed = false ; } else { sb . append ( " > \n " ) ; cur = 0 ; quote = false ; closed = true ; } } else if ( c == ' ▁ ' ) { if ( quote ) { sb . append ( c ) ; } else { if ( cur > 0 ) { sb . append ( " > \n " ) ; cur = 0 ; closed = true ; } else { } } } else { if ( cur == 0 ) sb . append ( ' < ' ) ; closed = false ; sb . append ( c ) ; cur ++ ; } } if ( ! closed ) sb . append ( ' > ' ) ; System . out . println ( sb ) ;    }   }

s = input ( ) . split ( ' " ' ) NEW_LINE


list1 = list ( ) cmd = input ( ) i = 0 n = len ( cmd ) while ( i < len ( cmd ) and i != - 1 ) : x = cmd [ i ] if x == ' " ' : ind = cmd . find ( ' " ' , i + 1 , n ) if ind == - 1 : break if ind + 1 < len ( cmd ) and cmd [ ind + 1 ] == ' ▁ ' : list1 . append ( cmd [ i + 1 : ind ] ) ; else : ind = cmd . find ( ' " ' , ind + 1 , n ) list1 . append ( cmd [ i + 1 : ind ] ) i = ind + 1 if ind == - 1 : break elif x != ' ▁ ' : j = i while ( i < n and cmd [ i ] != ' ▁ ' ) : i += 1 x = cmd [ j : i ] list1 . append ( x ) i += 1 else : i += 1   for x in list1 : print ( " < " , x , " > " , sep = " " ) NEW_LINE


c , s = list ( ) , input ( ) . split ( ' " ' ) for i in range ( len ( s ) ) : if i & 1 : c . append ( s [ i ] ) else : c . extend ( s [ i ] . split ( ) ) print ( * [ ' < ' + e + ' > ' for e in c ] , sep = ' \n ' ) NEW_LINE


a = str ( input ( ) ) b = ' < ' inKav = Falsex = ' ▁ ' for i in range ( len ( a ) ) : if a [ i ] != ' ▁ ' : if a [ i ] == ' " ' : if inKav : inKav = False else : inKav = True else : b += a [ i ] elif inKav : b += a [ i ] if ( a [ i ] == ' ▁ ' and x != ' ▁ ' and not inKav ) or i + 1 == len ( a ) and a [ i ] != ' ▁ ' : print ( b + ' > ' ) b = ' < ' x = a [ i ] NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   public class CommandLineArguments {


import java . util . ArrayList ; import java . util . Scanner ;   public class P291B {   public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String command = s . nextLine ( ) + " ▁ " ; ArrayList < String > lexemes = new ArrayList < > ( ) ; StringBuilder current = new StringBuilder ( " " ) ; boolean quote = false ; for ( int i = 0 ; i < command . length ( ) ; i ++ ) { if ( quote ) { if ( command . charAt ( i ) == ' " ' ) { quote = false ; lexemes . add ( current . toString ( ) ) ; current = new StringBuilder ( " " ) ; } else { current . append ( command . charAt ( i ) ) ; } } else { if ( command . charAt ( i ) == ' " ' ) { quote = true ; } else if ( command . charAt ( i ) == ' ▁ ' ) { if ( current . length ( ) != 0 ) { lexemes . add ( current . toString ( ) ) ; current = new StringBuilder ( " " ) ; } } else { current . append ( command . charAt ( i ) ) ; } } } for ( String lexeme : lexemes ) { System . out . printf ( " < % s > \n " , lexeme ) ; } } }


import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) {   int month , day ; int daysOfMonth = 0 ; int weekLimit = 7 ; int rowCount = 0 ; Scanner sc = new Scanner ( System . in ) ;   month = sc . nextByte ( ) ; day = sc . nextInt ( ) ;   if ( month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12 ) { daysOfMonth = 31 ; } else if ( month == 4 || month == 6 || month == 9 || month == 11 ) { daysOfMonth = 30 ; } else if ( month == 2 ) { daysOfMonth = 28 ; }   daysOfMonth = daysOfMonth - ( ( weekLimit - day ) + 1 ) ;

month , day , = map ( int , input ( ) . split ( ) )   short = [ 2 ] mid = [ 4 , 6 , 9 , 11 ] long = [ 1 , 3 , 5 , 7 , 8 , 10 , 12 ]     if month in short : if day == 1 : print ( 4 ) else : print ( 5 )   elif month in mid : if day == 7 : print ( 6 ) else : print ( 5 ) else : if day in ( 6 , 7 ) : print ( 6 ) else : print ( 5 ) NEW_LINE


m , d = map ( int , input ( ) . split ( ) ) from calendar import monthrange x = monthrange ( 2017 , m ) [ 1 ] if x == 28 : if d == 1 : print ( 4 ) else : print ( 5 ) elif x == 31 : if d == 7 or d == 6 : print ( 6 ) else : print ( 5 ) else : if d == 7 : print ( 6 ) else : print ( 5 ) NEW_LINE


import mathm , d = map ( int , input ( ) . split ( ) ) if m == 1 or m == 3 or m == 5 or m == 7 or m == 8 or m == 10 or m == 12 : t = 31 - ( 8 - d ) y = math . ceil ( t / 7 ) print ( y + 1 ) elif m == 4 or m == 6 or m == 9 or m == 11 : t = 30 - ( 8 - d ) y = math . ceil ( t / 7 ) print ( y + 1 ) else : t = 28 - ( 8 - d ) y = math . ceil ( t / 7 ) print ( y + 1 ) NEW_LINE


import java . io . * ; import java . util . * ;   import static java . lang . Math . * ;   import java . time . YearMonth ;   public class Task { public static void main ( String [ ] args ) throws IOException { Reader reader = new Reader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ;   int m = reader . nextInt ( ) ; int d = reader . nextInt ( ) ;   m = YearMonth . of ( 2017 , m ) . lengthOfMonth ( ) ; m -= 8 - d ; int c = 1 ; while ( m > 0 ) { m -= 7 ; ++ c ; }   out . println ( c ) ;   reader . close ( ) ; out . close ( ) ; } }   class Reader { private BufferedReader bufferedReader ; private StringTokenizer tokenizer ;   public Reader ( ) { bufferedReader = new BufferedReader ( new InputStreamReader ( System . in ) , 32786 ) ; }   public void close ( ) throws IOException { bufferedReader . close ( ) ; }   public String next ( ) throws IOException { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { tokenizer = new StringTokenizer ( bufferedReader . readLine ( ) ) ; }   return tokenizer . nextToken ( ) ; }   public int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; }   public long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } }


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 . function . Function ; import java . util . stream . Collectors ; public class _p000760A { static public void main ( final String [ ] args ) throws IOException { p000760A . _main ( args ) ; }


import java . util . Scanner ; import java . util . Stack ;   public class ArrayCollection {   public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int m = scan . nextInt ( ) ; int d = scan . nextInt ( ) ; int days = m == 2 ? 28 : 30 ; if ( m <= 7 && m % 2 != 0 || m > 7 && m % 2 == 0 ) { days = 31 ; } days = days + ( d - 1 ) ; int columns = ( days / 7.0 ) % 1 == 0 ? days / 7 : days / 7 + 1 ; System . out . println ( columns ) ;   }   }


import java . util . Scanner ;   public class PAC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int m = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int td ; if ( m == 2 ) td = 28 ; else if ( m == 4 || m == 6 || m == 9 || m == 11 ) td = 30 ; else td = 31 ; td += d - 1 ; System . out . println ( ( td + 6 ) / 7 ) ; sc . close ( ) ; } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ;   import javafx . util . Pair ;   public class Main {   public static void main ( String [ ] args ) { FastScanner input = new FastScanner ( ) ;   int n = input . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ;   } int ans = 1 ; int min = Integer . MAX_VALUE ; int max = Integer . MIN_VALUE ; int nextMinIndex = 0 ; int nextMaxIndex = 0 ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) {   if ( a [ i ] <= min ) { nextMinIndex = i ; min = a [ i ] ; } if ( a [ i ] >= max ) { nextMaxIndex = i ; max = Math . max ( max , a [ i ] ) ; } if ( Math . abs ( max - min ) <= 1 ) { count ++ ; ans = Math . max ( ans , count ) ; } else { count = 0 ; min = Integer . MAX_VALUE ; max = Integer . MIN_VALUE ; i = Math . min ( nextMaxIndex , nextMinIndex ) ; } } 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 ( ) ) ; }   long nextLong ( ) {   return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) throws IOException { return br . readLine ( ) ; } }   }


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


from collections import * from sys import stdin , stdoutinput = stdin . readlinen , a , l , p = int ( input ( ) ) , list ( map ( int , input ( ) . split ( ) ) ) , defaultdict ( int ) , 1 for i in range ( n ) : p = max ( p , i + 1 - ( max ( l [ a [ i ] + 1 ] , l [ a [ i ] - 2 ] ) if l [ a [ i ] - 1 ] > l [ a [ i ] + 1 ] else max ( l [ a [ i ] + 2 ] , l [ a [ i ] - 1 ] ) ) ) ; l [ a [ i ] ] = i + 1 ; print ( p ) NEW_LINE


n = int ( input ( ) ) p = [ 0 ] * 100003 ans = - 1 ar = input ( ) . split ( ) for i in range ( 1 , n + 1 ) : x = int ( ar [ i - 1 ] ) if ( p [ x - 1 ] > p [ x + 1 ] ) : ans = max ( ans , i - max ( p [ x + 1 ] , p [ x - 2 ] ) ) else : ans = max ( ans , i - max ( p [ x + 2 ] , p [ x - 1 ] ) ) p [ x ] = i ; print ( ans ) NEW_LINE


import java . util . Scanner ;   public class ConstantRange { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   int n = scanner . nextInt ( ) ; Integer [ ] range = new Integer [ n ] ;   for ( int i = 0 ; i < n ; i ++ ) range [ i ] = scanner . nextInt ( ) ;   int len = 1 ; int maxLen = 1 ; int max = 0 ; int min = 0 ; int latestMin = 0 ; int latestMax = 0 ;   for ( int i = 1 ; i < n ; i ++ ) { int change = i ; int newmin = min ; int newmax = max ; if ( range [ max ] < range [ i ] ) { latestMax = i ; if ( max == min ) { newmax = i ; } else { newmax = i ; change = latestMin ; newmin = change + 1 ; latestMin ++ ; len = - 1 ; } } else if ( range [ max ] . equals ( range [ i ] ) ) { latestMax = i ; }   if ( range [ min ] > range [ i ] ) { latestMin = i ; if ( max == min ) { newmin = i ; } else { newmin = i ;   change = latestMax ; newmax = change + 1 ; latestMax ++ ; len = - 1 ; } } else if ( range [ min ] . equals ( range [ i ] ) ) { latestMin = i ; }   i = change ; len ++ ;   min = newmin ; max = newmax ;   if ( maxLen < len ) maxLen = len ; }   System . out . println ( maxLen ) ; } }


import java . util . Scanner ;   public class ApproximatingaConstantRange {   static Scanner sc ;   public static void main ( String [ ] args ) {   sc = new Scanner ( System . in ) ;   int n = sc . nextInt ( ) ;


import java . io . BufferedWriter ; import java . io . ByteArrayInputStream ; import java . io . FileInputStream ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . InputMismatchException ;   public class Main { private static final long MOD = ( long ) 1e9 + 7 ; static InputStream is ; static PrintWriter out ; static String INPUT = " " ; static int lenbuf = 0 , ptrbuf = 0 ; private static byte [ ] inbuf = new byte [ 1024 ] ; static boolean readFile = false ;


import java . io . * ; import java . util . * ;   import static java . lang . Math . max ;    public class Main { BufferedReader br ; StringTokenizer in ; PrintWriter pw ; Random r ; int INF = ( int ) ( 2 * 1e9 ) + 1 ; long LNF = ( long ) 1e18 ; long mod = ( long ) ( 1e9 + 7 ) ; int pp = 27 ;

n , m , d = map ( int , input ( ) . split ( ) ) ph = [ [ int ( j ) for j in input ( ) . split ( ) ] for i in range ( n ) ] inf = [ [ int ( j ) for j in input ( ) . split ( ) ] for i in range ( m ) ] for i in range ( n ) : ph [ i ] [ 1 ] = - ph [ i ] [ 1 ] for i in range ( m ) : inf [ i ] [ 1 ] = - inf [ i ] [ 1 ] ph . sort ( reverse = True ) inf . sort ( reverse = True ) sw , sc = 0 , 0 for p in inf : sc += p [ 0 ] d += p [ 1 ] ans = 0 z = m - 1 for p in ph : sc += p [ 0 ] d += p [ 1 ] NEW_LINE


n , m , d = list ( map ( int , input ( ) . split ( ) ) )   a = [ ] b = [ ]   for i in range ( n ) : a . append ( list ( map ( int , input ( ) . split ( ) ) ) )   for i in range ( m ) : b . append ( list ( map ( int , input ( ) . split ( ) ) ) )   a = sorted ( a , key = lambda x : x [ 0 ] + ( 1 - x [ 1 ] * 1e-10 ) ) b = sorted ( b , key = lambda x : x [ 0 ] + ( 1 - x [ 1 ] * 1e-10 ) )   tc , td = 0 , 0   tc += a [ - 1 ] [ 0 ] tc += b [ - 1 ] [ 0 ] td += a [ - 1 ] [ 1 ] td += b [ - 1 ] [ 1 ]   ai = n - 1 bi = m - 1   if td > d : print ( 0 ) exit ( )   while ai > 0 : t = ai - 1 if td + a [ t ] [ 1 ] <= d : td += a [ t ] [ 1 ] tc += a [ t ] [ 0 ] ai -= 1 continue else : break cmax = tc   while bi > 0 : bi -= 1 tc += b [ bi ] [ 0 ] td += b [ bi ] [ 1 ] while td > d and ai < n : tc -= a [ ai ] [ 0 ] td -= a [ ai ] [ 1 ] ai += 1 if ai == n : break if td <= d : cmax = max ( cmax , tc ) print ( cmax ) NEW_LINE


import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . HashMap ; import java . util . Scanner ; import java . util . TreeMap ; import java . util . TreeSet ;    public class Main {   public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; String s [ ] = new String [ n ] ; int max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { s [ i ] = input . next ( ) ; } int len = 0 ; for ( char i = ' a ' ; i <= ' z ' ; i ++ ) { for ( char j = ' a ' ; j <= ' z ' ; j ++ ) { len = 0 ; for ( int k = 0 ; k < n ; k ++ ) { String test = s [ k ] ; String x = String . valueOf ( i ) ; String y = String . valueOf ( j ) ; test = test . replaceAll ( x , " " ) ; test = test . replaceAll ( y , " " ) ; if ( test . length ( ) == 0 ) { len += s [ k ] . length ( ) ; } } max = Math . max ( len , max ) ; } } System . out . println ( max ) ; } }

n = int ( input ( ) ) N = [ ] d = { } c = 0 M = { } for i in range ( n ) : s = input ( ) p = set ( s ) if len ( p ) > 2 : continue else : N . append ( len ( s ) ) d . update ( { c : p } ) c += 1 if len ( p ) == 1 : if s [ 0 ] not in M . keys ( ) : M . update ( { s [ 0 ] : len ( s ) } ) else : M [ s [ 0 ] ] += len ( s ) best = 0 done = [ ] for i in d : if d [ i ] not in done : p = d [ i ] c_sum = 0 for j in d : if d [ j ] . issubset ( p ) == True : c_sum += N [ j ] done . append ( d [ i ] ) best = max ( c_sum , best ) best_single = 0 for i in M : for j in M : if i != j : best_single = max ( best_single , M [ i ] + M [ j ] ) print ( max ( best , best_single ) )     NEW_LINE


n = int ( input ( ) ) l = [ ] ans = 0 for i in range ( n ) : s = input ( ) l . append ( s ) x = " abcdefghijklmnopqrstuvwxyz " for i in range ( 26 ) : for j in range ( 26 ) : if ( i == j ) : continue c = 0 for s in l : l1 = len ( s ) if ( s . count ( x [ i ] ) + s . count ( x [ j ] ) == l1 ) : c += l1 ans = max ( ans , c ) for i in range ( 26 ) : c = 0 for s in l : l1 = len ( s ) if ( s . count ( x [ i ] ) == l1 ) : c += l1 ans = max ( ans , c ) print ( ans )   NEW_LINE


n = int ( input ( ) ) l = [ ] ans = 0 for i in range ( n ) : s = input ( ) l . append ( s ) x = " abcdefghijklmnopqrstuvwxyz " for i in range ( 26 ) : for j in range ( i + 1 , 26 ) : c = 0 for s in l : l1 = len ( s ) if ( s . count ( x [ i ] ) + s . count ( x [ j ] ) == l1 ) : c += l1 ans = max ( ans , c )   c = 0 for s in l : l1 = len ( s ) if ( s . count ( ' z ' ) == l1 ) : c += l1ans = max ( ans , c ) print ( ans )   NEW_LINE


n = int ( input ( ) ) l = [ ] ans = 0 for i in range ( n ) : s = input ( ) l . append ( s ) x = " abcdefghijklmnopqrstuvwxyz " for i in range ( 26 ) : for j in range ( i + 1 , 26 ) : c = 0 for s in l : l1 = len ( s ) if ( s . count ( x [ i ] ) + s . count ( x [ j ] ) == l1 ) : c += l1 ans = max ( ans , c )   print ( ans )   NEW_LINE


n = int ( input ( ) )   words = [ ] letters = [ ] letfreq = { }   res = [ ]   for w in range ( n ) : wo = input ( ) if len ( set ( list ( wo ) ) ) < 3 : words . append ( wo ) for let in set ( list ( wo ) ) : letters . append ( let )   if len ( words ) == 0 : print ( 0 ) exit ( )   if len ( set ( letters ) ) == 1 : cnt = 0 for bruhy in words : cnt += len ( bruhy ) print ( cnt ) exit ( )   for lt1 in set ( letters ) : for lt2 in set ( letters ) : loc = 0 for o in words : if o . count ( lt1 ) + o . count ( lt2 ) == len ( o ) : loc += len ( o ) res . append ( loc )   print ( max ( res ) )   NEW_LINE


import java . util . * ;    public class BruteForce {   public static Scanner in = new Scanner ( System . in ) ; public static boolean check ( String txt ) { HashSet < Integer > set = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < txt . length ( ) ; i ++ ) set . add ( ( int ) txt . charAt ( i ) ) ; if ( set . size ( ) > 2 ) return false ; else return true ; } public static long getCost ( ArrayList < String > list , char a , char b ) { long cost = 0 ; if ( a == b ) { for ( int i = 0 ; i < list . size ( ) ; i ++ ) { int count = 0 ; String cur = list . get ( i ) ; for ( int j = 0 ; j < cur . length ( ) ; j ++ ) { if ( cur . charAt ( j ) == a ) count ++ ; else { count = 0 ; break ; } } cost += count ; } } else { for ( int i = 0 ; i < list . size ( ) ; i ++ ) { int count = 0 ; String cur = list . get ( i ) ; for ( int j = 0 ; j < cur . length ( ) ; j ++ ) { if ( cur . charAt ( j ) == a || cur . charAt ( j ) == b ) count ++ ; else { count = 0 ; break ; } } cost += count ; } } return cost ; } public static void main ( String [ ] args ) { int n = in . nextInt ( ) ; ArrayList < String > list = new ArrayList < String > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String cur = in . next ( ) ; if ( check ( cur ) ) list . add ( cur ) ; } long max = 0 ; for ( char i = ' a ' ; i <= ' z ' ; i ++ ) { for ( char j = ' a ' ; j <= ' z ' ; j ++ ) { long cur = getCost ( list , i , j ) ; max = Math . max ( cur , max ) ; } } System . out . println ( max ) ; } }


import java . util . * ; import static java . lang . Math . * ; import java . io . * ;   public class SolutionB { public static void main ( String args [ ] ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; List < String > words = new ArrayList < String > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String s = sc . next ( ) ; Set < Character > set = new HashSet < Character > ( ) ; boolean valid = true ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { set . add ( s . charAt ( j ) ) ; if ( set . size ( ) > 2 ) { valid = false ; break ; } } if ( valid ) words . add ( s ) ; } int max = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { for ( int j = i + 1 ; j < 26 ; j ++ ) { char c1 = ( char ) ( i + ' a ' ) ; char c2 = ( char ) ( j + ' a ' ) ; int curr = 0 ; for ( String s : words ) { boolean valid = true ; for ( int k = 0 ; k < s . length ( ) ; k ++ ) { char c = s . charAt ( k ) ; if ( c != c1 && c != c2 ) { valid = false ; break ; } } if ( valid ) curr += s . length ( ) ; } max = Math . max ( curr , max ) ; } } System . out . println ( max ) ; } }


import java . util . Scanner ; import java . util . Arrays ; import java . util . Vector ;    public class MainTest {


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


import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { FastReader input = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int T = 1 ; while ( T -- > 0 ) { int l = input . nextInt ( ) ; Stack < Long > st = new Stack < > ( ) ; long ans = 0 ; long inf = ( long ) Math . pow ( 2 , 32 ) ; st . push ( 1L ) ; for ( int i = 0 ; i < l ; i ++ ) { String s = input . next ( ) ; if ( s . equals ( " for " ) ) { int n = input . nextInt ( ) ; long x = st . peek ( ) ; x = x * n ; st . push ( Math . min ( inf , x ) ) ; } else if ( s . equals ( " add " ) ) { ans += st . peek ( ) ; } else { st . pop ( ) ; } } if ( ans >= inf ) { out . println ( " OVERFLOW ! ! ! " ) ; } else { out . println ( ans ) ; } } out . close ( ) ; } static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }

from collections import defaultdict , OrderedDict , Counterfrom sys import stdin , stdoutfrom bisect import bisect_left , bisect_right NEW_LINE


import timestartTimeProblem = time . time ( )   import fileinput , sys , itertools , functools , mathfrom bisect import * from heapq import * from collections import *     MOD = 10 ** 9 + 7 NEW_LINE


a = int ( input ( ) ) ans = [ ] prod = 1 total = 0 qem = pow ( 2 , 32 ) flag = 0 count = 0 kam = [ ] for i in range ( a ) : s = input ( ) if ( s [ 0 ] == ' a ' ) : gam = 1 if ( len ( ans ) - count >= 32 ) : print ( ' OVERFLOW ! ! ! ' ) exit ( 0 ) ; else : for j in kam : gam = gam * j total += gam if ( total >= qem ) : print ( ' OVERFLOW ! ! ! ' ) exit ( 0 ) ; elif ( s [ 0 ] == ' e ' ) : t = ans . pop ( ) if ( t == 1 ) : count -= 1 else : kam . pop ( ) else : r = int ( s [ 4 : : ] ) ans . append ( r ) if ( r == 1 ) : count += 1 if ( r - 1 ) : kam . append ( r ) print ( total ) NEW_LINE


import java . util . * ; import java . io . * ; public class Mamo { static long mod = 1000000007 ; static Reader in = new Reader ( ) ; static List < Integer > G [ ] ; static long a [ ] , p [ ] , xp [ ] , xv [ ] ; static StringBuilder Sd = new StringBuilder ( ) , Sl = new StringBuilder ( ) ; public static void main ( String [ ] args ) {


import java . util . * ; public class B_Edu66 { public static void main ( String [ ] args ) { Scanner omkar = new Scanner ( System . in ) ; int lines = omkar . nextInt ( ) ; long x = 0 ; long mult = 1 ; int temp ; int notMult = 0 ; Stack < Integer > stack = new Stack < Integer > ( ) ; String st ; for ( int i = 0 ; i < lines ; i ++ ) { st = omkar . next ( ) ; if ( st . charAt ( 0 ) == ' f ' ) { temp = omkar . nextInt ( ) ; stack . push ( temp ) ; if ( mult < Math . pow ( 2 , 32 ) ) { mult = mult * temp ; } else { notMult ++ ; } } if ( st . charAt ( 0 ) == ' a ' ) { x += mult ; if ( x >= Math . pow ( 2 , 32 ) ) { System . out . println ( " OVERFLOW ! ! ! " ) ; return ; } } if ( st . charAt ( 0 ) == ' e ' ) { if ( notMult > 0 ) { notMult -- ; stack . pop ( ) ; } else { mult = mult / stack . pop ( ) ; } } } System . out . println ( x ) ; }   }


import java . util . * ; import java . io . * ; public class EdA { static long [ ] mods = { 1000000007 , 998244353 , 1000000009 } ; static long mod = mods [ 0 ] ; public static MyScanner sc ; public static PrintWriter out ; public static void main ( String [ ] omkar ) throws Exception {


import java . util . * ;   public class CodeForces982A { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; String s = input . next ( ) ; int d = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == '1' ) { if ( d == - 1 ) { if ( i >= 2 ) { System . out . println ( " NO " ) ; return ; } } else if ( i - d == 1 || i - d > 3 ) { System . out . println ( " NO " ) ; return ; } d = i ; } }   if ( n - d > 2 || d == - 1 ) { System . out . println ( " NO " ) ; } else { System . out . println ( " YES " ) ; } } }

n = int ( input ( ) ) s = str ( input ( ) ) s = '0' + s + '0' if ( '11' in s ) or ( '000' in s ) : print ( " No " ) else : print ( " Yes " ) NEW_LINE


n = int ( input ( ) ) s = input ( ) if ( n == 1 ) : if ( s == "0" ) : print ( " No " ) else : print ( " Yes " ) exit ( 0 ) if ( "11" in s ) or ( "000" in s ) or ( s [ - 2 : ] == "00" ) or ( s [ : 2 ] == "00" ) : print ( " No " ) else : print ( " Yes " ) NEW_LINE


n = int ( input ( ) ) s = str ( input ( ) ) ans = ' YES ' count = 1 for i in range ( n ) : if int ( s [ i ] ) == 0 : count += 1 elif int ( s [ i ] ) == 1 and count > 0 : count = 0 else : ans = " NO " break if count > 2 : ans = " NO " breakif len ( s ) == 1 and int ( s [ 0 ] ) == 0 : ans = ' NO ' if count >= 2 : ans = ' NO ' print ( ans ) NEW_LINE


n = int ( input ( ) ) s = input ( ) a = '0' + s + '0' if '000' in a or '11' in a : print ( " NO " ) else : print ( " YES " ) NEW_LINE


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