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 ( ) ; }   void run ( FastScanner in , PrintWriter out ) {   long a = in . nextInt ( ) ; char [ ] ca = in . next ( ) . toCharArray ( ) ; int n = ca . length ;   Map < Long , Long > rangeSumCount = new HashMap < > ( ) ;   long cnt = 0 ; for ( int l = 0 ; l < n ; l ++ ) { long sum = 0 ; for ( int r = l ; r < n ; r ++ ) { sum += ca [ r ] - '0' ; long prev = rangeSumCount . getOrDefault ( sum , 0L ) ; rangeSumCount . put ( sum , prev + 1 ) ; } }   for ( long l : rangeSumCount . keySet ( ) ) { if ( a == 0 ) { cnt += rangeSumCount . getOrDefault ( 0L , 0L ) * rangeSumCount . get ( l ) ; } if ( l != 0 && ( a % l == 0 ) && rangeSumCount . containsKey ( a / l ) ) { cnt += rangeSumCount . get ( l ) * rangeSumCount . get ( a / l ) ; } }    out . println ( cnt ) ; }   static class FastScanner { BufferedReader br ; StringTokenizer st ;   public FastScanner ( InputStream in ) { br = new BufferedReader ( new InputStreamReader ( in ) ) ; st = null ; }   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 ( ) ) ; } } }

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

import java . util . * ; import java . io . * ; import static java . lang . Math . * ; public class Main { public static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } public static FastReader in = new FastReader ( ) ; public static PrintWriter out = new PrintWriter ( System . out ) ; public static final int MOD = ( int ) 1e9 + 7 ; public static void main ( String [ ] args ) {

a = int ( input ( ) ) s = input ( )   sm = { } for i in range ( len ( s ) ) : for j in range ( i , len ( s ) ) : if j == i : t = int ( s [ j ] ) else : t += int ( s [ j ] ) if t in sm : sm [ t ] += 1 else : sm [ t ] = 1 if a == 0 : if 0 in sm : sum_pairs = ( len ( s ) * ( len ( s ) + 1 ) ) // 2 print ( ( sm [ 0 ] * ( sum_pairs ) ) + ( sm [ 0 ] * ( ( sum_pairs ) - sm [ 0 ] ) ) ) else : print ( 0 ) else : c = 0 for f in sm : if f != 0 and a % f == 0 and ( a // f ) in sm : c += sm [ f ] * sm [ a // f ]   print ( c )   NEW_LINE

import sysfrom math import gcd , sqrt , ceil , log2from collections import defaultdict , Counter , dequefrom bisect import bisect_left , bisect_rightimport mathsys . setrecursionlimit ( 2 * 10 ** 5 + 10 ) import heapqfrom itertools import permutations   NEW_LINE

a = int ( input ( ) ) s = input ( ) d = { } for i in range ( len ( s ) ) : for j in range ( i , len ( s ) ) : if j == i : t = int ( s [ j ] ) else : t += int ( s [ j ] ) d [ t ] = d . get ( t , 0 ) + 1 if a == 0 : if 0 in d : cnt_pairs = ( len ( s ) * ( len ( s ) + 1 ) ) // 2 print ( ( d [ 0 ] * cnt_pairs ) + ( d [ 0 ] * ( cnt_pairs - d [ 0 ] ) ) ) else : print ( 0 ) else : c = 0 for f in d : if f != 0 and a % f == 0 and ( a // f ) in d : c += d [ f ] * d [ a // f ] print ( c ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class B134 { static int solve ( int x , int y ) { int cnt = 0 ; if ( x == 1 && y == 1 ) return 0 ; while ( true ) { if ( x == 0 || y == 0 ) return Integer . MAX_VALUE ; if ( x == 1 || y == 1 ) return ( cnt + Math . max ( x , y ) - 1 ) ; if ( x > y ) x -= y ; else y -= x ; cnt ++ ; } } public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; int ans = Integer . MAX_VALUE ; for ( int i = 1 ; i <= n ; ++ i ) { ans = Math . min ( ans , solve ( n , i ) ) ; } if ( n <= 2 ) ans = n - 1 ; System . out . println ( ans ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ;   public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class TaskB { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int n = in . nextInt ( ) ; if ( n == 1 ) { out . println ( 0 ) ; return ; } int res = n - 1 ; for ( int i = 1 ; i < n ; i ++ ) { res = Math . min ( res , solOne ( i , n ) ) ; } out . println ( res ) ; }   int solOne ( int l , int r ) { int res = 0 ; while ( l != 1 || r != 1 ) { int d = Math . abs ( l - r ) ; if ( d == 0 ) return Integer . MAX_VALUE ; l = Math . min ( l , r ) ; r = d ; res ++ ; } return res ; }   }   static class InputReader { private BufferedReader reader ; private StringTokenizer stt ;   public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) ) ; }   public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { return null ; } }   public String next ( ) { while ( stt == null || ! stt . hasMoreTokens ( ) ) { stt = new StringTokenizer ( nextLine ( ) ) ; } return stt . nextToken ( ) ; }   public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   } }

import java . io . * ; import java . util . * ; public class B134 { int x , y ; public B134 ( int xx , int yy ) { this . x = xx ; this . y = yy ; } static int INF = 1000000 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int n ; n = sc . nextInt ( ) ; int min = INF ; for ( int i = 1 ; i <= n ; i ++ ) { min = Math . min ( min , path ( n , i ) ) ; } System . out . println ( min ) ; } public static int path ( int a , int b ) { if ( b == 0 ) return INF ; if ( b == 1 ) return a - 1 ; return path ( b , a % b ) + a / b ; } }

import java . util . * ; import java . io . * ; public class Solution { static int t ; static int gcd ( int x , int y ) { if ( y == 0 ) return x ; t += x / y ; return gcd ( y , x % y ) ; } public static class Suffix implements Comparable < Suffix > { int index ; int rank ; int next ; public Suffix ( int ind , int r , int nr ) { index = ind ; rank = r ; next = nr ; }

n , ans = int ( input ( ) ) , 1000000 for i in range ( 1 , n + 1 ) : k , a , b = 0 , n , i while b > 1 : k += a // b a , b = b , a % b if b != 0 : ans = min ( ans , a - 1 + k ) print ( ans ) NEW_LINE

TMP = 0     def dfs ( a , b , n ) : global TMP if not b : TMP = n return None if b == 1 : TMP += a - 1 return None TMP += a // b dfs ( b , a % b , n )     class CodeforcesTask134BSolution : def __init__ ( self ) : self . result = ' ' self . n = 0   def read_input ( self ) : self . n = int ( input ( ) )   def process_task ( self ) : ans = self . n - 1 for i in range ( 1 , self . n ) : global TMP TMP = 0 dfs ( self . n , i , self . n ) ans = min ( ans , TMP ) self . result = str ( ans )   def get_result ( self ) : return self . result     if __name__ == " _ _ main _ _ " : Solution = CodeforcesTask134BSolution ( ) Solution . read_input ( ) Solution . process_task ( ) print ( Solution . get_result ( ) ) NEW_LINE

def solve ( n ) : ans = n - 1 for i in range ( 2 , n // 2 + 1 ) : j = n k = 0 while i > 1 and j > 1 : k += 1 if j >= i : j -= i else : i -= j if i < 1 or j < 1 : continue elif i == 1 : ans = min ( ans , k + j - 1 ) elif j == 1 : ans = min ( ans , k + i - 1 ) return ans   if __name__ == " _ _ main _ _ " : ans = solve ( int ( input ( ) ) ) print ( ans ) NEW_LINE

import math as m   def hcf ( a , b ) : while ( a != b ) : if ( a > b ) : a = a - b else : b = b - a return a n = int ( input ( ) )   if ( n == 1 or n == 2 ) : print ( n - 1 ) exit ( ) mnm = m . inf for k in range ( m . ceil ( n / 2 ) , n ) : if ( hcf ( n , k ) != 1 ) : continue p = k q = n - k count = 2 while ( p != 2 ) : diff = p - q if ( q > diff ) : p = q q = diff else : p = diff count += 1 if ( count < mnm ) : mnm = count print ( mnm ) NEW_LINE

def gc ( a , b , rs ) : if b == 1 : return [ 1 , rs + a - 1 ] if b == 0 : return [ a , rs ] rs += ( a // b ) return gc ( b , a % b , rs )   x = int ( input ( ) ) res = 10 ** 9   for n in range ( 1 , x ) : u = gc ( x , n , 0 ) if u [ 0 ] == 1 : res = min ( res , u [ 1 ] )   if res == 10 ** 9 : res = 0   print ( res ) NEW_LINE


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

import java . io . * ; import java . util . * ; public class CF1444B { 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 ( ) ) ; } } static int MOD = 998244353 ; static int [ ] rk , p , siz ; public static void main ( String [ ] args ) { FastReader br = new FastReader ( ) ; int N = br . nextInt ( ) ; long [ ] fac = new long [ 2 * N + 1 ] ; fac [ 0 ] = 1 ; for ( int i = 1 ; i <= 2 * N ; i ++ ) { fac [ i ] = ( fac [ i - 1 ] * i ) % MOD ; } int [ ] a = new int [ 2 * N ] ; for ( int i = 0 ; i < 2 * N ; i ++ ) { a [ i ] = br . nextInt ( ) ; } Arrays . sort ( a ) ; long sum = 0 ; for ( int i = N ; i < 2 * N ; i ++ ) { sum += a [ i ] ; } for ( int i = 0 ; i < N ; i ++ ) { sum -= a [ i ] ; } sum %= MOD ; sum *= fac [ 2 * N ] ; sum %= MOD ; sum *= inv ( fac [ N ] , MOD ) ; sum %= MOD ; sum *= inv ( fac [ N ] , MOD ) ; sum %= MOD ; System . out . println ( sum ) ; } public static long inv ( long a , long b ) {

import java . util . ArrayList ; import java . util . Arrays ; import java . util . Scanner ;     public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Integer [ ] ar = new Integer [ n + n ] ; for ( int i = 0 ; i < n + n ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; } Arrays . sort ( ar ) ; long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += ar [ n + n - i - 1 ] - ar [ i ] ; }

import java . util . * ;   public class Main {   private static final Scanner sc = new Scanner ( System . in ) ; private static final long mod = 998244353 ;   public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; long [ ] a = new long [ 2 * n ] ; long ans = 0 ; long fn = pow ( fact ( n ) , mod - 2 ) ; long count = fact ( 2 * n ) ;   for ( int i = 0 ; i < 2 * n ; i ++ ) { a [ i ] = sc . nextLong ( ) ; }   Arrays . sort ( a ) ;   for ( int i = 0 ; i < n ; i ++ ) { ans = mod ( ans + a [ 2 * n - i - 1 ] - a [ i ] ) ; }   ans = mod ( count * ans ) ; ans = mod ( ans * fn ) ; ans = mod ( ans * fn ) ;   System . out . println ( ans ) ; }   private static long fact ( long num ) { long ans = 1 ;   for ( long i = 2 ; i <= num ; i ++ ) { ans = mod ( ans * i ) ; }   return ans ; }   private static long mod ( long num ) { return ( num % mod + mod ) % mod ; }   private static long pow ( long a , long n ) { if ( n == 0 ) return 1 ;   long ans = pow ( a , n / 2 ) ; ans *= ans ; ans %= mod ;   if ( n % 2 == 1 ) { ans *= a ; ans %= mod ; }   return ans ; } }

n = int ( input ( ) ) NEW_LINE z = sorted ( map ( int , input ( ) . split ( ) ) ) NEW_LINE mod = 998244353 NEW_LINE fact = [ 1 ] * ( 2 * n + 1 ) NEW_LINE for i in range ( 1 , 2 * n + 1 ) : fact [ i ] = fact [ i - 1 ] * i % modinv = [ 0 ] * ( 2 * n + 1 ) NEW_LINE inv [ 2 * n ] = pow ( fact [ i ] , mod - 2 , mod ) NEW_LINE for i in range ( 2 * n - 1 , - 1 , - 1 ) : inv [ i ] = inv [ i + 1 ] * ( i + 1 ) % moddef NEW_LINE ncr ( n , r ) : NEW_LINE return ( fact [ n ] * inv [ n - r ] % mod * inv [ r ] % mod ) % mod   a , b = 0 , 0 NEW_LINE for i in range ( n ) : a += z [ i ] NEW_LINE for j in range ( n , 2 * n ) : b += z [ j ] NEW_LINE t = b - aprint ( ( ncr ( 2 * n , n ) * t ) % mod ) NEW_LINE

n = int ( input ( ) ) NEW_LINE mod = 998244353 NEW_LINE den = 1 NEW_LINE arr = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE arr . sort ( )   for i in range ( 1 , n + 1 ) : den = den * ( i + n ) * pow ( i , mod - 2 , mod ) % mod   print ( ( sum ( arr [ n : 2 * n ] ) - sum ( arr [ 0 : n ] ) ) * den % mod ) NEW_LINE

import java . util . * ;   public NEW_LINE class Main {   private static final Scanner sc = new Scanner ( System . in ) ; private static final long mod = 998244353 ;   public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; long [ ] a = new long [ 2 * n ] ; long ans = 0 ; long fn = pow ( fact ( n ) , mod - 2 ) ; long count = fact ( 2 * n ) ;   for ( int i = 0 ; i < 2 * n ; i + + ) { a [ i ] = sc . nextLong ( ) ; }   Arrays . sort ( a ) ;   for ( int i = 0 ; i < n ; i + + ) { ans = mod ( ans + a [ 2 * n - i - 1 ] - a [ i ] ) ; }   ans = mod ( count * ans ) ; ans = mod ( ans * fn ) ; ans = mod ( ans * fn ) ;   System . out . println ( ans ) ; }   private static long fact ( long num ) { long ans = 1 ;   for ( long i = 2 ; i <= num ; i + + ) { ans = mod ( ans * i ) ; }   return ans ; }   private static long mod ( long num ) { return ( num % mod + mod ) % mod ; }   private static long pow ( long a , long n ) { if ( n == 0 ) return 1 ;   long ans = pow ( a , n / 2 ) ; ans *= ans ; ans %= mod ;   if ( n % 2 == 1 ) { ans *= a ; ans %= mod ; }   return ans ; } } NEW_LINE


