import javax . swing . plaf . IconUIResource ; import java . io . * ; import java . lang . ref . SoftReference ; import java . math . BigInteger ; import java . nio . file . LinkOption ; import java . util . * ;

import java . util . Scanner ;   public class BearAndPoker { public static void main ( String [ ] args ) { Scanner xScanner = new Scanner ( System . in ) ; int n = xScanner . nextInt ( ) ; int [ ] bids = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { bids [ i ] = xScanner . nextInt ( ) ; bids [ i ] = removePrimeFactors2And3 ( bids [ i ] ) ; if ( i > 0 && bids [ i ] != bids [ i - 1 ] ) { System . out . println ( " NO " ) ; return ; } } System . out . println ( " YES " ) ; }   private static int removePrimeFactors2And3 ( int num ) {

import java . util . Scanner ;   public class BearAndPoker { public static void main ( String [ ] args ) { Scanner xScanner = new Scanner ( System . in ) ; int n = xScanner . nextInt ( ) ; int [ ] bids = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { bids [ i ] = xScanner . nextInt ( ) ; removePrimeFactors2And3 ( bids , i ) ; if ( i > 0 && bids [ i ] != bids [ i - 1 ] ) { System . out . println ( " NO " ) ; return ; } } System . out . println ( " YES " ) ; }   private static void removePrimeFactors2And3 ( int [ ] bids , int i ) {

def answer ( n , a ) : for i in range ( n ) : while a [ i ] % 2 == 0 : a [ i ] //= 2 while a [ i ] % 3 == 0 : a [ i ] //= 3 for i in range ( 1 , n ) : if a [ i - 1 ] != a [ i ] : return ' No '   return ' Yes '       return   def main ( ) : n = int ( input ( ) ) a = [ int ( i ) for i in input ( ) . split ( ) ] print ( answer ( n , a ) ) main ( ) NEW_LINE

from math import gcdn = int ( input ( ) ) ; arr = list ( map ( int , input ( ) . split ( ) ) ) s = set ( ) for i in arr : while i % 2 == 0 : i = i // 2 while i % 3 == 0 : i = i // 3 s . add ( i ) if len ( s ) != 1 : print ( " NO " ) else : print ( " YES " ) NEW_LINE

from math import ceil , sqrt , floor   def isPerfectSquare ( x ) : NEW_LINE

import sysinput = sys . stdin . readline   n = int ( input ( ) ) arr = [ int ( x ) for x in input ( ) . split ( ) ]   pos = set ( [ ] )   for z in arr : while ( z % 2 == 0 ) : z //= 2 while ( z % 3 == 0 ) : z //= 3 pos . add ( z ) if len ( pos ) != 1 : print ( " No " ) else : print ( " Yes " ) NEW_LINE


import java . util . * ; import java . io . * ; import java . math . * ; public class Euler { public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; PrintWriter o = new PrintWriter ( System . out ) ; int n = in . nextInt ( ) ; char [ ] ch = in . next ( ) . toCharArray ( ) ; char [ ] ans = new char [ ch . length ] ; Arrays . fill ( ans , '9' ) ; for ( int i = 0 ; i <= 9 ; i ++ ) { char [ ] ch1 = new char [ ch . length ] ; for ( int j = 0 ; j < n ; j ++ ) { int val = ch [ j ] - '0' ; val = ( val + i ) % 10 ; ch1 [ j ] = ( char ) ( val + '0' ) ; } for ( int j = 0 ; j < n ; j ++ ) { char [ ] ch2 = new char [ ch . length ] ; for ( int k = 0 ; k < n ; k ++ ) { ch2 [ ( k + j ) % n ] = ch1 [ k ] ; } ans = compare ( ans , ch2 ) ; } } for ( int i = 0 ; i < n ; i ++ ) { o . print ( ans [ i ] ) ; } o . println ( ) ; o . close ( ) ; o . flush ( ) ; return ; } public static char [ ] compare ( char [ ] ch1 , char [ ] ch2 ) { for ( int i = 0 ; i < ch1 . length ; i ++ ) { int val1 = ch1 [ i ] - '0' ; int val2 = ch2 [ i ] - '0' ; if ( val1 < val2 ) { return ch1 ; } if ( val2 < val1 ) { return ch2 ; } } return ch1 ; } static final Random random = new Random ( ) ; static void ruffleSort ( int [ ] a ) { int n = a . length ;

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

n = int ( input ( ) ) a = list ( input ( ) ) ans = afor i in range ( 10 ) : for j in range ( n ) : if a < ans : ans = a a = a [ 1 : ] + [ a [ 0 ] ] for j in range ( n ) : a [ j ] = str ( ( int ( a [ j ] ) + 1 ) % 10 ) print ( " " . join ( ans ) ) NEW_LINE

from ast import NameConstantimport bisectimport sysimport mathdef input ( ) : return sys . stdin . readline ( ) . strip ( ) def iinput ( ) : return int ( input ( ) ) def minput ( ) : return map ( int , sys . stdin . readline ( ) . strip ( ) . split ( ) ) def listinput ( ) : return list ( map ( int , sys . stdin . readline ( ) . strip ( ) . split ( ) ) ) n = int ( input ( ) ) a = list ( map ( int , input ( ) ) ) number_possible = [ ] while True : for i in range ( n ) : a [ i ] += 1 if a [ i ] == 10 : a [ i ] = 0 s = ' ' for i in range ( n ) : s += str ( a [ i ] ) if s not in number_possible : number_possible . append ( s ) else : breakfor i in range ( len ( number_possible ) ) : temp = number_possible [ i ] possible = [ temp ] while True : temp = temp [ 1 : ] + temp [ : 1 ] if temp not in possible : possible . append ( temp ) else : break number_possible [ i ] = min ( possible ) print ( min ( number_possible ) ) NEW_LINE


import java . io . * ; import java . util . * ; import java . math . * ;   public class B639 { public static void main ( String [ ] args ) throws IOException { FastScanner fs = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ;

import java . util . * ; import java . io . * ;    public class Forces {   public static PrintWriter cout ; public static void main ( String ... arg ) { Read cin = new Read ( ) ;

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

import sys , os , ioimport math , bisect , operatorinf , mod = float ( ' inf ' ) , 10 ** 9 + 7 NEW_LINE

n , d , h = map ( int , input ( ) . split ( ) ) if d > h * 2 : print ( - 1 ) ; exit ( ) if n > 2 and h == 1 and d == 1 : print ( - 1 ) ; exit ( ) cnt = 0 cur = 1   for i in range ( 1 , h + 1 ) : print ( cur , cur + 1 ) cur += 1 cnt += 1 remain = d - hif remain : cur += 1 ; print ( 1 , cur ) ; remain -= 1 ; cnt += 1 else : cur += 1 while cnt + 1 < n : print ( 2 , cur ) cur += 1 cnt += 1 if remain > 0 : while remain > 0 : print ( cur , cur + 1 ) cnt += 1 cur += 1 remain -= 1 cur += 1 else : cur += 1 while cnt + 1 < n : print ( 1 , cur ) cur += 1 cnt += 1 NEW_LINE

n , d , h = list ( map ( int , input ( ) . split ( ) ) ) if 2 * h < d or ( h == d == 1 and n > 2 ) : print ( - 1 ) else : ans = [ ] z = 1 for i in range ( h ) : ans . append ( ( i + 1 , i + 2 ) ) z = i + 2 k = d - h if k > 0 : ans . append ( ( 1 , z + 1 ) ) z += 1 k -= 1 NEW_LINE

n , d , h = map ( int , input ( ) . split ( ) ) if n == 2 : if d == h and d == 1 : print ( '1 ▁ 2' ) else : print ( - 1 ) elif d == 1 or d > 2 * h : print ( - 1 ) else : for i in range ( h ) : print ( i + 1 , i + 2 ) for i in range ( d - h ) : print ( 1 if i == 0 else i + h + 1 , i + h + 2 ) for i in range ( d + 1 , n ) : print ( 2 if d == h else 1 , i + 1 )     NEW_LINE

import math , sys , bisect , heapq , osfrom collections import defaultdict , Counter , dequefrom itertools import groupby , accumulatefrom functools import lru_cache NEW_LINE


import java . util . Scanner ;   public class n363B { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   int n = scanner . nextInt ( ) ; int k = scanner . nextInt ( ) ; int [ ] fence = new int [ n ] ; int a ; for ( int i = 0 ; i < n ; i ++ ) { a = scanner . nextInt ( ) ; if ( i == 0 ) fence [ i ] = a ; else fence [ i ] = fence [ i - 1 ] + a ; } int min = fence [ k - 1 ] ; int index = 1 ; int result ; for ( int i = 1 ; i < n - k + 1 ; i ++ ) { result = fence [ i + k - 1 ] - fence [ i - 1 ] ; if ( result < min ) { min = result ; index = i + 1 ; } } System . out . println ( index ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . List ; import java . util . StringTokenizer ;   public class Fence { 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 ( ) ; int n , k ; n = sc . nextInt ( ) ; k = sc . nextInt ( ) ; List < Integer > l = new ArrayList < > ( ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { l . add ( sc . nextInt ( ) ) ; sum += l . get ( i ) ; }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class B363_Fence {   public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer stt = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( stt . nextToken ( ) ) ; int k = Integer . parseInt ( stt . nextToken ( ) ) ; int [ ] arr = new int [ n ] ; stt = new StringTokenizer ( br . readLine ( ) ) ; int min = Integer . MAX_VALUE ; int index = 1 ; for ( int i = 0 ; i < n ; ++ i ) { arr [ i ] = Integer . parseInt ( stt . nextToken ( ) ) + ( i == 0 ? 0 : arr [ i - 1 ] ) ; if ( i >= k - 1 ) { if ( i == k - 1 ) { min = arr [ i ] ; index = 1 ; } else { int can = arr [ i ] - arr [ i - k ] ; if ( can < min ) { min = can ; index = i - k + 2 ; } } }   }

import java . util . * ; public class MyClass { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; int sum = 0 , d = 0 , k1 = k - 1 ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < k ; i ++ ) sum = sum + arr [ i ] ; int temp = sum ; for ( int i = k ; i < n ; i ++ ) { sum = sum + arr [ i ] - arr [ i - k ] ;

def solution ( ) : n , k = map ( int , input ( ) . split ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) sol = [ 0 ] * ( n - k + 1 ) sol [ 0 ] = sum ( arr [ : k ] ) mn = sol [ 0 ] idx = 1 for i in range ( 1 , n - k + 1 ) : sol [ i ] = sol [ i - 1 ] - arr [ i - 1 ] + arr [ i + k - 1 ] if sol [ i ] < mn : mn = sol [ i ] idx = i + 1 print ( idx )   	     returnsolution ( ) NEW_LINE

import pdb   def solve ( n , k , fence ) : res = 0 val = sum ( fence [ : k ] ) mn = val for l , r in zip ( range ( 1 , n ) , range ( k , n ) ) : val -= fence [ l - 1 ] val += fence [ r ] if val < mn : res = l mn = val print ( res + 1 )   def main ( ) : n , k = map ( int , input ( ) . split ( ) ) fence = list ( map ( int , input ( ) . split ( ) ) ) solve ( n , k , fence )   if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) s = 0 a = [ ] if n == 1 : print ( 1 ) else : for i in range ( k ) : a . append ( l [ i ] ) s += l [ i ] mn = s ans = k - 1 NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) m = list ( map ( int , input ( ) . split ( ) ) ) a = { } c = 0 d = 0 b = sum ( m [ : k ] ) for i in range ( n - k + 1 ) : b = b + c - d a [ b ] = i + 1 d = m [ i ] c = m [ i + k - 1 * ( i == n - k ) ] print ( a [ min ( a ) ] ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; sc . nextLine ( ) ; for ( int i = 2 ; i <= k + 1 ; i ++ ) { String na = sc . nextLine ( ) ; int l = na . length ( ) ; if ( na . length ( ) > 10 ) { na = na . charAt ( 0 ) + String . valueOf ( l - 2 ) + na . charAt ( na . length ( ) - 1 ) ; } System . out . println ( na ) ; } } }

import java . io . * ; public class sol { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; String a [ ] = new String [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { String line = br . readLine ( ) ; if ( line . length ( ) > 10 ) { a [ i ] = " " + line . charAt ( 0 ) + ( line . length ( ) - 2 ) + line . charAt ( line . length ( ) - 1 ) ; } else { a [ i ] = line ; } } for ( int i = 0 ; i < a . length ; i ++ ) { System . out . println ( a [ i ] ) ; } } }

import java . io . * ; import java . util . * ; import java . lang . * ; import java . util . Random ; public class Main { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scan = new Scanner ( System . in ) ; int repeat = scan . nextInt ( ) ; while ( repeat -- > 0 ) { String test = scan . next ( ) ; int len = test . length ( ) ; if ( len <= 10 ) { System . out . println ( test ) ; } else { String val = " " + ( test . length ( ) - 2 ) ; String str = test . charAt ( 0 ) + val + test . charAt ( test . length ( ) - 1 ) ; System . out . println ( str ) ; } } } }

import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { String str = scanner . next ( ) ; if ( str . length ( ) > 10 ) { System . out . println ( " " + str . charAt ( 0 ) + ( str . length ( ) - 2 ) + str . charAt ( str . length ( ) - 1 ) ) ; } else { System . out . println ( str ) ; } } } }

import java . util . Scanner ;   public class WayTooLongWords {   public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int i1 = scan . nextInt ( ) ; String [ ] strings = new String [ i1 ] ; for ( int i = 0 ; i < i1 ; i ++ ) { strings [ i ] = scan . next ( ) ; } String curr ; int length ;   for ( int i = 0 ; i < i1 ; i ++ ) { if ( strings [ i ] . length ( ) > 10 ) { curr = strings [ i ] ; length = curr . length ( ) ; System . out . println ( String . valueOf ( curr . charAt ( 0 ) ) + ( length - 2 ) + String . valueOf ( curr . charAt ( length - 1 ) ) ) ; } else { System . out . println ( strings [ i ] ) ; } } }   }

n = int ( input ( ) ) NEW_LINE if 1 <= n <= 100 : for NEW_LINE i in range ( n ) : words = input ( ) NEW_LINE if len ( words ) > 10 : NEW_LINE INDENT print ( words [ 0 ] + str ( len ( words ) - 2 ) + words [ - 1 ] ) else : NEW_LINE print ( words ) NEW_LINE DEDENT

for _ in range ( int ( input ( ) ) ) : line = input ( ) NEW_LINE length = len ( line ) NEW_LINE print ( ( line [ 0 ] + str ( length - 2 ) + line [ - 1 ] ) if length > 10 else line ) NEW_LINE

a = int ( input ( ) ) NEW_LINE for i in range ( a ) : x = input ( ) NEW_LINE if ( len ( x ) > 10 ) : NEW_LINE INDENT print ( x [ 0 ] + str ( len ( x ) - 2 ) + x [ - 1 ] ) else : NEW_LINE print ( x )                   NEW_LINE DEDENT

n = int ( input ( ) ) NEW_LINE for i in range ( n ) : str1 = input ( ) NEW_LINE if len ( str1 ) > 10 : NEW_LINE INDENT print ( str1 [ 0 ] + str ( len ( str1 ) - 2 ) + str1 [ - 1 ] ) else : NEW_LINE print ( str1 ) NEW_LINE DEDENT

l = [ ] NEW_LINE n = int ( input ( " " ) ) NEW_LINE for i in range ( n ) : x = input ( " " ) NEW_LINE l . append ( x ) NEW_LINE for i in l : if NEW_LINE len ( i ) <= 10 : print ( i ) else : s = " " NEW_LINE s = s + i [ 0 ] NEW_LINE s = s + str ( len ( i ) - 2 ) NEW_LINE s = s + i [ len ( i ) - 1 ] NEW_LINE print ( s ) NEW_LINE


import java . util . * ; import java . io . * ;   public class Bits {   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 = int ( input ( ) )   def count ( num ) : ct = 0 for i in range ( len ( num ) ) : if num [ i : i + 1 ] == '1' : ct += 1 return ct   for i in range ( n ) : line = input ( ) . split ( ) a = int ( line [ 0 ] ) b = int ( line [ 1 ] ) if a == b : print ( a ) continue   l = bin ( a ) [ 2 : : ] u = bin ( b ) [ 2 : : ]   while len ( l ) < 60 : l = '0' + l while len ( u ) < 60 : u = '0' + u start = '1' * 60   end = " " for j in range ( 59 ) : charL = l [ j : j + 1 ] charU = u [ j : j + 1 ]   if charL == charU and charL == '0' : end += '0' continue if charL != charU : end += '0' + start [ j + 1 : : ] break end += '1' NEW_LINE

def solve ( l , r ) : i = 62 while i >= 0 and l & ( 1 << i ) == r & ( 1 << i ) : i -= 1 if i < 0 : return l for c in [ r | ( ( 1 << ( i + 1 ) ) - 1 ) , l | ( ( 1 << i ) - 1 ) ] : if c <= r : return c     n = int ( input ( ) ) for _ in range ( n ) : l , r = map ( int , input ( ) . split ( ) ) print ( solve ( l , r ) ) NEW_LINE

import math , sysfrom collections import defaultdict , dequeimport bisect as bidef yes ( ) : print ( ' YES ' ) def no ( ) : print ( ' NO ' ) def I ( ) : return ( int ( sys . stdin . readline ( ) ) ) def In ( ) : return ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) def Sn ( ) : return sys . stdin . readline ( ) . strip ( ) def Pr ( x ) : sys . stdout . write ( str ( x ) + ' \n ' ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . HashSet ; import java . util . Set ;   public class CWeakenedCommonDivisor {   static int MAX = 1000000 ; static int SQRT = 1000 ; static ArrayList < Integer > primes = new ArrayList < > ( ) ; static boolean [ ] marked = new boolean [ MAX + 1 ] ; static ArrayList < Integer > factors = new ArrayList < > ( ) ;   static void sieve ( ) { marked [ 1 ] = true ; int i = 2 ; for ( ; i < SQRT ; i ++ ) { if ( ! marked [ i ] ) { primes . add ( i ) ; for ( int j = i * i ; j <= MAX ; j += i ) { marked [ j ] = true ; } } } for ( ; i <= MAX ; i ++ ) { if ( ! marked [ i ] ) { primes . add ( i ) ; } } }   public static void primeFactors ( int n ) { factors . clear ( ) ; for ( int i = 0 , p = primes . get ( i ) ; p * p <= n ; p = primes . get ( ++ i ) ) { while ( n % p == 0 ) { factors . add ( p ) ; n /= p ; } } if ( n > 1 ) { factors . add ( n ) ; } }   public static void main ( String [ ] args ) throws IOException {   BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; sieve ( ) ; Set < Integer > union = null ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] spl = br . readLine ( ) . split ( " ▁ " ) ; int a = Integer . parseInt ( spl [ 0 ] ) ; int b = Integer . parseInt ( spl [ 1 ] ) ; if ( i == 0 ) { union = new HashSet < Integer > ( ) ; primeFactors ( a ) ; union . addAll ( factors ) ; primeFactors ( b ) ; union . addAll ( factors ) ; } else {

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

import java . util . * ;   public class CodeForces1504C { static Set < Integer > set = new HashSet < > ( ) ; public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] b = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; b [ i ] = input . nextInt ( ) ; } divisor ( a [ 0 ] ) ; divisor ( b [ 0 ] ) ; int count = 0 ; for ( int m : set ) { boolean bool = true ; for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i ] % m != 0 && b [ i ] % m != 0 ) { bool = false ; break ; } } if ( bool ) { System . out . println ( m ) ; return ; } }   System . out . println ( - 1 ) ; }    public static void divisor ( int x ) { int y = x ; for ( int i = 2 ; i <= Math . sqrt ( x ) ; i ++ ) { boolean bool = false ; while ( y % i == 0 ) { y /= i ; bool = true ; }   if ( bool ) { set . add ( i ) ; } } if ( y != 1 ) { set . add ( y ) ; } } }

from collections import defaultdict , deque , Counterfrom sys import stdin , stdoutfrom heapq import heappush , heappopimport mathimport ioimport osimport mathimport bisect   NEW_LINE

import functoolsimport timefrom collections import Counter   def timer ( func ) : @ functools . wraps ( func ) def wrapper ( * args , ** kwargs ) : stime = time . perf_counter ( ) res = func ( * args , ** kwargs ) elapsed = time . perf_counter ( ) - stime print ( f " { func . _ _ name _ _ } ▁ in ▁ { elapsed : .4f } ▁ secs " ) return res return wrapper   class solver : NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   import java . util . Scanner ; import java . util . StringTokenizer ;    public class Main { 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 int zeroes ( int n ) { int count = 0 ; while ( n > 0 ) { n /= 5 ; count += n ; } return count ; } public static void binarySearch ( int n ) { int low = 0 ; int high = Integer . MAX_VALUE ; while ( low < high ) { int middle = ( low + high ) / 2 ; int count = zeroes ( middle ) ; if ( count < n ) { low = middle + 1 ; } else { high = middle ; } } int ans [ ] = new int [ 1000 ] ; int k = 0 ; while ( zeroes ( low ) == n ) { ans [ k ] = low ; k ++ ; low ++ ; } System . out . println ( k ) ; for ( int i = 0 ; i < k ; i ++ ) { System . out . print ( ans [ i ] + " ▁ " ) ; } }    public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; FastReader sc = new FastReader ( ) ; int n = sc . nextInt ( ) ; binarySearch ( n ) ; }   }

import java . util . * ; import java . io . * ; import java . math . * ; import java . lang . Math . * ;   public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long m = sc . nextLong ( ) ; long x = 5 ; long s = 0 ; long w = 0 ; long y = 0 ; while ( s < m ) { long r ; for ( long t = 1 ; t <= 100000 ; t ++ ) { r = x * t ; while ( r % 5 == 0 ) { s ++ ; r = r / 5 ; } if ( s > m ) { w = 1 ; break ; } else if ( s == m ) { w = 0 ; y = t ; break ; } } } long q = 5 * y ; if ( w == 0 ) { System . out . println ( "5" ) ; for ( int i = 0 ; i < 5 ; i ++ ) { System . out . print ( q + " ▁ " ) ; q ++ ; } } else { System . out . println ( "0" ) ; } } }

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

m = int ( input ( ) ) count = 0 i = n = 5 arr = [ ] while count <= m : while n % 5 == 0 : count += 1 n //= 5 if count == m : arr . append ( i ) i += 1 n = iif arr == [ ] : print ( 0 ) else : print ( 5 ) print ( * arr ) NEW_LINE

m = int ( input ( ) ) x , z = 5 , 0 while z < m : n = x while n % 5 == 0 : z += 1 n /= 5 x += 5 print ( f ' {5 } \n { x - 5 } ▁ { x - 4 } ▁ { x - 3 } ▁ { x - 2 } ▁ { x - 1 } ' if z == m else 0 ) NEW_LINE

n0 = lambda n : sum ( n // 5 ** i for i in range ( 1 , 64 ) ) n = int ( input ( ) )   l , r , x = 0 , 4000006 , 0 while l <= r : m = ( l + r ) // 2 k = n0 ( m ) if n == k : x = m r = m - 1 elif n > k : l = m + 1 else : r = m - 1   print ( f ' {5 } \n { x } ▁ { x + 1 } ▁ { x + 2 } ▁ { x + 3 } ▁ { x + 4 } ' if n0 ( x ) == n else 0 ) NEW_LINE

def findTrailingZeros ( t ) : count = 0 i = 5 while ( t / i >= 1 ) : count += int ( t / i ) i *= 5 return int ( count ) m = int ( input ( ) ) k = 0 N_list = list ( ) for i in range ( 0 , 500000 ) : t = findTrailingZeros ( i ) if ( t == m ) : k = k + 1 N_list . append ( i ) print ( k ) for i in N_list : print ( i , end = " ▁ " ) NEW_LINE

m = int ( input ( ) ) if m == 0 : print ( 1 , 2 , 3 , 4 ) else : ans = [ 1 ] i = 10 while ans [ - 1 ] < m : cnt = 0 num = i while num % 5 == 0 : num //= 5 cnt += 1 i += 5 ans . append ( cnt + ans [ - 1 ] ) if ans [ - 1 ] == m : print ( 5 ) ln = len ( ans ) for k in range ( ln * 5 , ( ln * 5 ) + 5 ) : print ( k , end = " ▁ " ) else : print ( 0 ) NEW_LINE


import java . util . Scanner ;   public class LCMWall { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   int x = scanner . nextInt ( ) ; int y = scanner . nextInt ( ) ;   int a = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ;   int comm = lcm ( x , y ) ; long ans = ( ( b - b % comm ) - ( a - a % comm ) ) / comm ;   if ( a % comm == 0 ) ans ++ ;   System . out . println ( ans ) ; }   public static int gcf ( int x , int y ) { if ( y == 0 ) return x ;   return gcf ( y , x % y ) ; }   public static int lcm ( int x , int y ) { return x * y / gcf ( x , y ) ; } }

import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { int x , y , a , b , min , max , sum = 0 , fir , lir ; Scanner scanner = new Scanner ( System . in ) ; x = scanner . nextInt ( ) ; y = scanner . nextInt ( ) ; a = scanner . nextInt ( ) ; b = scanner . nextInt ( ) ; min = Math . min ( x , y ) ; max = Math . max ( x , y ) ; int limit = b ; int common = max ; int temp = common / min ; while ( temp * min != common && common <= b ) { common += max ; temp = common / min ; } temp = ( ( int ) ( a / common ) * common ) ; fir = ( temp >= a ) ? temp : temp + common ; temp = ( ( int ) ( b / common ) * common ) ; while ( temp <= b ) { temp += common ; } lir = temp - common ; System . out . print ( ( ( lir - fir ) / common ) + 1 ) ;   } }

import java . util . * ; import java . lang . * ;

import math   x , y , a , b = map ( int , input ( ) . split ( ) ) l = x * y // math . gcd ( x , y ) print ( b // l - ( a - 1 ) // l ) NEW_LINE

x , y , a , b = map ( int , input ( ) . split ( ) ) u = 0 import math     f = math . gcd ( x , y ) lcm = x * y // f   print ( b // lcm - ( a - 1 ) // lcm ) NEW_LINE

from math import gcda , b , c , d = map ( int , input ( ) . split ( ) ) lcmm = ( a * b ) // gcd ( a , b ) div_c = ( d // lcmm ) - ( ( c - 1 ) // lcmm ) print ( div_c ) NEW_LINE

import math   x , y , a , b = map ( int , input ( ) . split ( ) ) l = max ( x , y ) * min ( x , y ) // math . gcd ( x , y ) print ( b // l - ( a - 1 ) // l ) NEW_LINE


import java . util . * ; public class Third {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s1 = sc . next ( ) ; String s2 = sc . next ( ) ; String s3 = sc . next ( ) ; int a1 = beauty ( s1 , n ) ; int a2 = beauty ( s2 , n ) ; int a3 = beauty ( s3 , n ) ; if ( a1 > a2 && a1 > a3 ) System . out . println ( " Kuro " ) ; else if ( a2 > a1 && a2 > a3 ) System . out . println ( " Shiro " ) ; else if ( a3 > a1 && a3 > a2 ) System . out . println ( " Katie " ) ; else System . out . println ( " Draw " ) ; }   static int beauty ( String s , int n ) { int cnt [ ] = new int [ 128 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; cnt [ c ] ++ ; } for ( char c = ' a ' ; c <= ' z ' ; c ++ ) { if ( cnt [ c ] == s . length ( ) && n == 1 ) cnt [ c ] -- ; else { cnt [ c ] += n ; cnt [ c ] = Math . min ( s . length ( ) , cnt [ c ] ) ; } } for ( char c = ' A ' ; c <= ' Z ' ; c ++ ) { if ( cnt [ c ] == s . length ( ) && n == 1 ) cnt [ c ] -- ; else { cnt [ c ] += n ; cnt [ c ] = Math . min ( s . length ( ) , cnt [ c ] ) ; } } int max = 0 ; for ( int i = 0 ; i < 128 ; i ++ ) { max = Math . max ( max , cnt [ i ] ) ; } return max ; } }

