import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String s1 = s . nextLine ( ) ; int k = s . nextInt ( ) ; HashMap < Character , Integer > h = new HashMap < > ( ) ; for ( int i = 0 ; i < s1 . length ( ) ; i ++ ) { if ( h . containsKey ( s1 . charAt ( i ) ) ) h . put ( s1 . charAt ( i ) , h . get ( s1 . charAt ( i ) ) + 1 ) ; else h . put ( s1 . charAt ( i ) , 1 ) ; } if ( k > s1 . length ( ) ) System . out . println ( " impossible " ) ; else if ( h . size ( ) >= k ) System . out . println ( "0" ) ; else { int count = k - h . size ( ) ; System . out . println ( count ) ; } } }


s = input ( ) k = int ( input ( ) ) arr = set ( list ( s ) )   x = len ( arr )     if ( x >= k ) : print ( 0 ) else : k -= x rem = len ( s ) - x   NEW_LINE


s = input ( ) k = int ( input ( ) )   ss = set ( s . strip ( ) )   ns = len ( ss )   if k > len ( s ) : print ( " impossible " ) else : print ( max ( 0 , k - ns ) )   NEW_LINE


s = list ( str ( input ( ) ) ) k = int ( input ( ) ) r = 0 possible = Trueif len ( s ) < k : possible = Falseelse : r = k - len ( set ( s ) ) r = 0 if r < 0 else rprint ( r if possible else " impossible " ) NEW_LINE


string = list ( input ( ) ) differnt_words = int ( input ( ) ) difset = set ( string )   if ( differnt_words > len ( string ) ) : print ( " impossible " ) else : val = differnt_words - len ( difset ) if ( val < 0 ) : print ( 0 ) else : print ( val ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n + 1 ] ; int box = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int beg = 0 , ent = 0 ; for ( int i = 2 ; i <= n ; i ++ ) { beg = 0 ; ent = 0 ; for ( int j = 1 ; j < i ; j ++ ) beg += a [ j ] ; for ( int k = i ; k <= n ; k ++ ) ent += a [ k ] ; if ( beg >= x && beg <= y && ent >= x && ent <= y ) box = i ; } System . out . println ( box ) ; } }

m = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) x , y = map ( int , input ( ) . split ( ) ) for i in range ( 1 , m ) : arr [ i ] += arr [ i - 1 ]   total = arr [ - 1 ]     for i in range ( m ) : if x <= arr [ i ] <= y and x <= total - arr [ i ] <= y : ans = i + 2 print ( ans ) exit ( ) print ( 0 ) NEW_LINE


n = int ( input ( ) ) arr = [ int ( z ) for z in input ( ) . split ( ) ] x , y = map ( int , input ( ) . split ( ) ) for i in range ( 1 , n ) : b = sum ( arr [ : i ] ) a = sum ( arr [ i : ] ) if b >= x and b <= y and a >= x and a <= y : print ( i + 1 ) exit ( ) print ( 0 ) NEW_LINE


n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) x = b [ 0 ] y = b [ 1 ] i = 1 s = sum ( a ) ans1 = 0 ans2 = sans = 0 while i <= n : ans1 += a [ i - 1 ] ans2 -= a [ i - 1 ] NEW_LINE


n = int ( input ( ) ) A = list ( map ( int , input ( ) . split ( ) ) ) x , y = map ( int , input ( ) . split ( ) )   for i in range ( 1 , n ) : A [ i ] = A [ i ] + A [ i - 1 ]   for i in range ( n ) : a = A [ i ] itr = A [ - 1 ] - a if a >= x and a <= y and itr >= x and itr <= y : print ( i + 2 ) breakelse : print ( 0 ) NEW_LINE


import sys , mathsys . setrecursionlimit ( 10 ** 8 ) ''' def ▁ fun ( ) : ▁ ▁ ▁ ▁ for ▁ i ▁ in ▁ range ( 16 ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ for ▁ j ▁ in ▁ range ( 4 ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ if ▁ i & (1 < < j ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( j , end = ' ' ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( ) import ▁ binarytreefrom ▁ collections ▁ import ▁ dequebst ▁ = ▁ binarytree . tree ( height = 4 , is _ perfect = True ) print ( bst ) def ▁ s ( bst ) : ▁ ▁ ▁ ▁ if ▁ bst : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ bst . left , bst . right ▁ = ▁ bst . right , bst . left ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ s ( bst . right ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ s ( bst . left ) s ( bst ) print ( bst ) '''   n = int ( input ( ) ) s = list ( map ( int , input ( ) . split ( ) ) ) x , y = map ( int , input ( ) . split ( ) ) ss = 0 pika = 1 for i in range ( n ) : ss += s [ i ] if x <= ss <= y and x <= sum ( s [ i + 1 : ] ) <= y : print ( i + 2 ) pika = 0 breakif pika == 1 : print ( 0 ) NEW_LINE


import java . util . * ; import java . io . * ; import java . text . * ; import java . math . * ; import java . lang . Math . * ;   public class A { public static void main ( String [ ] args ) throws Exception { new A ( ) . run ( ) ; } public FastIO file = new FastIO ( ) ; public int ntc , ctc ; public final long MOD = 1000000007L ;


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


import java . util . Scanner ;   public class GroupDividing { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ;   int m = scan . nextInt ( ) ; int [ ] sum = new int [ m + 1 ] ; int k = - 1 ;   for ( int i = 0 ; i < m ; i ++ ) sum [ i + 1 ] = sum [ i ] + scan . nextInt ( ) ;   int x = scan . nextInt ( ) ; int y = scan . nextInt ( ) ;   for ( int i = 1 ; i < m + 1 ; i ++ ) { if ( sum [ i ] >= x && sum [ i ] <= y && sum [ m ] - sum [ i ] >= x && sum [ m ] - sum [ i ] <= y ) { k = i ; break ; } } System . out . println ( k + 1 ) ; } }


import java . util . Arrays ; import java . util . Collections ; import java . util . Comparator ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; import java . util . TreeMap ;   public class orderBook {   public static void main ( String [ ] args ) {

import sys , os . pathfrom collections import * from copy import * import mathmod = 10 ** 9 + 7 if ( os . path . exists ( ' input . txt ' ) ) : sys . stdin = open ( " input . txt " , " r " ) sys . stdout = open ( " output . txt " , " w " )     n , s = map ( int , input ( ) . split ( ) ) mat = [ ] buy = { } sell = { } for i in range ( n ) : dpq = list ( map ( str , input ( ) . split ( ) ) ) d = dpq [ 0 ] p = int ( dpq [ 1 ] ) q = int ( dpq [ 2 ] ) if ( d == " S " ) : sell [ p ] = sell . get ( p , 0 ) + q else : buy [ p ] = buy . get ( p , 0 ) + qb = list ( buy . items ( ) ) b . sort ( ) sel = list ( sell . items ( ) ) sel . sort ( ) b = b [ - s : ] sel = sel [ : s ] b . reverse ( ) sel . reverse ( ) for i in sel : print ( ' S ' , * i ) for i in b : print ( ' B ' , * i )           NEW_LINE


n , s = map ( int , input ( ) . split ( ) )   buys , sells = { } , { }   for i in range ( n ) : line = input ( ) . split ( ) d = line [ 0 ] p = int ( line [ 1 ] ) v = int ( line [ 2 ] )   if d == ' B ' : if p in buys : buys [ p ] += v else : buys [ p ] = v else : if p in sells : sells [ p ] += v else : sells [ p ] = v   sells = sorted ( sells . items ( ) ) [ : s ] buys = sorted ( buys . items ( ) , reverse = True ) [ : s ]   for sell in sells [ : : - 1 ] : print ( ' S ' , sell [ 0 ] , sell [ 1 ] )   for buy in buys : print ( ' B ' , buy [ 0 ] , buy [ 1 ] ) NEW_LINE


n , s = input ( ) . split ( ) n , s = int ( n ) , int ( s ) dic = { } while n > 0 : listOfInput = input ( ) . split ( ) key = ' ▁ ' . join ( listOfInput [ : - 1 ] ) value = listOfInput [ - 1 ] if key in dic : dic [ key ] += int ( value ) else : dic [ key ] = int ( value ) n -= 1 listOfSells = sorted ( [ int ( key . split ( ) [ 1 ] ) for key in dic if key . split ( ) [ 0 ] == ' S ' ] ) [ : s ] listOfBuys = sorted ( [ int ( key . split ( ) [ 1 ] ) for key in dic if key . split ( ) [ 0 ] == ' B ' ] ) for i in range ( s ) : if listOfSells : value = listOfSells . pop ( ) key = ' S ▁ ' + str ( value ) print ( ' S ▁ ' + str ( value ) + ' ▁ ' + str ( dic [ key ] ) ) else : passfor i in range ( s ) : if listOfBuys : value = listOfBuys . pop ( ) key = ' B ▁ ' + str ( value ) print ( ' B ▁ ' + str ( value ) + ' ▁ ' + str ( dic [ key ] ) ) else : pass NEW_LINE


n , s = input ( ) . split ( ) n , s = int ( n ) , int ( s ) dic = { } while n > 0 : listOfInput = input ( ) . split ( ) key = ' ▁ ' . join ( listOfInput [ : - 1 ] ) value = listOfInput [ - 1 ] if key in dic : dic [ key ] += int ( value ) else : dic [ key ] = int ( value ) n -= 1 listOfSells = sorted ( [ int ( key . split ( ) [ 1 ] ) for key in dic if key . split ( ) [ 0 ] == ' S ' ] ) [ : s ] listOfBuys = sorted ( [ int ( key . split ( ) [ 1 ] ) for key in dic if key . split ( ) [ 0 ] == ' B ' ] ) for i in range ( s ) : if listOfSells : value = listOfSells . pop ( ) key = ' S ▁ ' + str ( value ) print ( ' S ▁ ' + str ( value ) + ' ▁ ' + str ( dic [ key ] ) ) else : passfor i in range ( s ) : if listOfBuys : value = listOfBuys . pop ( ) key = ' B ▁ ' + str ( value ) print ( ' B ▁ ' + str ( value ) + ' ▁ ' + str ( dic [ key ] ) ) else : pass           NEW_LINE


a , b = map ( int , input ( ) . split ( ) ) bs , s = { } , { } for _ in " ▁ " * a : x , y , z = input ( ) . split ( ) y , z = int ( y ) , int ( z ) if x == ' B ' : if y in bs : bs [ y ] += z else : bs [ y ] = z else : if y in s : s [ y ] += z else : s [ y ] = z NEW_LINE


import java . util . Scanner ;   public class B572 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int N = in . nextInt ( ) ; int S = in . nextInt ( ) ; int [ ] buy = new int [ 100001 ] ; int [ ] sell = new int [ 100001 ] ; for ( int n = 0 ; n < N ; n ++ ) { String type = in . next ( ) ; int p = in . nextInt ( ) ; int q = in . nextInt ( ) ; int [ ] A = ( type . charAt ( 0 ) == ' B ' ) ? buy : sell ; A [ p ] += q ; } int sellS = S ; int p = 0 ; while ( sellS > 0 && p < sell . length ) { if ( sell [ p ] > 0 ) { sellS -- ; } p ++ ; } p -- ; while ( p >= 0 ) { if ( sell [ p ] > 0 ) { System . out . println ( " S ▁ " + p + " ▁ " + sell [ p ] ) ; } p -- ; } int buyS = S ; for ( p = buy . length - 1 ; p >= 0 ; p -- ) { if ( buy [ p ] > 0 && buyS > 0 ) { buyS -- ; System . out . println ( " B ▁ " + p + " ▁ " + buy [ p ] ) ; } } }   }