import java . io . * ; import java . util . * ; public class Solution { public static Node root ; public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int k = Integer . parseInt ( st . nextToken ( ) ) ; Trie tn = new Trie ( ) ; root = tn . root ; for ( int i = 0 ; i < n ; i ++ ) tn . insert ( br . readLine ( ) ) ; boolean [ ] winner = DFS ( tn , tn . root ) ; if ( ! winner [ 0 ] || ( k % 2 == 0 && ! winner [ 1 ] ) ) out . println ( " Second " ) ; else out . println ( " First " ) ; out . close ( ) ; } public static boolean [ ] DFS ( Trie tn , Node cur ) { boolean [ ] winner = new boolean [ 2 ] ; boolean leaf = true ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( cur . children [ i ] != null ) { leaf = false ; boolean [ ] win = DFS ( tn , cur . children [ i ] ) ; winner [ 0 ] |= ! win [ 0 ] ; winner [ 1 ] |= ! win [ 1 ] ; } } return ( leaf ) ? new boolean [ ] { false , true } : winner ; } } class Node { Node [ ] children ;   public Node ( ) { children = new Node [ 26 ] ; } } class Trie { Node root = new Node ( ) ; public void insert ( String s ) { Node cur = root ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( cur . children [ s . charAt ( i ) - ' a ' ] == null ) cur . children [ s . charAt ( i ) - ' a ' ] = new Node ( ) ; cur = cur . children [ s . charAt ( i ) - ' a ' ] ; } } }

from sys import stdin , setrecursionlimit   setrecursionlimit ( 200000 )   n , k = [ int ( x ) for x in stdin . readline ( ) . split ( ) ]   tree = { }   for x in range ( n ) : s = stdin . readline ( ) . strip ( )   cur = tree for x in s : if not x in cur : cur [ x ] = { }   cur = cur [ x ]   def forced ( tree ) : if not tree : return ( False , True ) else : win = False lose = False for x in tree : a , b = forced ( tree [ x ] ) if not a : win = True if not b : lose = True return ( win , lose )   a , b = forced ( tree )   if a == 0 : print ( ' Second ' ) elif a == 1 and b == 1 : print ( ' First ' ) else : if k % 2 == 0 : print ( ' Second ' ) else : print ( ' First ' ) NEW_LINE