import java . io . BufferedReader ; import java . io . * ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; import java . math . * ; public class Main { 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 main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int t = 1 ;

n = int ( input ( ) ) black = list ( input ( ) ) white = list ( input ( ) ) katie = list ( input ( ) )   ALPHABET = [ chr ( i ) for i in range ( 65 , 65 + 26 ) ] + [ chr ( i ) for i in range ( 97 , 97 + 26 ) ]     def optimal_score ( LIST ) : d = { char : 0 for char in ALPHABET } for v in LIST : d [ v ] += 1 max_freq = max ( d . values ( ) ) L = len ( LIST ) res = 0 for freq in d . values ( ) : if L - freq >= n : res = max ( res , freq + n ) else : if not ( L - freq < n and n == 1 ) : res = L else : res = max ( res , L - 1 ) return res     score_black = optimal_score ( black ) score_white = optimal_score ( white ) score_katie = optimal_score ( katie )   M = max ( score_black , score_katie , score_white ) MAXCNT = 0   winner = " NOBODY "     if M == score_black : winner = " Kuro " MAXCNT += 1 if M == score_white : winner = " Shiro " MAXCNT += 1 if M == score_katie : winner = " Katie " MAXCNT += 1   if MAXCNT == 1 : print ( winner )   else : print ( " Draw " ) NEW_LINE

n = int ( input ( ) )   kuroo = input ( ) shiro = input ( ) katie = input ( )   kuroo_dict = { } shiro_dict = { } katie_dict = { }   def cal ( d , str , n ) :   for i in range ( len ( str ) ) : if str [ i ] in d : d [ str [ i ] ] += 1 else : d [ str [ i ] ] = 1   m = 0 for key in d : m = max ( m , d [ key ] )   if ( n == 1 and m == len ( str ) ) : m = len ( str ) - 1 else : m = min ( m + n , len ( str ) )     return m         ans_kuroo = cal ( kuroo_dict , kuroo , n ) ans_shiro = cal ( shiro_dict , shiro , n ) ans_katie = cal ( katie_dict , katie , n ) ans = max ( ans_kuroo , ans_shiro , ans_katie )   if ( ans_kuroo == ans_katie and ans_kuroo == ans ) or ( ans_katie == ans_shiro and ans_shiro == ans ) or ( ans_shiro == ans_kuroo and ans_kuroo == ans ) : print ( " Draw " ) else : if ans == ans_kuroo : print ( " Kuro " ) elif ans == ans_shiro : print ( " Shiro " ) else : print ( " Katie " )           NEW_LINE

n = int ( input ( ) ) se = [ ] def fun ( kuro ) : global se le = len ( kuro ) dic = { } for i in kuro : if ( i in dic ) : dic [ i ] += 1 else : dic [ i ] = 1 a1 = 1 for i in dic : ma = dic [ i ] rest = le - ma if ( rest >= n ) : a1 = max ( ma + n , a1 ) elif ( n != 1 ) : a1 = max ( ma + rest , a1 ) else : if ( rest == 0 ) : a1 = max ( a1 , ma - 1 ) else : a1 = max ( a1 , ma + 1 ) se . append ( a1 ) for i in range ( 3 ) : fun ( input ( ) ) ma = max ( se ) if ( se . count ( ma ) != 1 ) : print ( ' Draw ' ) else : if ( se [ 0 ] == ma ) : print ( ' Kuro ' ) elif ( se [ 1 ] == ma ) : print ( ' Shiro ' ) else : print ( ' Katie ' ) NEW_LINE


import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ;   public class Fridge { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int T = sc . nextInt ( ) ; while ( T -- > 0 ) { int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] ar = new int [ n ] ; List < Integer > grt = new ArrayList < Integer > ( ) ; List < Integer > sml = new ArrayList < Integer > ( ) ; long sum = 0 , cur = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; if ( ar [ i ] >= x ) grt . add ( ar [ i ] ) ; else sml . add ( ar [ i ] ) ; sum += ar [ i ] ; } Collections . sort ( sml ) ; Collections . sort ( grt ) ; int i = 0 ; int div = n ; while ( i < n ) {

t = int ( input ( ) ) u = [ ] for i in range ( t ) : z = list ( map ( int , input ( ) . split ( ) ) ) y = list ( map ( int , input ( ) . split ( ) ) ) x = z [ 1 ] n = z [ 0 ] e = [ ] c = [ ] b = [ ] for j in range ( len ( y ) ) : if y [ j ] >= x : e . append ( y [ j ] - x ) else : c . append ( x - y [ j ] ) b . append ( y [ j ] ) es = sum ( e ) c . sort ( ) b . sort ( ) k = 0 p = 0 NEW_LINE

t = int ( input ( ) )   while t > 0 : t -= 1 n , x = map ( int , input ( ) . split ( ' ▁ ' ) ) A = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) A . sort ( reverse = True )   c = 0 temp = 0 for i in range ( n ) : if temp + A [ i ] >= ( i + 1 ) * x : temp += A [ i ] c += 1 else : break print ( c ) NEW_LINE

for i in range ( int ( input ( ) ) ) : a , b = [ int ( i ) for i in input ( ) . split ( ) ] l = [ int ( i ) for i in input ( ) . split ( ) ] l . sort ( reverse = True ) count = 0 sumi = 0 for i in range ( a ) : if l [ i ] < b : k = b - l [ i ] if sumi >= k : count += 1 sumi -= k else : count += 1 sumi += ( l [ i ] - b ) print ( count ) NEW_LINE

n = int ( input ( ) ) for i in range ( n ) : a , b = [ int ( i ) for i in input ( ) . split ( ) ] s = [ int ( i ) for i in input ( ) . split ( ) ] s . sort ( ) total = sum ( s ) j = 0 while a > 0 and total // a < b : a -= 1 total -= s [ j ] j += 1 print ( a ) NEW_LINE

t = int ( input ( ) ) for i in range ( t ) : n , x = map ( int , input ( ) . split ( ) ) m = list ( map ( int , input ( ) . split ( ) ) ) m . sort ( ) s = sum ( m ) num = n for i in range ( n ) : if x <= s / num : break s = s - m [ i ] num -= 1 print ( num )                                                                                NEW_LINE


import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int al = scanner . nextInt ( ) ; int ar = scanner . nextInt ( ) ; int bl = scanner . nextInt ( ) ; int br = scanner . nextInt ( ) ; if ( br >= al - 1 && br <= 2 * ( al + 1 ) && al != 0 ) { System . out . println ( " YES " ) ; return ; } else if ( bl >= ar - 1 && bl <= 2 * ( ar + 1 ) && ar != 0 ) { System . out . println ( " YES " ) ; return ; } else { System . out . println ( " NO " ) ; } } }