import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ; public class Cat_Furrier { public static boolean samechars ( String [ ] st ) { int [ ] ar = new int [ 26 ] ; for ( int i = 0 ; i < st [ 0 ] . length ( ) ; i ++ ) ar [ st [ 0 ] . charAt ( i ) - ' a ' ] ++ ; for ( int j = 1 ; j < st . length ; j ++ ) { int [ ] tar = new int [ 26 ] ; for ( int i = 0 ; i < st [ j ] . length ( ) ; i ++ ) tar [ st [ j ] . charAt ( i ) - ' a ' ] ++ ; if ( ! Arrays . equals ( ar , tar ) ) return false ; } return true ; } public static void main ( String [ ] args ) {

n = int ( input ( ) ) arr = [ ] mi = 100000 def get_next ( word ) : return word [ 1 : len ( word ) ] + word [ 0 ] def other ( cur_word ) : total = 0 for i in range ( 1 , n ) : flag = 0 mw = arr [ i ] for j in range ( len ( mw ) ) : if ( mw == cur_word ) : flag = 1 break total += 1 mw = get_next ( mw ) if ( flag == 0 ) : return - 1 return total for i in range ( n ) : arr . append ( input ( ) ) cur_word = arr [ 0 ] for i in range ( len ( arr [ 0 ] ) ) : res = i + other ( cur_word ) mi = min ( res , mi ) cur_word = get_next ( cur_word ) print ( mi ) NEW_LINE


from collections import Counterfrom sys import stdin , stdout   STRS = [ ]   def main ( ) : n = int ( stdin . readline ( ) . rstrip ( ) )   for _ in range ( n ) : STRS . append ( stdin . readline ( ) . rstrip ( ) )   k = len ( STRS [ 0 ] ) best = float ( ' inf ' ) c = Counter ( STRS [ 0 ] ) for s in STRS : if c != Counter ( s ) : best = - 1 break   if best > 0 : table = [ [ float ( ' inf ' ) ] * k for _ in range ( n ) ] table [ 0 ] = list ( range ( k ) )   for i in range ( 1 , n ) : NEW_LINE


n = int ( input ( ) ) s = [ input ( ) for i in range ( n ) ] m = len ( s [ 0 ] ) ans = 10 ** 18 l = [ [ ] for i in range ( n ) ] for i in range ( n ) : for j in range ( m + 1 ) : l [ i ] . append ( s [ i ] ) s [ i ] = s [ i ] [ 1 : ] + s [ i ] [ 0 ] for i in range ( m ) : c = i flag = True for j in range ( 1 , n ) : if not l [ 0 ] [ i ] in l [ j ] : flag = False break idx = l [ j ] . index ( l [ 0 ] [ i ] ) c += idx if flag : ans = min ( ans , c ) if ans == 10 ** 18 : print ( - 1 ) else : print ( ans ) NEW_LINE


def check ( string1 , string2 ) : size1 = len ( string1 ) size2 = len ( string2 ) temp = ' ' if size1 != size2 : return 0 temp = string1 + string1 if ( temp . count ( string2 ) > 0 ) : return 1 else : return 0 n = int ( input ( ) ) s = [ ] for i in range ( n ) : s . append ( input ( ) ) for i in range ( 1 , n ) : if check ( s [ 0 ] , s [ i ] ) == 0 : print ( - 1 ) exit ( ) def r ( s1 , s2 ) : for i in range ( len ( s2 ) ) : if s2 [ i : ] + s2 [ : i ] == s1 : return ip = float ( " inf " ) for i in range ( n ) : ans = 0 for j in range ( n ) : if i == j : continue else : ans += r ( s [ i ] , s [ j ] ) p = min ( p , ans ) print ( p ) 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 ( ) ; int n = input . nextInt ( ) ; StringBuilder s [ ] = new StringBuilder [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { s [ i ] = new StringBuilder ( input . next ( ) ) ; }


import java . util . * ; import java . io . * ; import java . math . * ;   public class First {   public static int func ( int m , int n , String [ ] s ) { boolean flag = true ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < m ; i ++ ) { String target = s [ i ] + s [ i ] ; int sum = 0 ; for ( int j = 0 ; j < m ; j ++ ) { if ( i == j ) { continue ; } int index = target . lastIndexOf ( s [ j ] ) ; if ( index == - 1 ) { flag = false ; break ; } else { if ( index > 0 ) { sum += ( n - index ) ; } } } if ( ! flag ) { break ; } if ( min > sum ) { min = sum ; } } if ( ! flag ) { return - 1 ; } return min ; } public static void process ( ) throws IOException { int m = ni ( ) ; String [ ] s = new String [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { s [ i ] = nln ( ) ; } int n = s [ 0 ] . length ( ) ; int ans = ( m == 1 ) ? 0 : func ( m , n , s ) ; pn ( ans ) ; }    static AnotherReader sc ; static PrintWriter out ; public static void main ( String [ ] args ) throws IOException { out = new PrintWriter ( System . out ) ; sc = new AnotherReader ( ) ; boolean oj = true ;


import java . 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 ) {


import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; if ( i > 0 ) System . out . print ( ( a [ i - 1 ] + a [ i ] ) + " ▁ " ) ; } System . out . print ( a [ n - 1 ] ) ; } }

n = int ( input ( ) ) a = [ int ( x ) for x in input ( ) . split ( ) ] l = [ ] for i in range ( 1 , n ) : l . append ( a [ i ] + a [ i - 1 ] ) l . append ( a [ n - 1 ] ) print ( * l ) NEW_LINE


n = int ( input ( ) ) List = list ( map ( int , input ( ) . split ( ) ) )   A = 0 list_new = [ ] for i in range ( 0 , n ) : if i == len ( List ) - 1 : list_new . append ( List [ i ] ) break A = List [ i + 1 ] + List [ i ] list_new . append ( A ) A = 0   for i in range ( len ( list_new ) ) : print ( list_new [ i ] , end = " ▁ " ) NEW_LINE


def solve ( arr ) : res = [ arr [ - 1 ] ] for i in range ( len ( arr ) - 2 , - 1 , - 1 ) : res . insert ( 0 , arr [ i ] + arr [ i + 1 ] ) return res                       def main ( ) : n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) print ( * solve ( arr ) ) main ( ) NEW_LINE


n = int ( input ( ) ) li = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n - 1 ) : print ( li [ i ] + li [ i + 1 ] , end = ' ▁ ' ) print ( li [ n - 1 ] )   NEW_LINE


n = int ( input ( ) ) lst = [ int ( i ) for i in input ( ) . split ( ) ]   for i in range ( n - 1 ) : print ( lst [ i ] + lst [ i + 1 ] , end = ' ▁ ' ) print ( lst [ n - 1 ] ) NEW_LINE


import java . util . Scanner ;   public class MemoryAndCrow { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] b = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } for ( int j = 0 ; j < n - 1 ; j ++ ) { System . out . print ( b [ j ] + b [ j + 1 ] + " ▁ " ) ; } System . out . print ( b [ n - 1 ] ) ; } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; import java . util . stream . IntStream ; import javafx . util . Pair ;   public class Main {   static void sort ( long a [ ] ) { Random ran = new Random ( ) ; for ( int i = 0 ; i < a . length ; i ++ ) { int r = ran . nextInt ( a . length ) ; long temp = a [ r ] ; a [ r ] = a [ i ] ; a [ i ] = temp ; }   Arrays . sort ( a ) ; }   public static void main ( String [ ] args ) throws IOException { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int a [ ] = new int [ n ] ; int ans [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; } ans [ n - 1 ] = a [ n - 1 ] ; for ( int i = 0 ; i < n - 1 ; i ++ ) { ans [ i ] = a [ i ] + a [ i + 1 ] ; } for ( int an : ans ) { System . out . print ( an + " ▁ " ) ; } System . out . println ( ) ; }   }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; int [ ] arr = new int [ t ] ; int [ ] brr = new int [ t ] ; for ( int i = 0 ; i < t ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } for ( int j = 0 ; j < t - 1 ; j ++ ) { brr [ j ] = arr [ j ] + arr [ j + 1 ] ; } brr [ t - 1 ] = arr [ t - 1 ] ; for ( int x : brr ) { System . out . print ( x + " ▁ " ) ; } } }


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


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

from math import sqrt , floor , ceil   NEW_LINE


from sys import stdoutn = int ( input ( ) ) stdout . write ( "2 \n " ) for lv in range ( 2 , n + 1 ) : stdout . write ( str ( lv * ( lv + 1 ) * ( lv + 1 ) - ( lv - 1 ) ) + ' \n ' ) NEW_LINE


n = int ( input ( ) ) l = [ 2 ] cs = 2 for i in range ( 2 , n + 1 ) : xs = i * ( i + 1 ) ys = xs * xs ax = ys - cs ax = ax // i cs = xs l . append ( ax )   for i in range ( len ( l ) ) : print ( l [ i ] ) NEW_LINE


import mathn = int ( input ( ) ) al = 2 for i in range ( 1 , n + 1 ) : ai = ( i * i + i ) ** 2 ; res = ( ai - al ) // i ; al = ( i * i + i ) print ( int ( res ) ) NEW_LINE


import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( i == 1 ) { System . out . println ( "2" ) ; } else { System . out . println ( ( long ) i * ( i + 1 ) * ( i + 1 ) - ( i - 1 ) ) ; } } } }


import java . util . * ; import java . io . * ; import java . math . BigInteger ; public class mat { static class InputReader { private InputStream stream ; private byte [ ] inbuf = new byte [ 1024 ] ; private int start = 0 ; private int end = 0 ;   public InputReader ( InputStream stream ) { this . stream = stream ; }   private int readByte ( ) { if ( start == - 1 ) throw new UnknownError ( ) ; if ( end >= start ) { end = 0 ; try { start = stream . read ( inbuf ) ; } catch ( IOException e ) { throw new UnknownError ( ) ; } if ( start <= 0 ) return - 1 ; } return inbuf [ end ++ ] ; }   private boolean isSpaceChar ( int c ) { return ! ( c >= 33 && c <= 126 ) ; }   private int skip ( ) { int b ; while ( ( b = readByte ( ) ) != - 1 && isSpaceChar ( b ) ) ; return b ; }   public String next ( ) { int b = skip ( ) ; StringBuilder sb = new StringBuilder ( ) ; while ( ! ( isSpaceChar ( b ) ) ) {


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;

t = int ( input ( ) ) NEW_LINE for i in range ( t ) : n = int ( input ( ) ) NEW_LINE x = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE l = set ( ) NEW_LINE for j in x : if NEW_LINE j not in l : l . add ( j ) else : l . add ( j + 1 ) NEW_LINE l1 = set ( ) NEW_LINE


for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a . sort ( reverse = True ) NEW_LINE d = { } NEW_LINE for el in a : d [ el ] = True   for i in range ( n ) : if NEW_LINE not d . get ( a [ i ] + 1 , False ) : d [ a [ i ] + 1 ] = True NEW_LINE d . pop ( a [ i ] ) else : d [ a [ i ] ] = True   print ( len ( d ) ) NEW_LINE


for t in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE count = [ 0 ] * ( 2 * n + 2 ) NEW_LINE for i in a : count [ i ] += 1 NEW_LINE for i in range ( len ( a ) - 1 , - 1 , - 1 ) : if NEW_LINE count [ a [ i ] + 1 ] == 0 : count [ a [ i ] + 1 ] += 1 NEW_LINE count [ a [ i ] ] -= 1 NEW_LINE a [ i ] += 1 NEW_LINE print ( len ( set ( a ) ) ) NEW_LINE


from collections import defaultdictfor NEW_LINE _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE a = sorted ( list ( map ( int , input ( ) . split ( ) ) ) , reverse = 1 ) NEW_LINE d = defaultdict ( int ) NEW_LINE for i in a : d [ i ] += 1 NEW_LINE for i in a : if NEW_LINE not d [ i + 1 ] : d [ i ] -= 1 NEW_LINE if not d [ i ] : del d [ i ] NEW_LINE d [ i + 1 ] = 1 NEW_LINE print ( len ( d ) ) NEW_LINE


import java . util . Scanner ; import java . util . Set ; import java . util . TreeSet ;   public class Main { public static void main ( String [ ] args ) throws Exception { Scanner in = new Scanner ( System . in ) ; int t = in . nextInt ( ) ; int n ; while ( t != 0 ) { n = in . nextInt ( ) ; Set < Integer > s = new TreeSet < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int a = in . nextInt ( ) ; if ( s . contains ( a ) ) s . add ( a + 1 ) ; else s . add ( a ) ; } System . out . println ( s . size ( ) ) ; t -- ; } } }


import java . util . Scanner ;   public class B1466 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int N = in . nextInt ( ) ; int answer = 0 ; int last = 0 ; for ( int n = 0 ; n < N ; n ++ ) { int x = in . nextInt ( ) ; if ( last < x ) { last = x ; answer ++ ; } else if ( last == x ) { last = x + 1 ; answer ++ ; } } System . out . println ( answer ) ; } }   }


import java . util . * ; public class enhancements { public static void main ( String [ ] args ) { int t , n ;   Scanner sc = new Scanner ( System . in ) ;   t = sc . nextInt ( ) ;   while ( t -- > 0 ) { n = sc . nextInt ( ) ; Set < Integer > s = new TreeSet < > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { int a = sc . nextInt ( ) ; if ( s . contains ( a ) ) s . add ( a + 1 ) ; else s . add ( a ) ; }   System . out . println ( s . size ( ) ) ; }   }   }


import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int t = scanner . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int n = scanner . nextInt ( ) ; int k = scanner . nextInt ( ) ; int [ ] visit = new int [ 200 ] ; int count = 0 ;

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


t = int ( input ( ) ) NEW_LINE for _ in range ( t ) : n , k = map ( int , input ( ) . split ( ) ) NEW_LINE l = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE p = 0 NEW_LINE pre = - 1 NEW_LINE for i in range ( n ) : if NEW_LINE pre != l [ i ] : pre = l [ i ] NEW_LINE p += 1 NEW_LINE if k == 1 and p > 1 : NEW_LINE INDENT print ( - 1 ) else : NEW_LINE cnt = 1 NEW_LINE DEDENT p -= k NEW_LINE while p > 0 : p -= ( k - 1 ) NEW_LINE cnt += 1 NEW_LINE print ( cnt ) NEW_LINE


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


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


import java . io . * ; import java . util . * ;   public class Main { static PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; public static void main ( String [ ] args ) throws IOException { int t = input . nextInt ( ) ; int [ ] a = new int [ 105 ] ; Set < Integer > st = new HashSet < Integer > ( ) ; while ( t -- != 0 ) { st . clear ( ) ; int n = input . nextInt ( ) ; int k = input . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int x = input . nextInt ( ) ; st . add ( x ) ; } int cnt = st . size ( ) ; if ( k == 1 && cnt > 1 ) { pr . println ( - 1 ) ; continue ; } if ( cnt <= k ) { pr . println ( 1 ) ; continue ; } pr . println ( 1 + ( cnt - 2 ) / ( k - 1 ) ) ; } pr . flush ( ) ; } static class input { static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static StreamTokenizer in = new StreamTokenizer ( br ) ; static String nextLine ( ) throws IOException { return br . readLine ( ) ; } static int nextInt ( ) throws IOException { in . nextToken ( ) ; return ( int ) in . nval ; } static long nextLong ( ) throws IOException { in . nextToken ( ) ; return ( long ) in . nval ; } static double nextDouble ( ) throws IOException { in . nextToken ( ) ; return in . nval ; } } }