import com . sun . org . apache . bcel . internal . generic . AALOAD ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; import java . util . stream . IntStream ; import javafx . util . Pair ;   public class Main {   static void sort ( int a [ ] ) { Random ran = new Random ( ) ; for ( int i = 0 ; i < a . length ; i ++ ) { int r = ran . nextInt ( a . length ) ; int temp = a [ r ] ; a [ r ] = a [ i ] ; a [ i ] = temp ; }   Arrays . sort ( a ) ; } static int n , m ; static int a [ ] [ ] ; static int row [ ] ; public static void main ( String [ ] args ) throws IOException { Scanner input = new Scanner ( System . in ) ; n = input . nextInt ( ) ; m = input . nextInt ( ) ; int q = input . nextInt ( ) ; a = new int [ n ] [ m ] ; int max = Integer . MIN_VALUE ; int cur = 0 ; row = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { cur = 0 ; max = 0 ; for ( int j = 0 ; j < m ; j ++ ) { a [ i ] [ j ] = input . nextInt ( ) ; if ( a [ i ] [ j ] == 0 ) cur = 0 ; else cur ++ ; max = Math . max ( max , cur ) ; } row [ i ] = max ; }

''' Maximum ▁ number ▁ of ▁ consecutive ▁ 1 ' s ''' ml = lambda s : max ( map ( len , " " . join ( s ) . split ( '0' ) ) ) n , m , q = map ( int , input ( ) . split ( ) ) arr = [ ] l = [ 0 ] * nfor i in range ( n ) : a = list ( input ( ) . split ( ) ) arr . append ( a ) l [ i ] = ml ( a ) for i in range ( q ) : a , b = map ( int , input ( ) . split ( ) ) a -= 1 b -= 1 arr [ a ] [ b ] = str ( int ( arr [ a ] [ b ] ) ^ 1 ) l [ a ] = ml ( arr [ a ] ) print ( max ( l ) ) NEW_LINE

r , c , g = map ( int , input ( ) . split ( ) )   board = [ ] scores = [ ]   for i in range ( r ) : board . append ( [ int ( x ) for x in input ( ) . split ( ) ] )   curr = 0 m = 0 for num in board [ - 1 ] : if num == 1 : curr += 1 else : m = max ( m , curr ) curr = 0 m = max ( m , curr )   scores . append ( m )   for i in range ( g ) : x , y = map ( int , input ( ) . split ( ) ) x -= 1 y -= 1 if board [ x ] [ y ] : board [ x ] [ y ] = 0 else : board [ x ] [ y ] = 1   curr = 0 m = 0 for num in board [ x ] : if num == 1 : curr += 1 else : m = max ( m , curr ) curr = 0 m = max ( m , curr )   scores [ x ] = m   print ( max ( scores ) ) NEW_LINE

r = lambda : input ( ) . split ( ) g = lambda s : max ( map ( len , " " . join ( s ) . split ( '0' ) ) ) n , m , q = map ( int , r ( ) ) a = [ r ( ) for nn in range ( n ) ] b = list ( map ( g , a ) ) for qq in range ( q ) : x , y = map ( int , r ( ) ) a [ x - 1 ] [ y - 1 ] = str ( 1 - int ( a [ x - 1 ] [ y - 1 ] ) ) b [ x - 1 ] = g ( a [ x - 1 ] ) print ( max ( b ) ) NEW_LINE


import java . io . * ; import java . math . * ; import java . security . * ; import java . text . * ; import java . time . LocalTime ; import java . util . * ; import java . util . concurrent . * ; import java . util . regex . * ;    public class B {   public static void main ( String [ ] args ) { FastScanner scan = new FastScanner ( ) ;

h , w = map ( int , input ( ) . split ( ) ) s = [ list ( input ( ) ) for i in range ( h ) ] cnt = 0 p = 0 for i in range ( h ) : cnt += s [ i ] . count ( " * " ) for i in range ( 1 , h - 1 ) : for j in range ( 1 , w - 1 ) : if s [ i ] [ j ] == s [ i - 1 ] [ j ] == s [ i + 1 ] [ j ] == s [ i ] [ j - 1 ] == s [ i ] [ j + 1 ] == " * " : p += 1 l , r , u , d = j - 1 , j + 1 , i - 1 , i + 1 while 0 <= l and s [ i ] [ l ] == " * " : l -= 1 ; p += 1 while r < w and s [ i ] [ r ] == " * " : r += 1 ; p += 1 while u >= 0 and s [ u ] [ j ] == " * " : u -= 1 ; p += 1 while d < h and s [ d ] [ j ] == " * " : d += 1 ; p += 1 if p > 0 : break if p > 0 : breakprint ( " YES " if cnt == p != 0 else " NO " ) NEW_LINE

from collections import * import bisectimport heapqimport sys def ri ( ) : return int ( input ( ) ) def rl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) h , w = rl ( ) grid = [ [ x for x in " . " * w ] for _ in range ( h ) ] stars_row = [ 0 ] * hfor i in range ( h ) : grid [ i ] = [ x for x in input ( ) ] C = Counter ( grid [ i ] ) stars_row [ i ] = C [ ' * ' ] Cr = Counter ( stars_row )   if Cr [ 0 ] + Cr [ 1 ] != h - 1 : print ( " NO " ) sys . exit ( ) stars_col = [ 0 ] * wfor j in range ( w ) : for i in range ( h ) : if grid [ i ] [ j ] == " * " : stars_col [ j ] += 1   Cc = Counter ( stars_col )   if Cc [ 0 ] + Cc [ 1 ] != w - 1 : print ( " NO " ) sys . exit ( )     degrees = [ [ - 1 ] * w for _ in range ( h ) ] d0 = 0 d1 = 0 d2 = 0 d4 = 0 d_ = 0 for i in range ( h ) : for j in range ( w ) : if grid [ i ] [ j ] == " * " : degrees [ i ] [ j ] = 0 for di , dj in [ ( - 1 , 0 ) , ( 1 , 0 ) , ( 0 , - 1 ) , ( 0 , 1 ) ] : ni = i + di nj = j + dj if ni >= 0 and ni < h and nj >= 0 and nj < w : if grid [ ni ] [ nj ] == " * " : degrees [ i ] [ j ] += 1 if degrees [ i ] [ j ] == 1 : d1 += 1 elif degrees [ i ] [ j ] == 2 : d2 += 1 elif degrees [ i ] [ j ] == 4 : d4 += 1 elif degrees [ i ] [ j ] == 0 : d0 += 1 else : d_ += 1   NEW_LINE

from collections import * h , w = map ( int , input ( ) . split ( ) ) a = [ input ( ) for _ in [ 0 ] * h ]   def f ( a , w ) : c = Counter ( ( x . index ( ' * ' ) , x [ : : - 1 ] . index ( ' * ' ) , x . count ( ' * ' ) ) for x in a if ' * ' in x ) ; z = 2 ; if len ( c ) == 2 : ( x , y , z ) , u = c return z > 1 or x <= u [ 0 ] or y <= u [ 1 ] or sum ( u ) < w print ( ' YNEOS ' [ f ( a , w ) or f ( zip ( * a ) , h ) : : 2 ] )     NEW_LINE


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

import java . util . * ; import java . io . * ; import java . lang . * ; public class Solution { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; StringTokenizer st = new StringTokenizer ( " " ) ; String next ( ) { if ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) {   } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public static void main ( String [ ] args ) { new Solution ( ) . solve ( ) ; } void solve ( ) { int t = 1 ;

import java . util . Arrays ; import java . util . Scanner ;   public class solution { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int total = sc . nextInt ( ) ; int ride = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = total * a ; int count = ride ; while ( count <= total ) { ans = Math . min ( ans , count / ride * b + ( total - count ) * a ) ; count += ride ; } System . out . println ( Math . min ( total % ride == 0 ? total / ride * b : ( total / ride + 1 ) * b , ans ) ) ; } }

n , m , a , b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE

n , m , a , b = map ( int , input ( ) . split ( ) ) print ( min ( n * a , - n // m * - b , n // m * b + n % m * a ) ) NEW_LINE

n , m , a , b = map ( int , input ( ) . split ( ) ) l = [ ] for i in range ( 0 , n * 2 ) : l . append ( i * b + ( ( n - m * i ) * a if n - m * i > 0 else 0 ) ) print ( min ( l ) ) NEW_LINE

import mathn , m , a , b = list ( map ( int , input ( ) . split ( ) ) ) res = 100000000 for i in range ( n + 1 ) : res = min ( res , ( a * i + math . ceil ( ( n - i ) / m ) * b ) ) print ( res ) 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 ( ) ; }    static LinkedList < Integer > primes = new LinkedList < > ( ) ; static { boolean [ ] isPrime = new boolean [ 100_004 ] ; Arrays . fill ( isPrime , true ) ; for ( int i = 2 ; i < isPrime . length ; i ++ ) { if ( isPrime [ i ] ) { primes . offerLast ( i ) ; for ( long p = ( long ) i * i ; p < isPrime . length ; p += i ) isPrime [ ( int ) p ] = false ; } } }   void run ( FastScanner in , PrintWriter out ) {   int N = in . nextInt ( ) ;   HashMap < Integer , Integer > primeToSeqLength = new HashMap < > ( ) ;   LinkedList < Integer > myprimes = new LinkedList < > ( ) ; int max = 0 ; while ( N -- > 0 ) { int a = in . nextInt ( ) ;

import java . util . * ; import java . io . * ; import static java . lang . Math . * ;   public class PracticeProblem { public static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } }   public static FastReader in = new FastReader ( ) ; public static PrintWriter out = new PrintWriter ( System . out ) ; public static final int N = ( int ) 1e5 ;   public static void main ( String [ ] args ) { int n = in . nextInt ( ) ;   int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = in . nextInt ( ) ;   int [ ] dp = new int [ n ] ; int answer = - 1 ;   Map < Integer , Integer > primeMax = new HashMap < > ( ) ;   for ( int i = 0 ; i < n ; i ++ ) {

m = 10 ** 5 + 1 p = [ 0 ] * mt = [ [ ] for i in range ( m ) ] t [ 1 ] = [ 1 ] for i in range ( 2 , m ) : if not t [ i ] : t [ i ] = [ i ] for j in range ( 2 * i , m , i ) : t [ j ] . append ( i ) n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) : x = max ( p [ j ] for j in t [ a [ i ] ] ) + 1 for j in t [ a [ i ] ] : p [ j ] = xprint ( max ( p ) ) NEW_LINE

n = 100001 p = [ 0 ] * nt = [ [ ] for i in range ( n ) ] t [ 1 ] = [ 1 ] for i in range ( 2 , n ) : if not t [ i ] : t [ i ] = [ i ] for j in range ( 2 * i , n , i ) : t [ j ] . append ( i ) n = int ( input ( ) ) l = [ int ( i ) for i in input ( ) . split ( ) ]   for a in l : x = max ( p [ j ] for j in t [ a ] ) + 1 for j in t [ a ] : p [ j ] = xprint ( max ( p ) ) NEW_LINE


import java . util . * ;   import java . io . * ;   public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; TreeSet < Integer > remainNumber = new TreeSet < > ( ) ; TreeSet < Integer > checkingNumber = new TreeSet < > ( ) ; StringBuilder ans = new StringBuilder ( ) ; for ( int i = 1 ; i <= n ; i ++ ) remainNumber . add ( i ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; remainNumber . remove ( a [ i ] ) ; } for ( int i = 0 ; i < n ; i ++ ) { int len = checkingNumber . size ( ) ; if ( a [ i ] <= n ) checkingNumber . add ( a [ i ] ) ; if ( len == checkingNumber . size ( ) ) { ans . append ( remainNumber . pollFirst ( ) + " ▁ " ) ; } else { ans . append ( a [ i ] + " ▁ " ) ; } } System . out . println ( ans ) ; } }

n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) dp = [ 0 ] * ( n + 1 ) for i in arr : if i <= n : dp [ i ] += 1 ar = [ ] for i in range ( 1 , n + 1 ) : if dp [ i ] == 0 : ar . append ( i ) cnt = 0 for i in range ( n ) : if arr [ i ] > n : arr [ i ] = ar [ cnt ] ; cnt += 1 elif dp [ arr [ i ] ] >= 2 : dp [ arr [ i ] ] -= 1 ; arr [ i ] = ar [ cnt ] ; cnt += 1 print ( * arr ) NEW_LINE

n = int ( input ( ) ) inventory = [ * map ( int , input ( ) . split ( ) ) ] bool = [ False ] * 100001 indices = set ( ) for index , i in enumerate ( inventory ) : if i > n or bool [ i ] : indices . add ( index ) bool [ i ] = True   for i in range ( 1 , n + 1 ) : if not bool [ i ] : x = indices . pop ( ) inventory [ x ] = iprint ( " ▁ " . join ( [ * map ( str , inventory ) ] ) ) NEW_LINE

n = int ( input ( ) ) inventory = [ * map ( int , input ( ) . split ( ) ) ] bool = [ False ] * ( n + 1 ) bads = set ( ) for index , thing in enumerate ( inventory ) : if thing <= n : if bool [ thing ] : bads . add ( index ) else : bool [ thing ] = True else : bads . add ( index ) for num , isin in enumerate ( bool [ 1 : ] ) : if not isin and len ( bads ) : i = bads . pop ( ) inventory [ i ] = num + 1 bool [ num ] = True   print ( " ▁ " . join ( [ * map ( str , inventory ) ] ) ) NEW_LINE

from collections import *   n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) lst = [ 0 ] * ncnt = 0 for i in range ( n ) : if a [ i ] <= n : lst [ a [ i ] - 1 ] = 1 miss = [ ] for i in range ( n ) : if lst [ i ] == 0 : miss . append ( i + 1 ) lst = list ( miss ) d = defaultdict ( int ) for i in range ( n ) : if a [ i ] > n : print ( lst [ - 1 ] , end = " ▁ " ) lst . pop ( ) elif d [ a [ i ] ] == 0 : d [ a [ i ] ] += 1 print ( a [ i ] , end = " ▁ " ) else : print ( lst [ - 1 ] , end = " ▁ " ) lst . pop ( ) NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) x = [ 0 ] * ( 100001 ) z = [ 0 ] * ( 100001 ) y = list ( ) for i in range ( 0 , n ) : x [ a [ i ] ] += 1 for i in range ( 1 , n + 1 ) : if x [ i ] == 0 : y . append ( i ) j = 0 for i in range ( 0 , n ) : if z [ a [ i ] ] == 0 and a [ i ] <= n : print ( a [ i ] , end = " ▁ " ) z [ a [ i ] ] = 1 else : print ( y [ j ] , end = " ▁ " ) j += 1 NEW_LINE


import java . io . * ; import java . math . BigInteger ; import java . util . * ; public class Codeforces { public static void main ( String [ ] args ) throws UnsupportedEncodingException , IOException , Exception { StringBuilder out = new StringBuilder ( ) ; StringTokenizer tk ; Reader . init ( System . in ) ; Scanner sc = new Scanner ( System . in ) ;

import java . util . * ;   public class CodeForces371A { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int k = input . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; } if ( n == k ) { System . out . println ( 0 ) ; } else { int ans = 0 ; for ( int i = 0 ; i < k ; i ++ ) { int count_1 = 0 ; int count_2 = 0 ; for ( int j = i ; j < n ; j += k ) { if ( a [ j ] == 1 ) { count_1 ++ ; } else { count_2 ++ ; } } ans += Math . min ( count_2 , count_1 ) ; }   System . out . println ( ans ) ; } } }

import java . io . * ; import java . math . BigInteger ; import java . util . * ;   public class ACM { public static void main ( String args [ ] ) throws FileNotFoundException , IOException { Scanner x = new Scanner ( System . in ) ; int n = x . nextInt ( ) ; int k = x . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = x . nextInt ( ) ; } int sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) { int f = 0 , s = 0 ; for ( int j = i ; j < n ; j += k ) { if ( arr [ j ] == 1 ) { f ++ ; } else { s ++ ; }   } sum += Math . min ( f , s ) ; } System . out . println ( sum ) ; } }

n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) poc = 0 for i in range ( k ) : p1 , p2 = 0 , 0 for j in range ( i , n , k , ) : if a [ j ] == 1 : p1 += 1 else : p2 += 1 poc += min ( p1 , p2 ) print ( poc )     NEW_LINE

import math   n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) )   ans = 0 for i in range ( k ) : r = a [ i ] ; m = 0 for j in range ( n // k ) : if a [ i + j * k ] != r : m += 1 ans += min ( m , n // k - m )   print ( ans ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) A = list ( map ( int , input ( ) . split ( ) ) ) ans = 0 for i in range ( k ) : s1 , s2 = 0 , 0 for j in range ( i , n , k ) : if A [ j ] == 1 : s1 += 1 else : s2 += 1 ans = ans + min ( s1 , s2 ) print ( ans ) NEW_LINE


import java . util . Arrays ; import java . util . Scanner ;   public class Bai5 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int [ ] capacity = new int [ n * 2 ] ; for ( int i = 0 ; i < n * 2 ; i ++ ) { capacity [ i ] = sc . nextInt ( ) ; } Arrays . sort ( capacity ) ; double m = Math . min ( capacity [ 0 ] , ( double ) capacity [ n ] / 2 ) ; double total = 3 * m * n ; System . out . println ( Math . min ( total , w ) ) ; } }