import java . util . * ; import java . io . * ;   public class Tournament { public static void main ( String [ ] args ) throws IOException { BufferedReader brs = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ;   int t = 1 ;   while ( t -- > 0 ) { String str [ ] = brs . readLine ( ) . trim ( ) . split ( " ▁ " ) ; int gl = Integer . parseInt ( str [ 0 ] ) ; int gr = Integer . parseInt ( str [ 1 ] ) ; str = brs . readLine ( ) . trim ( ) . split ( " ▁ " ) ; int bl = Integer . parseInt ( str [ 0 ] ) ; int br = Integer . parseInt ( str [ 1 ] ) ; if ( check ( gl , br ) || check ( gr , bl ) ) pw . println ( " YES " ) ; else pw . println ( " NO " ) ; } pw . flush ( ) ; }   public static boolean check ( int g , int b ) { if ( b < g - 1 ) return false ;   b = b - 2 * ( g - 1 ) ; int x = b / 2 ; b -= x ;   if ( b < 3 && x < 3 ) return true ; else return false ; } }

def fingers ( a , b ) : if NEW_LINE b + 1 >= a and 2 * a + 2 >= b : NEW_LINE return True   a , a1 = map ( int , input ( ) . split ( ) ) NEW_LINE b , b1 = map ( int , input ( ) . split ( ) ) NEW_LINE if fingers ( a , b1 ) or fingers ( a1 , b ) == True : NEW_LINE INDENT print ( ' YES ' ) else : NEW_LINE print ( ' NO ' ) NEW_LINE DEDENT

from math import ceil   ai , ar = map ( int , input ( ) . split ( ) ) NEW_LINE bi , br = map ( int , input ( ) . split ( ) )   if ( ceil ( bi / 2 ) - 1 <= ar and not bi + 1 < ar ) or ( ceil ( br / 2 ) - 1 <= ai and not br + 1 < ai ) : NEW_LINE INDENT print ( ' YES ' ) else : NEW_LINE print ( ' NO ' ) NEW_LINE DEDENT

gf = input ( ) . split ( ) NEW_LINE bf = input ( ) . split ( )   al , ar = int ( gf [ 0 ] ) , int ( gf [ 1 ] ) NEW_LINE bl , br = int ( bf [ 0 ] ) , int ( bf [ 1 ] )   if ar - 1 <= bl <= 2 * ar + 2 or al - 1 <= br <= 2 * al + 2 : NEW_LINE INDENT print ( " YES " ) else : NEW_LINE print ( " NO " ) NEW_LINE DEDENT

import matha = input ( ) NEW_LINE a = a . split ( ) NEW_LINE a = [ int ( i ) for i in a ] NEW_LINE b = input ( ) NEW_LINE b = b . split ( ) NEW_LINE b = [ int ( i ) for i in b ] NEW_LINE if ( a [ 0 ] <= b [ 1 ] + 1 ) and ( math . floor ( ( b [ 1 ] + 1 ) / 2 ) - 1 <= a [ 0 ] ) : NEW_LINE INDENT print ( ' YES ' ) elif ( a [ 1 ] <= b [ 0 ] + 1 ) and ( math . floor ( ( b [ 0 ] + 1 ) / 2 ) - 1 <= a [ 1 ] ) : NEW_LINE print ( ' YES ' ) else : NEW_LINE print ( ' NO ' )   NEW_LINE DEDENT