import java . util . * ; import java . io . * ; public class A { public static void main ( String ar [ ] ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int t = Integer . parseInt ( br . readLine ( ) ) ; StringBuffer sb = new StringBuffer ( ) ; for ( int r = 0 ; r < t ; r ++ ) { int n = Integer . parseInt ( br . readLine ( ) ) ; String s1 [ ] = br . readLine ( ) . split ( " ▁ " ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = Integer . parseInt ( s1 [ i ] ) ; Arrays . sort ( a ) ; boolean b [ ] = new boolean [ 1000001 ] ; Arrays . fill ( b , true ) ; int k = 1 ; sb . append ( " YES " ) . append ( " \n " ) ; int count = 0 ; while ( count < n ) { while ( ! b [ k ] ) k ++ ; count ++ ; sb . append ( k ) . append ( " ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { int u = k + a [ j ] - a [ i ] ; if ( u <= 1000000 && u >= 1 ) b [ u ] = false ; } } k ++ ; } sb . append ( " \n " ) ; } System . out . println ( sb ) ; } }

for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) b = [ ] b . append ( 1 ) t = 10 ** 6 used = [ 0 ] * ( t + 1 ) used [ 1 ] = 1 can_be = 2 diffs = [ ] for i in range ( n ) : for j in range ( i + 1 , n ) : diffs . append ( a [ j ] - a [ i ] ) for i in range ( 1 , n ) : for j in diffs : used [ min ( b [ i - 1 ] + j , t ) ] = 1 while ( used [ can_be ] ) : can_be += 1 b . append ( can_be ) used [ can_be ] = 1 if len ( b ) == n : print ( ' YES ' ) for i in b : print ( i , end = ' ▁ ' ) print ( ' ' ) else : print ( ' NO ' )     NEW_LINE


''' from ▁ random ▁ import ▁ randint visited ▁ = ▁ [ -1 ] ▁ * ▁ ( 2 ▁ * ▁ 10 ▁ * * ▁ 6 ▁ + ▁ 1 ) t ▁ = ▁ int ( input ( ) ) for ▁ i ▁ in ▁ range ( t ) : ▁ ▁ ▁ ▁ n , ▁ A ▁ = ▁ int ( input ( ) ) , ▁ list ( map ( int , ▁ input ( ) . split ( ) ) ) ▁ ▁ ▁ ▁ A . sort ( ) ▁ ▁ ▁ ▁ res ▁ = ▁ [ 1 ] ▁ * ▁ n ▁ ▁ ▁ ▁ v ▁ = ▁ 1 ▁ ▁ ▁ ▁ cnt ▁ = ▁ 0 ▁ ▁ ▁ ▁ while ▁ cnt ▁ < ▁ n : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ # v ▁ = ▁ randint ( 1 , ▁ 10 * * 6 ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ if ▁ all ( visited [ a ▁ + ▁ v ] ▁ ! = ▁ i ▁ for ▁ a ▁ in ▁ A ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ for ▁ a ▁ in ▁ A : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ visited [ a ▁ + ▁ v ] ▁ = ▁ i ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ res [ cnt ] ▁ = ▁ v ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ cnt ▁ + = ▁ 1 ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ v ▁ + = ▁ 1 ▁ ▁ ▁ ▁ print ( " YES \n " ▁ + ▁ ' ▁ ' . join ( map ( str , res ) ) ) '''   t = int ( input ( ) )   def check ( arr , v , dic ) : for i in arr : if dic [ i + v ] == 1 : return True return False     def check2 ( arr , v , dic ) : ok = False for i in arr : if dic [ i + v ] == 1 : ok = True break return ok     dic = [ 0 ] * 2000005   for _ in range ( t ) : n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) arr . sort ( ) brr = [ 1 ] * n cnt = 0 i = 1 flag = True tmp = { } while cnt < n : ''' ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ while ▁ check ( arr , i , dic ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ i ▁ + = ▁ 1 ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ brr [ cnt ] ▁ = ▁ i  ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ for ▁ v ▁ in ▁ arr : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ # if ▁ i + v > 2e6 : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ # ▁ ▁ ▁ ▁ break ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ dic [ i + v ] ▁ = ▁ 1 ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ tmp [ i + v ] ▁ = ▁ 1 ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ cnt ▁ + = ▁ 1 ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ''' NEW_LINE


''' from ▁ random ▁ import ▁ randint visited ▁ = ▁ [ -1 ] ▁ * ▁ ( 2 ▁ * ▁ 10 ▁ * * ▁ 6 ▁ + ▁ 1 ) t ▁ = ▁ int ( input ( ) ) for ▁ i ▁ in ▁ range ( t ) : ▁ ▁ ▁ ▁ n , ▁ A ▁ = ▁ int ( input ( ) ) , ▁ list ( map ( int , ▁ input ( ) . split ( ) ) ) ▁ ▁ ▁ ▁ A . sort ( ) ▁ ▁ ▁ ▁ res ▁ = ▁ [ 1 ] ▁ * ▁ n ▁ ▁ ▁ ▁ v ▁ = ▁ 1 ▁ ▁ ▁ ▁ cnt ▁ = ▁ 0 ▁ ▁ ▁ ▁ while ▁ cnt ▁ < ▁ n : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ # v ▁ = ▁ randint ( 1 , ▁ 10 * * 6 ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ if ▁ all ( visited [ a ▁ + ▁ v ] ▁ ! = ▁ i ▁ for ▁ a ▁ in ▁ A ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ for ▁ a ▁ in ▁ A : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ visited [ a ▁ + ▁ v ] ▁ = ▁ i ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ res [ cnt ] ▁ = ▁ v ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ cnt ▁ + = ▁ 1 ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ v ▁ + = ▁ 1 ▁ ▁ ▁ ▁ print ( " YES \n " ▁ + ▁ ' ▁ ' . join ( map ( str , res ) ) ) '''   t = int ( input ( ) )   def check ( arr , v , dic ) : for i in arr : if dic [ i + v ] == 1 : return True return False     def check2 ( arr , v , dic ) : ok = False for i in arr : if dic [ i + v ] == 1 : ok = True break return ok     def check3 ( arr , v , dic ) : return any ( dic [ a + v ] == 1 for a in arr )     dic = [ 0 ] * 2000005   for _ in range ( t ) : n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) arr . sort ( ) brr = [ 1 ] * n cnt = 0 i = 1 flag = True tmp = { } while cnt < n : ''' ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ while ▁ check ( arr , i , dic ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ i ▁ + = ▁ 1 ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ brr [ cnt ] ▁ = ▁ i  ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ for ▁ v ▁ in ▁ arr : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ # if ▁ i + v > 2e6 : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ # ▁ ▁ ▁ ▁ break ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ dic [ i + v ] ▁ = ▁ 1 ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ tmp [ i + v ] ▁ = ▁ 1 ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ cnt ▁ + = ▁ 1 ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ''' NEW_LINE


visited = [ - 1 ] * ( 2 * 10 ** 6 + 1 ) t = int ( input ( ) ) for i in range ( t ) : n , A = int ( input ( ) ) , list ( map ( int , input ( ) . split ( ) ) ) A . sort ( ) res = [ ] v = 1 while len ( res ) < n : flag = True for a in A : if visited [ a + v ] == i : flag = False break if not flag : v += 1 continue for a in A : visited [ a + v ] = i res . append ( v ) v += 1 print ( " YES \n " + ' ▁ ' . join ( map ( str , res ) ) ) NEW_LINE


for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) b = [ ] b . append ( 1 ) used = [ 0 ] * ( 10 ** 6 + 1 ) used [ 1 ] = 1 can_be = 2 diffs = [ ] for i in range ( n ) : for j in range ( i + 1 , n ) : diffs . append ( a [ j ] - a [ i ] ) for i in range ( 1 , n ) : for j in diffs : used [ min ( b [ i - 1 ] + j , 10 ** 6 ) ] = 1 while ( used [ can_be ] ) : can_be += 1 b . append ( can_be ) used [ can_be ] = 1 if len ( b ) == n : print ( ' YES ' ) for i in b : print ( i , end = ' ▁ ' ) print ( ' ' ) else : print ( ' NO ' )     NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . io . PrintWriter ; import java . io . StreamTokenizer ; import java . util . Arrays ;   public class Main {   public static void main ( String [ ] args ) throws IOException { StreamTokenizer in = new StreamTokenizer ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; PrintWriter out = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; in . nextToken ( ) ; int t = ( int ) in . nval ; for ( int i = 0 ; i < t ; i ++ ) { in . nextToken ( ) ; int n = ( int ) in . nval ; int a [ ] = new int [ n ] ; for ( int j = 0 ; j < n ; j ++ ) { in . nextToken ( ) ; int num = ( int ) in . nval ; a [ j ] = num ; } if ( n == 1 ) { out . println ( " YES " ) ; out . println ( 1 ) ; continue ; } int chaA [ ] = new int [ 1000010 ] ; Arrays . sort ( a ) ; for ( int j = 0 ; j < n - 1 ; j ++ ) { for ( int k = j + 1 ; k < n ; k ++ ) { chaA [ a [ k ] - a [ j ] ] = 1 ;


import java . util . * ; import java . math . * ; public class SavingTheCity { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int runs = sc . nextInt ( ) ; while ( runs -- > 0 ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; char [ ] arr = sc . next ( ) . toCharArray ( ) ; int ones = 0 ; int zeros = 0 ; int out = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( arr [ i ] == '0' ) zeros ++ ; else { ones ++ ; if ( ones == 1 ) out += a ; else out += Math . min ( a , zeros * b ) ; zeros = 0 ; } } System . out . println ( out ) ; } } }

from sys import stdin , stdoutstdin . readlinedef NEW_LINE mp ( ) : NEW_LINE return list ( map ( int , stdin . readline ( ) . strip ( ) . split ( ) ) ) NEW_LINE def it ( ) : return int ( stdin . readline ( ) . strip ( ) ) NEW_LINE from collections import defaultdict as dd , Counter as C , dequeimport NEW_LINE math   for _ in range ( it ( ) ) : a , b = mp ( ) NEW_LINE l = input ( ) NEW_LINE s = l . strip ( '0' ) NEW_LINE ind = 0 NEW_LINE ans , flag = a , 0 NEW_LINE for i in range ( 1 , len ( s ) ) : if NEW_LINE s [ i ] == '1' and flag == 0 : k = i - ind NEW_LINE ans += min ( ( k - 1 ) * b , a ) NEW_LINE ind = i NEW_LINE flag = 1 elif s [ i ] == '1' : k = i - ind NEW_LINE ans += min ( ( k - 1 ) * b , a ) NEW_LINE ind = i NEW_LINE if not flag : if NEW_LINE s : NEW_LINE if s [ 0 ] == '1' : NEW_LINE INDENT print ( a ) else : NEW_LINE print ( 0 ) else : print ( 0 ) else : print ( ans )     NEW_LINE DEDENT


import sysfor NEW_LINE x in range ( int ( input ( ) ) ) : a , b = map ( int , input ( ) . split ( ) ) NEW_LINE s = input ( ) NEW_LINE s = s . strip ( '0' ) NEW_LINE if '1' not in s or s == [ ] : print ( 0 ) NEW_LINE continue NEW_LINE ans = a NEW_LINE zero = 0 NEW_LINE for i in s : if NEW_LINE i == '0' : zero += 1 NEW_LINE if i == '1' : if NEW_LINE zero > 0 : ans += min ( a , zero * b ) NEW_LINE zero = 0 NEW_LINE print ( ans ) NEW_LINE


t = int ( input ( ) ) NEW_LINE for _ in range ( t ) : a , b = map ( int , input ( ) . split ( ) ) NEW_LINE s = input ( ) NEW_LINE id = 0 NEW_LINE id1 = 0 NEW_LINE ans = 0 NEW_LINE m = float ( ' inf ' ) NEW_LINE for i in range ( len ( s ) ) : if NEW_LINE s [ i ] == '0' : m += 1 else : ans += min ( a , b * m ) NEW_LINE m = 0 NEW_LINE print ( ans ) NEW_LINE


t = int ( input ( ) ) NEW_LINE for _ in range ( t ) : a , b = map ( int , input ( ) . split ( ) ) NEW_LINE s = input ( ) NEW_LINE cnt = 10 ** 6 NEW_LINE ans = 0 NEW_LINE for i in range ( len ( s ) ) : if NEW_LINE s [ i ] == "0" : cnt += 1 else : ans += min ( a , cnt * b ) NEW_LINE cnt = 0 NEW_LINE print ( ans ) NEW_LINE


import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ;   public class B1443 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int A = in . nextInt ( ) ; int B = in . nextInt ( ) ; String S = in . next ( ) ; int pos1 = S . indexOf ( '1' ) ; int answer = 0 ; if ( pos1 != - 1 ) { List < Integer > gaps = new ArrayList < > ( ) ; while ( true ) { int pos0 = S . indexOf ( '0' , pos1 ) ; if ( pos0 == - 1 ) break ; pos1 = S . indexOf ( '1' , pos0 ) ; if ( pos1 == - 1 ) break ; gaps . add ( pos1 - pos0 ) ; } Collections . sort ( gaps ) ; answer += A ; for ( int gap : gaps ) { answer += Math . min ( gap * B , A ) ; } } System . out . println ( answer ) ; } }   }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;    public class Main {   public static void main ( String [ ] args ) throws IOException {   Scanner sc = new Scanner ( System . in ) ; int testCases = sc . nextInt ( ) ; while ( testCases -- > 0 ) { StringBuilder inp = new StringBuilder ( sc . next ( ) ) ; int n = inp . length ( ) ; boolean aliceTurn = true ; for ( int i = 0 ; i < n ; i ++ ) { if ( aliceTurn ) { if ( inp . charAt ( i ) == ' a ' ) { inp . setCharAt ( i , ' b ' ) ; } else { inp . setCharAt ( i , ' a ' ) ; } aliceTurn = false ; } else { if ( inp . charAt ( i ) == ' z ' ) { inp . setCharAt ( i , ' y ' ) ; } else { inp . setCharAt ( i , ' z ' ) ; } aliceTurn = true ; } } System . out . println ( inp . toString ( ) ) ; } }   static class Scanner { StringTokenizer st ; BufferedReader br ;   public Scanner ( InputStream s ) { br = new BufferedReader ( new InputStreamReader ( s ) ) ; }   public String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return st . nextToken ( ) ; }   public int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; }   public long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; }   public double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; }   public char nextChar ( ) throws IOException { return next ( ) . charAt ( 0 ) ; }   public String nextLine ( ) throws IOException { return br . readLine ( ) ; }   public boolean ready ( ) throws IOException { return br . ready ( ) ; }   } }