import java . io . File ; import java . util . Arrays ; import java . util . Scanner ; import java . util . StringTokenizer ;   public class p021 { public static void main ( String args [ ] ) throws Exception {

import java . util . * ; import java . lang . * ; import java . io . * ; import java . math . * ;   public class Codechef { static int n ; static double w ; static Double arr [ ] ; static BufferedReader bf ; static StringBuffer str = new StringBuffer ( " " ) ;   static boolean f ( double mid ) { double girl = mid / ( n * 3 ) ; double boy = 2 * mid / ( n * 3 ) ; return arr [ 0 ] >= girl && arr [ n ] >= boy ; } static void solve ( ) throws Exception { String s [ ] = bf . readLine ( ) . trim ( ) . split ( " \\ s + " ) ; n = Integer . parseInt ( s [ 0 ] ) ; w = Double . parseDouble ( s [ 1 ] ) ; arr = new Double [ 2 * n ] ; s = bf . readLine ( ) . trim ( ) . split ( " \\ s + " ) ; for ( int i = 0 ; i < ( 2 * n ) ; i ++ ) arr [ i ] = Double . parseDouble ( s [ i ] ) ; Arrays . sort ( arr ) ; double ans = arr [ 0 ] ; double l = 0 , r = w ; for ( int i = 0 ; i < 100 ; i ++ ) { double mid = l + ( r - l ) / 2 ; if ( f ( mid ) ) { ans = mid ; l = mid ; } else r = mid ; } str . append ( ans + " \n " ) ; }   public static void main ( String [ ] args ) throws java . lang . Exception { bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; solve ( ) ; System . out . print ( str ) ; } }

import java . util . Arrays ; import java . util . Scanner ;   public class PashaAndTea { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long w = sc . nextInt ( ) ; int [ ] a = new int [ n * 2 ] ; for ( int i = 0 ; i < n * 2 ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; double unit = Math . min ( a [ 0 ] , ( double ) a [ n ] / 2 ) ; double max = Math . min ( w , unit * n * 3 ) ; System . out . println ( max ) ; } }

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

n , w = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) g = a [ 0 ] b = a [ n ] if ( g * 2 ) <= b : b = ( g * 2 ) elif ( g * 2 ) > b : g = b / 2 ans = ( g * n ) + ( b * n ) if ans > w : ans = wprint ( ans ) NEW_LINE

n , w = map ( int , input ( ) . split ( ) ) a = [ int ( x ) for x in input ( ) . split ( ) ] a . sort ( )   print ( min ( a [ 0 ] , a [ n ] / 2 , w / 3 / n ) * 3 * n ) NEW_LINE

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

n , w = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) g = a [ 0 ] b = a [ n ] if g >= w : print ( w ) else : if g * 2 > b : g = b / 2 t = g * n + g * 2 * n if t <= w : print ( t ) else : print ( w ) NEW_LINE

n , w = map ( int , input ( ) . split ( ) ) a = [ float ( x ) for x in input ( ) . split ( ) ] a . sort ( ) tt = min ( a [ 0 ] , ( a [ n ] / 2 ) ) ttt = 3 * n * ttt = wt = min ( w , 3 * n * tt ) print ( t ) NEW_LINE


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 . util . ArrayList ; import java . util . Scanner ;   public class JeffandDigits { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; System . out . println ( getIndex ( scanner , n ) ) ; }   private static String getIndex ( Scanner scanner , int n ) { ArrayList < Integer > arrayList = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { arrayList . add ( scanner . nextInt ( ) ) ; } if ( ! arrayList . contains ( 0 ) ) return " - 1" ; int count = 0 ; int count0 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arrayList . get ( i ) == 5 ) count ++ ; if ( arrayList . get ( i ) == 0 ) count0 ++ ; }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int ar [ ] = new int [ N ] ; boolean isDivisibleByTen = false ; int sum = 0 ; int zeroCount = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int val = sc . nextInt ( ) ; sum += val ; if ( val == 0 ) { isDivisibleByTen = true ; zeroCount ++ ; } } if ( ! isDivisibleByTen ) System . out . println ( - 1 ) ; else { int val = sum / 45 ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < 9 * val ; i ++ ) { sb . append ( 5 ) ; } for ( int i = 0 ; i < zeroCount ; i ++ ) { if ( sb . toString ( ) . length ( ) == 0 ) { sb . append ( 0 ) ; break ; } else sb . append ( 0 ) ; } System . out . println ( sb . toString ( ) ) ; } } }

import java . util . Scanner ;   public class A352 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int five = 0 ; int zero = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int x = scanner . nextInt ( ) ; if ( x == 5 ) { five ++ ; } else { zero ++ ; } } if ( five < 9 && zero >= 1 ) { System . out . println ( "0" ) ; } else if ( five == n ) { System . out . println ( " - 1" ) ; } else { int temp = five % 9 ; five -= temp ; for ( int i = 0 ; i < five ; i ++ ) { System . out . print ( "5" ) ; } for ( int i = 0 ; i < zero ; i ++ ) { System . out . print ( "0" ) ; } } } }

import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int f = 0 , z = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( scan . nextInt ( ) == 5 ) { f ++ ; } else { z ++ ; } } if ( z == 0 ) { System . out . println ( " - 1" ) ; } else if ( f < 9 ) { System . out . println ( "0" ) ; } else { f = f - f % 9 ; for ( int i = 0 ; i < f ; i ++ ) { System . out . print ( "5" ) ; } for ( int j = 0 ; j < z ; j ++ ) { System . out . print ( "0" ) ; } }      }   }

import sysimport itertoolsimport collections     def rs ( x = ' ' ) : return sys . stdin . readline ( ) . strip ( ) if len ( x ) == 0 else input ( x ) . strip ( ) def ri ( x = ' ' ) : return int ( rs ( x ) ) def rm ( x = ' ' ) : return map ( str , rs ( x ) . split ( ) ) def rl ( x = ' ' ) : return rs ( x ) . split ( ) def rmi ( x = ' ' ) : return map ( int , rs ( x ) . split ( ) ) def rli ( x = ' ' ) : return [ int ( x ) for x in rs ( x ) . split ( ) ] def println ( val ) : sys . stdout . write ( str ( val ) + ' \n ' )     def solve ( testCase ) : n , a = ri ( ) , rli ( ) fives = a . count ( 5 ) zeros = n - fives NEW_LINE

def solution ( ) : n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) c5 = 0 c0 = 0 for i in arr : if i == 5 : c5 += 1 else : c0 += 1 c5 = ( c5 // 9 ) * 9   if c0 == 0 : print ( - 1 ) return elif c5 == 0 : print ( 0 ) return else : st = '5' * c5 st += '0' * c0 print ( int ( st ) ) 	 	               	   if __name__ == ' _ _ main _ _ ' : solution ( ) NEW_LINE

n = int ( input ( ) ) bt = list ( map ( int , input ( ) . split ( ) ) ) if 0 in bt : c5 = 0 c0 = 0 for a in bt : if a == 5 : c5 += 1 else : c0 += 1 if c5 < 9 : print ( 0 ) else : print ( ( int ( c5 / 9 ) ) * 9 * "5" + c0 * "0" ) else : print ( - 1 ) NEW_LINE

import mathn = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) c5 = l . count ( 5 ) cc = math . floor ( c5 / 9 ) c0 = l . count ( 0 ) if c0 == 0 : print ( - 1 ) else : if cc == 0 : print ( 0 ) else : a = '5' * ( 9 * cc ) + '0' * c0 print ( a ) NEW_LINE


import java . math . BigInteger ; import java . sql . Array ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collection ; import java . util . Collections ; import java . util . Comparator ; import java . util . HashMap ; import java . util . InputMismatchException ; import java . util . Iterator ; import java . util . LinkedHashSet ; import java . util . LinkedList ; import java . util . List ; import java . util . Map ; import java . util . Map . Entry ; import java . util . PriorityQueue ; import java . util . Queue ; import java . util . Scanner ; import java . util . Set ; import java . util . Stack ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . TreeMap ; import java . util . TreeSet ; public class Main { static InputReader rd = new InputReader ( System . in ) ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long m = sc . nextLong ( ) ; long l = sc . nextLong ( ) ; int t = 0 ;

n , m , l = list ( map ( int , input ( ) . split ( ) ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) arr = [ 0 ] + arr + [ 0 ]   count = 0 for i in range ( 1 , n + 1 ) : if arr [ i ] > l and arr [ i - 1 ] <= l : count += 1 for _ in range ( m ) : s = input ( ) . split ( ) if s [ 0 ] == "0" : print ( count ) else : p , q = int ( s [ 1 ] ) , int ( s [ 2 ] ) arr [ p ] += q if arr [ p ] <= l or arr [ p ] - q > l : continue if arr [ p - 1 ] <= l and arr [ p + 1 ] <= l : count += 1 elif arr [ p - 1 ] > l and arr [ p + 1 ] > l : count -= 1 NEW_LINE

import sys   def Find ( parent , x ) : if parent [ x ] != x : parent [ x ] = Find ( parent , parent [ x ] ) return parent [ x ] def Union ( parent , rank , x , y ) : x_root = Find ( parent , x ) y_root = Find ( parent , y ) if x_root == y_root : return if rank [ x_root ] < rank [ y_root ] : parent [ x_root ] = y_root elif rank [ x_root ] > rank [ y_root ] : parent [ y_root ] = x_root else : parent [ x_root ] = y_root rank [ y_root ] += 1 hair_n , request_n , fav = map ( int , sys . stdin . readline ( ) . split ( ) ) hair = [ - 1 ] + list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) parent_list = [ i for i in range ( hair_n + 1 ) ] rank_list = [ 0 for i in range ( hair_n + 1 ) ] ans = 0 for i in range ( 1 , hair_n ) : if hair [ i ] > fav and hair [ i + 1 ] > fav : Union ( parent_list , rank_list , i , i + 1 ) for i in range ( 1 , hair_n + 1 ) : if i == parent_list [ i ] and hair [ i ] > fav : ans += 1 for r in range ( request_n ) : query = list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) if query [ 0 ] == 1 : growing_hair = query [ 1 ] change = query [ 2 ] prev_hair = hair [ growing_hair ] hair [ growing_hair ] += change if hair [ growing_hair ] > fav and prev_hair <= fav : ans += 1 if hair [ growing_hair - 1 ] > fav : ans -= 1 if growing_hair < hair_n : if hair [ growing_hair + 1 ] > fav : ans -= 1 else : print ( ans ) NEW_LINE

import sys   hair_n , request_n , fav = map ( int , input ( ) . split ( ) ) hair = [ - 1 ] + list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) + [ - 1 ] ans = 0   new = Falsefor i in range ( 1 , hair_n + 1 ) : if hair [ i ] > fav and new == False : ans += 1 new = True elif hair [ i ] <= fav : new = False for r in range ( request_n ) : query = list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) if query [ 0 ] == 1 : growing_hair = query [ 1 ] change = query [ 2 ] prev_hair = hair [ growing_hair ] hair [ growing_hair ] += change if hair [ growing_hair ] > fav and prev_hair <= fav : ans += 1 if hair [ growing_hair - 1 ] > fav : ans -= 1 if growing_hair < hair_n : if hair [ growing_hair + 1 ] > fav : ans -= 1 else : print ( ans ) NEW_LINE

n , m , l = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) subs = [ 0 ] * ( n + 2 ) cnt = 0 flag = Falsefor i in range ( n ) : if a [ i ] > l : if flag == False : cnt += 1 flag = True subs [ i + 1 ] = 1 else : flag = Falsefor i in range ( m ) : q = tuple ( map ( int , input ( ) . split ( ) ) ) op = q [ 0 ] if op == 1 : op , p , d = q before = a [ p - 1 ] a [ p - 1 ] += d if before <= l < a [ p - 1 ] : subs [ p ] = 1 if subs [ p - 1 ] and subs [ p + 1 ] : cnt -= 1 elif not ( subs [ p - 1 ] or subs [ p + 1 ] ) : cnt += 1 else : print ( cnt ) NEW_LINE