al , ar = map ( int , input ( ) . split ( ) ) NEW_LINE bl , br = map ( int , input ( ) . split ( ) ) NEW_LINE if 2 * ( al + 1 ) >= br >= al - 1 or 2 * ( ar + 1 ) >= bl >= ar - 1 : NEW_LINE INDENT print ( " YES " ) else : NEW_LINE print ( " NO " ) NEW_LINE DEDENT


import java . io . * ; import java . util . * ; import java . math . * ; import java . math . BigInteger ;    public final class A { static StringBuilder ans = new StringBuilder ( ) ; static FastReader in = new FastReader ( ) ; static ArrayList < ArrayList < Integer > > g , tg ; static long mod = 998244353 ; static boolean set [ ] , col [ ] ; static int D [ ] , par [ ] ; static pair size [ ] , size1 [ ] ; static char G [ ] [ ] ; static int dp [ ] [ ] ;

import java . util . * ; import java . io . * ; import java . math . * ;   public class Main   { static FastReader sc = new FastReader ( ) ; static int dp [ ] [ ] ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ;   public class Main {   static void sort ( int a [ ] ) { Random ran = new Random ( ) ; for ( int i = 0 ; i < a . length ; i ++ ) { int r = ran . nextInt ( a . length ) ; int temp = a [ r ] ; a [ r ] = a [ i ] ; a [ i ] = temp ; }   Arrays . sort ( a ) ; }   public static void main ( String [ ] args ) throws IOException { FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; int a [ ] = new int [ n + 1 ] ; int max = Integer . MIN_VALUE ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = input . nextInt ( ) ; max = Math . max ( max , a [ i ] ) ; }

import java . util . * ; import java . lang . * ; import java . io . * ;   public class GFG { 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 ( ) ) ; } } public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ;     int size = sc . nextInt ( ) ; long a [ ] = new long [ size ] ; int c = 0 ; for ( int u = 0 ; u < size ; u ++ ) { a [ u ] = sc . nextLong ( ) ; if ( a [ u ] != 1 ) { c ++ ; } } Arrays . sort ( a ) ; if ( c != 0 ) { System . out . print ( "1 ▁ " ) ; for ( int u = 0 ; u < size - 1 ; u ++ ) { System . out . print ( a [ u ] + " ▁ " ) ; } } if ( c == 0 ) { for ( int u = 0 ; u < size - 1 ; u ++ ) { System . out . print ( a [ u ] + " ▁ " ) ; } System . out . print ( "2 ▁ " ) ; }   System . out . println ( ) ; } }

# include < bits / stdc ++ . h > using namespace std ; int a [ 100001 ] ; int main ( ) { int n ; cin >> n ; for ( int i = 0 ; i < n ; i ++ ) { cin >> a [ i ] ; } sort ( a , a + n ) ; if ( a [ n - 1 ] == 1 ) { a [ n - 1 ] = 2 ; } else { a [ n - 1 ] = 1 ; sort ( a , a + n ) ; } sort ( a , a + n ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { cout << a [ i ] << " ▁ " ; } cout << a [ n - 1 ] ; }

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) temp = max ( a ) if len ( set ( a ) ) == 1 and a [ 0 ] == 1 : print ( * a [ : - 1 ] , 2 ) else : a [ a . index ( temp ) ] = 1 a . sort ( ) print ( * a ) NEW_LINE

a = int ( input ( ) ) b = list ( map ( int , input ( ) . split ( ) ) ) z = max ( b ) if z == 1 : b [ b . index ( z ) ] = 2 else : b [ b . index ( z ) ] = 1 print ( * sorted ( b ) ) NEW_LINE

import sysfrom functools import lru_cache , cmp_to_keyfrom heapq import merge , heapify , heappop , heappush NEW_LINE


import java . util . * ;   public class CF102 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; if ( n % 2 == 0 ) { if ( k <= n / 3 && k != 0 ) { System . out . println ( 1 + " ▁ " + 2 * k ) ; } else { if ( k == 0 || k == n ) { System . out . println ( 0 + " ▁ " + 0 ) ; } else { System . out . println ( 1 + " ▁ " + ( n - k ) ) ; } } } else { if ( k <= ( n / 3 ) ) { if ( k == 0 ) { System . out . println ( 0 + " ▁ " + 0 ) ; } else { System . out . println ( 1 + " ▁ " + 2 * k ) ;   } } else { if ( k == n ) { System . out . println ( 0 + " ▁ " + 0 ) ; } else { System . out . println ( 1 + " ▁ " + ( n - k ) ) ; } } }   } }

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

import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String a [ ] = new String [ 8 ] ; int n = input . nextInt ( ) ; int k = input . nextInt ( ) ; if ( k == 0 || k == n ) System . out . println ( 0 + " ▁ " + 0 ) ; else { System . out . print ( 1 + " ▁ " ) ; int sale = n - k ; System . out . println ( Math . min ( sale , k * 2 ) ) ; } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int k = s . nextInt ( ) ; if ( k == 0 || k == n ) System . out . print ( "0 ▁ " ) ; else System . out . print ( "1 ▁ " ) ; if ( n - ( 3 * k ) >= 0 ) System . out . print ( 2 * k ) ; else System . out . print ( n - k ) ; } }

import mathinp = input ( ) n , k = inp . split ( ) n = int ( n ) k = int ( k ) minn = 1 if ( n - k == 0 ) or ( k == 0 ) : minn = 0 maxx = 0   maxx = k * 2 if ( n - maxx - k < 0 ) : maxx = n - k     print ( minn , end = " ▁ " ) print ( maxx ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) if n == k or k == 0 : print ( 0 , 0 ) else : print ( 1 , min ( n - k , 2 * k ) ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) if k == n or k == 0 : print ( 0 , 0 ) elif k <= ( n ) // 3 : print ( 1 , k * 2 ) else : print ( 1 , n - k ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) print ( min ( k , 1 , 1 - ( k == n ) ) , min ( k * 2 , n - k ) ) NEW_LINE

n , k = input ( ) . split ( ) n = int ( n ) k = int ( k ) if ( k >= n or k == 0 ) : min1 = 0 max1 = 0 else : min1 = 1 if ( k * 3 <= n ) : max1 = k * 2 else : x = k * 3 - n max1 = k * 2 - xprint ( min1 , end = " ▁ " ) print ( max1 ) NEW_LINE


import java . io . * ; import java . util . * ; public class Solution { public static void main ( String args [ ] ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int n = Integer . parseInt ( reader . readLine ( ) ) ; String s = reader . readLine ( ) ; int arr [ ] = new int [ n ] , arr_1 [ ] = new int [ n ] , arr_2 [ ] = new int [ n ] ; arr_1 [ 0 ] = 1 ; arr_2 [ n - 1 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( s . charAt ( i - 1 ) == ' R ' ) arr_1 [ i ] = arr_1 [ i - 1 ] + 1 ; else if ( s . charAt ( i - 1 ) == ' = ' ) arr_1 [ i ] = arr_1 [ i - 1 ] ; else arr_1 [ i ] = 1 ; } for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( s . charAt ( i ) == ' L ' ) arr_2 [ i ] = arr_2 [ i + 1 ] + 1 ; else if ( s . charAt ( i ) == ' = ' ) arr_2 [ i ] = arr_2 [ i + 1 ] ; else arr_2 [ i ] = 1 ; } for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = Math . max ( arr_1 [ i ] , arr_2 [ i ] ) ; pw . print ( + arr [ i ] + " ▁ " ) ; } pw . flush ( ) ; pw . close ( ) ;

import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; }   public static long mod = 17352642619633L ;   int oo = 5000 ;   void run ( FastScanner in , PrintWriter out ) {

n = int ( input ( ) ) NEW_LINE s = input ( )   ans = [ 0 for i in range ( n ) ]   for i in range ( n ) : min_val = 1 NEW_LINE if i > 0 : if NEW_LINE s [ i - 1 ] == ' = ' : ans [ i ] = ans [ i - 1 ] NEW_LINE continue NEW_LINE if s [ i - 1 ] == ' R ' : min_val = ans [ i - 1 ] + 1 NEW_LINE cnt_low = 0 NEW_LINE for j in range ( i , n - 1 ) : if NEW_LINE s [ j ] == ' = ' : NEW_LINE continue NEW_LINE if s [ j ] == ' L ' : cnt_low += 1 NEW_LINE if s [ j ] == ' R ' : break NEW_LINE min_val = max ( min_val , cnt_low + 1 ) NEW_LINE ans [ i ] = min_val   print ( * ans ) NEW_LINE

import mathfrom NEW_LINE collections NEW_LINE import Counter , defaultdictfrom NEW_LINE itertools NEW_LINE import accumulate   R = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE dp = [ [ 0 ] * 1005 for i in range ( n + 1 ) ] NEW_LINE for i in range ( 1 , 1001 ) : dp [ 0 ] [ i ] = idp [ 0 ] [ 1001 ] = math . inffor NEW_LINE i in range ( n ) : dp [ i ] [ 0 ] = math . inffor NEW_LINE i in range ( 1 , n ) : NEW_LINE if s [ i - 1 ] == ' L ' : rmin = math . inf NEW_LINE for j in range ( 1000 , 0 , - 1 ) : dp [ i ] [ j ] = rmin + j NEW_LINE rmin = min ( rmin , dp [ i - 1 ] [ j ] ) elif s [ i - 1 ] == ' R ' : rmin = math . inf NEW_LINE for j in range ( 1 , 1001 ) : dp [ i ] [ j ] = rmin + j NEW_LINE rmin = min ( rmin , dp [ i - 1 ] [ j ] ) else : for j in range ( 1 , 1001 ) : dp [ i ] [ j ] = dp [ i - 1 ] [ j ] + jrem = NEW_LINE min ( ( dp [ n - 1 ] [ j ] , j ) for j in range ( 1 , 1001 ) ) [ 0 ] NEW_LINE res = [ - 1 ] * nfor NEW_LINE i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE for j in range ( 1 , 1001 ) : if NEW_LINE rem == dp [ i ] [ j ] : res [ i ] = j NEW_LINE rem -= j NEW_LINE continueprint ( ' ▁ ' . join ( map ( str , res ) ) ) NEW_LINE

import sysfrom NEW_LINE math NEW_LINE import log2 , floor , ceil , sqrt , gcdimport NEW_LINE bisect NEW_LINE

from collections import deque   n = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE ans = [ 1 ] * n   for i in range ( 1 , n ) : if NEW_LINE s [ i - 1 ] == ' R ' : ans [ i ] = ans [ i - 1 ] + 1 elif s [ i - 1 ] == ' = ' : ans [ i ] = ans [ i - 1 ]   for i in range ( n - 2 , - 1 , - 1 ) : if NEW_LINE s [ i ] == ' L ' : ans [ i ] = max ( ans [ i + 1 ] + 1 , ans [ i ] ) elif s [ i ] == ' = ' : ans [ i ] = max ( ans [ i ] , ans [ i + 1 ] )     print ( * ans ) NEW_LINE

n = int ( input ( ) ) NEW_LINE r = [ 1 ] * ns = input ( ) NEW_LINE y = 1 NEW_LINE while y : y = 0 NEW_LINE for i in range ( n - 1 ) : if NEW_LINE s [ i ] == ' = ' and r [ i ] != r [ i + 1 ] : r [ i ] = r [ i + 1 ] = max ( r [ i : i + 2 ] ) ; NEW_LINE y = 1 NEW_LINE if s [ i ] == ' L ' and r [ i ] <= r [ i + 1 ] : r [ i ] = r [ i + 1 ] + 1 ; y = 1 NEW_LINE if s [ i ] == ' R ' and r [ i ] >= r [ i + 1 ] : r [ i + 1 ] = r [ i ] + 1 ; y = 1 NEW_LINE print ( * r ) NEW_LINE


import java . util . Scanner ;   public class Nauuo_and_Votes { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a , b , c ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; if ( a + c < b ) { System . out . println ( " - " ) ; } else if ( a > b + c ) { System . out . println ( " + " ) ; } else if ( a == b && c == 0 ) { System . out . println ( "0" ) ; } else if ( c != 0 ) { System . out . println ( " ? " ) ; } } }