t = int ( input ( ) ) NEW_LINE while t :     NEW_LINE s = input ( ) NEW_LINE strinig_list = [ ] NEW_LINE for i in range ( len ( s ) ) : if NEW_LINE i % 2 == 0 : NEW_LINE if s [ i ] != " a " : NEW_LINE INDENT strinig_list . append ( " a " ) else : NEW_LINE strinig_list . append ( " b " ) else : if s [ i ] != " z " : NEW_LINE strinig_list . append ( " z " ) else : NEW_LINE strinig_list . append ( " y " ) NEW_LINE DEDENT for i in strinig_list : print ( i , end = " " ) NEW_LINE print ( " " ) NEW_LINE t -= 1   NEW_LINE


t = int ( input ( ) ) NEW_LINE for i in range ( t ) : s = list ( map ( str , input ( ) ) ) NEW_LINE for j in range ( len ( s ) ) : if NEW_LINE j % 2 == 0 : NEW_LINE if s [ j ] == " a " : NEW_LINE INDENT s [ j ] = " b " else : NEW_LINE s [ j ] = " a " else : if s [ j ] == " z " : NEW_LINE s [ j ] = " y " else : NEW_LINE s [ j ] = " z " NEW_LINE DEDENT print ( ' ' . join ( map ( str , s ) ) )           NEW_LINE


def solve ( ) : string = input ( ) NEW_LINE newStr = " "   for count , i in enumerate ( string ) : if NEW_LINE count % 2 != 0 : NEW_LINE if i == " z " : NEW_LINE INDENT newStr += " y " else : NEW_LINE newStr += " z " else : if i == " a " : NEW_LINE newStr += " b " else : NEW_LINE newStr += " a " NEW_LINE DEDENT print ( newStr )     for i in range ( int ( input ( ) ) ) : solve ( )     NEW_LINE


for t in range ( int ( input ( ) ) ) : s = input ( ) NEW_LINE r = ' ' NEW_LINE for i in range ( len ( s ) ) : if NEW_LINE i % 2 == 0 : NEW_LINE if s [ i ] != ' a ' : NEW_LINE INDENT r += ' a ' else : NEW_LINE r += ' b ' else : if s [ i ] != ' z ' : NEW_LINE r += ' z ' else : NEW_LINE r += ' y ' NEW_LINE DEDENT print ( r ) NEW_LINE


import java . util . * ; import java . lang . * ; import java . io . * ;   public class Codechef { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; sc . nextLine ( ) ; while ( t -- > 0 ) { String s = sc . nextLine ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' a ' && i % 2 == 0 ) System . out . print ( " b " ) ; else if ( i % 2 == 0 ) System . out . print ( " a " ) ; else { if ( s . charAt ( i ) == ' z ' ) System . out . print ( " y " ) ; else System . out . print ( " z " ) ; } } System . out . println ( ) ; } } }


import java . util . * ; import java . lang . * ; import java . io . * ; import java . math . BigInteger ;   public class Test { public static void main ( String [ ] args ) { new A ( ) . run ( ) ; } static class A { public void run ( ) { Scanner in = new Scanner ( System . in ) ; int t = in . nextInt ( ) ; while ( t -- > 0 ) { char [ ] s = in . next ( ) . toCharArray ( ) ; int c = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( c == 0 ) { if ( s [ i ] == ' a ' ) s [ i ] = ' b ' ; else s [ i ] = ' a ' ; } else { if ( s [ i ] == ' z ' ) s [ i ] = ' y ' ; else s [ i ] = ' z ' ; } c ^= 1 ; } System . out . println ( s ) ; } } } }


import java . util . * ; import java . lang . * ; import java . io . * ;   public class Codechef { public static void main ( String [ ] args ) throws java . lang . Exception { FastReader in = new FastReader ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; int t = 1 ; t = in . nextInt ( ) ; while ( t > 0 ) { -- t ; String s = in . next ( ) ; StringBuilder ans = new StringBuilder ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) { if ( s . charAt ( i ) == ' a ' ) sb . append ( " b " ) ; else sb . append ( " a " ) ; } else { if ( s . charAt ( i ) == ' z ' ) sb . append ( " y " ) ; else sb . append ( " z " ) ; } } sb . append ( " \n " ) ; } System . out . print ( sb ) ; } static int upper_bound ( int arr [ ] , int x ) { int a = Arrays . binarySearch ( arr , x ) ; if ( a < 0 ) { a *= ( - 1 ) ; return a - 1 ; } else { while ( a < arr . length && arr [ a ] == x ) ++ a ; return a ; } } static long gcd ( long a , long b ) { if ( a == 0 ) return b ; else return gcd ( b % a , a ) ; }


import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; String str = s . next ( ) ; long prefix [ ] = new long [ str . length ( ) ] ; long suffix [ ] = new long [ str . length ( ) ] ; for ( int i = 1 ; i < str . length ( ) ; i ++ ) { prefix [ i ] = prefix [ i - 1 ] ; if ( str . charAt ( i ) == ' v ' && str . charAt ( i - 1 ) == ' v ' ) { prefix [ i ] ++ ; } } for ( int i = str . length ( ) - 2 ; i >= 0 ; i -- ) { suffix [ i ] = suffix [ i + 1 ] ; if ( str . charAt ( i ) == ' v ' && str . charAt ( i + 1 ) == ' v ' ) { suffix [ i ] ++ ; }   } long ans = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == ' o ' ) { ans += prefix [ i ] * suffix [ i ] ; } } System . out . println ( ans ) ; } }


st = input ( ) li = [ ] s = 0   for i in range ( len ( st ) ) : if ( st [ i ] == " v " ) : s += 1 else : if ( s > 1 ) : li . append ( s - 1 ) li . append ( 0 ) s = 0 if ( s > 0 ) : li . append ( s - 1 ) NEW_LINE


import java . util . * ; import java . io . * ; import java . math . * ;   public class First { public static void process ( ) throws IOException { String s = nln ( ) . trim ( ) ; char ch [ ] = s . toCharArray ( ) ; int n = ch . length ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 ) { a [ i ] = 0 ; } else { if ( ch [ i ] == ' v ' && ch [ i ] == ch [ i - 1 ] ) { a [ i ] = a [ i - 1 ] + 1 ; } else { a [ i ] = a [ i - 1 ] ; } } } int x = a [ n - 1 ] ; long ans = 0l ; for ( int i = 0 ; i < n ; i ++ ) { if ( ch [ i ] == ' o ' ) { ans += ( ( ( long ) a [ i ] ) * ( x - a [ i ] ) ) ; } } pn ( ans ) ; }    static AnotherReader sc ; static PrintWriter out ; public static void main ( String [ ] args ) throws IOException { out = new PrintWriter ( System . out ) ; sc = new AnotherReader ( ) ; boolean oj = true ;


import java . io . * ; import java . util . * ; import java . lang . * ;   public class c1 { public static FScanner scan ; public static PrintWriter out ; public static void main ( String [ ] args ) { scan = new FScanner ( ) ; out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ;   int T = 1 ;


import java . util . * ;   public class Test {   public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ;   int count = 0 ; for ( int i = 0 ; i <= a ; i += 2 ) { int rem = n ; rem = rem - i / 2 ; for ( int j = 0 ; j <= b && j <= rem ; j ++ ) { int rem1 = rem - j ; if ( rem1 % 2 == 0 && rem1 / 2 <= c ) count ++ ; } } System . out . println ( count ) ; } }

n , a , b , c = list ( map ( int , input ( ) . split ( ) ) ) res = 0 for x in range ( c + 1 ) : for y in range ( b + 1 ) : diff = n - 2 * x - y if diff >= 0 and diff * 2 <= a : res += 1 print ( res ) NEW_LINE


def nik ( rudy , x , y , z , cot ) : for i in range ( z + 1 ) : for j in range ( y + 1 ) : t = rudy - i * 2 - j if t >= 0 and x * 0.5 >= t : cot += 1 return cotrudy , x , y , z = list ( map ( int , input ( ) . split ( ) ) ) cot = 0 print ( nik ( rudy , x , y , z , cot ) )   NEW_LINE


def nik ( rudy , pig , y , z ) : temp = 0 for i in range ( z + 1 ) : for j in range ( y + 1 ) : t = rudy - i * 2 - j if t >= 0 and pig * 0.5 >= t : temp += 1 print ( temp ) rudy , pig , y , z = list ( map ( int , input ( ) . split ( ) ) ) nik ( rudy , pig , y , z ) NEW_LINE


n , c , b , a = map ( int , input ( ) . split ( ) )   c = c // 2   k = 0 for i in range ( a + 1 ) :   if 2 * i > n : break   for j in range ( b + 1 ) :   if 2 * i + j > n :   break   if 2 * i + j + c >= n :   k += 1   print ( k ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; import java . io . PrintWriter ;   public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int a = Integer . parseInt ( st . nextToken ( ) ) ; int b = Integer . parseInt ( st . nextToken ( ) ) ; int c = Integer . parseInt ( st . nextToken ( ) ) ; br . close ( ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int count = 0 ; for ( int j = 0 ; j <= b ; j ++ ) { for ( int k = 0 ; k <= c ; k ++ ) { if ( n - j - 2 * k > 0 && n - j - 2 * k > 0.5 * a ) continue ; if ( n - j - 2 * k >= 0 ) count ++ ; } } pw . println ( count ) ; pw . flush ( ) ; pw . close ( ) ; } }


import com . sun . org . apache . bcel . internal . generic . AALOAD ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . * ; import java . util . stream . IntStream ; import javafx . util . Pair ;   public class Main {   static void sort ( int a [ ] ) { Random ran = new Random ( ) ; for ( int i = 0 ; i < a . length ; i ++ ) { int r = ran . nextInt ( a . length ) ; int temp = a [ r ] ; a [ r ] = a [ i ] ; a [ i ] = temp ; }   Arrays . sort ( a ) ; }   public static void main ( String [ ] args ) throws IOException {   Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int x1 , y1 , x2 , y2 ; x1 = y1 = Integer . MAX_VALUE ; x2 = y2 = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { int a = input . nextInt ( ) ; int b = input . nextInt ( ) ; x1 = Math . min ( x1 , a ) ; y1 = Math . min ( y1 , b ) ; x2 = Math . max ( x2 , a ) ; y2 = Math . max ( y2 , b ) ; } if ( x1 == x2 || y1 == y2 ) { System . out . println ( " - 1" ) ; } else { System . out . println ( Math . abs ( x2 - x1 ) * Math . abs ( y2 - y1 ) ) ; } }   }


n = int ( input ( ) ) if n == 1 : x1 , y1 = map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) print ( - 1 ) elif n == 2 : x1 , y1 = map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) x2 , y2 = map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) if x1 == x2 or y1 == y2 : print ( - 1 ) else : print ( abs ( x1 - x2 ) * abs ( y1 - y2 ) ) elif n == 3 : x1 , y1 = map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) x2 , y2 = map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) x3 , y3 = map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) if x1 != x2 and y1 != y2 : print ( abs ( x1 - x2 ) * abs ( y1 - y2 ) ) elif x1 != x3 and y1 != y3 : print ( abs ( x1 - x3 ) * abs ( y1 - y3 ) ) else : print ( abs ( x2 - x3 ) * abs ( y2 - y3 ) ) else : x1 , y1 = map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) x2 , y2 = map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) x3 , y3 = map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) x4 , y4 = map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) if x1 != x2 and y1 != y2 : print ( abs ( x1 - x2 ) * abs ( y1 - y2 ) ) elif x1 != x3 and y1 != y3 : print ( abs ( x1 - x3 ) * abs ( y1 - y3 ) ) else : print ( abs ( x1 - x4 ) * abs ( y1 - y4 ) ) NEW_LINE