import java . util . * ; import java . lang . * ; import java . io . * ;   public class FastIO { BufferedReader br ; StringTokenizer st ; public FastIO ( ) {

import java . io . * ; import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; PrintWriter out = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; int n = in . nextInt ( ) , k = in . nextInt ( ) ; out . print ( ( k + 1 ) + " ▁ " ) ; for ( int i = 1 ; i <= 2 * n ; i ++ ) if ( i != k + 1 ) out . print ( i + " ▁ " ) ;   out . flush ( ) ; out . close ( ) ; in . close ( ) ; } }

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

import java . io . BufferedReader ; import java . io . File ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ;   import javafx . util . Pair ;   public class Main {   public static void main ( String args [ ] ) { FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; int k = input . nextInt ( ) * 2 ; int a [ ] = new int [ n * 2 ] ; int j = 1 ; for ( int i = 0 ; i < 2 * n ; i += 2 , j ++ ) { a [ i ] = ( j ) * 2 ; a [ i + 1 ] = ( j ) * 2 - 1 ; }

n , k = map ( int , input ( ) . split ( ) ) r = 2 * n - 2 * kfor i in range ( 2 * n , r , - 2 ) : print ( i - 1 , i , end = ' ▁ ' ) for i in range ( r , 1 , - 2 ) : print ( i , i - 1 , end = ' ▁ ' ) NEW_LINE

import math   ans = [ ] n , m = map ( int , input ( ) . split ( ) ) for i in range ( 1 , n + 1 ) : ans . append ( [ 2 * i - 1 , 2 * i ] )   current = 0 i = 0 while current != 2 * m and i < n : if current < m and i < n : ans [ i ] [ 0 ] , ans [ i ] [ 1 ] = ans [ i ] [ 1 ] , ans [ i ] [ 0 ] current += 1 i += 1 for i in ans : print ( * i , end = " ▁ " ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) if ( k == 0 ) : for i in range ( 1 , 2 * n + 1 ) : print ( i , end = " ▁ " ) else : l = [ i for i in range ( 1 , 2 * n + 1 ) ] for i in range ( 1 , k + 1 ) : j = 2 * i - 1 m = 2 * i while ( j <= m ) : temp = l [ j - 1 ] l [ j - 1 ] = l [ m - 1 ] l [ m - 1 ] = temp j = j + 1 m = m - 1 for i in range ( 2 * n ) : print ( l [ i ] , end = " ▁ " ) NEW_LINE

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


import java . io . * ; import java . util . ArrayList ; import java . util . StringTokenizer ;

import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int n = scn . nextInt ( ) ; int k = scn . nextInt ( ) ; int len = 0 ; int len1 = 0 ; for ( int i = 2 ; i < n ; i ++ ) { int count = 0 ; for ( int j = 2 ; j < i ; j ++ ) { if ( ( i % j ) == 0 ) { count ++ ; } } if ( count == 0 ) { len ++ ; } } int [ ] arr = new int [ len ] ; for ( int i = 2 ; i < n ; i ++ ) { int count = 0 ; for ( int j = 2 ; j < i ; j ++ ) { if ( ( i % j ) == 0 ) { count ++ ; } } if ( count == 0 ) { arr [ len1 ] = i ; len1 ++ ; } } int num = 0 ; for ( int i = 0 ; i < arr . length - 1 ; i ++ ) { int ans = arr [ i ] + arr [ i + 1 ] + 1 ;

seive = [ ] def precalc ( n ) : i = 2 while ( i * i <= n ) : if ( seive [ i ] ) : j = i * i while ( j <= n ) : seive [ j ] = False j += i i += 1 def main ( ) : global seive n , k = map ( int , input ( ) . split ( ) ) seive , nums , cnt = [ True ] * ( n + 1 ) , [ ] , 0 precalc ( n ) for i in range ( 2 , n + 1 ) : if ( seive [ i ] ) : nums . append ( i ) limit = len ( nums ) if ( k == 0 ) : print ( ' YES ' ) return if ( n == 1 or n == 2 or n == 3 ) : print ( ' NO ' ) return for num in range ( 4 , n + 1 ) : if ( seive [ num ] ) : num -= 1 for number in range ( 0 , limit ) : if ( number + 1 < limit and nums [ number ] + nums [ number + 1 ] == num ) : cnt += 1 NEW_LINE

def is_prime ( num ) : if num == 1 or num % 2 == 0 : return False if num == 2 : return True for i in range ( 3 , 1 + int ( num ** 0.5 ) ) : if num % i == 0 : return False return True     n , m = map ( int , input ( ) . split ( ) ) lst = [ ] count = 0   for i in range ( 2 , n + 1 ) : if is_prime ( i ) : lst . append ( i )   for i in range ( 2 , len ( lst ) ) : if count == m : break for j in range ( i ) : if lst [ j ] + lst [ j + 1 ] + 1 == lst [ i ] : count += 1 break   print ( ' YES ' if count == m else ' NO ' ) NEW_LINE

def solve ( n , k ) : primes = set ( [ * range ( 2 , n + 1 ) ] )   for i in range ( 2 , int ( n ** ( 1 / 2 ) ) + 1 ) : if i in primes : j = 2 while i * j < n : if i * j in primes : primes . remove ( i * j ) j += 1 primesL = list ( primes )   total = 0 for i in range ( len ( primesL ) - 2 ) : if ( primesL [ i ] + primesL [ i + 1 ] + 1 ) in primes : total += 1   if total >= k : print ( " YES " ) else : print ( " NO " )   n , k = map ( int , input ( ) . split ( " ▁ " ) ) solve ( n , k ) NEW_LINE


import java . util . * ; public class secauc { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = sc . nextInt ( ) ; int max = - 1 ; int index = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > max ) { max = arr [ i ] ; index = i ; } } Arrays . sort ( arr ) ; System . out . println ( ( index + 1 ) + " ▁ " + arr [ n - 2 ] ) ; } }

import java . util . * ;   public class Solution { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; Map < Integer , Integer > prices = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { prices . put ( scan . nextInt ( ) , i + 1 ) ; } List < Integer > pList = new ArrayList < > ( prices . keySet ( ) ) ; Collections . sort ( pList ) ; int participantN = prices . get ( pList . get ( n - 1 ) ) ; int sum = pList . get ( n - 2 ) ; System . out . println ( participantN + " ▁ " + sum ) ; } }

import java . util . * ; public class SecondPriceAuction { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; int temp = 0 ; int pos = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( temp < a [ i ] ) { temp = a [ i ] ; pos = i + 1 ; } } Arrays . sort ( a ) ; System . out . println ( pos + " ▁ " + a [ n - 2 ] ) ;   } }

import java . util . * ; import java . io . * ;   public class solution { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; int index = 0 ; int max = 0 ; int a [ ] = new int [ n ] ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; if ( a [ i ] > max ) { max = a [ i ] ; index = i + 1 ; } } Arrays . sort ( a ) ; System . out . println ( index + " ▁ " + a [ n - 2 ] ) ; } }

import java . util . Arrays ; import java . util . Scanner ;   public class SecondPriceAuction {   public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } int max = a [ 0 ] ; int ind = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > max ) { max = a [ i ] ; ind = i ; } } Arrays . sort ( a ) ; System . out . println ( ( ind + 1 ) + " ▁ " + a [ n - 2 ] ) ; }   }

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

n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) i = l . index ( max ( l ) ) + 1 l . remove ( max ( l ) ) print ( i , max ( l ) ) NEW_LINE

n = int ( input ( ) ) p = list ( map ( int , input ( ) . split ( ) ) ) b = sorted ( p ) a = max ( p ) c = p . index ( a ) + 1 d = b [ - 2 ] print ( c , d ) NEW_LINE

n = int ( input ( ) ) x = list ( map ( int , input ( ) . split ( ) ) ) c = x . copy ( ) c . sort ( ) print ( x . index ( max ( x ) ) + 1 , c [ - 2 ] ) NEW_LINE


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