import java . util . * ; import static java . lang . Math . abs ;   public class Test { public static void main ( String [ ] args ) {   Scanner input = new Scanner ( System . in ) ; int x = input . nextInt ( ) ; int y = input . nextInt ( ) ; int z = input . nextInt ( ) ;   if ( x - y > z ) { System . out . println ( " + " ) ; } else if ( y - x > z ) { System . out . println ( " - " ) ; } else if ( x - y == 0 && z == 0 ) { System . out . println ( 0 ) ; } else { System . out . println ( " ? " ) ; } } }

import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;   while ( sc . hasNext ( ) ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int z = sc . nextInt ( ) ; if ( x > y ) { if ( x <= y + z ) { System . out . println ( " ? " ) ; } else { System . out . println ( " + " ) ; } } else if ( x < y ) { if ( y <= x + z ) { System . out . println ( " ? " ) ; } else { System . out . println ( " - " ) ; } } else { if ( z == 0 ) { System . out . println ( "0" ) ; } else { System . out . println ( " ? " ) ; } } } } }

import java . util . Scanner ;   public class Nk { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ;   int x = input . nextInt ( ) ; int y = input . nextInt ( ) ; int z = input . nextInt ( ) ; int a = x - y ;   if ( a + z < 0 ) { System . out . println ( " - " ) ; }   if ( a == 0 && z == 0 ) { System . out . println ( "0" ) ; }   if ( a == 0 && z > 0 ) { System . out . println ( " ? " ) ; }   if ( a != 0 && a > 0 ) {   if ( a > z ) { System . out . println ( " + " ) ; }   if ( a < z || a == z ) { System . out . println ( " ? " ) ; }   if ( a < 0 && a + z == 0 ) { System . out . println ( " ? " ) ; }   if ( a < 0 && a + z > 0 ) { System . out . println ( " ? " ) ; } }   if ( a < 0 ) {   if ( a + z == 0 ) { System . out . println ( " ? " ) ; }   if ( ( a + z ) > 0 ) { System . out . println ( " ? " ) ; } }   if ( a == 0 && z < 0 ) { System . out . println ( " ? " ) ; } } }

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

def main ( ) : up , down , dont = map ( int , input ( ) . split ( ) ) if up == down : print ( 0 if dont == 0 else " ? " ) elif up > down and down + dont < up : print ( " + " ) elif up < down and dont + up < down : print ( " - " ) else : print ( " ? " )     if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE

a = [ int ( i ) for i in input ( ) . split ( ) ] x = a [ 0 ] y = a [ 1 ] z = a [ 2 ] if y == x and z == 0 : print ( '0' ) elif x > y + z : print ( ' + ' ) elif y > x + z : print ( ' - ' ) else : print ( ' ? ' ) NEW_LINE

a , b , c = map ( int , input ( ) . split ( ) ) if a > b + c : print ( ' + ' ) elif a + c < b : print ( ' - ' ) elif a <= b and c != 0 : t = a a = b b = t if a <= ( b + c ) or c >= ( a - b ) or a == b : print ( ' ? ' )   elif a > b and c != 0 : if c >= ( a - b ) : print ( ' ? ' )   elif a == b and c == 0 : print ( 0 )   NEW_LINE

x , y , z = map ( int , input ( ) . split ( ) ) if x > y : if z >= abs ( x - y ) : print ( " ? " ) else : print ( " + " ) elif y > x : if z >= abs ( x - y ) : print ( " ? " ) else : print ( " - " ) else : if z == 0 : print ( "0" ) else : print ( " ? " ) NEW_LINE