n = int ( input ( ) ) st = [ ] if n == 1 : print ( " - 1" ) elif n == 2 : for i in range ( 2 ) : st . append ( tuple ( map ( int , input ( ) . split ( ) ) ) ) if st [ 0 ] [ 0 ] == st [ 1 ] [ 0 ] or st [ 1 ] [ 1 ] == st [ 0 ] [ 1 ] : print ( " - 1" ) else : print ( abs ( st [ 0 ] [ 0 ] - st [ 1 ] [ 0 ] ) * abs ( st [ 1 ] [ 1 ] - st [ 0 ] [ 1 ] ) ) else : b = False for i in range ( n ) : st . append ( tuple ( map ( int , input ( ) . split ( ) ) ) ) for i in range ( n - 1 ) : for ii in range ( i + 1 , n ) : if st [ i ] [ 0 ] != st [ ii ] [ 0 ] and st [ ii ] [ 1 ] != st [ i ] [ 1 ] : print ( abs ( st [ i ] [ 0 ] - st [ ii ] [ 0 ] ) * abs ( st [ i ] [ 1 ] - st [ ii ] [ 1 ] ) ) b = True ; break if b : break     NEW_LINE


def solve ( ) : n = int ( input ( ) ) pairs = [ ] for _ in range ( n ) : pairs . append ( tuple ( map ( int , input ( ) . split ( ) ) ) )   pairs . sort ( )   left = min ( pairs , key = lambda x : x [ 0 ] ) [ 0 ] right = max ( pairs , key = lambda x : x [ 0 ] ) [ 0 ]   top = max ( pairs , key = lambda x : x [ 1 ] ) [ 1 ] bot = min ( pairs , key = lambda x : x [ 1 ] ) [ 1 ]   area = ( right - left ) * ( top - bot ) if area == 0 : print ( - 1 ) else : print ( area ) solve ( )   NEW_LINE


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


import java . util . Scanner ;   public class SymmetryPool { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   int n = scanner . nextInt ( ) ;   int [ ] [ ] coo = new int [ n ] [ 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { coo [ i ] [ 0 ] = scanner . nextInt ( ) ; coo [ i ] [ 1 ] = scanner . nextInt ( ) ; }   if ( n == 1 ) { System . out . println ( - 1 ) ; } else if ( n == 2 ) { int side1 = Math . abs ( coo [ 0 ] [ 1 ] - coo [ 1 ] [ 1 ] ) ; int side2 = Math . abs ( coo [ 0 ] [ 0 ] - coo [ 1 ] [ 0 ] ) ; if ( side1 == 0 || side2 == 0 ) { System . out . println ( - 1 ) ; } else { System . out . println ( side1 * side2 ) ; } } else { int side1 = 0 ; int side2 = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { if ( coo [ i ] [ 1 ] - coo [ i + 1 ] [ 1 ] != 0 ) side2 = Math . abs ( coo [ i ] [ 1 ] - coo [ i + 1 ] [ 1 ] ) ; if ( coo [ i ] [ 0 ] - coo [ i + 1 ] [ 0 ] != 0 ) side1 = Math . abs ( coo [ i ] [ 0 ] - coo [ i + 1 ] [ 0 ] ) ; }   System . out . println ( side1 * side2 ) ; } } }