import java . io . * ; import java . math . * ; import java . security . * ; import java . text . * ; import java . time . LocalTime ; import java . util . * ; import java . util . concurrent . * ; import java . util . regex . * ;    public class D {    public static void main ( String [ ] args ) { FastScanner scan = new FastScanner ( ) ;

import java . io . * ; import java . util . * ;   public class NewClassTest42 { static final int LINE_LENGTH = 64 ;

import java . util . * ; public class CityDay {   public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; long a [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextLong ( ) ; int res = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { int c = 0 , d = 0 , flag = 0 ; for ( int j = i - 1 ; j >= 0 ; j -- ) { if ( c == x ) break ; if ( a [ j ] < a [ i ] ) { flag = 1 ; break ; } c ++ ; } for ( int j = i + 1 ; j < n ; j ++ ) { if ( flag == 1 ) break ; if ( d == y ) break ; if ( a [ j ] < a [ i ] ) { flag = 1 ; break ; } d ++ ; } if ( flag == 0 ) { res = i + 1 ; break ; } } System . out . println ( res ) ; sc . close ( ) ; } }

from sys import stdinn , x , y = map ( int , stdin . readline ( ) . split ( ) ) a = list ( map ( int , stdin . readline ( ) . split ( ) ) ) for i in range ( n ) : if min ( a [ max ( i - x , 0 ) : min ( i + y + 1 , n ) ] ) == a [ i ] : print ( i + 1 ) break NEW_LINE

n , x , y = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) i = 0 if n == 1 : print ( 1 ) else : for i in range ( n ) : cnt = 0 j = i - 1 ok = True while j > 0 : if cnt == x : ok = True break if a [ i ] >= a [ j ] : ok = False break else : cnt += 1 j -= 1 if ok : z = 0 j = i + 1 while j <= n - 1 : if z == y : ok = True break if a [ i ] >= a [ j ] : ok = False break else : z += 1 j += 1 if ok : break print ( i + 1 ) NEW_LINE

n , a , b = list ( map ( int , input ( ) . split ( ) ) ) days = list ( map ( int , input ( ) . split ( ) ) )   for i in range ( n ) : start = max ( 0 , i - a ) end = min ( i + b + 1 , n ) if days [ i ] == min ( days [ start : end ] ) : print ( i + 1 ) break NEW_LINE


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

import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; long f = sc . nextLong ( ) ; long l = sc . nextLong ( ) ; long max = 0 ; int j = 0 ; int p = 0 ; ArrayList < Long > res = new ArrayList < > ( ) ; for ( j = 0 ; j < 60 ; j ++ ) { for ( p = 0 ; p < 60 ; p ++ ) { if ( ( Math . pow ( x , j ) + Math . pow ( y , p ) ) <= 1000000000000000000l ) { if ( ( pow ( x , j ) + pow ( y , p ) ) >= f && ( pow ( x , j ) + pow ( y , p ) ) <= l ) { res . add ( ( pow ( x , j ) + pow ( y , p ) ) ) ; } } } } int i = 0 ; Collections . sort ( res ) ; long [ ] arr = new long [ res . size ( ) + 1 ] ; if ( res . size ( ) > 0 ) { arr [ 0 ] = res . get ( 0 ) - f ; for ( i = 1 ; i < arr . length - 1 ; i ++ ) {

import sys , math , itertoolsfrom collections import Counter , deque , defaultdictfrom bisect import bisect_left , bisect_right from heapq import heappop , heappush , heapifymod = 10 ** 9 + 7 INF = float ( ' inf ' ) def inp ( ) : return int ( sys . stdin . readline ( ) ) def inpl ( ) : return list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) def inpl_1 ( ) : return list ( map ( lambda x : int ( x ) - 1 , sys . stdin . readline ( ) . split ( ) ) ) def inps ( ) : return sys . stdin . readline ( ) def inpsl ( x ) : tmp = sys . stdin . readline ( ) ; return list ( tmp [ : x ] ) def err ( x ) : print ( x ) ; exit ( )   x , y , l , r = inpl ( ) se = set ( ) for a in range ( 100 ) : if x ** a > r : break for b in range ( 100 ) : now = x ** a + y ** b if now > r : break if now >= l : se . add ( now ) res = 0 NEW_LINE

x , y , l , r = map ( int , input ( ) . split ( ' ▁ ' ) )   arr_x = [ 1 ] while True : if arr_x [ - 1 ] * x <= r : arr_x . append ( arr_x [ - 1 ] * x ) else : break   arr_y = [ 1 ] while True : if arr_y [ - 1 ] * y <= r : arr_y . append ( arr_y [ - 1 ] * y ) else : break   L = [ i + j for i in arr_x for j in arr_y if i + j >= l and i + j <= r ] L = sorted ( list ( set ( L ) ) )   ans = 0 curr = l - 1 for i in L : ans = max ( ans , i - curr - 1 ) curr = i   ans = max ( ans , r + 1 - curr - 1 )   print ( ans ) NEW_LINE

def solve ( ) : x , y , l , r = [ int ( s ) for s in input ( ) . split ( ' ▁ ' ) ]   def pows ( x ) : z = 1 p = set ( ) while z <= 10 ** 18 : p . add ( z ) z *= x return p   x_pows = pows ( x ) y_pows = pows ( y )   fails = [ l - 1 ]   for a in x_pows : for b in y_pows : if l <= a + b <= r : fails . append ( a + b ) fails . sort ( ) fails . append ( r + 1 ) m = 0   for i in range ( 1 , len ( fails ) ) : m = max ( fails [ i ] - fails [ i - 1 ] - 1 , m )   return m     print ( solve ( ) ) NEW_LINE

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


import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sampleLength = sc . nextInt ( ) ; int repeats = sc . nextInt ( ) ; String sample = sc . next ( ) ; String result = getString ( sample , sampleLength , repeats ) ; System . out . println ( result ) ;   }   public static String getString ( String sample , int length , int repeats ) { StringBuilder sb = new StringBuilder ( sample ) ;   int mainPos = 0 ; int samplePos = 0 ;   for ( int i = 0 ; i < repeats ; i ++ ) { for ( int j = 0 ; j < length ; j ++ ) { if ( ( mainPos + samplePos ) >= sb . length ( ) ) { sb . append ( sample . charAt ( samplePos ) ) ; } if ( sb . charAt ( mainPos + samplePos ) != sample . charAt ( samplePos ) ) { i -- ; break ; } samplePos ++ ; } mainPos ++ ; samplePos = 0 ; }   return sb . toString ( ) ; }   }

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

import java . util . * ; import java . io . * ; public class Main { public static int mod = 1000000007 ; public static void solve ( InputReader in ) { int n = in . readInt ( ) ; int k = in . readInt ( ) ; char s [ ] = in . readString ( ) . toCharArray ( ) ; int lps [ ] = new int [ n ] ; for ( int i = 1 ; i < n ; i ++ ) { int j = lps [ i - 1 ] ; while ( j > 0 && s [ i ] != s [ j ] ) { j = lps [ j - 1 ] ; } if ( s [ i ] == s [ j ] ) { lps [ i ] = ++ j ; } } int sub = n - lps [ n - 1 ] ; for ( int i = 0 ; i < k - 1 ; i ++ ) { for ( int j = 0 ; j < sub ; j ++ ) { System . out . print ( s [ j ] ) ; } } System . out . print ( new String ( s ) ) ; } public static void main ( String [ ] args ) {

def foo ( s ) : if len ( s ) == 1 : return s for i in range ( 1 , len ( s ) ) : if s . startswith ( s [ i : ] ) : return s [ len ( s ) - i : ] return s n , k = [ int ( x ) for x in input ( ) . split ( ) ] t = input ( ) print ( t + ( foo ( t ) * ( k - 1 ) ) ) NEW_LINE

n , k = list ( map ( int , input ( ) . split ( ) ) ) s = input ( ) for x in range ( 1 , n ) : if s [ : - x ] == s [ x : ] : print ( s + s [ - x : ] * ( k - 1 ) ) breakelse : print ( s * k ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) s = input ( ) p = len ( s ) - 1 while s [ : p ] != s [ - p : ] : p = p - 1 print ( s + s [ p : ] * ( k - 1 ) ) NEW_LINE

v = input ( ) . split ( ) n = int ( v [ 0 ] ) k = int ( v [ 1 ] )   s = input ( ) ap = 0   i = 1 while i < n : if s [ : i ] == s [ - i : ] : ap = i   i += 1   print ( s + s [ ap : ] * ( k - 1 ) ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) s = input ( ) f = 0 for i in range ( 1 , n ) : if s [ : n - i ] == s [ i : ] : f = 1 breakif f == 0 : print ( s * k ) else : j = n - i final = s [ j : ] print ( s + final * ( k - 1 ) ) NEW_LINE


import java . lang . * ; import java . util . * ; import java . io . * ; public class Problem {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] ar = new int [ n ] ; int [ ] wake = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) ar [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) wake [ i ] = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans += ( wake [ i ] == 1 ) ? ar [ i ] : 0 ; } int cur = 0 , max = 0 ; int i = 0 , j = 0 ; while ( j <= n ) { if ( j < k ) { cur += ( wake [ j ] == 0 ) ? ar [ j ] : 0 ; } else if ( j >= k && j < n ) { cur += ( ( wake [ j ] == 0 ) ? ar [ j ] : 0 ) - ( ( wake [ i ] == 0 ) ? ar [ i ] : 0 ) ; i ++ ; } max = Math . max ( max , cur ) ; j ++ ; } System . out . println ( ans + max ) ; }   }

import java . util . * ; public class square { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , k = sc . nextInt ( ) ; int [ ] a = new int [ n ] , wake = new int [ n ] ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { wake [ i ] = sc . nextInt ( ) ; if ( wake [ i ] == 1 ) sum += a [ i ] ; } int zeros = 0 , max = 0 ; for ( int i = 0 ; i < k ; i ++ ) if ( wake [ i ] == 0 ) { zeros ++ ; max += a [ i ] ; } int temp = max ; for ( int i = 1 ; i <= n - k ; i ++ ) { if ( wake [ i - 1 ] == 0 ) temp -= a [ i - 1 ] ; if ( wake [ i + k - 1 ] == 0 ) temp += a [ i + k - 1 ] ; max = Math . max ( max , temp ) ; } System . out . println ( sum + max ) ; } }

import java . io . * ; import java . util . * ;   public class FlippingGame {   public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String nk [ ] = br . readLine ( ) . trim ( ) . split ( " ▁ " ) ; int n = Integer . parseInt ( nk [ 0 ] ) ; int k = Integer . parseInt ( nk [ 1 ] ) ; int a [ ] = new int [ n ] ; int awake [ ] = new int [ n ] ; int p [ ] = new int [ n ] ; int p2 [ ] = new int [ n ] ;   String ss [ ] = br . readLine ( ) . trim ( ) . split ( " ▁ " ) ; String x [ ] = br . readLine ( ) . trim ( ) . split ( " ▁ " ) ;   int j = 0 , max = 0 ;   while ( j < n ) { a [ j ] = Integer . parseInt ( ss [ j ] ) ; awake [ j ] = Integer . parseInt ( x [ j ] ) ; if ( j == 0 ) { if ( awake [ j ] == 1 ) p [ j ] = a [ j ] ; p2 [ j ] = a [ j ] ; } else if ( awake [ j ] == 0 ) { p [ j ] = p [ j - 1 ] ; p2 [ j ] = p2 [ j - 1 ] + a [ j ] ; } else { p [ j ] = p [ j - 1 ] + a [ j ] ; p2 [ j ] = p2 [ j - 1 ] + a [ j ] ; } j ++ ; }   for ( int i = 0 ; i < n - k + 1 ; i ++ ) { if ( i == 0 ) { max = Math . max ( max , p2 [ i + k - 1 ] + ( p [ n - 1 ] - p [ i + k - 1 ] ) ) ; } else {

import java . util . * ; import java . io . * ; import java . math . * ;   public class First { public static void process ( ) throws IOException { int n = ni ( ) ; int k = ni ( ) ; int a [ ] = new int [ n + 1 ] ; int beh [ ] = new int [ n + 1 ] ; int p [ ] = new int [ n + 1 ] ;   int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i + 1 ] = ni ( ) ; } for ( int i = 1 ; i <= n ; i ++ ) { beh [ i ] = ni ( ) ; } if ( k >= n ) { for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i + 1 ] ; } pn ( sum ) ; } else { for ( int i = 1 ; i <= n ; i ++ ) { if ( beh [ i ] == 1 ) { sum += a [ i ] ; p [ i ] = p [ i - 1 ] ; } else { p [ i ] = p [ i - 1 ] + a [ i ] ; } } int max = Integer . MIN_VALUE ; for ( int i = 1 ; i <= ( n - k + 1 ) ; i ++ ) { int x = p [ i + ( k - 1 ) ] - p [ i - 1 ] ; max = Math . max ( max , x ) ; } sum += max ; pn ( sum ) ; }             }    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 ;

n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) t = list ( map ( int , input ( ) . split ( ) ) ) p = 0 for i in range ( n ) : if t [ i ] == 1 : p += a [ i ] a [ i ] = 0 ans = s = sum ( a [ : k ] ) for i in range ( 0 , n - k ) : s = s + a [ i + k ] - a [ i ] ans = max ( ans , s ) print ( ans + p ) NEW_LINE

n , k = map ( int , input ( ) . split ( " ▁ " ) ) v = list ( map ( int , input ( ) . split ( " ▁ " ) ) ) condition = list ( map ( int , input ( ) . split ( " ▁ " ) ) ) sum = 0 for i in range ( n ) : if condition [ i ] == 1 : sum += v [ i ] v [ i ] = 0 sum2 = 0 for i in range ( k ) : if condition [ i ] == 0 : sum2 += v [ i ] temp = sum2for i in range ( 0 , n - k ) : temp = temp - v [ i ] + v [ i + k ] if temp > sum2 : sum2 = tempprint ( sum2 + sum ) NEW_LINE

n , k = map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) lst = list ( map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) ) t = list ( map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) ) s = 0 l = [ ] for i in range ( n ) : if t [ i ] == 1 : s += lst [ i ] if t [ i ] == 0 : l . append ( lst [ i ] ) else : l . append ( 0 ) s1 = sum ( l [ : k ] ) m = s1for i in range ( n - k ) : s1 -= l [ i ] s1 += l [ k + i ] if s1 > m : m = s1print ( m + s ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) m = list ( map ( int , input ( ) . split ( ) ) ) d , e , s , f = 0 , 0 , 0 , 0 for i in range ( n ) : if m [ i ] : s = s + l [ i ] l [ i ] = 0 if i > k - 1 : e = max ( e , d ) d = d - l [ f ] f = f + 1   d = d + l [ i ]   print ( s + max ( d , e ) ) NEW_LINE


import java . util . Scanner ;   public class SolutionA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; if ( n == 0 ) { System . out . println ( 0 ) ; } else if ( n % 2 == 0 ) { System . out . println ( n + 1 ) ; } else { System . out . println ( ( n + 1 ) / 2 ) ; }   } }