def main_function ( ) : x , y , z = [ int ( i ) for i in input ( ) . split ( " ▁ " ) ] if x - y > z : return " + " elif y - x > z : return " - " elif z == 0 : return 0 else : return " ? "     print ( main_function ( ) )   NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ; import static java . util . Arrays . sort ; import javafx . util . Pair ;   public class Main {   public static void main ( String [ ] args ) {   FastScanner input = new FastScanner ( ) ; char a [ ] = input . next ( ) . toCharArray ( ) ;   int m = input . nextInt ( ) ; int store [ ] = new int [ a . length ] ;   for ( int i = 0 ; i < m ; i ++ ) { int start = input . nextInt ( ) - 1 ; store [ start ] ++ ; } for ( int i = 1 ; i < a . length / 2 ; i ++ ) { store [ i ] += store [ i - 1 ] ; }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class CF525_D2_B { public static void main ( String [ ] args ) { FastReader scanner = new FastReader ( ) ; String s = scanner . next ( ) ; int n = scanner . nextInt ( ) ; int [ ] changes = new int [ s . length ( ) + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { int l = scanner . nextInt ( ) - 1 ; int r = s . length ( ) - l ; changes [ l ] ++ ; changes [ r ] -- ;   } char [ ] arr = s . toCharArray ( ) ; int sum = 0 ; for ( int i = 0 ; i < changes . length / 2 ; i ++ ) { sum += changes [ i ] ; if ( sum % 2 == 1 ) { int j = s . length ( ) - i - 1 ; char temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; } } System . out . println ( String . valueOf ( arr ) ) ; }   static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }

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

import java . io . * ; import java . util . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;    public class Main1 {   static class pair implements Comparable < pair > { int a ; int b ; public pair ( int a , int b ) { this . a = a ; this . b = b ; } @ Override public int compareTo ( pair o ) {

s = [ i for i in input ( ) ] m = int ( input ( ) ) ; n = len ( s ) arr = list ( map ( int , input ( ) . split ( ) ) ) ; dp = [ 0 ] * nfor i in arr : dp [ i - 1 ] += 1 ; dp [ n - i ] += 1 for i in range ( 1 , n ) : dp [ i ] += dp [ i - 1 ] for i in range ( ( n + 1 ) // 2 ) : if dp [ i ] & 1 == 1 : s [ i ] , s [ n - i - 1 ] = s [ n - i - 1 ] , s [ i ] print ( " " . join ( s ) ) NEW_LINE

import math , sys , bisect , heapq , osfrom collections import defaultdict , Counter , dequefrom itertools import groupby , accumulatefrom functools import lru_cache NEW_LINE

import sys , os , ioimport math , bisect , operatorinf , mod = float ( ' inf ' ) , 10 ** 9 + 7 NEW_LINE

from sys import * inp = lambda : stdin . readline ( )   def main ( ) : s = inp ( ) [ : - 1 ] n = int ( inp ( ) ) a = [ 0 for i in range ( len ( s ) + 5 ) ] l = map ( int , inp ( ) . split ( ) ) for b in l :   a [ b - 1 ] = ( a [ b - 1 ] + 1 ) % 2 temp = [ c for c in s ] yet = 0 for i in range ( len ( s ) // 2 ) : yet = ( yet + a [ i ] ) % 2 if yet == 1 : temp [ i ] , temp [ len ( s ) - i - 1 ] = temp [ len ( s ) - i - 1 ] , temp [ i ] print ( " " . join ( temp ) )     if __name__ == " _ _ main _ _ " : main ( ) NEW_LINE


import java . io . * ; import java . util . * ;   public class Coach { static boolean [ ] v = new boolean [ 100 ] ; static ArrayList < ArrayList < Integer > > adj = new ArrayList < ArrayList < Integer > > ( 100 ) ; public static ArrayList < Integer > dfs ( ArrayList < ArrayList < Integer > > adj , int j , ArrayList < Integer > list ) { list . add ( j ) ;

import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ;   public class absolute { static List < Integer > [ ] adj ; static List < List < Integer > > groups ; public static void dfs ( int u , boolean [ ] visited , List < Integer > temp ) { visited [ u ] = true ; temp . add ( u ) ; Iterator itr = adj [ u ] . listIterator ( ) ; while ( itr . hasNext ( ) ) { int v = ( int ) itr . next ( ) ; if ( ! visited [ v ] ) dfs ( v , visited , temp ) ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; adj = new LinkedList [ n + 1 ] ; groups = new ArrayList < List < Integer > > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) adj [ i ] = new LinkedList ( ) ; for ( int i = 0 ; i < m ; i ++ ) { int u = sc . nextInt ( ) ; int v = sc . nextInt ( ) ; adj [ u ] . add ( v ) ; adj [ v ] . add ( u ) ; } boolean [ ] visited = new boolean [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { if ( ! visited [ i ] ) { List < Integer > temp = new ArrayList < Integer > ( ) ; if ( adj [ i ] . size ( ) > 0 ) dfs ( i , visited , temp ) ;

n , m = map ( int , input ( ) . split ( ) ) d = { i : [ ] for i in range ( 1 , n // 3 + 1 ) } idx = [ - 1 for i in range ( n + 1 ) ] arr = [ ] key = 1 for i in range ( m ) : a , b = map ( int , input ( ) . split ( ) ) if idx [ a ] == idx [ b ] and idx [ a ] != - 1 : continue elif idx [ a ] == - 1 and idx [ b ] == - 1 : idx [ a ] = key idx [ b ] = key if key > n // 3 : print ( - 1 ) exit ( ) d [ key ] . append ( a ) d [ key ] . append ( b ) key += 1 elif idx [ a ] != - 1 and idx [ b ] == - 1 : idx [ b ] = idx [ a ] if len ( d [ idx [ a ] ] ) < 3 : d [ idx [ a ] ] . append ( b ) else : print ( - 1 ) exit ( ) elif idx [ a ] == - 1 and idx [ b ] != - 1 : idx [ a ] = idx [ b ] if len ( d [ idx [ b ] ] ) < 3 : d [ idx [ b ] ] . append ( a ) else : print ( - 1 ) exit ( ) else : print ( - 1 ) exit ( ) remain = [ ] for i in range ( 1 , n + 1 ) : if idx [ i ] == - 1 : remain . append ( i ) ptr = 0 for i in d : if len ( d [ i ] ) < 3 : for j in range ( 3 - len ( d [ i ] ) ) : d [ i ] . append ( remain [ ptr ] ) ptr += 1 print ( * d [ i ] ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) a = list ( range ( n ) ) visited = [ - 1 ] * ngraph = [ [ ] for _ in ' ▁ ' * n ] for _ in range ( m ) : i , j = map ( int , input ( ) . split ( ) ) visited [ i - 1 ] = 0 visited [ j - 1 ] = 0 graph [ i - 1 ] . append ( j - 1 ) graph [ j - 1 ] . append ( i - 1 ) def dfs ( v , c , s ) : visited [ v ] = 1 c [ 0 ] += 1 a . remove ( v ) s . append ( ( v + 1 ) ) if c [ 0 ] > 3 : print ( - 1 ) exit ( 0 ) for i in graph [ v ] : if visited [ i ] == 0 : dfs ( i , c , s ) ans = [ ] for i in range ( n ) : if visited [ i ] == 1 or visited [ i ] == - 1 : continue c = [ 0 ] s = [ ] if visited [ i ] == 0 : dfs ( i , c , s ) ans . append ( s ) ans_ = [ ] for _ in range ( n // 3 ) : if ans : x = ans . pop ( 0 ) while len ( x ) < 3 : if a : x . append ( a . pop ( 0 ) + 1 ) else : print ( - 1 ) exit ( 0 ) ans_ . append ( x ) else : if len ( a ) >= 3 : h = [ ] for i in range ( 3 ) : h . append ( a . pop ( 0 ) + 1 ) ans_ . append ( h ) else : print ( - 1 ) exit ( 0 ) for i in ans_ : print ( * i ) NEW_LINE


import java . io . FileInputStream ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; import java . util . stream . Collectors ; public class _p001106A { static public void main ( final String [ ] args ) throws IOException { p001106A . _main ( args ) ; }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . io . BufferedWriter ; import java . io . Writer ; import java . io . OutputStreamWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ;     public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastReader in = new FastReader ( inputStream ) ; OutputWriter out = new OutputWriter ( outputStream ) ; ALunarNewYearAndCrossCounting solver = new ALunarNewYearAndCrossCounting ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ALunarNewYearAndCrossCounting { public void solve ( int testNumber , FastReader r , OutputWriter out ) { int n = r . nextInt ( ) ; char mat [ ] [ ] = new char [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { mat [ i ] = r . next ( ) . toCharArray ( ) ; }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { int n , x = 0 ; Scanner reader = new Scanner ( System . in ) ; n = reader . nextInt ( ) ; String [ ] s = new String [ n ] ; int i , j , t = 0 ; for ( i = 0 ; i < n ; ++ i ) s [ i ] = reader . next ( ) ; for ( i = 1 ; i < n - 1 ; ++ i ) { for ( j = 1 ; j < n - 1 ; ++ j ) { if ( s [ i ] . charAt ( j ) == ' X ' && s [ i ] . charAt ( j ) == s [ i - 1 ] . charAt ( j - 1 ) && s [ i ] . charAt ( j ) == s [ i - 1 ] . charAt ( j + 1 ) && s [ i ] . charAt ( j ) == s [ i + 1 ] . charAt ( j + 1 ) && s [ i + 1 ] . charAt ( j - 1 ) == s [ i ] . charAt ( j ) ) ++ t ; } } System . out . println ( t ) ; } }

if __name__ == ' _ _ main _ _ ' : aa = [ ] res = 0 n = int ( input ( ) ) for _ in range ( n ) : aa . append ( list ( map ( { ' X ' : 1 , ' . ' : 0 } . get , input ( ) ) ) )   def check ( i , j ) : sm = aa [ i ] [ j ] for di in [ - 1 , 1 ] : for dj in [ - 1 , 1 ] : sm += aa [ i + di ] [ j + dj ] return sm == 5   for i in range ( 1 , n - 1 ) : for j in range ( 1 , n - 1 ) : res += check ( i , j ) print ( res ) NEW_LINE

n = int ( input ( ) ) l = [ ] for z in range ( n ) : p = input ( ) p = list ( p ) l . append ( p ) c = 0 for i in range ( 1 , n - 1 ) : for j in range ( 1 , n - 1 ) : if l [ i ] [ j ] == ' X ' and l [ i - 1 ] [ j - 1 ] == ' X ' and l [ i - 1 ] [ j + 1 ] == ' X ' and l [ i + 1 ] [ j - 1 ] == ' X ' and l [ i + 1 ] [ j + 1 ] == ' X ' : c += 1 if n < 3 : print ( 0 ) else : print ( c ) NEW_LINE

cases = int ( input ( ) ) M = [ ] while cases : cases -= 1 s = input ( ) M . append ( s ) ct = 0 for i , row in enumerate ( M [ 1 : - 1 ] , start = 1 ) : for j , col in enumerate ( row [ 1 : - 1 ] , start = 1 ) : if M [ i ] [ j ] == M [ i - 1 ] [ j - 1 ] == M [ i - 1 ] [ j + 1 ] == M [ i + 1 ] [ j - 1 ] == M [ i + 1 ] [ j + 1 ] == ' X ' : ct += 1   print ( ct )           NEW_LINE

p = list ( map ( int , input ( ) . split ( ) ) ) k = p [ 0 ] a = [ ] for i in range ( k ) : s = input ( ) a . append ( s ) ans = int ( 0 ) for i in range ( 1 , k - 1 ) : for j in range ( 1 , k - 1 ) : if a [ i - 1 ] [ j - 1 ] == ' X ' and a [ i - 1 ] [ j + 1 ] == ' X ' and a [ i + 1 ] [ j - 1 ] == ' X ' and a [ i + 1 ] [ j + 1 ] == ' X ' and a [ i ] [ j ] == ' X ' : ans = ans + 1 print ( ans ) NEW_LINE

import sys   def main ( ) : n , * s = sys . stdin . read ( ) . strip ( ) . split ( ' \n ' ) c , t = 0 , [ ( - 1 , 1 ) , ( - 1 , - 1 ) , ( 1 , 1 ) , ( 1 , - 1 ) , ( 0 , 0 ) ] for i in range ( 1 , int ( n ) - 1 ) : for j in range ( 1 , int ( n ) - 1 ) : c += all ( s [ i + m ] [ j + n ] == ' X ' for m , n in t ) return c print ( main ( ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . util . ArrayList ; import java . util . HashSet ; import java . util . Random ; import java . util . StringTokenizer ;   public class HilbertsHotel { static final int MAXN = 1000_006 ; static final long MOD = ( long ) 1e9 + 7 ; public static void main ( String [ ] args ) throws IOException { MyScanner s = new MyScanner ( ) ; Print p = new Print ( ) ;

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

import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; Set < Integer > ns = new HashSet < > ( n , 1 ) ; for ( int i = 0 ; i < n ; i ++ ) { ns . add ( ( ( i + sc . nextInt ( ) ) % n + n ) % n ) ; } System . out . println ( ns . size ( ) == n && ns . contains ( 0 ) && ns . contains ( n - 1 ) ? " YES " : " NO " ) ; } } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; import java . io . BufferedReader ; import java . io . InputStreamReader ;   public class First {   public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ;

import sysinput = sys . stdin . readlinet = int ( input ( ) ) for you in range ( t ) : n = int ( input ( ) ) l = input ( ) . split ( ) li = [ int ( i ) for i in l ] hashi = dict ( ) for i in range ( n ) : z = i + li [ i ] if z % n in hashi : hashi [ z % n ] += 1 else : hashi [ z % n ] = 1 poss = 1 for i in hashi : if ( hashi [ i ] > 1 ) : poss = 0 break if ( poss ) : print ( " Yes " ) else : print ( " No " ) NEW_LINE

""" ▁ import ▁ syssys . stdin ▁ = ▁ open ( ' input . txt ' , ▁ ' r ' ) sys . stdout ▁ = ▁ open ( ' output . txt ' , ▁ ' w ' ) ▁ """ def sol ( ) : x = int ( input ( ) ) s = list ( map ( int , input ( ) . split ( ) ) ) st = set ( ) for n in range ( x ) : u = ( s [ n ] + n ) % x st . add ( u )   print ( ' YES ' if len ( list ( st ) ) == x else ' NO ' )     for n in range ( int ( input ( ) ) ) : sol ( ) NEW_LINE

import sysinput = sys . stdin . readline   def read ( ) : return list ( map ( int , input ( ) . split ( ) ) )   for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) a = read ( ) for i in range ( n ) : a [ i ] = ( a [ i ] + i ) % n if len ( set ( a ) ) == n : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE

for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) arr = [ ( int ( i ) + n ) % n for i in input ( ) . split ( ) ] occ = [ 0 for i in range ( n ) ] no = 0 for i in range ( n ) : if occ [ ( i + arr [ i ] ) % n ] != 1 : occ [ ( i + arr [ i ] ) % n ] = 1 else : print ( " NO " ) no = 1 break if not no : print ( " YES " ) NEW_LINE

import os , sysfrom io import BytesIO , IOBase   BUFSIZE = 8192     class FastIO ( IOBase ) : newlines = 0   def __init__ ( self , file ) : self . _fd = file . fileno ( ) self . buffer = BytesIO ( ) self . writable = " x " in file . mode or " r " not in file . mode self . write = self . buffer . write if self . writable else None   def read ( self ) : while True : b = os . read ( self . _fd , max ( os . fstat ( self . _fd ) . st_size , BUFSIZE ) ) if not b : break ptr = self . buffer . tell ( ) self . buffer . seek ( 0 , 2 ) , self . buffer . write ( b ) , self . buffer . seek ( ptr ) self . newlines = 0 return self . buffer . read ( )   def readline ( self ) : while self . newlines == 0 : b = os . read ( self . _fd , max ( os . fstat ( self . _fd ) . st_size , BUFSIZE ) ) self . newlines = b . count ( b " \n " ) + ( not b ) ptr = self . buffer . tell ( ) self . buffer . seek ( 0 , 2 ) , self . buffer . write ( b ) , self . buffer . seek ( ptr ) self . newlines -= 1 return self . buffer . readline ( )   def flush ( self ) : if self . writable : os . write ( self . _fd , self . buffer . getvalue ( ) ) self . buffer . truncate ( 0 ) , self . buffer . seek ( 0 )     class IOWrapper ( IOBase ) : def __init__ ( self , file ) : self . buffer = FastIO ( file ) self . flush = self . buffer . flush self . writable = self . buffer . writable self . write = lambda s : self . buffer . write ( s . encode ( " ascii " ) ) self . read = lambda : self . buffer . read ( ) . decode ( " ascii " ) self . readline = lambda : self . buffer . readline ( ) . decode ( " ascii " )     sys . stdin , sys . stdout = IOWrapper ( sys . stdin ) , IOWrapper ( sys . stdout ) input = lambda : sys . stdin . readline ( ) . rstrip ( " \n " )   NEW_LINE


import java . util . * ; import java . lang . * ;

import java . io . * ; import java . util . * ;   public class Main { public static void main ( String [ ] args ) throws Exception { long n = nl ( ) , a = nl ( ) , b = nl ( ) , c = nl ( ) ; if ( n < a && n < b ) { pln ( 0 ) ; } else if ( n >= a && n < b ) { pln ( n / a ) ; } else if ( a <= ( b - c ) ) { pln ( n / a ) ; } else { long rem = ( n - b ) % ( b - c ) + c ; pln ( ( n - b ) / ( b - c ) + 1 + rem / a ) ;   } flush ( ) ; }   static Reader in = new Reader ( ) ; static StringBuilder output = new StringBuilder ( ) ; static final int imod = 1000_000_007 ; static final long mod = 1000_000_007 ; static final int imax = 1000_000_000 ; static final int imin = - 1000_000_000 ; static final long lmax = 1000_000_000_000_000_000L ; static final long lmin = - 1000_000_000_000_000_000L ;

import java . io . * ; import java . math . BigInteger ; import java . util . * ;   public class Main { static int MOD = 1000000007 ;

import java . util . Scanner ;   public class BottleBuyer { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   long n = scanner . nextLong ( ) ; long a = scanner . nextLong ( ) ; long b = scanner . nextLong ( ) ; long c = scanner . nextLong ( ) ; long bc = b - c ; long ans = 0 ;   if ( a <= bc || b > n ) ans = n / a ; else { ans = ( n - b ) / bc + 1 + ( ( n - b ) % bc + c ) / a ; }   System . out . println ( ans ) ; } }

I = lambda : int ( input ( ) ) n , a , b , c = I ( ) , I ( ) , I ( ) , I ( ) d , l = b - c , max ( n - c , 0 ) print ( max ( l // d + ( l % d + c * ( n >= b ) ) // a , n // a + max ( 0 , n % a - c ) // d ) ) NEW_LINE

def solve ( n , a , b , c ) :   if b - c >= a : return n // a if n < b : return n // a g = ( ( n - b ) // ( b - c ) ) + 1 p = ( n - g * ( b - c ) ) // a return g + p     if __name__ == ' _ _ main _ _ ' : N = int ( input ( ) ) A = int ( input ( ) ) B = int ( input ( ) ) C = int ( input ( ) )   result = solve ( N , A , B , C ) print ( result ) NEW_LINE

import sys , os , iofrom sys import stdinfrom math import log , gcd , ceilfrom collections import defaultdict , deque , Counterfrom heapq import heappush , heappopfrom bisect import bisect_left , bisect_rightimport math       alphabets = list ( ' abcdefghijklmnopqrstuvwxyz ' )     def isPrime ( x ) : for i in range ( 2 , x ) : if i * i > x : break if ( x % i == 0 ) : return False return Truedef ncr ( n , r , p ) : num = den = 1 for i in range ( r ) : num = ( num * ( n - i ) ) % p den = ( den * ( i + 1 ) ) % p return ( num * pow ( den , p - 2 , p ) ) % pdef primeFactors ( n ) : l = [ ] while n % 2 == 0 : l . append ( 2 ) n = n / 2 for i in range ( 3 , int ( math . sqrt ( n ) ) + 1 , 2 ) : while n % i == 0 : l . append ( int ( i ) ) n = n / i if n > 2 : l . append ( n ) return list ( set ( l ) ) def power ( x , y , p ) : res = 1 x = x % p if ( x == 0 ) : return 0 while ( y > 0 ) : if ( ( y & 1 ) == 1 ) : res = ( res * x ) % p y = y >> 1 NEW_LINE

from collections import defaultdict , deque , Counterfrom sys import stdin , stdoutfrom heapq import heappush , heappopimport mathimport ioimport osimport mathimport bisect   NEW_LINE


import java . io . * ; import java . util . * ;     public class Main { static int [ ] a = new int [ 200020 ] ; static int [ ] b = new int [ 200020 ] ; static Integer [ ] ia = new Integer [ 200020 ] ; static Integer [ ] ib = new Integer [ 200020 ] ; static int [ ] answer = new int [ 200020 ] ; public static void main ( String args [ ] ) { Scanner in ; PrintStream out ; in = new Scanner ( new BufferedInputStream ( System . in ) ) ; out = System . out ; try { in = new Scanner ( new FileInputStream ( " in . in " ) ) ; out = new PrintStream ( " out . out " ) ; } catch ( FileNotFoundException e ) { } int n = in . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; ia [ i ] = i ; } for ( int i = 0 ; i < n ; i ++ ) { b [ i ] = in . nextInt ( ) ; ib [ i ] = i ; } Arrays . sort ( ia , 0 , n , new MyCom ( ) ) ; Arrays . sort ( ib , 0 , n , new YourCom ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { answer [ ib [ i ] ] = a [ ia [ i ] ] ; } for ( int i = 0 ; i < n ; i ++ ) { out . print ( answer [ i ] ) ; if ( i + 1 < n ) out . print ( ' ▁ ' ) ; else out . println ( ) ; } } static class MyCom implements Comparator < Integer > { public int compare ( Integer i1 , Integer i2 ) { return a [ i2 ] - a [ i1 ] ; } } static class YourCom implements Comparator < Integer > { public int compare ( Integer i1 , Integer i2 ) { return b [ i1 ] - b [ i2 ] ; } } }

import java . io . * ; import java . util . * ;     public class Main { static int [ ] a = new int [ 200020 ] ; static int [ ] b = new int [ 200020 ] ; static Integer [ ] ia = new Integer [ 200020 ] ; static Integer [ ] ib = new Integer [ 200020 ] ; static int [ ] answer = new int [ 200020 ] ; public static void main ( String args [ ] ) { Scanner in ; PrintStream out ; in = new Scanner ( new BufferedInputStream ( System . in ) ) ; out = System . out ; try { in = new Scanner ( new FileInputStream ( " in . in " ) ) ; out = new PrintStream ( " out . out " ) ; } catch ( FileNotFoundException e ) { } int n = in . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; ia [ i ] = i ; } for ( int i = 0 ; i < n ; i ++ ) { b [ i ] = in . nextInt ( ) ; ib [ i ] = i ; } Arrays . sort ( ia , 0 , n , new MyCom ( ) ) ; Arrays . sort ( ib , 0 , n , new YourCom ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { answer [ ib [ i ] ] = a [ ia [ i ] ] ; } for ( int i = 0 ; i < n ; i ++ ) { out . print ( answer [ i ] ) ; if ( i + 1 < n ) out . print ( ' ▁ ' ) ; else out . println ( ) ; } } static class MyCom implements Comparator < Integer > { @ Override public int compare ( Integer i1 , Integer i2 ) { return a [ i2 ] - a [ i1 ] ; } } static class YourCom implements Comparator < Integer > { @ Override public int compare ( Integer i1 , Integer i2 ) { return b [ i1 ] - b [ i2 ] ; } } }

import java . io . * ; import java . util . * ;     public class Main { static int [ ] a = new int [ 200020 ] ; static int [ ] b = new int [ 200020 ] ; static Integer [ ] ia = new Integer [ 200020 ] ; static Integer [ ] ib = new Integer [ 200020 ] ; static int [ ] answer = new int [ 200020 ] ; public static void main ( String args [ ] ) { Scanner in ; PrintStream out ; try { in = new Scanner ( new FileInputStream ( " in . in " ) ) ; out = new PrintStream ( " out . out " ) ; } catch ( FileNotFoundException e ) { in = new Scanner ( new BufferedInputStream ( System . in ) ) ; out = System . out ; } int n = in . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; ia [ i ] = i ; } for ( int i = 0 ; i < n ; i ++ ) { b [ i ] = in . nextInt ( ) ; ib [ i ] = i ; } Arrays . sort ( ia , 0 , n , new MyCom ( ) ) ; Arrays . sort ( ib , 0 , n , new YourCom ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { answer [ ib [ i ] ] = a [ ia [ i ] ] ; } for ( int i = 0 ; i < n ; i ++ ) { out . print ( answer [ i ] ) ; if ( i + 1 < n ) out . print ( ' ▁ ' ) ; else out . println ( ) ; } } static class MyCom implements Comparator < Integer > { @ Override public int compare ( Integer i1 , Integer i2 ) { return a [ i2 ] - a [ i1 ] ; } } static class YourCom implements Comparator < Integer > { @ Override public int compare ( Integer i1 , Integer i2 ) { return b [ i1 ] - b [ i2 ] ; } } }

# include < bits / stdc ++ . h > using namespace std ; # define lli long long int # define pb push_back # define mem0 ( a ) memset ( a , 0 , sizeof ( a ) ) # define mem_1 ( a ) memset ( a , - 1 , sizeof ( a ) ) # define mem1 ( a ) memset ( a , 1 , sizeof ( a ) ) # define memf ( a ) memset ( a , false , sizeof ( a ) ) # define all ( v ) v . begin ( ) , v . end ( ) # define ff first # define ss second # define PI 3.1415926536 # define INF 10000000000000 # define mod1 1000000007 # define endl " \n " # define PI 3.1415926536

m = int ( input ( ) ) a = sorted ( map ( int , input ( ) . split ( ) ) , reverse = True ) b = sorted ( ( bi , i ) for i , bi in enumerate ( map ( int , input ( ) . split ( ) ) ) ) v = [ None ] * mfor i in range ( m ) : v [ b [ i ] [ 1 ] ] = str ( a [ i ] ) print ( ' ▁ ' . join ( v ) ) NEW_LINE

m = int ( input ( ) ) a = [ int ( i ) for i in input ( ) . split ( ) ] b = [ int ( i ) for i in input ( ) . split ( ) ]   a_streak = a . copy ( ) b_streak = b . copy ( )   a_streak . sort ( reverse = True ) b_streak . sort ( )   mapping = { }   for ind , b_i in enumerate ( b_streak ) : if b_i not in mapping : mapping [ b_i ] = [ a_streak [ ind ] ] else : mapping [ b_i ] . append ( a_streak [ ind ] )   NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; char [ ] arr = reader . readLine ( ) . toCharArray ( ) ; int n = arr . length ; boolean [ ] [ ] forward = new boolean [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int cur = 0 ; boolean mark = true ; for ( int j = i ; j < n ; j ++ ) { if ( arr [ j ] == ' ) ' ) cur -- ; else cur ++ ; if ( cur < 0 ) mark = false ; forward [ i ] [ j ] = mark ; } } boolean [ ] [ ] backward = new boolean [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int cur = 0 ; boolean mark = true ; for ( int j = i ; j > - 1 ; j -- ) { if ( arr [ j ] == ' ( ' ) cur -- ; else cur ++ ; if ( cur < 0 ) mark = false ; backward [ j ] [ i ] = mark ; } } int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { if ( forward [ i ] [ j ] && backward [ i ] [ j ] && ( j - i + 1 ) % 2 == 0 ) { ans ++ ; } } } System . out . println ( ans ) ; } }

import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; }   public static long mod = 17352642619633L ;   void run ( FastScanner in , PrintWriter out ) {   char [ ] ca = in . next ( ) . toCharArray ( ) ; int n = ca . length ;   int cnt = 0 ; for ( int l = 0 ; l < n ; l ++ ) {   int score = 0 ; int qmarks = 0 ; for ( int r = l ; r < n ; r ++ ) { char c = ca [ r ] ; if ( c == ' ) ' ) score -- ; if ( c == ' ( ' ) score ++ ; if ( c == ' ? ' ) qmarks ++ ;   if ( qmarks > 0 && qmarks > score ) {

import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . io . PrintWriter ;   public class Div1_459A {   public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter printer = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; String str = reader . readLine ( ) ; int ans = 0 ;   for ( int i = 0 ; i < str . length ( ) ; i ++ ) { int nO = 0 ; int nC = 0 ; loop2 : for ( int j = i ; j < str . length ( ) ; j ++ ) { if ( str . charAt ( j ) == ' ( ' ) { nO ++ ; } else if ( str . charAt ( j ) == ' ? ' ) { if ( nO > 0 ) { nO -- ; nC ++ ; } else { nO ++ ; } } else { if ( nO > 0 ) { nO -- ; } else if ( nC > 0 ) { nC -- ; nO ++ ; } else { break loop2 ; } } if ( nO == 0 ) { ans ++ ; } } } printer . println ( ans ) ; printer . close ( ) ; } }

s = input ( ) ans = 0 for i in range ( 0 , len ( s ) - 1 ) : addQ = 0 subQ = 0 cur = 0 for j in range ( i , len ( s ) ) : if s [ j ] == ' ( ' : cur += 1 elif s [ j ] == ' ) ' : cur -= 1 if cur < 0 and subQ > 0 : cur += 2 subQ -= 1 addQ += 1 else : if cur > 0 : subQ += 1 cur -= 1 else : addQ += 1 cur += 1 if cur < 0 : break if cur == 0 : ans += 1 print ( ans ) NEW_LINE

s = input ( ) res , n = 0 , len ( s ) for i in range ( n - 1 ) : j , c , q = i , 0 , 0 while j < n and c + q >= 0 : if ( s [ j ] == ' ( ' ) : c += 1 elif ( s [ j ] == ' ) ' ) : c -= 1 else : q += 1   if ( c < q ) : c , q = q , c res += ( c == q ) j += 1 print ( res ) NEW_LINE


import java . util . * ;   public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ;   int n = s . nextInt ( ) ; boolean [ ] b = new boolean [ n + 1 ] ; int res = 0 ; for ( int i = 2 ; i <= n ; i ++ ) b [ i ] = isPrime ( i ) ;   for ( int i = 3 ; i <= n ; i ++ ) { int c = 0 ; for ( int j = 2 ; j <= i ; j ++ ) { if ( b [ j ] && i % j == 0 ) c ++ ; } if ( c == 2 ) res ++ ; }   System . out . println ( res ) ; s . close ( ) ; }   public static boolean isPrime ( int n ) { for ( int i = 2 ; i < n ; i ++ ) { if ( n % i == 0 ) return false ; }   return true ; } }

import java . util . Arrays ; import java . util . Scanner ;   public class AlmostPrime {   public static void main ( String [ ] args ) {   Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; System . out . println ( func ( n ) ) ; }   public static int func ( int n ) { int prime [ ] = new int [ n + 1 ] ; int pf [ ] = new int [ n + 1 ] ; Arrays . fill ( prime , 1 ) ; Arrays . fill ( pf , 0 ) ; int ct = 0 ;   for ( int i = 2 ; i <= n ; i ++ ) { if ( prime [ i ] == 1 ) { for ( int j = i + i ; j <= n ; j = j + i ) { prime [ j ] = 0 ; pf [ j ] += 1 ; } }   if ( pf [ i ] == 2 ) ct ++ ; } return ct ;   } }

import java . util . * ; public class Main {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int ans = 0 ; for ( int k = 6 ; k <= N ; k ++ ) { int n = k , cnt = 0 ; for ( int i = 2 ; i * i < n && cnt < 3 ; i ++ ) { if ( n % i == 0 ) cnt ++ ; while ( n % i == 0 && cnt < 3 ) { n = n / i ; } } if ( n != 1 ) cnt ++ ; if ( cnt == 2 ) { ans ++ ;

import java . util . * ; import java . lang . * ; import java . io . * ;   public class Codechef { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int final_count = 0 ; for ( int i = 4 ; i <= n ; i ++ ) { int num = i ; int count = 0 ; int [ ] arr_count = new int [ i + 1 ] ; for ( int j = 2 ; j <= Math . sqrt ( i ) ; j ++ ) { if ( num % j == 0 ) { while ( num % j == 0 ) { arr_count [ j ] ++ ; num = num / j ; } } } if ( num != 1 ) arr_count [ num ] ++ ; for ( int k = 2 ; k < arr_count . length ; k ++ ) if ( arr_count [ k ] > 0 ) count ++ ; if ( count == 2 ) final_count = final_count + 1 ; } System . out . println ( final_count ) ; } }

import java . util . * ;   public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ;   int n = s . nextInt ( ) ; int [ ] primes = new int [ n + 1 ] ; int res = 0 ;

a = int ( input ( ) ) prime = [ True ] * 3001 prime [ 0 ] = prime [ 1 ] = 0 for i in range ( 2 , 3001 ) : if prime [ i ] : for j in range ( i * i , 3001 , i ) : prime [ j ] = Falseallprime = [ ] for i in range ( 2 , 3001 ) : if prime [ i ] : allprime . append ( i ) def check_devisor ( n ) : ans = 0 for p in allprime : if n % p == 0 : ans += 1 if p > n : break return ans == 2 print ( sum ( [ check_devisor ( i ) for i in range ( 2 , a + 1 ) ] ) ) NEW_LINE

def almostprime ( val ) : a = 0 l = 0 b = [ ] d = [ ] for i in range ( 2 , val ) : a = 0 for j in range ( 2 , i ) : if ( i % j != 0 ) : pass else : a += 1 if a == 0 : b . append ( i ) for i in range ( 2 , val ) : c = 0 for j in range ( 0 , len ( b ) ) : if ( i % b [ j ] == 0 ) : c += 1 if c == 2 : d . append ( i ) print ( len ( d ) )                           almostprime ( int ( input ( ) ) + 1 ) NEW_LINE

n = int ( input ( ) ) ans = 0 for i in range ( 2 , n + 1 ) : j = 2 k = i cnt = 0 while ( j * j <= k ) : if ( k % j == 0 ) : cnt += 1 while ( k % j == 0 ) : k = k // j j += 1 if ( k != 1 ) : cnt += 1 if ( cnt == 2 ) : ans += 1 print ( ans ) NEW_LINE

seive = [ ] def precalc ( n ) : i = 2 while ( i * i <= n ) : if ( seive [ i ] ) : j = i * i while ( j <= n ) : seive [ j ] = False j += i i += 1 def main ( ) : global seive n = int ( input ( ) ) seive = [ True ] * ( n + 1 ) precalc ( n ) res , cnt = [ ] , 0 for i in range ( 2 , n + 1 ) : if ( seive [ i ] ) : res . append ( i ) for i in range ( 2 , n + 1 ) : temp = 0 for j in range ( 2 , n + 1 ) : if ( seive [ j ] and i % j == 0 ) : temp += 1 if ( temp == 2 ) : cnt += 1 print ( cnt ) main ( ) NEW_LINE


import java . io . * ; import java . util . * ;   public class Main {    public static void main ( String [ ] args ) throws IOException , InterruptedException { int n = sc . nextInt ( ) ; Pair [ ] time = new Pair [ n ] ; for ( int i = 0 ; i < n ; i ++ ) time [ i ] = new Pair ( sc . nextInt ( ) , sc . nextInt ( ) ) ; pairSort ( time ) ;

import java . io . * ; import java . util . * ; public class Main {   public static final int mod = 1000000007 ; static long [ ] [ ] dp ; public static void main ( String [ ] args ) throws IOException {

import java . util . * ; import java . io . * ;

def second ( x ) : return x [ 1 ] n = int ( input ( ) ) arr = [ ] for i in range ( n ) : a , b = map ( int , input ( ) . split ( ) ) arr . append ( [ a , b ] ) arr . sort ( key = second )   ans = 1 till = arr [ 0 ] [ 1 ] for i in range ( n ) : if ( arr [ i ] [ 0 ] > till ) : ans += 1 till = arr [ i ] [ 1 ] print ( ans ) NEW_LINE

n = int ( input ( ) )   main = [ ] for i in range ( n ) : s , e = map ( int , input ( ) . split ( ) ) main . append ( ( s , e ) )   main . sort ( key = lambda x : x [ 1 ] )   cs , ce = main [ 0 ] [ 0 ] , main [ 0 ] [ 1 ] count = 1 for s , e in main [ 1 : ] : if ce < s : count += 1 cs = s ce = e   print ( count ) NEW_LINE

import sys     n = int ( sys . stdin . readline ( ) ) orders = [ tuple ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) for _ in range ( n ) ]   orders . sort ( key = lambda x : x [ 1 ] ) prev_r = Nonecount = 0 for l , r in orders : if not prev_r or prev_r < l : count += 1 prev_r = r   print ( count ) NEW_LINE

n = int ( input ( ) ) a = [ ] for i in range ( n ) : l , r = map ( int , input ( ) . split ( ) ) a . append ( ( r , l ) ) a . sort ( ) L = - 1 ans = 0 for x in a : if x [ 1 ] > L : L = x [ 0 ] ans += 1 print ( ans ) NEW_LINE


import java . io . * ; import java . util . * ; public class Asd { static PrintWriter w = new PrintWriter ( System . out ) ; static FastScanner s = new FastScanner ( ) ; public static void main ( String [ ] args ) { int t = 1 ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ; import static java . util . Arrays . sort ; import javafx . util . Pair ;   public class Main { public static void main ( String [ ] args ) {   FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; int k = input . nextInt ( ) ; int a [ ] = new int [ n ] ; int min = Integer . MAX_VALUE ; int max = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; min = Math . min ( a [ i ] , min ) ; max = Math . max ( max , a [ i ] ) ; } if ( k == 1 ) { System . out . println ( min ) ; } else if ( k == 2 ) { System . out . println ( Math . max ( a [ 0 ] , a [ n - 1 ] ) ) ; } else { System . out . println ( max ) ; } }   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 ( ) ; } }   }

import java . util . Scanner ;   public class MaximumMinimum {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int min = Integer . MAX_VALUE ; int max = Integer . MIN_VALUE ; int ans = - 1 ; if ( k == 1 ) { for ( int x = 0 ; x < n ; x ++ ) { int num = sc . nextInt ( ) ; if ( num < min ) { min = num ; } } ans = min ; } else if ( k >= 3 ) { for ( int x = 0 ; x < n ; x ++ ) { int num = sc . nextInt ( ) ; if ( num > max ) { max = num ; } } ans = max ; } else { int a = 0 ; int b = 0 ; for ( int x = 0 ; x < n ; x ++ ) { int num = sc . nextInt ( ) ; if ( x == 0 ) { a = num ; } else if ( x == n - 1 ) { b = num ; } } ans = Math . max ( a , b ) ; } System . out . println ( ans ) ; }   }

# include < bits / stdc ++ . h > using namespace std ; typedef long long int ll ; typedef long double ld ; # define PI 3.14159265358979323846264338327950288419716939937510 ll mind ( ll x , ll y ) { if ( x > y ) { return y ; } else { return x ; } } ll maxd ( ll x , ll y ) { if ( x > y ) { return x ; } else { return y ; } }   int main ( ) { ios_base :: sync_with_stdio ( false ) ; cin . tie ( NULL ) ; ll n , k ; cin >> n >> k ; vector < ll > v ; for ( ll i = 0 ; i < n ; i ++ ) { ll t ; cin >> t ; v . push_back ( t ) ; } if ( k == 1 ) { sort ( v . begin ( ) , v . end ( ) ) ; cout << v [ 0 ] ; } else if ( k >= 3 ) { sort ( v . rbegin ( ) , v . rend ( ) ) ; cout << v [ 0 ] ; } else { ll d = max ( v [ 0 ] , v [ n - 1 ] ) ; cout << d ; } return 0 ; }

def maxOfSegmentMins ( array , len , k ) : if k == 1 : return min ( array ) if k == 2 : return max ( array [ 0 ] , array [ n - 1 ] ) return max ( array )     if __name__ == ' _ _ main _ _ ' : n , k = map ( int , input ( ) . split ( ) ) array = [ int ( x ) for x in input ( ) . split ( ) ]   print ( maxOfSegmentMins ( array , len ( array ) , k ) ) NEW_LINE

def maxMaxMin ( nums , k ) : if k == 1 : return min ( nums ) else : maximum = max ( nums ) if k != 2 : return maximum if nums [ 0 ] == maximum or nums [ - 1 ] == maximum : return maximum return max ( nums [ 0 ] , nums [ - 1 ] )       n , k = map ( int , input ( ) . split ( ) ) nums = list ( map ( int , input ( ) . split ( ) ) ) print ( maxMaxMin ( nums , k ) ) NEW_LINE

n , k = map ( int , input ( ) . split ( " ▁ " ) ) arr = list ( map ( int , input ( ) . split ( " ▁ " ) ) )   if k > 2 : print ( max ( arr ) ) elif k == 2 : print ( max ( arr [ 0 ] , arr [ - 1 ] ) ) else : print ( min ( arr ) ) NEW_LINE

[ N , K ] = map ( int , input ( ) . split ( " ▁ " ) ) nums = list ( map ( int , input ( ) . split ( " ▁ " ) ) ) if K == 1 : print ( min ( nums ) ) elif K == 2 : print ( max ( nums [ 0 ] , nums [ - 1 ] ) ) else : print ( max ( nums ) ) NEW_LINE


import java . util . * ; import java . io . * ; public class CF663A { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; StringTokenizer st ; st = new StringTokenizer ( br . readLine ( ) ) ; int plus = 0 ; int neg = 0 ; PriorityQueue < Integer > stack = new PriorityQueue < Integer > ( ) ; PriorityQueue < Integer > stack1 = new PriorityQueue < Integer > ( ) ; int a [ ] = new int [ 105 ] ;

import java . util . * ;   public class Rebus { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String line = scan . nextLine ( ) ; String [ ] S = line . split ( " = " ) ; int N = Integer . parseInt ( S [ 1 ] . trim ( ) ) ; int max = N , min = 1 , nplus = 0 , nminus = 0 ;

s = input ( ) a = s . split ( )   tot = 0 b = [ 1 if x == ' ? ' else x for x in a ] for i , x in enumerate ( b ) : if x == 1 : if i == 0 or b [ i - 1 ] == ' + ' : tot += 1 elif b [ i - 1 ] == ' - ' : tot -= 1   goal = int ( b [ - 1 ] ) if tot < goal : for i , x in enumerate ( b ) : if x == 1 and i == 0 or b [ i - 1 ] == ' + ' and tot < goal : a = min ( goal - 1 , goal - tot ) tot += a b [ i ] += a   elif tot > goal : for i , x in enumerate ( b ) : if x == 1 and b [ i - 1 ] == ' - ' and tot > goal : a = min ( goal - 1 , tot - goal ) tot -= a b [ i ] += a if tot != goal : print ( " Impossible " ) else : print ( " Possible " ) print ( ' ▁ ' . join ( [ str ( x ) for x in b ] ) )     NEW_LINE

sgn , a , b = 1 , 0 , 0 sol = " " ok = 0 for ch in input ( ) . split ( ) : if ch == ' ? ' : if sgn == 1 : a += 1 ch = ' P ' else : b += 1 ch = ' M ' elif ch == ' + ' : sgn = 1 elif ch == ' - ' : sgn = - 1 elif ch != ' = ' : n = int ( ch ) ok = 1 if not ok : sol += chpl , mn = [ n ] * a , [ 1 ] * bs = n * a - bi , j = 0 , 0 while s > n and ( i < a or j < b ) : if i < a : amt = min ( s - n , n - 1 ) pl [ i ] -= amt s -= amt i += 1 else : amt = min ( s - n , n - 1 ) mn [ j ] += amt s -= amt j += 1 if s != n : print ( " Impossible " ) else : print ( " Possible " ) for ch in sol : if ch != ' P ' and ch != ' M ' : print ( ch , end = ' ▁ ' ) elif ch == ' P ' : print ( pl [ - 1 ] , end = ' ▁ ' ) pl . pop ( ) else : print ( mn [ - 1 ] , end = ' ▁ ' ) mn . pop ( ) print ( n ) NEW_LINE

l = [ i for i in input ( ) . split ( ' ▁ ' ) ] n , make = int ( l [ - 1 ] ) , int ( l [ - 1 ] ) positives = 1 negatives = 0 for i in l : if i == ' - ' : make += 1 negatives += 1 elif i == ' + ' : positives += 1 if make > n * positives or ( make < positives and negatives == 0 ) : print ( ' Impossible ' ) exit ( 0 ) ans = [ ] for i in range ( n , 0 , - 1 ) : while make >= i : ans . append ( i ) make -= i if make == 0 : break     idx = 0 while len ( ans ) > 0 and len ( ans ) < positives : if ans [ idx ] == 1 : idx += 1 if idx > len ( ans ) or ans [ idx ] == 1 : break ans [ idx ] -= 1 ans . append ( 1 )   idx = 0 negs = [ 0 ] * negativeswhile len ( ans ) < positives : ans . append ( 1 ) negs [ idx ] += 1 if negs [ idx ] == n : print ( ' Impossible ' ) exit ( 0 ) idx = ( idx + 1 ) % negatives print ( ' Possible ' ) print ( ans [ 0 ] , end = ' ▁ ' ) j , k = 0 , 1 for i in l : if i == ' - ' : print ( i , 1 + negs [ j ] , end = ' ▁ ' ) j += 1 elif i == ' + ' : print ( i , ans [ k ] , end = ' ▁ ' ) k += 1 elif i != ' ? ' : print ( i , end = ' ▁ ' ) print ( ) NEW_LINE

import sysr = input ( ) r , n = r . split ( ' = ' ) z = ' ' for i in r : z = z + i * ( i in [ ' + ' , ' - ' ] ) r = zn = int ( n ) p , v = r . count ( ' + ' ) + 1 , r . count ( ' - ' ) if not ( p - n * v <= n <= p * n - v ) : print ( ' Impossible ' ) sys . exit ( ) print ( ' Possible ' ) s = 0 ans = ' ' for i in range ( len ( r ) ) : zn = 1 if i > 0 and r [ i - 1 ] == ' - ' : zn = - 1 if zn == 1 : p -= 1 else : v -= 1 for x in range ( 1 , n + 1 ) : if s + x * zn + p - n * v <= n <= s + x * zn + p * n - v : s += x * zn zn = ' + ' if zn == 1 else ' - ' ans = ans + str ( x ) + ' ▁ ' + str ( r [ i ] ) + ' ▁ ' breakans = ans + str ( abs ( n - s ) ) + ' ▁ ' print ( ans + ' = ▁ ' + str ( n ) ) NEW_LINE