import java . io . * ; import java . util . * ;   public class Main { static BufferedReader br ; static StringTokenizer st ;   static String nextToken ( ) { try { while ( st == null || ! st . hasMoreTokens ( ) ) { st = new StringTokenizer ( br . readLine ( ) ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } return st . nextToken ( ) ; }   static int nextInt ( ) { return Integer . parseInt ( nextToken ( ) ) ; }   static char nextChar ( ) throws IOException { return ( char ) br . read ( ) ; }   private static long nextLong ( ) { return Long . parseLong ( nextToken ( ) ) ; }   private static String nextString ( ) throws IOException { return br . readLine ( ) ; }   public static void main ( String [ ] args ) throws IOException { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ;

n = ( int ( input ( ) ) ) R = list ( map ( int , input ( ) . split ( ) ) ) Time = 0 ; check = FalseOutput = [ ] while ( check == False ) : pos_max = [ ] ; pos_sec = [ ] ; Max_sec = - 1 ; Max_num = 0 ; Max = - 1 ; Min = 999999999 ; Time += 1 ; string = ' ' for i in range ( len ( R ) - 1 , - 1 , - 1 ) : if ( R [ i ] < Min ) : Min = R [ i ] if ( R [ i ] > Max ) : Max_sec = Max ; Max = R [ i ] ; pos_sec = pos_max ; pos_max = [ ] ; pos_max . append ( i ) ; Max_num = 1 elif ( R [ i ] == Max ) : Max_num += 1 ; pos_max . append ( i ) elif ( R [ i ] > Max_sec ) : Max_sec = R [ i ] pos_sec = [ ] pos_sec . append ( i ) NEW_LINE


n = int ( input ( ) )   L = list ( map ( int , input ( ) . split ( ) ) )   ans = 0   M = [ ]   while max ( L ) != min ( L ) :   ans += 1   k = max ( L )   if L . count ( k ) == 3 :   s = ' '   for i in range ( len ( L ) ) :   if L [ i ] == k :   s += '1'   L [ i ] -= 1   else :   s += '0'   M . append ( s )           else :               max_1 = 0   max_2 = 1   if L [ max_1 ] < L [ max_2 ] :   max_1 , max_2 = max_2 , max_1   for i in range ( 2 , n ) :   if L [ i ] > L [ max_1 ] :   max_2 , max_1 = max_1 , i   elif L [ i ] > L [ max_2 ] :   max_2 = i   s = ' '   for i in range ( n ) :   if i == max_1 or i == max_2 :   s += '1'   else :   s += '0'   M . append ( s )   L [ max_1 ] -= 1   if L [ max_1 ] < 0 :   L [ max_1 ] = 0   L [ max_2 ] -= 1   if L [ max_2 ] < 0 :   L [ max_2 ] = 0   print ( max ( L ) )   print ( ans )   for i in M :   print ( i )       NEW_LINE


import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; }   public static long mod = 17352642619633L ;   void run ( FastScanner in , PrintWriter out ) {   int N = in . nextInt ( ) ; TreeSet < int [ ] > ts = new TreeSet < > ( ( a , b ) -> { return a [ 0 ] == b [ 0 ] ? a [ 1 ] - b [ 1 ] : a [ 0 ] - b [ 0 ] ; } ) ; int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int [ ] r = new int [ 2 ] ; r [ 0 ] = in . nextInt ( ) ; r [ 1 ] = i ; ts . add ( r ) ;   sum += r [ 0 ] ; }   List < List < Integer > > ans = new ArrayList < > ( ) ; for ( int i = 0 ; i < 10000 && ts . first ( ) [ 0 ] != ts . last ( ) [ 0 ] ; i ++ ) {   int diff = sum - N * ts . first ( ) [ 0 ] ;   int numPick = diff % 2 == 0 ? 2 : 3 ; numPick = Math . min ( numPick , N ) ;


import java . math . BigInteger ; import java . util . Scanner ;   public class A185 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long N = in . nextLong ( ) ; BigInteger bigN = BigInteger . valueOf ( N ) ; BigInteger two = BigInteger . valueOf ( 2 ) ; BigInteger mod = BigInteger . valueOf ( 1000000007 ) ; BigInteger power = two . modPow ( bigN , mod ) ; long result = power . add ( BigInteger . ONE ) . multiply ( power ) . divide ( two ) . mod ( mod ) . longValue ( ) ; System . out . println ( result ) ; }   }

n = int ( input ( ) ) m = pow ( 10 , 9 ) + 7 if n == 0 : print ( 1 ) else : print ( ( pow ( 2 , 2 * n - 1 , m ) + pow ( 2 , n - 1 , m ) ) % m ) NEW_LINE


z = 1000000007 def f ( a , m ) : p = 1 while m : if m % 2 : p = ( p * a ) % z m -= 1 else : m //= 2 a = ( a * a ) % z return pn = int ( input ( ) ) x = f ( 2 , n ) print ( ( x * ( x + 1 ) // 2 ) % z ) NEW_LINE


import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ;   public class Compressing { public static class pair { double dist ; int pop ; public pair ( double dist , int pop ) { this . dist = dist ; this . pop = pop ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int pop = sc . nextInt ( ) ; pair [ ] ar = new pair [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; double dist = Math . sqrt ( x * x + y * y ) ; ar [ i ] = new pair ( dist , c ) ; } Arrays . sort ( ar , ( a , b ) -> Double . compare ( a . dist , b . dist ) ) ; int i = 0 ; while ( pop < 1000000 && i < n ) { pop += ar [ i ] . pop ;

n , p = map ( int , input ( ) . split ( ) ) dic = { } for i in range ( n ) : x , y , t = map ( int , input ( ) . split ( ) ) dist = ( ( x ** 2 ) + ( y ** 2 ) ) ** .5 if dist in dic . keys ( ) : dic [ dist ] = dic [ dist ] + t else : dic [ dist ] = tfor j in sorted ( dic ) : p = p + dic [ j ] if p >= 1000000 : print ( j ) breakelse : print ( - 1 ) NEW_LINE


from sys import stdin , stdoutfrom math import sqrtnmbr = lambda : int ( stdin . readline ( ) ) lst = lambda : list ( map ( int , stdin . readline ( ) . split ( ) ) ) sq = lambda x , y : ( x * x + y * y ) mega = 10 ** 6 def fn ( rad ) : sm = init for a , b , pop in l1 : if sq ( a , b ) <= rad : sm += pop if sm >= mega : return True return Falsefor _ in range ( 1 ) : NEW_LINE


from math import sqrt as rfrom collections import defaultdict as dq   n , s = map ( int , input ( ) . split ( ) )   left = 1000000 - s   d = dq ( int ) for i in range ( n ) : x , y , k = map ( int , input ( ) . split ( ) ) d [ x , y ] = k   minm = float ( ' inf ' ) f = 0 for k1 , v1 in d . items ( ) : xc = abs ( k1 [ 0 ] ) yc = abs ( k1 [ 1 ] ) total = 0 rad = round ( r ( xc ** 2 + ( yc ** 2 ) ) , 7 ) for k2 , v2 in d . items ( ) : if round ( r ( k2 [ 0 ] ** 2 + ( k2 [ 1 ] ** 2 ) ) , 7 ) <= rad : total += v2 if total >= left : if rad < minm : minm = rad f = 1   print ( minm if f == 1 else - 1 ) NEW_LINE


import mathn , s = map ( int , input ( ) . split ( ) ) dist = [ ] for _ in range ( n ) : x , y , k = map ( int , input ( ) . split ( ) ) dist . append ( [ math . sqrt ( x * x + y * y ) , k ] ) left = 1000000 - sdist . sort ( key = lambda x : x [ 0 ] ) ans = 0 i = - 1 while ans < left : i += 1 if i == n : break ans = ans + dist [ i ] [ 1 ] if i >= 0 and i < n : print ( dist [ i ] [ 0 ] ) else : print ( " - 1" ) NEW_LINE


import java . util . * ;   public class Main {   public static double distance ( double x , double y ) { return Math . sqrt ( ( x * x ) + ( y * y ) ) ; }   public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; long s = input . nextLong ( ) ; double a [ ] [ ] = new double [ n ] [ 2 ] ; TreeMap < Double , Long > map = new TreeMap < > ( ) ; long sum = s ; for ( int i = 0 ; i < n ; i ++ ) { double x = input . nextDouble ( ) ; double y = input . nextDouble ( ) ; long people = input . nextLong ( ) ; double key = distance ( x , y ) ; map . put ( key , map . getOrDefault ( key , 0L ) + people ) ; sum += people ; } if ( sum < 1000000 ) { System . out . println ( " - 1" ) ; } else { for ( Map . Entry < Double , Long > entry : map . entrySet ( ) ) { Long value = entry . getValue ( ) ; s += value ; if ( s >= 1000000 ) { System . out . println ( entry . getKey ( ) ) ; return ; } } }   }   }


import java . lang . * ; import java . util . * ; import java . io . * ;   public class Codeforces {   public void solve ( ) throws IOException { FastScanner fs = new FastScanner ( ) ; StringBuilder print = new StringBuilder ( ) ; int n = fs . nextInt ( ) , pop = fs . nextInt ( ) ; Places [ ] places = new Places [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int x = fs . nextInt ( ) , y = fs . nextInt ( ) , p = fs . nextInt ( ) ; float d = x * x + y * y ; places [ i ] = new Places ( d , p ) ; } Arrays . sort ( places , ( o1 , o2 ) -> { if ( o1 . r != o2 . r ) return ( int ) ( o1 . r - o2 . r ) ; else return o2 . pop - o1 . pop ; } ) ; for ( int i = 0 ; i < n ; i ++ ) { pop += places [ i ] . pop ; if ( pop >= 1000000 ) { System . out . printf ( " % .6f % n " , Math . sqrt ( places [ i ] . r ) ) ; return ; } } System . out . println ( " - 1" ) ; } class Places { float r ; int pop ; Places ( float r , int pop ) { this . r = r ; this . pop = pop ; } } public static void main ( String [ ] args ) throws IOException { try { new Codeforces ( ) . solve ( ) ; } catch ( Exception e ) {


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . io . BufferedWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . Writer ; import java . io . OutputStreamWriter ; import java . util . NoSuchElementException ; import java . io . InputStream ;   public class Main { public static void main ( String [ ] args ) { new Thread ( null , new TaskA ( ) , " qqq " , 256 * 1024 * 1024 ) . start ( ) ;

import sys   class Node : def __init__ ( self , d ) : global nodes self . ch = { } self . a = [ [ ] , [ ] ] self . d = d nodes += [ self ]   nodes = [ ] pairs = [ ] res = 0   N = int ( sys . stdin . readline ( ) ) _input = sys . stdin . readlines ( ) _input = [ s [ : - 1 ] for s in _input ] A = [ _input [ : N ] , _input [ N : ] ] T = Node ( 0 )   for i , l in enumerate ( A ) : for j , s in enumerate ( l ) : t = T for c in s : v = ord ( c ) - ord ( ' a ' ) if not v in t . ch : t . ch [ v ] = Node ( t . d + 1 ) t = t . ch [ v ] t . a [ i ] += [ j + 1 ]   for n in reversed ( nodes ) : for i in n . ch : n . a [ 0 ] += n . ch [ i ] . a [ 0 ] n . a [ 1 ] += n . ch [ i ] . a [ 1 ] k = min ( len ( n . a [ 0 ] ) , len ( n . a [ 1 ] ) ) for i in range ( k ) : pairs += [ str ( n . a [ 0 ] [ - 1 ] ) + ' ▁ ' + str ( n . a [ 1 ] [ - 1 ] ) ] n . a [ 0 ] . pop ( ) n . a [ 1 ] . pop ( ) res += n . d   print ( res ) print ( ' \n ' . join ( pairs ) ) NEW_LINE


import sys   SIGMA = 26   nodes = [ ] pairs = [ ] res = 0   class Node : def __init__ ( self ) : self . ch = { } self . a = [ ] self . b = [ ] self . d = 0   def add ( self , s , i ) : t = self for c in s : v = ord ( c ) - ord ( ' a ' ) if not v in t . ch : t . ch [ v ] = Node ( ) t . ch [ v ] . d = t . d + 1 nodes . append ( t . ch [ v ] ) t = t . ch [ v ] t . a . append ( i )   def inc ( self , s , i ) : t = self for c in s : v = ord ( c ) - ord ( ' a ' ) if not v in t . ch : break t = t . ch [ v ] t . b . append ( i )   def solve ( self ) : global pairs global res for i in range ( SIGMA ) : if i in self . ch : self . a . extend ( self . ch [ i ] . a ) self . b . extend ( self . ch [ i ] . b ) k = min ( len ( self . a ) , len ( self . b ) ) for i in range ( k ) : pairs . append ( str ( self . a [ - 1 ] ) + ' ▁ ' + str ( self . b [ - 1 ] ) ) self . a . pop ( ) self . b . pop ( ) res += self . d return res   sys . setrecursionlimit ( 2000000 ) _input = sys . stdin . readlines ( ) _input = [ s [ : - 1 ] for s in _input ] N = int ( _input [ 0 ] ) A = _input [ 1 : N + 1 ] B = _input [ N + 1 : ] T = Node ( ) nodes . append ( T ) for i , s in enumerate ( A ) : T . add ( s , i + 1 ) for i , s in enumerate ( B ) : T . inc ( s , i + 1 ) for n in reversed ( nodes ) : n . solve ( ) print ( res ) print ( ' \n ' . join ( pairs ) ) NEW_LINE


import sys   SIGMA = 26   nodes = [ ] pairs = [ ] res = 0   class Node : def __init__ ( self ) : self . ch = { } self . a = [ ] self . b = [ ] self . d = 0   def add ( self , s , i ) : t = self for c in s : v = ord ( c ) - ord ( ' a ' ) if not v in t . ch : t . ch [ v ] = Node ( ) t . ch [ v ] . d = t . d + 1 nodes . append ( t . ch [ v ] ) t = t . ch [ v ] t . a . append ( i )   def inc ( self , s , i ) : t = self for c in s : v = ord ( c ) - ord ( ' a ' ) if not v in t . ch : break t = t . ch [ v ] t . b . append ( i )   def solve ( self ) : global pairs global res for i in range ( SIGMA ) : if i in self . ch : self . a . extend ( self . ch [ i ] . a ) self . b . extend ( self . ch [ i ] . b ) k = min ( len ( self . a ) , len ( self . b ) ) for i in range ( k ) : pairs . append ( str ( self . a [ - 1 ] ) + ' ▁ ' + str ( self . b [ - 1 ] ) ) self . a . pop ( ) self . b . pop ( ) res += self . d return res   _input = sys . stdin . readlines ( ) _input = [ s [ : - 1 ] for s in _input ] N = int ( _input [ 0 ] ) A = _input [ 1 : N + 1 ] B = _input [ N + 1 : ] T = Node ( ) nodes . append ( T ) for i , s in enumerate ( A ) : T . add ( s , i + 1 ) for i , s in enumerate ( B ) : T . inc ( s , i + 1 ) for n in reversed ( nodes ) : n . solve ( ) print ( res ) print ( ' \n ' . join ( pairs ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . NoSuchElementException ; import java . util . StringTokenizer ;   public class CodeforceSol11a { static FastScanner in ; static PrintWriter out ; public static class FastScanner { BufferedReader br ; StringTokenizer st ; public FastScanner ( InputStream in ) { br = new BufferedReader ( new InputStreamReader ( 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 ( ) ) ; } }   public static void main ( String [ ] args ) {


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

from collections import defaultdictb , q , l , m = map ( int , input ( ) . split ( ) ) arr = [ int ( x ) for x in input ( ) . split ( ) ] d = defaultdict ( bool ) for i in arr : d [ i ] = Trueif ( b == 0 ) : if ( d [ b ] ) : print ( 0 ) else : print ( " inf " ) elif ( q == 0 ) : if ( abs ( b ) > l ) : print ( 0 ) else : ans = 0 if ( not d [ b ] ) : ans += 1 if ( d [ 0 ] ) : print ( ans ) else : print ( " inf " )   elif ( q == 1 ) : if ( abs ( b ) > l ) : print ( 0 ) else : if ( d [ b ] ) : print ( 0 ) else : print ( " inf " ) elif ( q == - 1 ) : if ( abs ( b ) > l ) : print ( 0 ) else : if ( d [ b ] and d [ - b ] ) : print ( 0 ) else : print ( " inf " ) else : possible = [ ] curr = b while ( abs ( curr ) <= l ) : if ( not d [ curr ] ) : possible . append ( curr ) curr *= q print ( len ( possible ) ) NEW_LINE


b1 , q , l , m = list ( map ( int , input ( ) . split ( ) ) ) a = list ( map ( int , input ( ) . split ( ) ) ) if abs ( b1 ) > l : print ( 0 ) elif b1 == 0 : if b1 in a : print ( 0 ) else : print ( ' inf ' ) elif q == 1 : if b1 in a : print ( 0 ) else : print ( ' inf ' ) elif q == - 1 : if b1 in a and - b1 in a : print ( 0 ) else : print ( ' inf ' ) elif q == 0 : if 0 not in a : print ( ' inf ' ) elif b1 in a : print ( 0 ) else : print ( 1 ) else : ans = 0 while abs ( b1 ) <= l : if b1 not in a : ans = ans + 1 b1 = b1 * q print ( ans ) NEW_LINE


a , b , c , d = map ( int , input ( ) . split ( ) ) l = set ( list ( map ( int , input ( ) . split ( ) ) ) ) if ( abs ( a ) > c ) : print ( 0 ) exit ( 0 ) if ( a == 0 ) : if 0 in l : print ( 0 ) exit ( 0 ) else : print ( " inf " ) exit ( 0 ) if ( b == 1 ) : if a in l : print ( 0 ) exit ( 0 ) else : print ( " inf " ) exit ( 0 ) if ( b == - 1 ) : if ( - a in l ) and ( a in l ) : print ( 0 ) exit ( 0 ) else : print ( " inf " ) exit ( 0 ) if ( b == 0 ) : if 0 in l : if a in l : print ( 0 ) exit ( 0 ) else : print ( 1 ) exit ( 0 ) else : print ( " inf " ) exit ( 0 ) ans = 0 while ( abs ( a ) <= c ) : if ( a not in l ) : ans += 1 a = a * bprint ( ans ) NEW_LINE


b , q , L , m = map ( int , input ( ) . split ( ) ) p = list ( map ( int , input ( ) . split ( ) ) )   def solve ( b , q , L , m , p ) : if q == 1 : if b in p : return 0 elif abs ( b ) <= L : return ' inf ' else : return 0 if q == - 1 : if ( b not in p or - b not in p ) and abs ( b ) <= L : return ' inf ' else : return 0 if q == 0 : if 0 not in p and abs ( b ) <= L : return ' inf ' elif b in p or not abs ( b ) <= L : return 0 else : return 1 if b == 0 : if 0 not in p : return ' inf ' else : return 0 s = 0 while abs ( b ) <= L : if b not in p : s += 1 b = b * q return s   print ( solve ( b , q , L , m , p ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . * ; public class cdfmu2b { static void merge ( int arr [ ] , int l , int m , int r ) { int n1 = m - l + 1 ; int n2 = r - m ; int L [ ] = new int [ n1 ] ; int R [ ] = new int [ n2 ] ; for ( int i = 0 ; i < n1 ; ++ i ) L [ i ] = arr [ l + i ] ; for ( int j = 0 ; j < n2 ; ++ j ) R [ j ] = arr [ m + 1 + j ] ; int i = 0 , j = 0 ; int k = l ; while ( i < n1 && j < n2 ) { if ( L [ i ] <= R [ j ] ) { arr [ k ] = L [ i ] ; i ++ ; } else { arr [ k ] = R [ j ] ; j ++ ; } k ++ ; } while ( i < n1 ) { arr [ k ] = L [ i ] ; i ++ ; k ++ ; } while ( j < n2 ) { arr [ k ] = R [ j ] ; j ++ ; k ++ ; } } static void sort ( int arr [ ] , int l , int r ) { if ( l < r ) { int m = ( l + r ) / 2 ; sort ( arr , l , m ) ; sort ( arr , m + 1 , r ) ; merge ( arr , l , m , r ) ; } } public static int lowerBound ( int [ ] array , int length , int value ) { int low = 0 ; int high = length ; while ( low < high ) { final int mid = ( low + high ) / 2 ;


import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; import java . lang . Math ; public class Account { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int m = sc . nextInt ( ) ;

m , n = map ( int , input ( ) . split ( ) ) l = [ ] for i in range ( m ) : k = list ( map ( int , input ( ) . split ( ) ) ) l . append ( k ) p = [ 0 ] * 6 for i in range ( m ) : for j in range ( 1 , n + 1 ) : p [ j ] = max ( p [ j ] , p [ j - 1 ] ) p [ j ] += l [ i ] [ j - 1 ] print ( p [ n ] , end = ' ▁ ' ) NEW_LINE


from itertools import accumulatem , n = map ( int , input ( ) . split ( ) ) t = [ ] for i in range ( m ) : arr = list ( map ( int , input ( ) . split ( ) ) ) t . append ( arr ) d = [ 0 ] * mfor i in range ( n ) : d [ 0 ] += t [ 0 ] [ i ] for j in range ( 1 , m ) : d [ j ] = max ( d [ j - 1 ] , d [ j ] ) + t [ j ] [ i ] print ( * d ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) ) x = [ ] for i in range ( n ) : x . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in range ( 1 , m ) : x [ 0 ] [ i ] += x [ 0 ] [ i - 1 ] for i in range ( 1 , n ) : for j in range ( m ) : if j == 0 : x [ i ] [ j ] += x [ i - 1 ] [ j ] else : x [ i ] [ j ] += max ( x [ i - 1 ] [ j ] , x [ i ] [ j - 1 ] ) for i in x : print ( i [ - 1 ] , end = " ▁ " ) NEW_LINE


import sysimport mathdef fn ( n , m , a ) : if n == 1 : t1 = 0 for i in range ( m ) : t1 = t1 + a [ i ] [ 0 ] print ( t1 , end = ' ▁ ' ) return 0 t = [ 0 ] * n t [ 0 ] = a [ 0 ] [ 0 ] for i in range ( 1 , n ) : t [ i ] = a [ 0 ] [ i ] + t [ i - 1 ] print ( t [ n - 1 ] , end = ' ▁ ' ) for i in range ( 1 , m ) : t [ 0 ] = t [ 0 ] + a [ i ] [ 0 ] for j in range ( n - 1 ) : if t [ j + 1 ] < t [ j ] : t [ j + 1 ] = a [ i ] [ j + 1 ] + t [ j ] else : t [ j + 1 ] = t [ j + 1 ] + a [ i ] [ j + 1 ] print ( t [ n - 1 ] , end = ' ▁ ' ) if __name__ == ' _ _ main _ _ ' : input = sys . stdin . read ( ) data = list ( map ( int , input . split ( ) ) ) n = ( data [ 1 ] ) m = data [ 0 ] a = [ [ 0 ] * n for i in range ( m ) ] l = data [ 2 : ] k = 0 for i in range ( m ) : for j in range ( n ) : a [ i ] [ j ] = l [ k ] k = k + 1 ( fn ( n , m , a ) ) NEW_LINE


m , n = map ( int , input ( ) . split ( ) ) t = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( m ) ] cnt = [ [ 0 ] * n for i in range ( m ) ] for i in range ( m ) : for j in range ( n ) : if i == j == 0 : cnt [ i ] [ j ] = t [ i ] [ j ] elif i == 0 : cnt [ i ] [ j ] = cnt [ i ] [ j - 1 ] + t [ i ] [ j ] elif j == 0 : cnt [ i ] [ j ] = cnt [ i - 1 ] [ j ] + t [ i ] [ j ] else : cnt [ i ] [ j ] = max ( cnt [ i - 1 ] [ j ] , cnt [ i ] [ j - 1 ] ) + t [ i ] [ j ] ans = [ ] for i in range ( m ) : ans . append ( cnt [ i ] [ n - 1 ] ) print ( * ans ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ;   import javafx . util . Pair ;   public class Main {   public static void main ( String [ ] args ) { FastScanner input = new FastScanner ( ) ;   int pictures = input . nextInt ( ) ; int painters = input . nextInt ( ) ; int a [ ] [ ] = new int [ pictures + 1 ] [ painters + 1 ] ; for ( int i = 1 ; i <= pictures ; i ++ ) { for ( int j = 1 ; j <= painters ; j ++ ) { a [ i ] [ j ] = Math . max ( a [ i ] [ j - 1 ] , a [ i - 1 ] [ j ] ) + input . nextInt ( ) ; } } for ( int i = 1 ; i <= pictures ; i ++ ) { System . out . print ( a [ i ] [ painters ] + " ▁ " ) ; } System . out . println ( " " ) ; }   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 . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class Task416B { public static void main ( String [ ] args ) throws IOException { Task416B task = new Task416B ( ) ; task . resolve ( ) ; }   private void resolve ( ) throws IOException { BufferedReader bufferedReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ;   String [ ] strings = bufferedReader . readLine ( ) . split ( " ▁ " ) ; int pictureCount = Integer . parseInt ( strings [ 0 ] ) ; int artistCount = Integer . parseInt ( strings [ 1 ] ) ;   int [ ] [ ] drawTime = new int [ pictureCount ] [ artistCount ] ; for ( int i = 0 ; i < pictureCount ; i ++ ) { strings = bufferedReader . readLine ( ) . split ( " ▁ " ) ; for ( int j = 0 ; j < artistCount ; j ++ ) { drawTime [ i ] [ j ] = Integer . parseInt ( strings [ j ] ) ; } }   int [ ] [ ] endTime = new int [ pictureCount ] [ artistCount ] ; endTime [ 0 ] [ 0 ] = drawTime [ 0 ] [ 0 ] ; for ( int i = 1 ; i < artistCount ; i ++ ) { endTime [ 0 ] [ i ] = drawTime [ 0 ] [ i ] + endTime [ 0 ] [ i - 1 ] ; }   for ( int i = 1 ; i < pictureCount ; i ++ ) { endTime [ i ] [ 0 ] = drawTime [ i ] [ 0 ] + endTime [ i - 1 ] [ 0 ] ; }   for ( int i = 1 ; i < pictureCount ; i ++ ) { for ( int j = 1 ; j < artistCount ; j ++ ) { endTime [ i ] [ j ] = Math . max ( endTime [ i - 1 ] [ j ] , endTime [ i ] [ j - 1 ] ) + drawTime [ i ] [ j ] ; } }   for ( int i = 0 ; i < pictureCount ; i ++ ) { System . out . print ( endTime [ i ] [ artistCount - 1 ] + " ▁ " ) ; } } }


import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) {   Scanner scanner = new Scanner ( System . in ) ; String s = scanner . next ( ) ; String newstr = s . replaceAll ( " a " , " " ) ;   int removedcharlength = s . length ( ) - newstr . length ( ) ; int midindex = newstr . length ( ) / 2 ; if ( newstr . substring ( 0 , midindex ) . equals ( newstr . substring ( midindex ) ) ) { String strz = s . substring ( 0 , midindex + removedcharlength ) . replaceAll ( " a " , " " ) ;   if ( s . substring ( midindex + removedcharlength ) . equals ( strz ) ) System . out . println ( s . substring ( 0 , midindex + removedcharlength ) ) ; else System . out . println ( " : ( " ) ; } else System . out . println ( " : ( " ) ;   }   }

def check ( t , n ) : flag = True if n % 2 != 0 : return False mid = n // 2 i = 0 while i < n // 2 : if t [ i ] != t [ mid ] : flag = False break i += 1 mid += 1 return flagif __name__ == ' _ _ main _ _ ' : t = input ( ) n = len ( t ) S = set ( t ) if len ( S ) == 1 and ' a ' in S : print ( t ) elif t . count ( ' a ' ) == 0 : if n % 2 == 1 : print ( ' : ( ' ) else : if not check ( t , n ) : print ( ' : ( ' ) else : print ( t [ : n // 2 ] ) else : s = ' ' for i in range ( n ) : if t [ i ] != ' a ' : s += t [ i ] if check ( s , len ( s ) ) : s = s [ len ( s ) // 2 : ] if t [ n - len ( s ) : ] == s : print ( t [ : n - len ( s ) ] ) else : print ( ' : ( ' ) else : print ( ' : ( ' ) NEW_LINE


t = input ( ) c = 0 n = len ( t ) s = ' ' a = ' : ( ' for i in range ( n ) : if i - c == n - i : if s == t [ i : ] : a = t [ : i ] break if t [ i ] == ' a ' : c += 1 if t [ i ] != ' a ' : s += t [ i ] if c == n : print ( t ) else : print ( a ) NEW_LINE


T = input ( ) Tp = ' '   for i in T : Tp += ( i , ' ' ) [ i == ' a ' ]   l = len ( Tp ) k = len ( T )   if l % 2 == 1 : print ( ' : ( ' ) exit ( 0 )   for i , j in zip ( range ( 1 + l // 2 ) , range ( l // 2 , l ) ) : if not Tp [ i ] == Tp [ j ] : print ( ' : ( ' ) exit ( 0 )   for i in range ( k - l // 2 , k ) : if T [ i ] == ' a ' : print ( ' : ( ' ) exit ( 0 )   for i in range ( k - l // 2 ) : print ( T [ i ] , end = ' ' ) NEW_LINE


def check ( arr , s ) : if len ( arr ) != len ( s ) : return False n = len ( arr ) for i in range ( n ) : if arr [ i ] != s [ i ] : return False return Trues = input ( ) n = len ( s ) cta = s . count ( ' a ' ) ans = " : ( " new = 0 if cta == n : ans = selif cta == 0 : if n % 2 == 0 and s [ : n // 2 ] == s [ n // 2 : ] : ans = s [ : n // 2 ] else : ind = 0 rem = [ ] for i in range ( n ) : if s [ i ] == ' a ' : ind = i for i in range ( ind ) : if s [ i ] != ' a ' : rem . append ( s [ i ] ) new += 1 for i in range ( ind + 1 , n ) : rem_len = n - i if rem_len == new : if check ( rem , s [ i : ] ) : ans = s [ : i ] break else : rem . append ( s [ i ] ) new += 1 print ( ans ) NEW_LINE


import java . util . * ; public class file { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; String str = scn . nextLine ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( char c : str . toCharArray ( ) ) { if ( c != ' a ' ) { sb . append ( c ) ; } } if ( sb . length ( ) % 2 == 0 ) { if ( sb . substring ( 0 , sb . length ( ) / 2 ) . equals ( sb . substring ( sb . length ( ) / 2 , sb . length ( ) ) ) ) { if ( str . substring ( str . length ( ) - sb . length ( ) / 2 , str . length ( ) ) . equals ( sb . substring ( 0 , sb . length ( ) / 2 ) ) ) { System . out . println ( str . substring ( 0 , str . length ( ) - sb . length ( ) / 2 ) ) ; } else { System . out . println ( " : ( " ) ; } } else { System . out . println ( " : ( " ) ; } } else { System . out . println ( " : ( " ) ; } } }


import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String t = in . next ( ) ; String s = t . substring ( 0 , ( int ) ( t . length ( ) + t . chars ( ) . filter ( c -> c == ' a ' ) . count ( ) ) / 2 ) ; System . out . println ( t . equals ( s + s . replaceAll ( " a " , " " ) ) ? s : " : ( " ) ; } }


import java . util . Scanner ;   public class Nineteen {   public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s ; s = scanner . nextLine ( ) ; System . out . println ( enumerate ( s ) ) ; }   public static int enumerate ( String source ) { byte [ ] counter = new byte [ ] { - 1 , 0 , 0 , 0 } ; for ( char ch : source . toCharArray ( ) ) { switch ( ch ) { case ' n ' : counter [ 0 ] ++ ; break ; case ' i ' : counter [ 1 ] ++ ; break ; case ' e ' : counter [ 2 ] ++ ; break ; case ' t ' : counter [ 3 ] ++ ; break ; } }   counter [ 0 ] /= 2 ; counter [ 2 ] /= 3 ; int min1 = Math . min ( counter [ 0 ] , counter [ 1 ] ) ; int min2 = Math . min ( counter [ 2 ] , counter [ 3 ] ) ; int min = Math . min ( min1 , min2 ) ; return min ; } }

a = str ( input ( ) ) import collectionscnt = collections . Counter ( a ) ans = min ( { ( cnt [ ' n ' ] - 1 ) // 2 , cnt [ ' e ' ] // 3 , cnt [ ' i ' ] , cnt [ ' t ' ] } ) if ans < 1 : print ( 0 ) else : print ( ans ) NEW_LINE


str = input ( ) ans = { ' n ' : 0 , ' i ' : 0 , ' e ' : 0 , ' t ' : 0 } for i in str : if i in ans : ans [ i ] += 1 ans [ ' n ' ] -= 1 ans [ ' n ' ] //= 2 ans [ ' e ' ] //= 3 ans = min ( ans . values ( ) ) print ( ans if ans > 0 else 0 ) NEW_LINE


a = input ( ) b = a . count ( ' n ' ) c = a . count ( ' i ' ) d = a . count ( ' e ' ) e = a . count ( ' t ' )   if b > 4 : print ( min ( ( b - 1 ) // 2 , c , d // 3 , e ) ) elif b == 3 or b == 4 : print ( min ( 1 , c , d // 3 , e ) ) else : print ( 0 ) NEW_LINE


st = input ( ) nn = st . count ( ' n ' ) ne = st . count ( ' e ' ) ni = st . count ( ' i ' ) nt = st . count ( ' t ' )   ans = min ( ( nn - 1 ) // 2 , ne // 3 , ni , nt ) print ( max ( ans , 0 ) ) NEW_LINE


word = input ( ) n = word . count ( ' n ' ) i = word . count ( ' i ' ) e = word . count ( ' e ' ) t = word . count ( ' t ' )   if ( n < 3 ) : print ( 0 ) else : print ( min ( ( n - 1 ) // 2 , i , e // 3 , t ) ) NEW_LINE


import java . math . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ;   int n = 0 ; int t = 0 ; int i = 0 ; int e = 0 ; for ( int x = 0 ; x < s . length ( ) ; x ++ ) { if ( s . charAt ( x ) == ' n ' ) n ++ ; if ( s . charAt ( x ) == ' t ' ) t ++ ; if ( s . charAt ( x ) == ' i ' ) i ++ ; if ( s . charAt ( x ) == ' e ' ) e ++ ; } n = ( n - 1 ) / 2 ; e = e / 3 ; int c = Math . min ( n , t ) ; int d = Math . min ( e , i ) ; int z = Math . min ( c , d ) ; System . out . println ( z ) ; } }


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


import java . util . Arrays ; import java . util . Scanner ;   public class Game { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ;   String str = input . nextLine ( ) ; int [ ] freq = new int [ 4 ] ; Arrays . fill ( freq , 0 ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { switch ( str . charAt ( i ) ) { case ' n ' : freq [ 0 ] ++ ; break ;   case ' i ' : freq [ 1 ] ++ ; break ;   case ' e ' : freq [ 2 ] ++ ; break ;   case ' t ' : freq [ 3 ] ++ ; break ;   default : break ; } } if ( freq [ 0 ] < 3 || freq [ 1 ] < 1 || freq [ 2 ] < 3 || freq [ 3 ] < 1 ) { System . out . println ( 0 ) ; return ; }   int ans = 0 ; if ( freq [ 0 ] >= 3 && freq [ 1 ] >= 1 && freq [ 2 ] >= 3 && freq [ 3 ] >= 1 ) { freq [ 0 ] -- ; } while ( ( freq [ 0 ] >= 2 && ( freq [ 0 ] % 3 <= 2 ) ) && freq [ 1 ] >= 1 && freq [ 2 ] >= 3 && freq [ 3 ] >= 1 ) { freq [ 0 ] -= 2 ; freq [ 1 ] -- ; freq [ 2 ] -= 3 ; freq [ 3 ] -- ; ans ++ ; } System . out . println ( ans ) ;   } }


import java . util . Arrays ; import java . util . Scanner ; import java . util . Stack ;   public class Main {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;   while ( sc . hasNext ( ) ) { String source = sc . nextLine ( ) ; int n = 0 ; int e = 0 ; int i = 0 ; int t = 0 ; for ( int j = 0 ; j < source . length ( ) ; j ++ ) { if ( source . charAt ( j ) == ' n ' ) { n ++ ; } if ( source . charAt ( j ) == ' e ' ) { e ++ ; } if ( source . charAt ( j ) == ' t ' ) { t ++ ; } if ( source . charAt ( j ) == ' i ' ) { i ++ ; }   } n = ( n - 1 ) / 2 ; e /= 3 ; int min1 = Math . min ( n , e ) ; int min2 = Math . min ( i , t ) ; int min = Math . min ( min1 , min2 ) ; System . out . println ( min ) ; }   } }


import java . util . Scanner ;   public class noOfPositions { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( ( i - 1 ) >= a && ( n - i ) <= b ) c ++ ; } System . out . println ( c ) ; } }

n , a , b = map ( int , input ( ) . split ( ) ) ans = 0 while n - a - 1 > b : a += 1 print ( n - a ) NEW_LINE


def main ( ) : n , a , b = map ( int , input ( ) . split ( ) ) print ( n - max ( a + 1 , n - b ) + 1 ) if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE


n , a , b = map ( int , input ( ) . split ( ) ) itog = 0 for i in range ( 1 , n + 1 ) : if i - 1 >= a and n - i <= b : itog += 1 print ( itog ) NEW_LINE


import java . util . * ;   public class Solve {   static Scanner scan = new Scanner ( System . in ) ;   public static void solve ( int n , int a , int b ) {   System . out . println ( Math . min ( ( n - a ) , ( b + 1 ) ) ) ; }   public static void main ( String [ ] args ) {   int n = scan . nextInt ( ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ;   solve ( n , a , b ) ; } }


import java . util . * ;     import java . io . * ; import java . lang . * ; import java . math . BigInteger ;   public class Main { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int front = 0 ; int end = n ; int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { front ++ ; end -- ; if ( front > a && end <= b ) { ans ++ ;


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   public class experiment { static int M = 1_000_000_007 ; static int INF = Integer . MAX_VALUE ; static final FastScanner fs = new FastScanner ( ) ;


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ;

for i in range ( int ( input ( ) ) ) : n , x = list ( map ( int , input ( ) . split ( ) ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) b = x // a [ - 1 ] if b == 0 : b += 1 if x % a [ - 1 ] != 0 : b += 1 for i in range ( n - 2 , - 1 , - 1 ) : c = x // a [ i ] if c == 0 : c += 1 if x % a [ i ] != 0 : c += 1 b = min ( b , c ) else : b = min ( b , c ) break print ( b ) NEW_LINE


from math import ceil , sqrt , gcd , factorialfrom collections import defaultdict as ddd = dd ( lambda : 0 ) from sys import stdininput = stdin . readline def mp ( ) : return map ( int , input ( ) . split ( ) ) def it ( ) : return int ( input ( ) ) for _ in range ( it ( ) ) : a , b = mp ( ) s = list ( mp ( ) ) if b in s : print ( 1 ) else : print ( max ( 2 , ceil ( b / max ( s ) ) ) ) NEW_LINE


import mathfor _ in " ▁ " * int ( input ( ) ) : n , x = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) mx = max ( a ) print ( 1 if x in a else 2 if mx > x else math . ceil ( x / mx ) ) NEW_LINE


for _ in range ( int ( input ( ) ) ) : n , x = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( )   start = int ( x / a [ - 1 ] ) * a [ - 1 ] ans = int ( x / a [ - 1 ] ) diff = x - start temp = ans for i in a : if i > diff and start != 0 : ans += 1 break elif i == diff : ans += 1 break if temp == ans : ans += 2 if x % a [ - 1 ] == 0 : ans = int ( x / a [ - 1 ] ) print ( ans ) NEW_LINE


import mathfor _ in range ( int ( input ( ) ) ) : n , x = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) if x in a : print ( 1 ) elif 2 * a [ - 1 ] > x : print ( 2 ) else : res = float ( ' inf ' ) for i in range ( n - 1 , - 1 , - 1 ) : if x % a [ i ] == 0 : res = min ( x // a [ i ] , res ) else : res = min ( math . ceil ( x / a [ i ] ) , res ) print ( res ) NEW_LINE


import java . util . * ; public class Problem1307b { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( x % a [ i ] == 0 ) { ans = Math . min ( ans , x / a [ i ] ) ; } else if ( a [ i ] > x ) { ans = Math . min ( ans , x / a [ i ] + 2 ) ; } else { ans = Math . min ( ans , x / a [ i ] + 1 ) ; } } System . out . println ( ans ) ; } } }


import java . util . * ; import java . io . * ; import java . math . * ;     public class B {   private static long INF = 2000000000000000000L , M = 1000000007 , MM = 998244353 ; private static int N = 0 ;   public static void process ( ) throws IOException {   int n = sc . nextInt ( ) , m = sc . nextInt ( ) ; int arr [ ] = sc . readArray ( n ) ; int max = 0 ; for ( int e : arr ) { if ( e == m ) { System . out . println ( 1 ) ; return ; } max = max ( e , max ) ; } int cc = ceil ( m , max ) ; if ( cc < 2 ) System . out . println ( 2 ) ; else System . out . println ( cc ) ;   }


import java . io . * ; import java . util . * ;   public class C335A { static PrintWriter out = new PrintWriter ( ( System . out ) ) ; static Kioken sc = new Kioken ( ) ;   public static void main ( String args [ ] ) throws IOException { int t = 1 ;

n = int ( input ( ) ) p = list ( map ( int , input ( ) . split ( ) ) )   dp = [ 0 ] * ( n + 1 ) for x in p : dp [ x ] = 1 + dp [ x - 1 ]   res = n - max ( dp ) print ( res ) NEW_LINE


n = int ( input ( ) ) arr = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE


n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) l = [ 0 ] * ( n + 1 ) for c in arr : l [ c ] = l [ c - 1 ] + 1 print ( n - max ( l ) ) NEW_LINE


n = int ( input ( ) ) l = [ int ( x ) for x in input ( ) . split ( ) ] b = [ 0 ] * ( n + 1 ) for i in l : b [ i ] = b [ i - 1 ] + 1 print ( n - max ( b ) )     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 . io . * ; import java . util . * ; import java . lang . * ; import java . math . * ; import java . text . DecimalFormat ; import java . lang . reflect . Array ; import java . io . BufferedOutputStream ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigDecimal ; public class B { public static PrintWriter out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ;


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


import java . io . * ; import java . util . * ; import java . lang . * ;   public class B {   public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; int n = in . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] inva = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) - 1 ; inva [ a [ i ] ] = i ; } int curr = 1 ; int ans = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( inva [ i ] < inva [ i - 1 ] ) curr = 1 ; else curr ++ ;


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . StringTokenizer ;   public class Big_VOVA { 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 ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; int t = in . nextInt ( ) ; StringBuilder sb = new StringBuilder ( ) ; while ( t -- > 0 ) { int n = in . nextInt ( ) ; int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = in . nextInt ( ) ; } Arrays . sort ( arr ) ; int gcd = arr [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) { int max = Integer . MIN_VALUE ; int ind = i ; for ( int j = i ; j >= 0 ; j -- ) { int val = gcd ( gcd , arr [ j ] ) ; if ( max < val ) { max = val ; ind = j ; } }

from math import gcdfor NEW_LINE _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE l = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = [ ] NEW_LINE visited = [ 0 ] * n NEW_LINE maxi = max ( l ) NEW_LINE id = l . index ( maxi ) NEW_LINE visited [ id ] = 1 NEW_LINE ans . append ( maxi ) NEW_LINE k = 0 NEW_LINE hcf = - 1 NEW_LINE while k < n - 2 : for NEW_LINE i in range ( n ) : NEW_LINE if visited [ i ] == 0 : curr_hcf = gcd ( l [ i ] , maxi ) NEW_LINE if curr_hcf > hcf : curr_id = i NEW_LINE hcf = curr_hcf NEW_LINE ans . append ( l [ curr_id ] ) NEW_LINE visited [ curr_id ] = 1 NEW_LINE maxi = hcf NEW_LINE k += 1 NEW_LINE hcf = - 1 NEW_LINE for i in range ( n ) : if NEW_LINE visited [ i ] == 0 : ans . append ( l [ i ] ) NEW_LINE print ( * ans ) NEW_LINE


ll = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE t = lambda : int ( input ( ) ) NEW_LINE ss = lambda : input ( ) NEW_LINE from math import log10 , log2 , ceil , factorial as f , gcd NEW_LINE


for i in range ( int ( input ( ) ) ) : from math import gcd NEW_LINE n = int ( input ( ) ) NEW_LINE arr = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE arr . sort ( ) NEW_LINE li = [ ] NEW_LINE li . append ( arr . pop ( ) ) NEW_LINE hcf = li [ - 1 ] NEW_LINE while ( len ( arr ) > 0 ) : m , q = 0 , 0 NEW_LINE for x in arr : if NEW_LINE m < gcd ( hcf , x ) : m = gcd ( hcf , x ) NEW_LINE q = x NEW_LINE li += [ q ] NEW_LINE arr . remove ( q ) NEW_LINE hcf = m NEW_LINE print ( * li ) NEW_LINE


from math import gcdfor NEW_LINE _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE l = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = [ ] NEW_LINE visited = [ 0 ] * n NEW_LINE maxi = 0 NEW_LINE for i in range ( n ) : hcf = 0 NEW_LINE for j in range ( n ) : if NEW_LINE visited [ j ] == 0 and gcd ( maxi , l [ j ] ) > hcf : max_id = j NEW_LINE hcf = gcd ( maxi , l [ j ] ) NEW_LINE ans . append ( l [ max_id ] ) NEW_LINE visited [ max_id ] = 1 NEW_LINE maxi = hcf NEW_LINE


import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ;   public class B1407 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int N = in . nextInt ( ) ; List < Integer > rest = new ArrayList < > ( ) ; for ( int n = 0 ; n < N ; n ++ ) { rest . add ( in . nextInt ( ) ) ; } StringBuilder output = new StringBuilder ( ) ; int gcd = 0 ; int nextGCD ; int nextNumber = 0 ; while ( ! rest . isEmpty ( ) ) { nextGCD = 0 ; for ( int a : rest ) { int candGCD = gcd ( a , gcd ) ; if ( candGCD > nextGCD ) { nextGCD = candGCD ; nextNumber = a ; } } gcd = nextGCD ; output . append ( nextNumber ) . append ( ' ▁ ' ) ; rest . remove ( ( Integer ) nextNumber ) ; } System . out . println ( output ) ; } }   static int gcd ( int a , int b ) { return ( b == 0 ) ? a : gcd ( b , a % b ) ; }   }


import java . util . Scanner ;   public class B38 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; int rookX = s . charAt ( 0 ) - ' a ' ; int rookY = s . charAt ( 1 ) - '1' ; s = in . next ( ) ; int knightX = s . charAt ( 0 ) - ' a ' ; int knightY = s . charAt ( 1 ) - '1' ; int [ ] [ ] moves = new int [ ] [ ] { { 1 , 2 } , { - 1 , 2 } , { 1 , - 2 } , { - 1 , - 2 } , { 2 , 1 } , { - 2 , 1 } , { 2 , - 1 } , { - 2 , - 1 } } ; int answer = 0 ; for ( int x = 0 ; x < 8 ; x ++ ) { if ( x == rookX ) continue ; for ( int y = 0 ; y < 8 ; y ++ ) { if ( y == rookY ) continue ; if ( x == knightX && y == knightY ) continue ; boolean ok = true ; for ( int [ ] move : moves ) { int beatX = x + move [ 0 ] ; int beatY = y + move [ 1 ] ; if ( ( beatX == rookX && beatY == rookY ) || ( beatX == knightX && beatY == knightY ) ) { ok = false ; break ; } } if ( ok ) { answer ++ ; } } } System . out . println ( answer ) ; }   }

first = input ( ) second = input ( ) s = " abcdefjh " ans = 0 for i in " abcdefgh " : for j in range ( 1 , 9 ) : move = i + str ( j )   if move != first and move != second : if not i in first and not str ( j ) in first : NEW_LINE


n = 9 chs = [ [ 0 for i in range ( 0 , n ) ] for j in range ( 0 , n ) ] a = input ( ) b = input ( ) lx = ord ( a [ 0 ] ) - 96 ly = int ( a [ 1 ] ) hx = ord ( b [ 0 ] ) - 96 hy = int ( b [ 1 ] ) chs [ hy ] [ hx ] = chs [ ly ] [ lx ] = 1 for i in range ( 1 , n ) : for j in range ( 1 , n ) : if ( ly == i or lx == j ) or ( ( abs ( i - ly ) == 1 and abs ( j - lx ) == 2 ) or ( abs ( i - ly ) == 2 and abs ( j - lx ) == 1 ) ) : chs [ i ] [ j ] = 1 if ( abs ( hy - i ) == 1 and abs ( hx - j ) == 2 ) or ( abs ( hy - i ) == 2 and abs ( hx - j ) == 1 ) : chs [ i ] [ j ] = 1 ans = 0 for i in range ( 1 , n ) : for j in range ( 1 , n ) : if chs [ i ] [ j ] == 0 : ans += 1 print ( ans ) NEW_LINE