import java . util . * ; import java . io . * ; public class Main { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } public static void main ( String [ ] args ) {   FastReader reader = new FastReader ( ) ; long dummy = reader . nextLong ( ) ;

import java . util . * ; import java . io . * ; public final class Codeforces { public static BufferedReader buffer = new BufferedReader ( new InputStreamReader ( System . in ) ) ; public static BufferedWriter logger = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; public static void main ( String [ ] args ) { try { long n = Long . parseLong ( buffer . readLine ( ) ) ; n = n + 1 ; if ( n % 2 == 0 ) { logger . write ( n / 2 + " " ) ; } else { if ( n == 1 ) { n = 0 ; } logger . write ( n + " " ) ; } logger . flush ( ) ; } catch ( IOException exc ) { } } }

import java . io . * ; import java . util . * ;   import javax . lang . model . util . ElementScanner6 ;   public class codeforces { public static void main ( String [ ] args ) throws IOException { BufferedReader bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; long n = Long . parseLong ( bf . readLine ( ) . trim ( ) ) ; if ( n == 0 ) System . out . println ( 0 ) ; else { if ( ( n + 1 ) % 2 == 0 ) System . out . println ( ( n + 1 ) / 2 ) ; else System . out . println ( n + 1 ) ; } } }

n = int ( input ( ) ) if n == 0 : print ( 0 ) elif n % 2 == 1 : print ( ( n + 1 ) // 2 ) else : print ( n + 1 ) NEW_LINE

n = int ( input ( ) ) n += 1 if ( n == 1 ) : print ( 0 ) elif n % 2 == 0 : print ( n // 2 ) else : print ( n ) NEW_LINE

n = int ( input ( ) ) + 1 if n < 2 : print ( 0 ) elif n % 2 == 0 : print ( n // 2 ) else : print ( n ) NEW_LINE

n = int ( input ( ) ) + 1 if n == 1 : print ( 0 ) elif n % 2 : print ( n ) else : print ( n // 2 ) NEW_LINE

n = int ( input ( ) ) + 1   if n == 1 : print ( 0 ) else : if n % 2 : print ( n ) else : print ( n // 2 ) NEW_LINE


import java . nio . file . FileAlreadyExistsException ; import java . sql . SQLOutput ; import java . util . * ;   public class Example { static int [ ] dp ;   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;

import java . util . * ;   public class CF102 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int length = s . length ( ) ; int index = s . lastIndexOf ( '1' ) ; if ( length == 1 ) { System . out . println ( 0 ) ; return ; } if ( index != ( 0 ) ) { long ans = ( length - 1 ) / 2 + 1 ;

import java . util . Scanner ;   public class BowWowAndTheTimetable { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; solve ( scanner . nextLine ( ) ) ; }   public static void solve ( String numbers ) { if ( numbers . lastIndexOf ( "1" ) == 0 || numbers . equals ( "0" ) ) System . out . println ( numbers . length ( ) / 2 ) ; else System . out . println ( ( numbers . length ( ) + 1 ) / 2 ) ; } }

s = input ( )   print ( ( len ( s ) + ( s . count ( '1' ) > 1 ) ) // 2 ) NEW_LINE

s = input ( ) res = len ( s ) // 2 if len ( s ) % 2 == 1 : for c in s [ 1 : ] : if c == '1' : res += 1 breakprint ( res ) NEW_LINE

import mathn = input ( ) if n == '0' : print ( 0 ) else : k = int ( n , 2 ) NEW_LINE

import math   s = input ( ) if len ( s ) == 1 : print ( 0 ) elif len ( s ) == 2 : print ( 1 ) else : ans = math . ceil ( len ( s ) / 2 ) if s [ 1 : ] . count ( '1' ) == 0 and len ( s ) % 2 == 1 : ans -= 1 print ( ans ) NEW_LINE

n = input ( )   l = len ( n )       if l % 2 == 0 : print ( int ( l / 2 ) ) else : c = n . count ( '1' ) if c > 1 : print ( int ( l / 2 ) + 1 ) else : print ( int ( l / 2 ) ) NEW_LINE


import java . util . * ; public class TheNewYearMeetingFriends { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int arr [ ] = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) arr [ i ] = in . nextInt ( ) ; Arrays . sort ( arr ) ; int result = ( arr [ 1 ] - arr [ 0 ] ) + ( arr [ 2 ] - arr [ 1 ] ) ; System . out . println ( result ) ; } }

import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ;   int x1 = in . nextInt ( ) ; int x2 = in . nextInt ( ) ; int x3 = in . nextInt ( ) ; int max = Math . max ( x1 , Math . max ( x2 , x3 ) ) ; int min = Math . min ( x1 , Math . min ( x2 , x3 ) ) ;   System . out . println ( max - min ) ;    }   }

import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ;   int x1 = in . nextInt ( ) ; int max = x1 ; int min = x1 ; int x2 = in . nextInt ( ) ; max = Math . max ( max , x2 ) ; min = Math . min ( min , x2 ) ; int x3 = in . nextInt ( ) ; max = Math . max ( max , x3 ) ; min = Math . min ( min , x3 ) ; System . out . println ( max - min ) ;       }   }

import java . util . Scanner ;   public class A723 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int x1 = scanner . nextInt ( ) , x2 = scanner . nextInt ( ) , x3 = scanner . nextInt ( ) , max , min ;   max = Math . max ( x1 , Math . max ( x2 , x3 ) ) ; min = Math . min ( x1 , Math . min ( x2 , x3 ) ) ; System . out . println ( max - min ) ; } }

import java . util . Arrays ; import java . util . Scanner ;   public class MeetingFriends { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n1 = scanner . nextInt ( ) ; int n2 = scanner . nextInt ( ) ; int n3 = scanner . nextInt ( ) ;   int min = Math . min ( Math . min ( n1 , n2 ) , n3 ) ; int max = Math . max ( Math . max ( n1 , n2 ) , n3 ) ;   int [ ] arr = { n1 , n2 , n3 } ; int mid = Arrays . stream ( arr ) . filter ( e -> e != min && e != max ) . toArray ( ) [ 0 ] ;   System . out . println ( ( max - mid ) + ( mid - min ) ) ;   } }

a = ( int ( i ) for i in input ( ) . split ( ) ) a = sorted ( a ) print ( ( a [ 1 ] - a [ 0 ] ) + ( a [ 2 ] - a [ 1 ] ) ) NEW_LINE

friend_coordinate = list ( map ( int , input ( ) . split ( ) ) ) min_value = min ( friend_coordinate ) max_value = max ( friend_coordinate )   mid = ( min_value + max_value ) // 2 print ( ( max_value - mid ) + ( mid - min_value ) ) NEW_LINE

a = list ( map ( int , input ( ) . split ( " ▁ " ) ) ) a . sort ( ) print ( abs ( a [ 1 ] - a [ 0 ] ) + abs ( a [ 1 ] - a [ 2 ] ) ) NEW_LINE

l = list ( map ( int , input ( ) . split ( ) ) ) l . sort ( ) mi , mm , md = l [ 0 ] , l [ 1 ] , l [ 2 ] print ( abs ( mi - mm ) + abs ( md - mm ) ) NEW_LINE


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

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 ( ) ;   long n = input . nextInt ( ) ; long a , b , c , d ; a = input . nextInt ( ) ; b = input . nextInt ( ) ; c = input . nextInt ( ) ; d = input . nextInt ( ) ; long count = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { long z1 = b - c + i ; long x2 = i + a - d ; long z2 = i + a + b - c - d ; if ( ( z1 > 0 && z1 <= n ) && ( x2 > 0 && x2 <= n ) && ( z2 > 0 && z2 <= n ) ) { count ++ ; } } System . out . println ( count * n ) ; }   static class FastScanner {   BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ;   String next ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) {   return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) throws IOException { return br . readLine ( ) ; } }   }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long x , y , z , w ; long result = 0 ; for ( x = 1 ; x <= n ; x ++ ) { y = b - c + x ; z = a - d + x ; w = a + b - c - d + x ; if ( ( y >= 1 ) && ( y <= n ) && ( z >= 1 ) && ( z <= n ) && ( w >= 1 ) && ( w <= n ) ) { result ++ ; } } result = result * n ;

import java . util . Scanner ;   public class PaintingCounter { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   int n = scanner . nextInt ( ) ; int a = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; int d = scanner . nextInt ( ) ;   int A = b - c ; int B = a - d ; int C = a + b - c - d ;   long sub = Math . max ( Math . max ( A , B ) , C ) ; long diff = Math . min ( Math . min ( A , B ) , C ) ;   if ( diff < 0 ) { if ( sub < 0 ) sub = 0 ; sub -= diff ; }   long count = n - sub ;   if ( count < 0 ) count = 0 ; else count *= n ;   System . out . println ( count ) ; } }

import java . util . * ; public class b { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long n = in . nextInt ( ) , a = in . nextInt ( ) , b = in . nextInt ( ) , c = in . nextInt ( ) , d = in . nextInt ( ) ; if ( Math . abs ( a - d ) + Math . abs ( b - c ) <= n ) System . out . printf ( " % d \n " , n * ( n - Math . abs ( a - d ) - Math . abs ( b - c ) ) ) ; else System . out . printf ( "0 \n " ) ; in . close ( ) ; } }

l = list ( map ( int , input ( ) . split ( ) ) ) n = l [ 0 ] a = l [ 1 ] b = l [ 2 ] c = l [ 3 ] d = l [ 4 ] k = 0 for i in range ( n ) : x = i + 1 c2 = x + b - c c3 = x + a - d c4 = x + a + b - c - d if ( c2 > 0 and c3 > 0 and c4 > 0 ) : if ( c2 < n + 1 and c3 < n + 1 and c4 < n + 1 ) : k += 1 print ( n * k ) NEW_LINE

import sysimport mathfrom collections import defaultdictimport itertools   MAXNUM = math . infMINNUM = - 1 * math . inf     def getInt ( ) : return int ( sys . stdin . readline ( ) . rstrip ( ) )     def getInts ( ) : return map ( int , sys . stdin . readline ( ) . rstrip ( ) . split ( " ▁ " ) )     def getString ( ) : return sys . stdin . readline ( ) . rstrip ( )     def printOutput ( ans ) : sys . stdout . write ( str ( ans ) + " \n " )     def solve ( n , a , b , c , d ) :   maxCorner = max ( a + b , a + c , c + d , b + d ) minCorner = min ( a + b , a + c , c + d , b + d ) diff = maxCorner - minCorner   if n * ( n - diff ) >= 0 : return n * ( n - diff ) return 0         def readinput ( ) : n , a , b , c , d = getInts ( ) printOutput ( solve ( n , a , b , c , d ) )   readinput ( ) NEW_LINE

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

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


import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; import java . io . * ; import java . math . * ; public class Main { InputStream is ; PrintWriter out ; String INPUT = " " ;

def findMoves ( x , y , p , q ) : res = 21 for i in range ( 11 ) : for j in range ( 11 ) : if i > 0 or j > 0 : if ( x + ( i * p ) + ( j * q ) ) % 10 == y : res = min ( i + j - 1 , res ) if res == 21 : return - 1 return resdef calc ( p , q ) : ans = 0 for i in range ( 10 ) : for j in range ( 10 ) : if count [ i ] [ j ] > 0 : moves = findMoves ( i , j , p , q ) if moves == - 1 : return - 1 else : ans += ( moves * count [ i ] [ j ] ) return anss = str ( input ( ) ) n = len ( s ) count = [ [ 0 ] * 10 for i in range ( 10 ) ] for i in range ( n - 1 ) : j = int ( s [ i ] ) k = int ( s [ i + 1 ] ) count [ j ] [ k ] += 1 answer = [ [ 0 ] * 10 for i in range ( 10 ) ] for i in range ( 10 ) : for j in range ( 10 ) : answer [ i ] [ j ] = calc ( i , j ) print ( " ▁ " . join ( str ( x ) for x in answer [ i ] ) ) NEW_LINE

from collections import * s = input ( ) c = Counter ( ( ord ( y ) - ord ( x ) ) % 10 for x , y in zip ( s , s [ 1 : ] ) ) for i in range ( 100 ) : a = [ - 1 ] * 10 for j in range ( 1 , 11 ) : for k in range ( j + 1 ) : x = ( ( j - k ) * ( i // 10 ) + k * ( i % 10 ) ) % 10 if a [ x ] == - 1 : a [ x ] = j - 1 z = 0 for x in c : if a [ x ] == - 1 : z = - 1 break else : z += a [ x ] * c [ x ] print ( z ) NEW_LINE


import java . io . * ; import java . util . * ;   public class Main { static FastReader sc = new FastReader ( ) ; static PrintWriter out = new PrintWriter ( System . out ) ; public static void main ( String [ ] args ) throws IOException {

n = input ( ) lst = list ( map ( float , input ( ) . split ( ) ) ) ds = [ ] ds . append ( 0 ) for i , elem in enumerate ( lst [ 1 : ] ) : ds . append ( ds [ i ] * elem + lst [ i ] * elem ) ans = 2 * sum ( ds ) + sum ( lst ) print ( ans ) 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 [ ] cnt = new int [ 100 ] ; int n = 2 * in . nextInt ( ) ;   int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; cnt [ a [ i ] ] ++ ; }

import java . io . * ; import java . util . * ;   public class CF353B { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; int [ ] kk = new int [ 100 ] ; int [ ] pp = new int [ 100 ] ; int [ ] qq = new int [ 100 ] ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int [ ] aa = new int [ n + n ] ; for ( int i = 0 ; i < n + n ; i ++ ) { int a = Integer . parseInt ( st . nextToken ( ) ) ; kk [ a ] ++ ; aa [ i ] = a ; } int p = 0 , q = 0 ; for ( int a = 10 ; a <= 99 ; a ++ ) if ( kk [ a ] >= 2 ) { p ++ ; q ++ ; pp [ a ] ++ ; qq [ a ] ++ ; kk [ a ] -= 2 ; } else if ( kk [ a ] >= 1 && p <= q ) { p ++ ; pp [ a ] ++ ; kk [ a ] -- ; } else if ( kk [ a ] >= 1 && p > q ) { q ++ ; qq [ a ] ++ ; kk [ a ] -- ; } int m = p * q ; for ( int a = 10 ; a <= 99 ; a ++ ) while ( kk [ a ] > 0 ) if ( p <= q ) { p ++ ; pp [ a ] ++ ; kk [ a ] -- ; } else { q ++ ; qq [ a ] ++ ; kk [ a ] -- ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < n + n ; i ++ ) { int a = aa [ i ] , g ; if ( pp [ a ] > 0 ) { g = 1 ; pp [ a ] -- ; } else { g = 2 ; qq [ a ] -- ; } sb . append ( g + " ▁ " ) ; } System . out . println ( m ) ; System . out . println ( sb ) ; } }

import java . util . * ;   public class Round205B {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Map < Integer , List < Integer > > map = new HashMap < > ( ) ; for ( int i = 0 ; i < 2 * n ; i ++ ) { map . computeIfAbsent ( sc . nextInt ( ) , k -> new ArrayList < > ( ) ) . add ( i ) ; } int [ ] b = new int [ 2 * n ] ; int max = 2 * n ; int group = 1 ; for ( List < Integer > list : map . values ( ) ) { if ( list . size ( ) == 1 ) { b [ list . get ( 0 ) ] = group ; group = 3 - group ; } } for ( List < Integer > list : map . values ( ) ) { if ( list . size ( ) > 1 ) { for ( int i = 0 ; i < list . size ( ) ; i ++ ) { b [ list . get ( i ) ] = group ; group = 3 - group ; } max -= list . size ( ) - 2 ; } } if ( max % 2 == 0 ) { max = max * max / 4 ; } else { max = ( max / 2 ) * ( max / 2 + 1 ) ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i : b ) { sb . append ( i ) . append ( " ▁ " ) ; } System . out . println ( max + " \n " + sb ) ; }   }

from sys import stdin   n = int ( stdin . readline ( ) ) a = [ int ( x ) for x in stdin . readline ( ) . split ( ) ] a = sorted ( [ ( a [ x ] , x ) for x in range ( n * 2 ) ] )   group = { }   for x , ind in a : if x in group : group [ x ] . append ( ind ) else : group [ x ] = [ ind ]   g2 = [ ]   for x in group : g2 . append ( [ len ( group [ x ] ) , group [ x ] ] )   g2 . sort ( )   left = 0 right = 0   board = [ 0 for x in range ( n * 2 ) ]   ind = 0 for x , l in g2 : if x == 1 : ind += 1 if left <= right : left += 1 board [ l [ 0 ] ] = '1' else : right += 1 board [ l [ 0 ] ] = '2' else : break   if right > left : turn = Trueelse : turn = False   for x , l in g2 [ ind : ] : left += 1 right += 1   if x % 2 == 1 : last = l . pop ( ) if turn : board [ last ] = '1' else : board [ last ] = '2' turn = not turn for n in l [ : : 2 ] : board [ n ] = '1' for n in l [ 1 : : 2 ] : board [ n ] = '2' print ( left * right ) print ( ' ▁ ' . join ( board ) ) NEW_LINE

n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) adj = [ [ ] for i in range ( 100 ) ] for i in range ( 2 * n ) : adj [ arr [ i ] ] . append ( i ) res = [ 0 ] * ( 2 * n ) mul , curr = [ ] , 1 x = [ 0 , 0 ] for i in range ( 10 , 100 ) : if len ( adj [ i ] ) == 1 : res [ adj [ i ] [ 0 ] ] = curr x [ curr - 1 ] += 1 curr = 3 - curr if len ( adj [ i ] ) > 1 : res [ adj [ i ] [ 0 ] ] = 1 res [ adj [ i ] [ 1 ] ] = 2 x [ 0 ] += 1 x [ 1 ] += 1 for j in range ( 2 , len ( adj [ i ] ) ) : mul . append ( adj [ i ] [ j ] ) for i in range ( len ( mul ) ) : res [ mul [ i ] ] = curr curr = 3 - currprint ( x [ 0 ] * x [ 1 ] ) print ( * res ) NEW_LINE

from collections import * n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) c = Counter ( a ) for i in range ( 2 * n ) : a [ i ] = [ a [ i ] , i ] a . sort ( ) ans = [ 0 for i in range ( 2 * n ) ] da , db = { } , { } f = 0 for i in range ( 2 * n ) : if ( c [ a [ i ] [ 0 ] ] == 1 ) : continue ans [ a [ i ] [ 1 ] ] = f + 1 if ( f & 1 ) : da [ a [ i ] [ 0 ] ] = 1 else : db [ a [ i ] [ 0 ] ] = 1 f ^= 1 for i in range ( 2 * n ) : if ( ans [ a [ i ] [ 1 ] ] != 0 ) : continue ans [ a [ i ] [ 1 ] ] = f + 1 if ( f & 1 ) : da [ a [ i ] [ 0 ] ] = 1 else : db [ a [ i ] [ 0 ] ] = 1 f ^= 1 print ( len ( da ) * len ( db ) ) print ( * ans ) NEW_LINE

n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) g = [ [ ] for i in range ( 100 ) ] for i in range ( 2 * n ) : g [ arr [ i ] ] . append ( i ) x = 0 y = 0 curr = 1 r = [ ] for i in range ( 10 , 100 ) : if len ( g [ i ] ) == 1 : arr [ g [ i ] [ 0 ] ] = curr if curr == 1 : x += 1 else : y += 1 curr = 3 - curr if len ( g [ i ] ) > 1 : arr [ g [ i ] [ 0 ] ] = 1 arr [ g [ i ] [ 1 ] ] = 2 x += 1 y += 1 for j in range ( 2 , len ( g [ i ] ) ) : r . append ( g [ i ] [ j ] ) for i in range ( len ( r ) ) : arr [ r [ i ] ] = 2 - ( i % 2 ) print ( x * y ) print ( * arr ) NEW_LINE

n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) g = [ [ ] for i in range ( 100 ) ] for i in range ( 2 * n ) : g [ arr [ i ] ] . append ( i ) x = 0 y = 0 curr = 1 flip = 2 for i in range ( 10 , 100 ) : if len ( g [ i ] ) == 1 : arr [ g [ i ] [ 0 ] ] = curr if curr == 1 : x += 1 else : y += 1 curr = 3 - curr if len ( g [ i ] ) > 1 : arr [ g [ i ] [ 0 ] ] = 1 arr [ g [ i ] [ 1 ] ] = 2 x += 1 y += 1 for j in range ( 2 , len ( g [ i ] ) ) : arr [ g [ i ] [ j ] ] = flip flip = 3 - flipprint ( x * y ) print ( * arr ) NEW_LINE


import java . util . * ; import java . io . BufferedReader ; import java . io . FileNotFoundException ; import java . io . FileReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ;   public class divs { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { String s = sc . next ( ) ; char [ ] a = s . toCharArray ( ) ; Arrays . sort ( a ) ;

import java . util . Scanner ; import java . util . Arrays ;   public class Main { public static void main ( String [ ] args ) { Scanner puttingvaluesinside = new Scanner ( System . in ) ; int t = puttingvaluesinside . nextInt ( ) ; puttingvaluesinside . nextLine ( ) ; while ( t -- > 0 ) { char c [ ] = puttingvaluesinside . nextLine ( ) . toCharArray ( ) ; boolean flag = true ;

import java . util . * ; import java . io . * ; public class A { public static FastReader sc = new FastReader ( ) ; public static PrintWriter out = new PrintWriter ( System . out ) ; public static void taskSolver ( ) { char ch [ ] = sc . next ( ) . toCharArray ( ) ; int arr [ ] = new int [ ch . length ] ; for ( int i = 0 ; i < ch . length ; i ++ ) { arr [ i ] = ch [ i ] - ' a ' ; } Arrays . sort ( arr ) ; int flag = 1 ; for ( int i = 1 ; i < arr . length ; i ++ ) { if ( arr [ i ] != arr [ i - 1 ] + 1 ) { flag = 0 ; break ; } } if ( flag == 0 ) out . println ( " No " ) ; else out . println ( " Yes " ) ; } public static void main ( String args [ ] ) throws java . lang . Exception { int t = sc . nextInt ( ) ; while ( t -- > 0 ) taskSolver ( ) ; out . close ( ) ; } static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int t = in . nextInt ( ) ; for ( int cas = 1 ; cas <= t ; cas ++ ) { String s = in . next ( ) ;

import java . util . * ; public class question { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; for ( int l = 0 ; l < t ; l ++ ) { String s = sc . next ( ) ; char arr [ ] = s . toCharArray ( ) ; Arrays . sort ( arr ) ; int count = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( i < arr . length - 1 ) { char ch = arr [ i ] ; int x = ch ; if ( arr [ i + 1 ] == ( char ) ( x + 1 ) ) count ++ ; } } if ( count == arr . length - 1 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; }   } }

n = int ( input ( ) ) for i in range ( n ) : a = sorted ( list ( input ( ) ) ) flag = True for j in range ( len ( a ) - 1 ) : if ord ( a [ j ] ) + 1 != ord ( a [ j + 1 ] ) : flag = False if ( flag ) : print ( " Yes " ) else : print ( " No " ) NEW_LINE