import java . util . Scanner ;   public class _0707Digitalroot {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; for ( int i = 0 ; i < n ; i ++ ) { long k = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; System . out . println ( ( ( k - 1 ) * 9L ) + x ) ; } }   }

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

import java . util . Scanner ; import java . util . Arrays ; public class Codechef { public static void main ( String [ ] args ) throws java . lang . Exception { try { Scanner sc = new Scanner ( System . in ) ; int t , k , i ; long n ; t = sc . nextInt ( ) ; while ( t > 0 ) { t -- ; n = sc . nextLong ( ) ; k = sc . nextInt ( ) ; System . out . println ( k + ( n - 1 ) * 9 ) ; } } catch ( Exception e ) { } } }

import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; int t = s . nextInt ( ) ; while ( t -- != 0 ) { long k = s . nextLong ( ) ; long x = s . nextLong ( ) ; System . out . println ( x + ( 9 * ( k - 1 ) ) ) ; } } }

for _ in range ( int ( input ( ) ) ) : k , x = map ( int , input ( ) . split ( ) ) print ( 9 * ( k - 1 ) + x ) NEW_LINE

n = int ( input ( ) ) for i in range ( n ) : k , x = input ( ) . split ( " ▁ " )   k = int ( k ) x = int ( x ) if k == 1 : print ( x ) else : sum = ( ( k - 1 ) * 9 ) + x print ( sum ) NEW_LINE

for i in range ( int ( input ( ) ) ) : k , x = map ( int , input ( ) . split ( ) ) print ( 9 * ( k - 1 ) + x ) NEW_LINE

def solve ( ) : k , x = map ( int , input ( ) . split ( ) ) print ( 9 * ( k - 1 ) + x )   t = int ( input ( ) ) for _ in range ( t ) : solve ( ) NEW_LINE

t = int ( input ( ) ) lst = [ ] res = [ ] for i in range ( 0 , t ) : lst = [ int ( i ) for i in input ( ) . split ( ) ] ele = 9 * lst [ 0 ] + lst [ 1 ] - 9 res . append ( ele )   for i in range ( 0 , t ) : print ( res [ i ] ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; import java . io . PrintWriter ;     public class A {    public static void main ( String [ ] args ) throws IOException { FastReader sc = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int diff = 0 ; while ( n -- > 0 ) { int i = sc . nextInt ( ) , j = sc . nextInt ( ) ; diff += j - i + 1 ; }   int m = ( diff + k - 1 ) / k ; out . println ( k * m - diff ) ; out . close ( ) ; }

import java . util . * ; import java . io . * ; public class Main { public static void main ( String args [ ] ) {   FastReader in = new FastReader ( ) ; PrintWriter so = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; int n = in . nextInt ( ) ; int k = in . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int l = in . nextInt ( ) ; int r = in . nextInt ( ) ; ans += r - l + 1 ; } if ( ans % k == 0 ) so . println ( "0" ) ; else so . println ( ( int ) Math . ceil ( ( double ) ans / k ) * k - ans ) ; so . flush ( ) ; } 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 ( ) ) ; }   int [ ] readIntArray ( int n ) { int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextInt ( ) ; return a ; }   long [ ] readLongArray ( int n ) { long a [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextLong ( ) ; return a ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }

import java . util . * ;   public class Problems { 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 ] [ 2 ] ; int i , i2 ; int covered = 0 ; for ( i = 0 ; i < n ; i ++ ) { for ( i2 = 0 ; i2 < 2 ; i2 ++ ) { a [ i ] [ i2 ] = input . nextInt ( ) ; } covered = covered + ( ( a [ i ] [ 1 ] - a [ i ] [ 0 ] ) + 1 ) ; } covered = covered % k ; if ( covered != 0 ) { covered = k - covered ; } System . out . println ( covered ) ; } }

import java . util . * ; import java . math . * ; public class PoloPenguin { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int out = 0 ; while ( n -- > 0 ) { int l = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; out += r - l + 1 ; } if ( out <= k ) System . out . println ( k - out ) ; else { int num = ( int ) Math . ceil ( ( double ) out / ( double ) k ) ; k *= num ; System . out . println ( k - out ) ; } } }

n , k = input ( ) . split ( ) n = int ( n ) k = int ( k ) seg = 0 for i in range ( n ) : l , r = input ( ) . split ( ) l = int ( l ) r = int ( r ) seg += ( ( r - l ) + 1 ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) ans = 0 for i in range ( n ) : l , r = map ( int , input ( ) . split ( ) ) ans += r - l + 1 if ans % k == 0 : print ( 0 ) else : print ( k - ans % k ) NEW_LINE

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

s = [ int ( s ) for s in input ( ) . split ( ) ] d = [ ] total = 0 total_init = 0 for i in range ( s [ 0 ] ) : d . append ( [ int ( d ) for d in input ( ) . split ( ) ] ) for i in d : total += i [ 1 ] - i [ 0 ] + 1 total_init = totalif total % s [ 1 ] == 0 : print ( 0 ) else : while total % s [ 1 ] != 0 : total += 1 print ( total - total_init ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) arr = [ ] c = 0 for i in range ( n ) : a , b = map ( int , input ( ) . split ( ) ) c = c + b - a + 1   if c % k == 0 : print ( 0 ) else : print ( k - c % k ) NEW_LINE


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

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

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) l = [ abs ( a [ i + 1 ] - a [ i ] ) for i in range ( n - 1 ) ] dp = [ [ 0 , 0 ] for i in range ( n - 1 ) ] dp [ 0 ] [ 0 ] = l [ 0 ] ans = max ( dp [ 0 ] ) for i in range ( 1 , n - 1 ) : dp [ i ] = [ max ( dp [ i - 1 ] [ 1 ] + l [ i ] , l [ i ] ) , max ( dp [ i - 1 ] [ 0 ] - l [ i ] , - l [ i ] ) ] ans = max ( ans , max ( dp [ i ] ) ) print ( ans ) NEW_LINE

n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( " ▁ " ) ) ) d = [ ] for i in range ( n - 1 ) : a = 1 if i % 2 : a = - 1 d . append ( a * ( abs ( l [ i ] - l [ i + 1 ] ) ) )   s , b = 0 , 0 sm , bm = 0 , 0 for i in range ( n - 1 ) : s = max ( d [ i ] , s + d [ i ] ) b = max ( s , b )   for i in range ( 1 , n - 1 ) : sm = min ( d [ i ] , sm + d [ i ] ) bm = min ( sm , bm ) print ( max ( abs ( bm ) , abs ( b ) ) ) NEW_LINE

import sysinput = sys . stdin . readline   n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) d = [ 0 ] * nc = [ 0 ] * ne = [ 0 ] * nx = 1 mx = 0   for i in range ( 1 , n ) : d [ i ] = abs ( a [ i ] - a [ i - 1 ] )   for i in range ( 1 , n ) : c [ i ] = max ( 0 , c [ i - 1 ] + d [ i ] * x ) e [ i ] = max ( 0 , e [ i - 1 ] + d [ i ] * ( - x ) ) mx = max ( mx , max ( c [ i ] , e [ i ] ) ) x = - x   print ( mx ) NEW_LINE

n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) new = [ ] c = 1 for i in range ( n - 1 ) : new . append ( abs ( arr [ i ] - arr [ i + 1 ] ) * c ) c *= - 1 s = 0 s1 = 0 m = 0 for i in range ( n - 1 ) : s += new [ i ] if s < 0 : s = 0 if i > 0 : s1 += - new [ i ] if s1 < 0 : s1 = 0 m = max ( m , s1 ) m = max ( m , s ) print ( m ) NEW_LINE


import java . util . * ; import java . lang . * ; import java . math . BigInteger ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Map . Entry ; import java . util . Scanner ; import java . util . Set ; import java . util . StringTokenizer ;    @ SuppressWarnings ( " unused " ) public class A { public static FastScannerA scan = new FastScannerA ( ) ; public static PrintWriter out = new PrintWriter ( System . out ) ; static void sort ( int [ ] a ) { ArrayList < Integer > l = new ArrayList < > ( ) ; for ( int i : a ) l . add ( i ) ; Collections . sort ( l ) ; for ( int i = 0 ; i < a . length ; i ++ ) a [ i ] = l . get ( i ) ; } public static void solve ( ) { int n = scan . nextInt ( ) ; int [ ] a = scan . readArray ( n ) ; int [ ] last = new int [ 1010 ] ; int cnt = 0 ; sort ( a ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j <= 1000 ; j ++ ) { if ( a [ i ] > last [ j ] ) { if ( last [ j ] > 0 ) { cnt ++ ; } last [ j ] = a [ i ] ; break ; } } }

import java . io . BufferedOutputStream ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Collections ; import java . util . StringTokenizer ;   public class beautifulpaintings {   public static void main ( String [ ] args ) throws Exception { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ;   int n = Integer . parseInt ( in . readLine ( ) ) ; StringTokenizer st = new StringTokenizer ( in . readLine ( ) ) ; ArrayList < Integer > nums = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int num = Integer . parseInt ( st . nextToken ( ) ) ; nums . add ( num ) ; } Collections . sort ( nums ) ; int last = nums . remove ( 0 ) ; int count = 0 ; for ( int i = 1 ; i < n ; i ++ ) { int next = - 1 ; for ( int j = 0 ; j < nums . size ( ) ; j ++ ) { if ( nums . get ( j ) > last ) { next = j ; break ; } } if ( next != - 1 ) { last = nums . remove ( next ) ; count ++ ; } else { last = nums . remove ( 0 ) ; } } out . println ( count ) ; in . close ( ) ; out . close ( ) ; } }

import java . util . Scanner ;   public class BeautifulPaintings651 {   public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int count [ ] = new int [ 1001 ] ; int max = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { max = Math . max ( max , ++ count [ scan . nextInt ( ) ] ) ; } System . out . println ( n - max ) ; } }

import java . util . Scanner ; import java . util . Arrays ; import java . util . HashSet ; public class Main { public static void main ( String [ ] args ) { Scanner puttingvaluesinside = new Scanner ( System . in ) ; int arr [ ] [ ] = new int [ 1001 ] [ 1001 ] ; int t = puttingvaluesinside . nextInt ( ) ; while ( t -- > 0 ) { int temp = puttingvaluesinside . nextInt ( ) ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( arr [ i ] [ temp ] == 0 ) { arr [ i ] [ temp ] = 1 ; break ; } } } int ans = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < arr . length ; j ++ ) { if ( arr [ i ] [ j ] == 1 ) count ++ ; } if ( count == 0 ) break ; ans += count - 1 ; } System . out . println ( ans ) ; } }

n = int ( input ( ) ) A = [ int ( a ) for a in input ( ) . split ( ) ] A . sort ( ) last = A [ 0 ] c = 0 aux = 0 for i in range ( n ) : a = A [ i ] if a == last : aux += 1 else : aux = 1 last = A [ i ] c = max ( c , aux ) print ( n - c ) NEW_LINE

import collectionsn = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) cs = collections . Counter ( arr ) ans = 0 while cs : ans += len ( cs ) - 1 for k in list ( cs . keys ( ) ) : cs [ k ] -= 1 if not cs [ k ] : del cs [ k ] print ( ans ) NEW_LINE

n = int ( input ( ) ) arr = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) t = 0 i = 0j = 0 while i < len ( arr ) and j < len ( arr ) : if arr [ i ] < arr [ j ] : i += 1 t += 1 j += 1 elif arr [ i ] == arr [ j ] : j += 1 print ( t ) NEW_LINE

'''   ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ Online ▁ Python ▁ Compiler . ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ Code , ▁ Compile , ▁ Run ▁ and ▁ Debug ▁ python ▁ program ▁ online . Write ▁ your ▁ code ▁ in ▁ this ▁ editor ▁ and ▁ press ▁ " Run " ▁ button ▁ to ▁ execute ▁ it .   ''' from collections import Countern = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) c = Counter ( l ) s = list ( set ( l ) ) s . sort ( ) cn = 0 while ( True ) : for i in range ( len ( s ) ) : if ( c [ s [ i ] ] != 0 ) : NEW_LINE


import java . io . * ; import java . util . StringTokenizer ;    public class ivanTheFool { public static long mod = 1000000007 ; public static void fout ( long x ) { System . out . println ( x ) ; } 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 long pmod ( long x , long y ) { long r = 1 ; while ( y > 0 ) { if ( y % 2 == 1 ) { r = ( r * x ) % mod ; } x = ( x * x ) % mod ; y >>= 1 ; } return r ; }   public static void main ( String [ ] args ) { FastReader rd = new FastReader ( ) ; long n , m ; n = rd . nextLong ( ) ; m = rd . nextLong ( ) ; long answer = 0 ; long [ ] fact = new long [ 200000 ] ; fact [ 0 ] = 1 ; for ( long i = 1 ; i < 200000 ; ++ i ) { fact [ ( int ) i ] = ( fact [ ( int ) i - 1 ] * i ) % mod ; } answer += 2 ;

import java . io . File ; import java . util . Scanner ; import java . util . StringTokenizer ;   public class p004 { public static void main ( String args [ ] ) throws Exception { StringTokenizer stok = new StringTokenizer ( new Scanner ( System . in ) . useDelimiter ( " \\ A " ) . next ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; int n = Integer . parseInt ( stok . nextToken ( ) ) ; int m = Integer . parseInt ( stok . nextToken ( ) ) ; long mod = ( long ) 1e9 + 7 ; long [ ] [ ] dp = new long [ 100005 ] [ 2 ] ; dp [ 1 ] [ 0 ] = 2 ; for ( int i = 2 ; i <= 100000 ; i ++ ) { dp [ i ] [ 0 ] = ( dp [ i - 1 ] [ 0 ] + dp [ i - 1 ] [ 1 ] ) % mod ; dp [ i ] [ 1 ] = dp [ i - 1 ] [ 0 ] ; } long tot = ( dp [ n ] [ 0 ] + dp [ n ] [ 1 ] + dp [ m ] [ 0 ] + dp [ m ] [ 1 ] + mod - 2 ) % mod ; System . out . println ( tot ) ; } }

import io , osinput = io . BytesIO ( os . read ( 0 , os . fstat ( 0 ) . st_size ) ) . readlinen , m = list ( map ( int , input ( ) . split ( ) ) ) z = ( 10 ** 9 ) + 7 fib = [ 0 , 1 , 2 ] for i in range ( 3 , max ( n , m ) + 1 ) : fib . append ( ( fib [ - 1 ] + fib [ - 2 ] ) % z ) print ( ( 2 * ( ( fib [ n ] + fib [ m ] - 1 ) % z ) ) % z ) NEW_LINE

from sys import stdininput = lambda : stdin . readline ( ) . strip ( ) lin = lambda : list ( map ( int , input ( ) . split ( ) ) ) iin = lambda : int ( input ( ) ) main = lambda : map ( int , input ( ) . split ( ) ) from math import ceil , sqrt , factorial , logfrom collections import dequefrom bisect import bisect_leftmod = 998244353 mod = 1000000007 def gcd ( a , b ) : a , b = max ( a , b ) , min ( a , b ) while a % b != 0 : a , b = b , a % b return bdef moduloinverse ( a ) : return ( pow ( a , mod - 2 , mod ) ) def solve ( we ) : n , m = main ( ) fib = [ 1 , 1 ] for i in range ( max ( n , m ) + 3 ) : fib . append ( ( fib [ - 1 ] + fib [ - 2 ] ) % mod ) print ( ( 2 * ( fib [ n ] + fib [ m ] - 1 ) ) % mod ) qwe = 1 NEW_LINE


import java . util . Scanner ;   public class A1443 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; StringBuilder output = new StringBuilder ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int N = in . nextInt ( ) ; for ( int n = 1 ; n <= N ; n ++ ) { output . append ( 2 * ( N + n ) ) . append ( ' ▁ ' ) ; } output . append ( ' \n ' ) ; } System . out . print ( output ) ; }   }

import java . util . * ; import java . util . Collections ; public class HelloWorld {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) {

import java . util . * ;   public class Main { static boolean judge ( int a , int b ) { if ( a % b == 0 || b % a == 0 ) { return false ; } return true ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- != 0 ) { int n = sc . nextInt ( ) ; Queue < Integer > q = new LinkedList < > ( ) ; int i = 4 ; q . offer ( i ) ; while ( true ) { if ( q . size ( ) == n ) break ; i += 2 ; int mid = q . element ( ) ; if ( judge ( mid , i ) ) { q . add ( i ) ; } else { q . remove ( ) ; q . add ( i ) ; } } for ( int j = 0 ; j < n ; j ++ ) { System . out . print ( q . poll ( ) + " ▁ " ) ; } System . out . println ( ) ; } } }

import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tc = sc . nextInt ( ) ; while ( tc -- > 0 ) { int n = sc . nextInt ( ) ; int mid = 2 * n ; int count = n ; for ( int i = 4 * n ; i > mid && count > 0 ; i -= 2 ) { System . out . print ( i + " ▁ " ) ; count -- ; } System . out . println ( ) ; } sc . close ( ) ; }   }

for t in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE for i in range ( n ) : print ( 4 * n - 2 * i , end = ' ▁ ' ) NEW_LINE print ( ) NEW_LINE

import sys   NEW_LINE def main ( ) : _ , * l = map ( int , sys . stdin . read ( ) . strip ( ) . split ( ) ) NEW_LINE out = [ ] NEW_LINE for n in l : out . append ( ' ▁ ' . join ( map ( str , range ( 4 * n , 2 * n , - 2 ) ) ) ) NEW_LINE return out NEW_LINE print ( * main ( ) , sep = ' \n ' ) NEW_LINE

import sys   input = sys . stdin . buffer . readlinet = int ( input ( ) )   for _ in range ( t ) : n = int ( input ( ) )   print ( * range ( 2 * n + 2 , 4 * n + 1 , 2 ) ) NEW_LINE

import sys   input = sys . stdin . buffer . readlinet = int ( input ( ) )   for _ in range ( t ) : n = int ( input ( ) )   print ( " ▁ " . join ( list ( map ( str , list ( range ( 2 * n + 2 , 4 * n + 1 , 2 ) ) ) ) ) ) NEW_LINE

def string_list ( s , char ) : output_list = [ ] NEW_LINE intermediator = " " NEW_LINE for i in range ( len ( s ) ) : if NEW_LINE s [ i ] != char : intermediator += s [ i ] NEW_LINE if i == len ( s ) - 1 : NEW_LINE INDENT output_list . append ( int ( intermediator ) ) else : NEW_LINE if NEW_LINE DEDENT intermediator : output_list . append ( int ( intermediator ) ) NEW_LINE intermediator = " " NEW_LINE return output_list     NEW_LINE def list_string ( l , char ) : output_str = " " NEW_LINE for i in range ( len ( l ) - 1 ) : output_str += str ( l [ i ] ) + char NEW_LINE output_str += str ( l [ len ( l ) - 1 ] ) NEW_LINE return output_str     NEW_LINE def merge_sort ( l ) : def NEW_LINE merge ( l1 , l2 ) : i , j = 0 , 0 NEW_LINE output_list = [ ] NEW_LINE while i < len ( l1 ) and j < len ( l2 ) : if NEW_LINE l1 [ i ] < l2 [ j ] : output_list . append ( l1 [ i ] ) NEW_LINE i += 1 else : output_list . append ( l2 [ j ] ) NEW_LINE j += 1 NEW_LINE if i == len ( l1 ) : NEW_LINE INDENT output_list += ( l2 [ j : ] ) else : NEW_LINE output_list += ( l1 [ i : ] ) NEW_LINE DEDENT return output_list   NEW_LINE def sorts ( l ) : if NEW_LINE len ( l ) < 2 : NEW_LINE return l else : mid = len ( l ) // 2 NEW_LINE left = sorts ( l [ : mid ] ) NEW_LINE right = sorts ( l [ mid : ] ) NEW_LINE return merge ( left , right ) NEW_LINE return sorts ( l )       NEW_LINE def main_function ( ) : output_list = [ ] NEW_LINE t = int ( input ( ) ) NEW_LINE for i in range ( t ) : n = int ( input ( ) ) NEW_LINE output_list . append ( list_string ( [ 4 * n - i for i in range ( 2 * n ) if not i % 2 ] , " ▁ " ) ) NEW_LINE return list_string ( output_list , " \n " )       print ( main_function ( ) )   NEW_LINE


import javax . print . DocFlavor ; import javax . swing . * ; import java . awt . image . BandedSampleModel ; import java . util . * ;   public class Example { static long [ ] [ ] dp ;

import java . io . * ; import java . util . * ; 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 ( ) ) ; String [ ] ip = br . readLine ( ) . split ( " ▁ " ) ; int c1 = 0 , c2 = 0 , c3 = 0 , c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( Integer . parseInt ( ip [ i ] ) == 4 ) c = c + 1 ; else if ( Integer . parseInt ( ip [ i ] ) == 1 ) c1 = c1 + 1 ; else if ( Integer . parseInt ( ip [ i ] ) == 2 ) c2 = c2 + 1 ; else if ( Integer . parseInt ( ip [ i ] ) == 3 ) c3 = c3 + 1 ; } c = c + c3 ; c1 = ( c3 >= c1 ) ? 0 : c1 - c3 ; if ( c2 % 2 == 0 ) { c = c + ( c2 / 2 ) ; c = c + ( c1 % 4 == 0 ? c1 / 4 : ( c1 / 4 ) + 1 ) ; } else { c2 = ( c2 * 2 ) + c1 ; c = c + ( c2 % 4 == 0 ? c2 / 4 : ( c2 / 4 ) + 1 ) ; } System . out . println ( c ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { int count = 0 ; int count1 = 0 ; int count2 = 0 ; int count3 = 0 ; 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 ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == 4 ) { arr [ i ] = 0 ; count ++ ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == 3 ) { count3 ++ ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == 2 ) { count2 ++ ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == 1 ) { count1 ++ ; } } if ( count3 > count1 ) { count = count1 + count ; count3 = count3 - count1 ; count1 = 0 ; count = count + count1 ; count = count + count3 ; count3 = 0 ; count1 = 0 ;   }   else { count = count3 + count ; count1 = count1 - count3 ; count3 = 0 ; } count = ( count2 / 2 ) + count ; if ( count2 % 2 != 0 ) { if ( count1 < 3 ) { count ++ ; count1 = 0 ; count2 = 0 ; } else { count1 = count1 - 2 ; count ++ ; count2 = 0 ; } } count = count + ( count1 / 4 ) ; if ( count1 % 4 > 0 ) { count ++ ; } System . out . println ( count ) ; } }

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

n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) a = l . count ( 1 ) b = l . count ( 2 ) c = l . count ( 3 ) d = l . count ( 4 ) res = dres += ca -= cif b % 2 == 0 : res += b // 2 else : res += ( b // 2 ) + 1 a -= 2 if a > 0 : if a % 4 != 0 : res += ( a // 4 ) + 1 else : res += a // 4 print ( res ) NEW_LINE

from math import ceil   n = int ( input ( ) ) s = [ int ( si ) for si in input ( ) . split ( ) ]   count = { 1 : 0 , 2 : 0 , 3 : 0 , 4 : 0 } for si in s : count [ si ] += 1   NEW_LINE


import java . io . * ; import java . util . * ;   public class GFG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int y = ( int ) ( ( double ) Math . log ( N ) / Math . log ( 2 ) ) ; System . out . println ( y + 1 ) ; } }

import java . util . * ;   public class CodeForces1037A { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; System . out . println ( ( long ) ( Math . log ( n ) / Math . log ( 2 ) ) + 1 ) ; } }

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 ans = 0 ; while ( n > 1 ) { ans ++ ; n /= 2 ; } System . out . println ( ans + 1 ) ; } public static void main ( String [ ] args ) {

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

import java . util . Scanner ;    public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; for ( int i = 1 ; i <= 1000 ; i ++ ) { if ( Math . pow ( 2 , i ) > n ) { System . out . println ( i ) ; break ; } } }   }

a = int ( input ( ) )   n = acount = 0 arr = [ ]   while 1 : if 2 ** count <= a : arr . append ( 2 ** count ) n -= 2 ** count else : break if n <= 0 : break   count += 1   if n > 0 : arr . append ( n )   print ( len ( arr ) ) NEW_LINE

print ( len ( bin ( int ( input ( ) ) ) [ 2 : ] ) ) NEW_LINE

def solve ( num ) : ans = 0 power = 0 while ans < num : ans += 2 ** power power += 1 return power print ( solve ( int ( input ( ) ) ) )   NEW_LINE

t = int ( input ( ) ) i = 1 k = 0 x = 0 while x < t : x = x + i i = i * 2 k = k + 1 print ( k ) NEW_LINE

n = int ( input ( ) ) for i in range ( 1 , 35 ) : if 2 ** i - 1 >= n : print ( i ) ; break NEW_LINE


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

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

import java . util . Scanner ;   public class sinngerjocker { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;   int event_num = sc . nextInt ( ) ; int toatl_time = sc . nextInt ( ) ; int sum = 0 ; int total_jokes = 0 ; int arr [ ] = new int [ event_num ] ; for ( int i = 0 ; i < event_num ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; sum = sum + arr [ i ] ;   }   if ( toatl_time < sum + ( event_num - 1 ) * 10 ) { System . out . println ( " - 1" ) ; return ; } else { total_jokes = ( ( ( event_num - 1 ) * 10 ) / 5 ) + ( toatl_time - ( sum + ( event_num - 1 ) * 10 ) ) / 5 ; System . out . println ( total_jokes ) ;   } }    }

import java . util . * ; public class DevuTheSinger { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int d = sc . nextInt ( ) ;   int [ ] arr = new int [ n ] ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; sum += arr [ i ] ; } sc . close ( ) ;   if ( ( sum + ( n - 1 ) * 10 ) <= d ) { int ans = ( n - 1 ) * 2 ; ans = ans + ( d - ( sum + ( n - 1 ) * 10 ) ) / 5 ; System . out . println ( ans ) ; } else System . out . println ( - 1 ) ;    } }

import mathtotalTime = 0 n , d = input ( ) . split ( ) n = int ( n ) d = int ( d ) songList = list ( map ( int , input ( ) . split ( ) ) ) initialJokeCount = 0 for i in range ( n ) : if ( i != n - 1 ) : totalTime += songList [ i ] + 10 initialJokeCount += 2 else : totalTime += songList [ i ]   if ( totalTime > d ) : print ( - 1 ) else : remainingTime = d - totalTime ; remainingJokeCount = math . floor ( remainingTime / 5 ) print ( initialJokeCount + remainingJokeCount ) NEW_LINE

n , d = map ( int , input ( ) . split ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) )   if ( sum ( arr ) + ( n - 1 ) * 10 ) > d : print ( - 1 ) else : ans = ( d - sum ( arr ) ) // 5 print ( ans ) NEW_LINE

n , d = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) s = sum ( l ) + ( n - 1 ) * 10   if ( s > d ) : print ( - 1 ) else : x = ( n - 1 ) * 2 x += ( d - s ) // 5 print ( x ) NEW_LINE

import sysfrom os import pathif ( path . exists ( ' input . txt ' ) and path . exists ( ' output . txt ' ) ) : sys . stdout = open ( ' output . txt ' , ' w ' ) sys . stdin = open ( ' input . txt ' , ' r ' )     def main ( ) : N , D = map ( int , input ( ) . split ( ) ) times = list ( map ( int , input ( ) . split ( ) ) ) crack = 0 for i in range ( N ) : if i < N - 1 : D -= times [ i ] + 10 crack += 2 else : D -= times [ i ] crack += D // 5   if D < 0 : print ( - 1 ) else : print ( crack )       main ( ) NEW_LINE


import java . io . * ; import java . util . * ; import java . text . * ; import java . math . * ;   public class MyClass { public static void main ( String args [ ] ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; String name [ ] = new String [ n ] ; int [ ] ar = new int [ n ] ; HashMap < String , Integer > m = new HashMap < String , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; name [ i ] = st . nextToken ( ) ; ar [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; m . put ( name [ i ] , m . getOrDefault ( name [ i ] , 0 ) + ar [ i ] ) ; } int max = - 10000000 ; for ( String s : m . keySet ( ) ) { max = Math . max ( max , m . get ( s ) ) ; } HashMap < String , Integer > map = ( HashMap ) m . clone ( ) ; m . clear ( ) ; for ( int i = 0 ; i < n ; i ++ ) { m . put ( name [ i ] , m . getOrDefault ( name [ i ] , 0 ) + ar [ i ] ) ; if ( m . get ( name [ i ] ) >= max && map . get ( name [ i ] ) == max ) { sb . append ( name [ i ] + " \n " ) ; break ; } } System . out . print ( sb ) ; } }

import java . util . * ;   public class P2A { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Map < String , Integer > map = new HashMap < > ( ) ; int t = sc . nextInt ( ) ; int max = Integer . MIN_VALUE , k = 0 ; String ansName = " " ; String [ ] names = new String [ t ] ; int [ ] scores = new int [ t ] ; while ( t -- > 0 ) { String name = sc . next ( ) ; int score = sc . nextInt ( ) ; map . put ( name , map . getOrDefault ( name , 0 ) + score ) ; int curVal = map . get ( name ) ; names [ k ] = name ; scores [ k ] = map . get ( name ) ; k ++ ; } max = Collections . max ( map . values ( ) ) ; for ( int i = 0 ; i < names . length ; i ++ ) { if ( map . get ( names [ i ] ) == max && max <= scores [ i ] ) { ansName = names [ i ] ; break ; } } System . out . println ( ansName ) ; } }

import java . util . HashSet ; import java . util . Scanner ; import java . util . HashMap ;   public class Winner { public static void main ( final String [ ] parameters ) { Scanner input = new Scanner ( System . in ) ; int totalLines = input . nextInt ( ) ; String [ ] players = new String [ totalLines ] ; int [ ] scores = new int [ totalLines ] ; HashMap < String , Integer > scoreBoard = new HashMap < > ( ) ;   for ( int index = 0 ; index < totalLines ; index ++ ) { players [ index ] = input . next ( ) ; scores [ index ] = input . nextInt ( ) ;   scoreBoard . put ( players [ index ] , scoreBoard . getOrDefault ( players [ index ] , 0 ) + scores [ index ] ) ; }   HashSet < String > winners = new HashSet < > ( ) ; int maximumScore = Integer . MIN_VALUE ;   for ( String key : scoreBoard . keySet ( ) ) { if ( scoreBoard . get ( key ) > maximumScore ) { winners . clear ( ) ; winners . add ( key ) ; maximumScore = scoreBoard . get ( key ) ; } else if ( scoreBoard . get ( key ) == maximumScore ) { winners . add ( key ) ; } }    scoreBoard . clear ( ) ; String result = " " ;   for ( int index = 0 ; index < totalLines ; index ++ ) { String player = players [ index ] ; int playerScore = scoreBoard . getOrDefault ( player , 0 ) + scores [ index ] ;   if ( playerScore >= maximumScore && winners . contains ( player ) ) { result = player ; break ; }   scoreBoard . put ( player , playerScore ) ; }   System . out . println ( result ) ;    } }

n = int ( input ( ) ) d = { } q = [ ]   for i in range ( n ) : x , y = input ( ) . split ( ) y = int ( y ) q . append ( [ x , y ] ) d [ x ] = d . get ( x , 0 ) + yans = max ( d . values ( ) ) ma = { } for x , y in q : ma [ x ] = ma . get ( x , 0 ) + y if ma [ x ] >= ans and d [ x ] == ans : print ( x ) break NEW_LINE

from sys import * input = stdin . readlinet = int ( input ( ) ) l = { } level = [ ] for i in range ( t ) : s , p = map ( str , input ( ) . split ( ) ) p = int ( p ) l [ s ] = l . get ( s , 0 ) + p level . append ( [ l [ s ] , s ] ) res = list ( l . values ( ) ) maxp = max ( res ) name = [ ] for i in l : if ( l [ i ] == maxp ) : name . append ( i ) for i in level : if ( i [ 0 ] >= maxp and i [ 1 ] in name ) : print ( i [ 1 ] ) break   NEW_LINE

def main ( ) : n = int ( input ( ) ) scores = dict ( ) book = list ( ) for i in range ( n ) : name , score = input ( ) . split ( ) scores [ name ] = scores . setdefault ( name , 0 ) + int ( score ) book . append ( [ name , int ( score ) ] ) m = max ( scores . values ( ) ) winners = dict ( ) for k , v in scores . items ( ) : if v == m : winners . setdefault ( k , 0 ) for round in book : if round [ 0 ] in winners . keys ( ) : winners [ round [ 0 ] ] += round [ 1 ] if ( winners [ round [ 0 ] ] >= m ) : print ( round [ 0 ] ) break return   if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE


import java . util . Scanner ;   public class AddingDigits { public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ; int a = in . nextInt ( ) * 10 , b = in . nextInt ( ) , n = in . nextInt ( ) , i , j ; in . close ( ) ;   for ( i = 9 ; i >= 0 ; i -- ) { if ( ( a + i ) % b == 0 ) { System . out . print ( a + i ) ; for ( j = 0 ; j < n - 1 ; j ++ ) System . out . print ( 0 ) ; return ; } } System . out . println ( - 1 ) ; } }

import java . util . * ; import java . io . * ; public class A { static FastReader in = new FastReader ( ) ; static final Random random = new Random ( ) ; static long mod = 1000000007L ; public static void main ( String args [ ] ) throws IOException { int t = 1 ;

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

a , b , n = [ int ( x ) for x in input ( ) . split ( ) ] for i in range ( 10 ) : temp = str ( a ) + str ( i ) if ( int ( temp ) % b == 0 ) : a = temp breakif ( int ( a ) % b != 0 ) : a = - 1 else : a = a + ( '0' * ( n - 1 ) ) print ( a ) NEW_LINE

a , b , n = map ( int , input ( ) . split ( ) ) x = str ( a ) flag = 0 for i in range ( 10 ) : if int ( str ( a ) + str ( i ) ) % b == 0 : x += str ( i ) flag = 1 breakif flag == 0 : print ( - 1 ) else : for i in range ( n - 1 ) : x += "0" print ( x ) NEW_LINE

def f ( a , b , c ) : res = None cnt = 0 for i in range ( 0 , 9 + 1 ) : if int ( str ( a ) + str ( i ) ) % b == 0 : res = str ( a ) + str ( i ) break     if res == None : return - 1 return res + ( c - 1 ) * "0"         a , b , c = map ( int , input ( ) . strip ( ) . split ( ) ) print ( f ( a , b , c ) ) NEW_LINE

a , b , n = map ( int , input ( ) . split ( ) ) a = a * 10 + 9 mod = a % bif mod > 9 : print ( - 1 ) exit ( ) else : a -= moda = str ( a ) + '0' * ( n - 1 ) print ( a ) NEW_LINE

a , b , n = map ( int , input ( ) . split ( " ▁ " ) ) fixed_length = len ( str ( a ) ) if a % b == 0 : print ( a * 10 ** n ) else : while len ( str ( a ) ) != fixed_length + n : flag = False for digit in range ( 10 ) : if int ( str ( a ) + str ( digit ) ) % b == 0 : a = int ( str ( a ) + str ( digit ) ) flag = True break if flag == False : print ( - 1 ) break if a % b == 0 : a *= 10 ** ( n - ( len ( str ( a ) ) - fixed_length ) ) breakif len ( str ( a ) ) == n + fixed_length : print ( a )                           ''' brute ▁ force ▁ przeciez ▁ po ▁ osiagnieciu ▁ pierwszej ▁ podzielnoscimozesz ▁ dodac ▁ tylko ▁ zera ▁ i ▁ koniec ▁ algorytmu ''' NEW_LINE


import java . util . * ; import java . io . * ; import static java . lang . System . out ; import static java . util . Arrays . * ; import static java . lang . Math . * ; public class ContestMain { private static Reader in = new Reader ( ) ; private static StringBuilder ans = new StringBuilder ( ) ; private static long MOD = 1000000007 ;

import java . io . * ; import java . math . BigInteger ; import java . util . * ;   public class Template implements Runnable {   BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer ( " " ) ;   void init ( ) throws FileNotFoundException { try { in = new BufferedReader ( new FileReader ( " input . txt " ) ) ; out = new PrintWriter ( " output . txt " ) ; } catch ( Exception e ) { in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; out = new PrintWriter ( System . out ) ; } }   String readString ( ) throws IOException { while ( ! tok . hasMoreTokens ( ) ) { try { tok = new StringTokenizer ( in . readLine ( ) ) ; } catch ( Exception e ) { return null ; } } return tok . nextToken ( ) ; }   int readInt ( ) throws IOException { return Integer . parseInt ( readString ( ) ) ; }   int [ ] readIntArray ( int size ) throws IOException { int [ ] res = new int [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { res [ i ] = readInt ( ) ; } return res ; }   long readLong ( ) throws IOException { return Long . parseLong ( readString ( ) ) ; }   double readDouble ( ) throws IOException { return Double . parseDouble ( readString ( ) ) ; }   < T > List < T > [ ] createGraphList ( int size ) { List < T > [ ] list = new List [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { list [ i ] = new ArrayList < > ( ) ; } return list ; }   public static void main ( String [ ] args ) { new Template ( ) . run ( ) ;

import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class B394 { public static void main ( String [ ] args ) { InputReader in = new InputReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; final long start = System . currentTimeMillis ( ) ; new Task1 ( ) . solve ( in , out ) ; final long duration = System . currentTimeMillis ( ) - start ; out . close ( ) ; }   static class Task1 { public void solve ( InputReader in , PrintWriter out ) { int p = in . nextInt ( ) , x = in . nextInt ( ) ; int [ ] ans ; for ( int last = 1 ; last <= 9 ; last ++ ) { ans = new int [ p ] ; ans [ p - 1 ] = last ; int carry = 0 ;   for ( int i = p - 2 ; i >= 0 ; i -- ) { int temp = ( ans [ i + 1 ] * x + carry ) ; ans [ i ] = temp % 10 ; carry = temp / 10 ; }   if ( ( ans [ 0 ] * x + carry ) == ans [ p - 1 ] && ans [ 0 ] != 0 ) {

p , k = input ( ) . split ( )   p = int ( p ) k = int ( k )   y = 10 * k - 1 x = ( ( 10 ** ( p - 1 ) ) - k ) % y     b = True   for i in range ( k , 10 ) : if ( ( x * i % y ) == 0 ) : NEW_LINE

p , k = map ( int , input ( ) . split ( ) ) u = 10 * k - 1 v = pow ( 10 , p - 1 , u ) - kfor y in range ( k , 10 ) : if ( y * v ) % u == 0 : q = d = 9 * y while q % u : q = 10 * q + d q = str ( q // u ) print ( q * ( p // len ( q ) ) ) breakelse : print ( ' Impossible ' ) NEW_LINE


import java . io . BufferedReader ; import java . io . File ; import java . io . FileInputStream ; import java . io . IOException ; import java . io . InputStreamReader ; import java . nio . file . Paths ; import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . StringTokenizer ;   public class FindingBorders {   public static void main ( String [ ] args ) throws Exception {

MOD = int ( 1e9 + 7 ) n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) arr . sort ( ) l = 1 ; r = 0 for i in range ( n ) : r = ( r + l * arr [ i ] ) % MOD l = l * 2 % MODl = 1 for i in range ( n - 1 , - 1 , - 1 ) : r = ( r - l * arr [ i ] ) % MOD l = l * 2 % MODprint ( r ) NEW_LINE

n , x = int ( input ( ) ) , list ( sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) ) kk = 1 a = 0 for i in range ( len ( x ) ) : a += ( x [ i ] - x [ len ( x ) - i - 1 ] ) * kk kk *= 2 kk %= 1000000007 a %= 1000000007 print ( a ) NEW_LINE

n = int ( input ( ) ) V = list ( map ( int , input ( ) . split ( ) ) ) V . sort ( ) Mod = int ( 1e9 + 7 ) Sum = 0 p = [ 1 ] for i in range ( n ) : p . append ( p [ i ] * 2 % Mod ) for i in range ( n - 1 ) : l = ( p [ i + 1 ] + Mod - 1 ) % Mod r = ( p [ n - i - 1 ] - 1 + Mod ) % Mod Sum = ( Sum + ( V [ i + 1 ] - V [ i ] ) * l * r ) % Modprint ( int ( Sum ) ) NEW_LINE

import sysinput = sys . stdin . readline   n = int ( input ( ) ) x = list ( map ( int , input ( ) . split ( ) ) ) x . sort ( ) ans = 0 MOD = 10 ** 9 + 7   for i in range ( n - 1 ) : d = x [ i + 1 ] - x [ i ] l = pow ( 2 , i + 1 , MOD ) - 1 r = pow ( 2 , n - i - 1 , MOD ) - 1 ans += d * l * r ans %= MOD   print ( ans ) NEW_LINE

n = int ( input ( ) ) ar = list ( map ( int , input ( ) . split ( ) ) ) ar . sort ( ) MOD = 10 ** 9 + 7 ans = 0 for i in range ( n ) : bef = i aft = n - i - 1 if bef < aft : ans -= ( ar [ i ] * ( pow ( 2 , aft , MOD ) - pow ( 2 , bef , MOD ) + MOD ) % MOD ) ans %= MOD elif aft < bef : ans += ( ar [ i ] * ( pow ( 2 , bef , MOD ) - pow ( 2 , aft , MOD ) + MOD ) % MOD ) ans %= MOD 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 ( ) ; }   int N ; void run ( FastScanner in , PrintWriter out ) {   N = in . nextInt ( ) ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Iterator ; import java . util . PriorityQueue ; import java . util . Random ; import java . util . StringTokenizer ; import java . util . TreeMap ;   public class Solution { static final int inf = ( int ) 1e8 ; public static void main ( String [ ] args ) throws IOException { FastScanner fs = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int tt = 1 ; while ( tt -- > 0 ) { int n = fs . nextInt ( ) ; int [ ] a = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) a [ i ] = fs . nextInt ( ) ;

n = int ( input ( ) ) A = [ int ( i ) for i in input ( ) . split ( ) ] ans = 0   st = [ 0 ]   tdeath = [ - 1 for i in range ( n ) ]   for i in range ( 1 , n ) : tdeath [ i ] = 0 while len ( st ) > 0 and A [ st [ - 1 ] ] < A [ i ] : tdeath [ i ] = max ( tdeath [ i ] , tdeath [ st [ - 1 ] ] + 1 ) st . pop ( ) if len ( st ) == 0 : tdeath [ i ] = - 1 st . append ( i ) ans = max ( ans , tdeath [ i ] + 1 ) print ( ans ) NEW_LINE

n = int ( input ( ) ) A = list ( map ( int , input ( ) . strip ( ) . split ( ) ) ) [ : : - 1 ] p = 0 p_max = 0 X = [ ] for i in A : NEW_LINE

N = int ( input ( ) ) psychos = list ( map ( int , input ( ) . split ( " ▁ " ) ) ) time_of_death = [ 0 for i in range ( N ) ]   stack = [ ( psychos [ 0 ] , 0 ) ] for index , p in enumerate ( psychos ) : if index == 0 : continue if p < stack [ - 1 ] [ 0 ] : stack . append ( ( p , 1 ) ) time_of_death [ index ] = 1   elif p > stack [ - 1 ] [ 0 ] : max_time = - 1 while stack != [ ] and p > stack [ - 1 ] [ 0 ] : max_time = max ( max_time , stack [ - 1 ] [ 1 ] ) del stack [ - 1 ] if stack == [ ] : NEW_LINE

def main ( ) :   from bisect import bisect_left as bl , bisect_right as br , insort import sys , math NEW_LINE


import java . io . * ; import java . math . * ; import java . time . LocalDate ; import java . time . Month ; 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 . MAX_VALUE ; 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 = 100 ; private static final int MAXA = 2000007 ; private static final int MAXLOG = 22 ; private static final double PI = Math . acos ( - 1 ) ; public static void main ( String [ ] args ) throws IOException {   InputReader in = new InputReader ( System . in ) ;

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

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

def f ( a , b ) : kentuky = a + b in ( ' pq ' , ' qp ' , ' bd ' , ' db ' ) yo_bro = a == b and a in ' AHIMOoTUVvWwXxY ' return kentuky or yo_bro     s = input ( ) n = len ( s ) for i in range ( n ) : if not f ( s [ i ] , s [ n - i - 1 ] ) : print ( ' NIE ' ) breakelse : print ( ' TAK ' )   NEW_LINE

import sys , os , iofrom sys import stdinfrom functools import cmp_to_keyfrom bisect import bisect_left , bisect_rightfrom collections import defaultdictdef ii ( ) : return int ( input ( ) ) def li ( ) : return list ( map ( int , input ( ) . split ( ) ) ) if ( os . path . exists ( ' input . txt ' ) ) : sys . stdin = open ( " input . txt " , " r " ) ; sys . stdout = open ( " output . txt " , " w " ) NEW_LINE


import java . util . * ;   public class CodeForces614A { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; long l = input . nextLong ( ) ; long r = input . nextLong ( ) ; long k = input . nextLong ( ) ; long ans = 1 ; long c = 0 ; for ( int p = 0 ; p < 62 ; p ++ ) { if ( ans >= l && ans <= r ) { System . out . print ( ans + " ▁ " ) ; c ++ ; } if ( Math . log10 ( ans ) + Math . log10 ( k ) > 18 ) { break ; } else { ans *= k ; } } if ( c == 0 ) { System . out . println ( " - 1" ) ; } } }

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

import java . io . * ; import java . math . BigDecimal ; import java . math . BigInteger ; import java . util . * ; import java . util . Comparator ;   public class scratch_25 { static class Reader { static BufferedReader reader ; static StringTokenizer tokenizer ;   static void init ( InputStream input ) { reader = new BufferedReader ( new InputStreamReader ( input ) ) ; tokenizer = new StringTokenizer ( " " ) ; }   static String next ( ) throws IOException { while ( ! tokenizer . hasMoreTokens ( ) ) {

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

l , r , k = map ( int , input ( ) . split ( ) ) p = 1 while p < l : p = p * klis = [ ] while p >= l and p <= r : lis . append ( p ) p = p * kif not lis : print ( - 1 ) else : for i in lis : print ( i , end = ' ▁ ' ) NEW_LINE

from math import logl , r , k = map ( int , input ( ) . split ( ) ) temp = int ( log ( l , k ) ) val = k ** tempif ( val < l ) : val *= kc = 0 while ( val <= r ) : print ( val , end = " ▁ " ) val *= k c += 1 if not c : print ( - 1 ) NEW_LINE

l , r , k = map ( int , input ( ) . split ( ) ) ans = 1 ; c = 0 while ( ans < l ) : ans = ans * kwhile ( ans <= r ) : c = c + 1 print ( ans ) ans = ans * kif ( c == 0 ) : print ( - 1 ) NEW_LINE

a = [ ] d = input ( ) . split ( ) l = int ( d [ 0 ] ) r = int ( d [ 1 ] ) k = int ( d [ 2 ] ) t = 1 ; a . append ( t ) ; while ( t < 10 ** 20 ) : t *= k ; a . append ( t ) ; cnt = 0 res = ' ' for i in range ( len ( a ) ) : if ( a [ i ] <= r and a [ i ] >= l ) : res += str ( a [ i ] ) + ' ▁ ' if ( len ( res ) <= 0 ) : print ( - 1 ) else : print ( res ) NEW_LINE

import math   l , r , k = map ( int , input ( ) . split ( ) )       h = 0 for j in range ( 10 ** 9 ) : if l <= k ** j <= r : print ( k ** j , end = ' ▁ ' ) h += 1 elif k ** j > r : break if h == 0 : print ( - 1 ) NEW_LINE


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 ) ; BProblemsForRound solver = new BProblemsForRound ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class BProblemsForRound { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int low = 1 ; int high = n ; int a , b ; while ( m -- > 0 ) { a = in . nextInt ( ) ; b = in . nextInt ( ) ; if ( a > b ) { int temp = a ; a = b ; b = temp ; } low = Math . max ( low , a ) ; high = Math . min ( high , b ) ; } out . println ( Math . max ( 0 , high - low ) ) ; }   }   static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ;   public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; }   public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; }   public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   } }

import sun . nio . cs . ext . MacThai ;   import java . io . * ; import java . util . * ; import java . lang . * ; import java . math . * ;    public class Main { static class sol { public static void solve ( InputReader in , PrintWriter out ) { int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int div2 = 1 , div1 = n ; int a , b ; for ( int i = 0 ; i < m ; i ++ ) { a = in . nextInt ( ) ; b = in . nextInt ( ) ; div2 = Math . max ( div2 , Math . min ( a , b ) ) ; div1 = Math . min ( div1 , Math . max ( a , b ) ) ; } if ( div1 - div2 >= 0 ) out . print ( div1 - div2 ) ; else out . print ( "0" ) ; } } public static void main ( String [ ] args ) throws FileNotFoundException { InputStream input = System . in ;

import java . io . * ; import java . util . * ;   public class problemforround { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int low = 1 , high = n ; while ( m > 0 ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( a > b ) { int c = a ; a = b ; b = c ; } low = Math . max ( low , a ) ; high = Math . min ( high , b ) ; -- m ; } System . out . println ( Math . max ( 0 , high - low ) ) ; } }

import java . util . * ; import javafx . util . Pair ;   public class VisTrain {   public static Scanner in = new Scanner ( System . in ) ;   public static void main ( String [ ] args ) { ArrayList < Pair < Integer , Integer > > list = new ArrayList < Pair < Integer , Integer > > ( ) ; HashSet < Integer > a = new HashSet < Integer > ( ) ; HashSet < Integer > b = new HashSet < Integer > ( ) ; int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; boolean [ ] visited = new boolean [ n + 1 ] ; int maxA = - 1 ; int minB = Integer . MAX_VALUE ; int tmp = m ; while ( tmp -- > 0 ) { int u = in . nextInt ( ) ; int v = in . nextInt ( ) ; int min = Math . min ( u , v ) ; int max = Math . max ( u , v ) ; maxA = Math . max ( maxA , min ) ; minB = Math . min ( minB , max ) ; list . add ( new Pair ( min , max ) ) ; a . add ( min ) ; b . add ( max ) ; visited [ u ] = visited [ v ] = true ; } if ( m == 0 ) { System . out . println ( n - 1 ) ; } else { boolean ans = true ; for ( Pair p : list ) { if ( ( a . contains ( p . getKey ( ) ) && a . contains ( p . getValue ( ) ) ) || ( b . contains ( p . getKey ( ) ) && b . contains ( p . getValue ( ) ) ) ) { ans = false ; break ; } } if ( ans && maxA < minB ) { int count = 0 ; for ( int i = maxA ; i <= minB ; i ++ ) { if ( ! visited [ i ] ) { count ++ ; } } System . out . println ( count + 1 ) ; } else { System . out . println ( "0" ) ; } } }   }

a , b = map ( int , input ( ) . split ( ) ) l , r = 0 , a ; ans = 1 z = [ 0 ] * ( a + 1 ) for _ in " ▁ " * b : u , v = sorted ( map ( int , input ( ) . split ( ) ) ) if z [ u ] == 2 or z [ v ] == 1 : ans = 0 elif z [ u ] != 0 and z [ v ] != 0 and z [ u ] == z [ v ] : ans = 0 else : z [ u ] = 1 ; z [ v ] = 2 if u >= r : ans = 0 if v <= l : ans = 0 l = max ( l , u ) ; r = min ( r , v ) if ans == 0 : print ( ans ) elif l == 0 and r == a : print ( a - 1 ) else : print ( r - l ) NEW_LINE

a , b = map ( int , input ( ) . split ( ) ) l , r = 1 , afor _ in " ▁ " * b : u , v = sorted ( map ( int , input ( ) . split ( ) ) ) ; l = max ( l , u ) ; r = min ( r , v ) print ( max ( r - l , 0 ) ) 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 . MAX_VALUE ; 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 int MAX = 1000005 ; private static final long MOD = 1000000007 ;   private static final int MAXN = 100007 ; private static final int MAXA = 10000009 ; private static final int MAXLOG = 22 ;   public static void main ( String [ ] args ) throws IOException {   InputReader in = new InputReader ( System . in ) ;

import java . io . * ; import java . util . * ;   public class A { 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 file = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = file . nextInt ( ) ; Integer [ ] arr = new Integer [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = file . nextInt ( ) ; } Arrays . sort ( arr ) ; long [ ] pref = new long [ n ] ; for ( int i = n - 1 ; i > - 1 ; -- i ) { pref [ i ] = arr [ i ] + ( i + 1 < n ? pref [ i + 1 ] : 0l ) ; } long max = 0 ; max += pref [ 0 ] ; for ( int i = 0 ; i < pref . length - 1 ; i ++ ) { max += pref [ i ] ; } out . println ( max ) ; out . close ( ) ;   }   }

import java . io . BufferedOutputStream ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ;   public class applemanandtoastman {   public static void main ( String [ ] args ) throws Exception { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ;   int n = Integer . parseInt ( in . readLine ( ) ) ; Long [ ] nums = new Long [ n ] ; StringTokenizer st = new StringTokenizer ( in . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { long num = Integer . parseInt ( st . nextToken ( ) ) ; nums [ i ] = num ; } Arrays . parallelSort ( nums ) ; long res = 0 ; for ( int i = 1 ; i < n ; i ++ ) { res += ( i + 1 ) * nums [ i - 1 ] ; } res += n * nums [ n - 1 ] ; out . println ( res ) ; in . close ( ) ; out . close ( ) ; } }

import java . io . * ; import java . util . * ; import java . math . * ; import java . lang . * ;   public class Solution implements Runnable {   public void run ( ) { InputReader sc = new InputReader ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int i = 0 , j = 0 , k = 0 ; int testcase = 0 ;

import java . util . * ;   public class CodeForces { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; long arr [ ] = new long [ ( int ) n ] ; long score = 0 ; for ( int i = 0 ; i < ( int ) n ; i ++ ) { arr [ i ] = sc . nextLong ( ) ; score += arr [ i ] ; } Arrays . sort ( arr ) ; long s = 0 ; long sum [ ] = new long [ ( int ) n - 1 ] ; for ( int i = ( int ) n - 1 ; i >= 1 ; i -- ) { s += arr [ i ] ; sum [ i - 1 ] = s ; } for ( int i = 0 ; i < ( int ) n - 1 ; i ++ ) { score += arr [ i ] + sum [ i ] ; } System . out . println ( score ) ; } }

if __name__ == ' _ _ main _ _ ' : for _ in range ( 1 ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) ans = 0 for i in range ( n ) [ : n - 1 ] : ans += ( i + 2 ) * a [ i ] ans += n * a [ n - 1 ] print ( ans ) NEW_LINE

n = int ( input ( ) ) l = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) s = [ l [ i ] * ( i + 2 ) for i in range ( n ) ] print ( sum ( s ) - l [ - 1 ] ) NEW_LINE

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

from sys import stdin   A = int ( stdin . readline ( ) ) B = list ( map ( int , stdin . readline ( ) . split ( ) ) ) K = 0   if A == 1 : print ( B [ 0 ] ) K = 1   if A == 2 : print ( 2 * ( B [ 0 ] + B [ 1 ] ) ) K = 1   if K == 0 : B . sort ( ) sum = B [ len ( B ) - 1 ] + B [ len ( B ) - 2 ] ans = sum   for t in range ( len ( B ) - 3 , - 1 , - 1 ) : sum += B [ t ] ans += sum   ans += sum   print ( ans ) NEW_LINE


import java . io . * ; import java . math . BigDecimal ; import java . math . BigInteger ; import java . util . * ;   public class Main { static class Reader { final private int BUFFER_SIZE = 1 << 16 ; private DataInputStream din ; private byte [ ] buffer ; private int bufferPointer , bytesRead ; public Reader ( ) { din = new DataInputStream ( System . in ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; } public Reader ( String file_name ) throws IOException { din = new DataInputStream ( new FileInputStream ( file_name ) ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; } public String readLine ( ) throws IOException { byte [ ] buf = new byte [ ( int ) ( 2e6 + 10 ) ] ;

import java . io . DataInputStream ; import java . io . FileInputStream ; import java . io . IOException ; import java . util . ArrayList ; import java . util . Scanner ;   public class Main { static class Reader { final private int BUFFER_SIZE = 1 << 16 ; private DataInputStream din ; private byte [ ] buffer ; private int bufferPointer , bytesRead ; public Reader ( ) { din = new DataInputStream ( System . in ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; } public Reader ( String file_name ) throws IOException { din = new DataInputStream ( new FileInputStream ( file_name ) ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; } public String readLine ( ) throws IOException { byte [ ] buf = new byte [ 64 ] ;

import java . io . * ; import java . util . * ;   public class B {   public static Reader sc = new Reader ( ) ;

def main ( ) : t = int ( input ( ) ) allans = [ ] for _ in range ( t ) : n , m , a , b = readIntArr ( ) adj = [ [ ] for __ in range ( n + 1 ) ] for __ in range ( m ) : u , v = readIntArr ( ) adj [ u ] . append ( v ) adj [ v ] . append ( u ) def reachableFromAWOPassingB ( a , b ) : st = [ a ] reachable = [ False for _ in range ( n + 1 ) ] reachable [ a ] = True while st : node = st . pop ( ) for nex in adj [ node ] : if nex != b and not reachable [ nex ] : reachable [ nex ] = True st . append ( nex ) reachable [ a ] = False return reachable vA = reachableFromAWOPassingB ( a , b ) vB = reachableFromAWOPassingB ( b , a ) aCnt = 0 bCnt = 0 for i in range ( 1 , n + 1 ) : if vA [ i ] and not vB [ i ] : aCnt += 1 if not vA [ i ] and vB [ i ] : bCnt += 1 ans = aCnt * bCnt allans . append ( ans ) multiLineArrayPrint ( allans ) return import sys NEW_LINE

import sysinput = sys . stdin . buffer . readlinedef dfs ( start , end ) : visited = [ 0 for i in range ( n + 1 ) ] stack = [ start ] while stack : start = stack . pop ( ) if ( start == end or visited [ start ] ) : continue visited [ start ] = 1 for i in graph [ start ] : if ( visited [ i ] == 0 ) : stack . append ( i ) return visited       for _ in range ( int ( input ( ) ) ) : n , m , a , b = map ( int , input ( ) . split ( ) ) graph = [ [ ] for i in range ( n + 1 ) ] for i in range ( m ) : x , y = map ( int , input ( ) . split ( ) ) graph [ x ] . append ( y ) graph [ y ] . append ( x ) vis = dfs ( a , b ) vis2 = dfs ( b , a ) ans1 , ans2 = 0 , 0 for i in range ( 1 , n + 1 ) : if i == a or i == b : continue if vis [ i ] and not vis2 [ i ] : ans1 += 1 if not vis [ i ] and vis2 [ i ] : ans2 += 1 print ( ans1 * ans2 ) NEW_LINE

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

def main ( ) : t = int ( input ( ) ) allans = [ ] for _ in range ( t ) : n , m , a , b = readIntArr ( ) adj = [ [ ] for __ in range ( n + 1 ) ] for __ in range ( m ) : u , v = readIntArr ( ) adj [ u ] . append ( v ) adj [ v ] . append ( u ) def reachableFromAWOPassingB ( a , b ) : st = [ a ] reachable = set ( ) reachable . add ( a ) while st : node = st . pop ( ) for nex in adj [ node ] : if nex != b and nex not in reachable : reachable . add ( nex ) st . append ( nex ) reachable . remove ( a ) return reachable vA = reachableFromAWOPassingB ( a , b ) vB = reachableFromAWOPassingB ( b , a ) NEW_LINE


import java . util . Scanner ;   public class Solution { public static void main ( String [ ] args ) { Solution solution = new Solution ( ) ; solution . solve ( ) ; }   private void solve ( ) { Scanner in = new Scanner ( System . in ) ; int t = in . nextInt ( ) ;   while ( t -- > 0 ) { int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int x1 = in . nextInt ( ) , y1 = in . nextInt ( ) ; int x2 = in . nextInt ( ) , y2 = in . nextInt ( ) ; long a = Math . max ( x1 , x2 ) - Math . min ( x1 , x2 ) ; long b = Math . max ( y1 , y2 ) - Math . min ( y1 , y2 ) ; if ( 2 * a <= n && 2 * b <= m ) System . out . println ( 2 * a * b ) ; else System . out . println ( 2 * a * b - ( 2 * a - n ) * ( 2 * b - m ) ) ; } } }

import java . util . Scanner ; import java . lang . Math ;   public class main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int t = s . nextInt ( ) ; for ( int k = 0 ; k < t ; k ++ ) { int n = s . nextInt ( ) ; int m = s . nextInt ( ) ; int x1 = s . nextInt ( ) ; int y1 = s . nextInt ( ) ; int x2 = s . nextInt ( ) ; int y2 = s . nextInt ( ) ; int x = Math . abs ( x1 - x2 ) ; int y = Math . abs ( y1 - y2 ) ; long sum = ( long ) n * m - ( long ) ( n - x ) * ( m - y ) * 2 ; x = n - 2 * x ; y = m - 2 * y ; if ( x > 0 && y > 0 ) sum += ( long ) x * y ; System . out . println ( sum ) ; } } }

import java . io . BufferedInputStream ; import java . io . BufferedOutputStream ; import java . io . BufferedReader ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class Main { public static void main ( String [ ] args ) throws FileNotFoundException , IOException { InputReader in = new InputReader ( new BufferedInputStream ( System . in ) ) ; PrintWriter out = new PrintWriter ( new OutputStreamWriter ( new BufferedOutputStream ( System . out ) ) ) ; TaskB solver = new TaskB ( ) ; long t1 = System . currentTimeMillis ( ) ; solver . solve ( 1 , in , out ) ; out . flush ( ) ; long t2 = System . currentTimeMillis ( ) ;

from sys import stdin   for case in range ( int ( stdin . readline ( ) ) ) : n , m , x1 , y1 , x2 , y2 = [ int ( x ) for x in stdin . readline ( ) . split ( ) ]   total = n * m   xDiff = abs ( x1 - x2 ) yDiff = abs ( y1 - y2 )   rectX = n - xDiff rectY = m - yDiff midSquare = ( rectX * 2 - n ) * ( rectY * 2 - m ) total -= 2 * ( n - xDiff ) * ( m - yDiff ) if rectX * 2 > n : total += max ( midSquare , 0 ) print ( total ) NEW_LINE

t = int ( input ( ) ) for q in range ( t ) : n , m , x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( ' ▁ ' ) ) print ( n * m - 2 * ( ( n - abs ( x1 - x2 ) ) * ( m - abs ( y1 - y2 ) ) ) + ( min ( 0 , ( n - 2 * ( n - abs ( x1 - x2 ) ) ) ) * min ( 0 , m - 2 * ( m - abs ( y1 - y2 ) ) ) ) ) NEW_LINE

import sysdef its ( x1 , y1 , x2 , y2 , x3 , y3 , x4 , y4 ) : x5 = max ( x1 , x3 ) ; y5 = max ( y1 , y3 ) x6 = min ( x2 , x4 ) ; y6 = min ( y2 , y4 ) if ( x5 <= x6 and y5 <= y6 ) : return ( x6 + 1 - x5 ) * ( y6 + 1 - y5 ) else : return 0   def main ( ) : t = int ( input ( ) ) for it in range ( 0 , t ) : n , m , x1 , y1 , x2 , y2 = [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] """ TABSYMBOL TABSYMBOL n = int ( sys . stdin ( ) . read ( ) ) TABSYMBOL TABSYMBOL m = int ( sys . stdin ( ) . read ( ) ) TABSYMBOL TABSYMBOL x1 = int ( sys . stdin ( ) . read ( ) ) TABSYMBOL TABSYMBOL y1 = int ( sys . stdin ( ) . read ( ) ) TABSYMBOL TABSYMBOL x2 = int ( sys . stdin ( ) . read ( ) ) TABSYMBOL TABSYMBOL y2 = int ( sys . stdin ( ) . read ( ) ) TABSYMBOL TABSYMBOL """ dr = min ( n - x1 , n - x2 ) dl = min ( x1 - 1 , x2 - 1 ) du = min ( y1 - 1 , y2 - 1 ) dd = min ( m - y1 , m - y2 ) x1p , y1p = x1 - dl , y1 - du x2p , y2p = x1 + dr , y1 + dd x3p , y3p = x2 - dl , y2 - du x4p , y4p = x2 + dr , y2 + dd NEW_LINE

import sysdef its ( x1 , y1 , x2 , y2 , x3 , y3 , x4 , y4 ) : x5 = max ( x1 , x3 ) ; y5 = max ( y1 , y3 ) x6 = min ( x2 , x4 ) ; y6 = min ( y2 , y4 ) if ( x5 <= x6 and y5 <= y6 ) : return ( x6 + 1 - x5 ) * ( y6 + 1 - y5 ) else : return 0   def main ( ) : t = int ( input ( ) ) it = 0 while ( it < t ) : n , m , x1 , y1 , x2 , y2 = [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] """ TABSYMBOL TABSYMBOL n = int ( sys . stdin ( ) . read ( ) ) TABSYMBOL TABSYMBOL m = int ( sys . stdin ( ) . read ( ) ) TABSYMBOL TABSYMBOL x1 = int ( sys . stdin ( ) . read ( ) ) TABSYMBOL TABSYMBOL y1 = int ( sys . stdin ( ) . read ( ) ) TABSYMBOL TABSYMBOL x2 = int ( sys . stdin ( ) . read ( ) ) TABSYMBOL TABSYMBOL y2 = int ( sys . stdin ( ) . read ( ) ) TABSYMBOL TABSYMBOL """ dr = min ( n - x1 , n - x2 ) dl = min ( x1 - 1 , x2 - 1 ) du = min ( y1 - 1 , y2 - 1 ) dd = min ( m - y1 , m - y2 ) x1p , y1p = x1 - dl , y1 - du x2p , y2p = x1 + dr , y1 + dd x3p , y3p = x2 - dl , y2 - du x4p , y4p = x2 + dr , y2 + dd NEW_LINE

for i in range ( int ( input ( ) ) ) : n , m , x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( ) ) w , h = abs ( x2 - x1 ) , abs ( y2 - y1 ) if w * 2 > n or h * 2 > m : print ( n * m - 2 * ( n - w ) * ( m - h ) ) else : print ( 2 * w * h ) NEW_LINE


import java . util . Scanner ;     public class Main { static final int M = 1010 ;   public static void main ( String [ ] args ) {

import java . io . * ; import java . util . * ; import java . math . * ;   public class Main { static class Point { int x , y ; Point ( int x , int y ) { this . x = x ; this . y = y ; } } public static void main ( String [ ] args ) throws java . lang . Exception {

import java . io . * ; import java . util . * ; import java . util . regex . * ; public class vk18 { public static void main ( String [ ] stp ) throws Exception { Scanner scan = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) , m = Integer . parseInt ( st . nextToken ( ) ) , i , j = 0 , max = 0 , count = 0 ; char [ ] [ ] c = new char [ n ] [ m ] ;

n , m = map ( int , input ( ) . split ( ) ) A = [ ] for i in range ( n ) : s = input ( ) X = [ char for char in s ] A . append ( X ) tot = 0 for i in range ( n ) : for j in range ( m ) : if A [ i ] [ j ] == ' * ' : tot += 1 row = [ ] col = [ ] for i in range ( n ) : row . append ( A [ i ] . count ( ' * ' ) ) t_A = list ( zip ( * A ) ) for j in range ( m ) : col . append ( t_A [ j ] . count ( ' * ' ) ) count = 0 ok = False for i in range ( n ) : if ok == True : break for j in range ( m ) : count = row [ i ] + col [ j ] if A [ i ] [ j ] == ' * ' : count -= 1 if count == tot : ok = True print ( " YES " ) print ( str ( i + 1 ) + " ▁ " + str ( j + 1 ) ) if ok == True : break if ok == False : print ( " NO " ) NEW_LINE

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

n , m = map ( int , input ( ) . split ( ) ) a = [ ] for i in range ( n ) : s = input ( ) a . append ( s ) r = [ 0 ] * nc = [ 0 ] * mf = 0 cnt = 0 for i in range ( n ) : for j in range ( m ) : if a [ i ] [ j ] == ' * ' : r [ i ] += 1 c [ j ] += 1 cnt += 1 r1 = 0 c1 = 0 for i in range ( n ) : if ( f ) : break for j in range ( m ) : d = r [ i ] + c [ j ] if a [ i ] [ j ] == " * " : d -= 1 if d == cnt : f = 1 r1 = i c1 = j break NEW_LINE

import math , sys , bisect , heapqfrom collections import defaultdict , Counter , dequefrom itertools import groupby , accumulate NEW_LINE


import java . util . * ; public class cowsAndPokerGame { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; int a [ ] = new int [ 26 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { a [ s . charAt ( i ) - ' A ' ] ++ ; } if ( a [ 8 ] == 0 ) { System . out . println ( a [ 0 ] ) ; } else if ( a [ 8 ] == 1 ) { System . out . println ( "1" ) ; } else if ( a [ 8 ] > 1 ) { System . out . println ( "0" ) ; } } }

import java . util . * ; import java . lang . * ; import java . io . * ;   public class Cow_and_poker {   public static void main ( String [ ] args ) throws java . lang . Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int t = Integer . parseInt ( br . readLine ( ) ) , c1 = 0 , c2 = 0 , c3 = 0 ; char c [ ] = br . readLine ( ) . toCharArray ( ) ; for ( int i = 0 ; i < t ; i ++ ) { if ( c [ i ] == ' A ' ) ++ c1 ; else if ( c [ i ] == ' I ' ) ++ c2 ; } System . out . println ( c2 == 1 ? 1 : c2 > 1 ? 0 : c1 ) ; }   }

import java . util . Scanner ;   public class Codeforces284B { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int kol = 0 ; int wrong = 0 ; in . nextLine ( ) ; String s = in . nextLine ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == ' I ' ) { wrong ++ ; } if ( s . charAt ( i ) == ' A ' ) { kol ++ ; } if ( wrong > 1 ) { break ; } } if ( wrong > 1 ) { System . out . println ( 0 ) ; } else { if ( wrong == 1 ) { System . out . println ( 1 ) ; } else { System . out . println ( kol ) ; } } } }

import java . io . * ; import java . math . BigDecimal ; import java . math . BigInteger ; import java . util . * ; import java . util . Comparator ;   public class scratch_25 { static class Reader { static BufferedReader reader ; static StringTokenizer tokenizer ;   static void init ( InputStream input ) { reader = new BufferedReader ( new InputStreamReader ( input ) ) ; tokenizer = new StringTokenizer ( " " ) ; }   static String next ( ) throws IOException { while ( ! tokenizer . hasMoreTokens ( ) ) {

def poker_cow ( n , seq ) : total = 0 ref = { " A " : 0 , " I " : 0 , " F " : 0 } for x in seq : ref [ x ] += 1 if ref [ " I " ] == 0 : return ref [ " A " ] elif ref [ " I " ] == 1 : return ref [ " I " ] else : return 0                     n = int ( input ( ) ) seq = input ( )   print ( poker_cow ( n , seq ) ) NEW_LINE

n = int ( input ( ) ) s = input ( )   A = 0 I = 0 for i in range ( n ) : if s [ i ] == ' A ' : A += 1 elif s [ i ] == ' I ' : I += 1   if I > 1 : print ( 0 ) elif I == 1 : print ( 1 ) else : print ( A ) NEW_LINE

n = int ( input ( ) ) s = input ( ) a = s . count ( " I " ) if a == 1 : print ( 1 ) elif a > 1 : print ( 0 ) else : b = s . count ( " A " ) print ( b ) NEW_LINE

from collections import Countert = int ( input ( ) ) arr = list ( input ( ) )   c = Counter ( arr ) if c [ ' I ' ] == 0 : res = c [ ' A ' ] elif c [ ' I ' ] == 1 : res = 1 else : res = 0 print ( res ) NEW_LINE

n = int ( input ( ) ) s = input ( ) koli = 0 kola = 0 for i in range ( n ) : if s [ i ] == ' I ' : koli += 1 if s [ i ] == ' A ' : kola += 1 if koli > 1 : print ( 0 ) exit ( ) if koli == 1 : print ( 1 ) exit ( ) print ( kola ) NEW_LINE


import java . util . Scanner ; import java . util . StringTokenizer ;   public class FreeIcecream { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String line = scanner . nextLine ( ) ;   StringTokenizer tokenizer = new StringTokenizer ( line ) ; long rowCount = Long . parseLong ( tokenizer . nextToken ( ) ) ; long begin = Long . parseLong ( tokenizer . nextToken ( ) ) ;    long currentStock = begin ; long distressedKid = 0 ; for ( long i = 0 ; i < rowCount ; i ++ ) { String row = scanner . nextLine ( ) ;   String [ ] s = row . split ( " ▁ " ) ; long request = Long . parseLong ( s [ 1 ] ) ; if ( s [ 0 ] . equalsIgnoreCase ( " + " ) ) { currentStock += request ; } else { if ( currentStock < request ) { distressedKid ++ ; } else { currentStock -= request ; } } } System . out . println ( currentStock + " ▁ " + distressedKid ) ; } }

import java . util . Scanner ; public class sol { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; long x = in . nextInt ( ) ; int distressed = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String q = in . next ( ) ; long d = in . nextInt ( ) ; if ( q . charAt ( 0 ) == ' + ' ) x += d ; else { if ( d > x ) { distressed ++ ; } else { x -= d ; } } } System . out . println ( x + " ▁ " + distressed ) ; } }

import java . util . * ; import java . io . * ;   public class FreeIceCream { public static void main ( String [ ] args ) { FastReader reader = new FastReader ( ) ;   int n = reader . nextInt ( ) ; long x = reader . nextLong ( ) ; int distressedKids = 0 ; long total = x ;   for ( int i = 0 ; i < n ; i ++ ) { String charac = reader . next ( ) ; int iceCreams = reader . nextInt ( ) ;   if ( charac . equals ( " + " ) ) { total += iceCreams ; } else if ( charac . equals ( " - " ) ) { if ( total >= iceCreams ) { total -= iceCreams ; } else { distressedKids ++ ; } } } System . out . println ( total + " ▁ " + distressedKids ) ; }   static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }

import java . util . Scanner ;   public class A686 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; long x = scanner . nextLong ( ) , distress = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String sym = scanner . next ( ) ; int d = scanner . nextInt ( ) ; if ( sym . equals ( " + " ) ) { x += d ; } if ( sym . equals ( " - " ) ) { x -= d ; if ( x < 0 ) { x += d ; distress ++ ; } } } System . out . println ( x + " ▁ " + distress ) ; } }

import java . math . BigInteger ; import java . util . Scanner ;   public class FreeIceCream { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; long x = scanner . nextInt ( ) ; scanner . nextLine ( ) ; BigInteger store = BigInteger . valueOf ( x ) ; int distCount = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String inst = scanner . nextLine ( ) ; char op = inst . charAt ( 0 ) ; long num = Integer . parseInt ( inst . substring ( 2 ) ) ; if ( op == ' - ' ) { if ( store . longValue ( ) >= num ) store = store . subtract ( BigInteger . valueOf ( num ) ) ; else distCount ++ ; } else store = store . add ( BigInteger . valueOf ( num ) ) ; } System . out . printf ( " % d ▁ % d " , store . longValue ( ) , distCount ) ; } }

n , x = map ( int , input ( ) . split ( ) ) a = 0   for i in range ( n ) : q , w = input ( ) . split ( ) w = int ( w ) if ( q == ' + ' ) : x += w else : if ( x >= w ) : x -= w else : a += 1   print ( x , a ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) )   dit = 0   for i in range ( n ) : val , ice = input ( ) . split ( ) ice = int ( ice ) if ( val == ' + ' ) : k += ice else : if ( ice > k ) : dit += 1 else : k -= ice   print ( k , dit ) NEW_LINE

n , x = [ int ( i ) for i in input ( ) . split ( ) ] b = 0 for i in range ( n ) : a = input ( ) if ' + ' in a : x += int ( a [ 2 : ] ) else : if int ( a [ 2 : ] ) > x : b += 1 else : x -= int ( a [ 2 : ] ) print ( x , b ) NEW_LINE

n , x = [ int ( i ) for i in input ( ) . split ( ) ] c = 0 for _ in range ( n ) : op , num = [ i for i in input ( ) . split ( ) ] num = int ( num ) if op == ' + ' : x += num elif x >= num : x -= num else : c += 1 print ( x , c ) NEW_LINE

n , x = map ( int , input ( ) . split ( ) ) ; s = 0 for _ in ' ▁ ' * n : d = int ( input ( ) . replace ( ' ▁ ' , ' ' ) ) if x + d < 0 : s += 1 else : x += dprint ( x , s ) NEW_LINE


import java . util . * ; import java . io . * ; public class albaaaai {   static ArrayList < point > adj [ ] ; static boolean visited [ ] ; static int distance [ ] [ ] ; static int n ; public static void Bfs ( int nn ) { visited = new boolean [ n ] ; Queue < Integer > q = new LinkedList < Integer > ( ) ; q . add ( nn ) ; visited [ nn ] = true ; while ( ! q . isEmpty ( ) ) { int node = q . poll ( ) ; for ( int i = 0 ; i < adj [ node ] . size ( ) ; i ++ ) { if ( ! visited [ adj [ node ] . get ( i ) . x ] ) { visited [ adj [ node ] . get ( i ) . x ] = true ; distance [ nn ] [ adj [ node ] . get ( i ) . x ] = distance [ nn ] [ node ] + adj [ node ] . get ( i ) . y ;

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

f = lambda : map ( int , input ( ) . split ( ) ) n , m = f ( ) p = [ ] for i in range ( m ) : a , b = f ( ) p . append ( ( a , 1 - b , i ) ) p . sort ( ) k = j = 0 s = [ 0 ] * mu , v = 1 , 3 for a , b , i in p : if not b : k += j s [ i ] = ( j + 1 , j + 2 ) j += 1 elif k : k -= 1 s [ i ] = ( u , v ) if v - u - 2 : u += 1 else : u , v = 1 , v + 1 else : print ( - 1 ) exit ( 0 ) for x , y in s : print ( x , y ) NEW_LINE


import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class pb1 { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int d = in . nextInt ( ) ; int m = in . nextInt ( ) ; ArrayList < Integer > a = new ArrayList < > ( ) ; ArrayList < Integer > b = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int v = in . nextInt ( ) ; if ( v <= m ) b . add ( v ) ; else a . add ( v ) ; } Collections . sort ( a ) ; Collections . sort ( b ) ; long [ ] apref = new long [ a . size ( ) + 1 ] ; long [ ] bpref = new long [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { if ( i <= a . size ( ) ) { apref [ i ] = apref [ i - 1 ] + a . get ( a . size ( ) - i ) ; } if ( i <= b . size ( ) ) { bpref [ i ] = bpref [ i - 1 ] + b . get ( b . size ( ) - i ) ; } else bpref [ i ] = bpref [ i - 1 ] ; } if ( a . size ( ) == 0 ) System . out . println ( bpref [ n ] ) ; else { long ans = 0 ; for ( int ai = 1 ; ai <= a . size ( ) && ( ai - 1 ) * ( d + 1 ) + 1 <= n ; ai ++ ) { ans = Math . max ( ans , apref [ ai ] + bpref [ n - ( ai - 1 ) * ( d + 1 ) - 1 ] ) ; } System . out . println ( ans ) ; } in . close ( ) ; } }

def solve ( ) : NEW_LINE INDENT input_str = input ( ) . split ( ) NEW_LINE n , d , m = int ( input_str [ 0 ] ) , int ( input_str [ 1 ] ) , int ( input_str [ 2 ] ) NEW_LINE a = [ 0 ] + [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE a [ 1 : ] = sorted ( a [ 1 : ] , reverse = True ) NEW_LINE muzzle_days_cnt = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if a [ i ] > m : NEW_LINE INDENT muzzle_days_cnt += 1 NEW_LINE DEDENT a [ i ] += a [ i - 1 ] NEW_LINE DEDENT ans = 0 NEW_LINE if muzzle_days_cnt == 0 : NEW_LINE INDENT print ( a [ n ] ) NEW_LINE return 0 NEW_LINE DEDENT for i in range ( 1 , muzzle_days_cnt + 1 ) : NEW_LINE INDENT days_left = n - ( ( i - 1 ) * ( d + 1 ) + 1 ) NEW_LINE if days_left >= 0 : NEW_LINE INDENT ans = max ( ans , ( a [ min ( n , muzzle_days_cnt + days_left ) ] - a [ muzzle_days_cnt ] ) + a [ i ] ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE return 0 NEW_LINE DEDENT solve ( ) NEW_LINE

n , d , m = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE days = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE days . sort ( reverse = True ) NEW_LINE smaller = [ i for i in days if i <= m ] NEW_LINE larger = [ i for i in days if i > m ] NEW_LINE highest = 0 NEW_LINE current = 0 NEW_LINE prefix_sums = [ 0 ] * ( 1 + len ( larger ) ) NEW_LINE for i in range ( 0 , len ( larger ) ) : NEW_LINE INDENT prefix_sums [ i + 1 ] = prefix_sums [ i ] + larger [ i ] NEW_LINE DEDENT prefix_sums2 = [ 0 ] * ( 1 + len ( smaller ) ) NEW_LINE for i in range ( 0 , len ( smaller ) ) : NEW_LINE INDENT prefix_sums2 [ i + 1 ] = prefix_sums2 [ i ] + smaller [ i ] NEW_LINE DEDENT if n == len ( smaller ) : NEW_LINE INDENT print ( sum ( smaller ) ) NEW_LINE DEDENT else : NEW_LINE INDENT for x in range ( 1 , len ( prefix_sums ) ) : NEW_LINE INDENT small_remaining = n - ( x - 1 ) * ( d + 1 ) - 1 NEW_LINE if small_remaining < 0 : NEW_LINE INDENT break NEW_LINE DEDENT if small_remaining >= len ( prefix_sums2 ) : NEW_LINE INDENT if small_remaining - len ( prefix_sums2 ) > d : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT highest = max ( highest , prefix_sums [ x ] + prefix_sums2 [ - 1 ] ) NEW_LINE continue NEW_LINE DEDENT DEDENT current = prefix_sums [ x ] + prefix_sums2 [ small_remaining ] NEW_LINE highest = max ( current , highest ) NEW_LINE DEDENT print ( highest ) NEW_LINE DEDENT

def to_int ( s ) : NEW_LINE INDENT return int ( s ) NEW_LINE DEDENT ndm = list ( map ( to_int , input ( ) . split ( ' ▁ ' ) ) ) NEW_LINE n = ndm [ 0 ] NEW_LINE d = ndm [ 1 ] NEW_LINE m = ndm [ 2 ] NEW_LINE values = list ( map ( to_int , input ( ) . split ( ' ▁ ' ) ) ) NEW_LINE good = [ ] NEW_LINE bad = [ ] NEW_LINE for v in values : NEW_LINE INDENT if v <= m : NEW_LINE INDENT good . append ( v ) NEW_LINE DEDENT else : NEW_LINE INDENT bad . append ( v ) NEW_LINE DEDENT DEDENT good . sort ( reverse = True ) NEW_LINE bad . sort ( reverse = True ) NEW_LINE goodSums = [ 0 ] NEW_LINE for i in good : NEW_LINE INDENT goodSums . append ( goodSums [ - 1 ] + i ) NEW_LINE DEDENT if len ( bad ) == 0 : NEW_LINE INDENT print ( goodSums [ - 1 ] ) NEW_LINE exit ( ) NEW_LINE DEDENT badSums = [ 0 ] NEW_LINE for i in bad : NEW_LINE INDENT badSums . append ( badSums [ - 1 ] + i ) NEW_LINE DEDENT sum = 0 NEW_LINE minGood = n - ( ( len ( bad ) - 1 ) * ( d + 1 ) + 1 ) NEW_LINE if minGood < 0 : NEW_LINE INDENT minGood = 0 NEW_LINE DEDENT for i in range ( minGood , len ( goodSums ) ) : NEW_LINE INDENT nLeft = n - i NEW_LINE exceed = nLeft // ( d + 1 ) NEW_LINE if not nLeft % ( d + 1 ) == 0 : NEW_LINE INDENT exceed += 1 NEW_LINE DEDENT sum = max ( sum , goodSums [ i ] + badSums [ exceed ] ) NEW_LINE DEDENT print ( sum ) NEW_LINE

import sys NEW_LINE input = sys . stdin . readline NEW_LINE def getInts ( ) : NEW_LINE INDENT return [ int ( s ) for s in input ( ) . split ( ) ] NEW_LINE DEDENT def getInt ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT def getStrs ( ) : NEW_LINE INDENT return [ s for s in input ( ) . split ( ) ] NEW_LINE DEDENT def getStr ( ) : NEW_LINE INDENT return input ( ) . strip ( ) NEW_LINE DEDENT def listStr ( ) : NEW_LINE INDENT return list ( input ( ) . strip ( ) ) NEW_LINE DEDENT import collections as col NEW_LINE import math NEW_LINE def solve ( ) : NEW_LINE INDENT N , D , M = getInts ( ) NEW_LINE A = getInts ( ) NEW_LINE A . sort ( reverse = True ) NEW_LINE if N == 1 or A [ 0 ] <= M : NEW_LINE INDENT return sum ( A ) NEW_LINE DEDENT safe , dangerous = [ ] , [ ] NEW_LINE for a in A : NEW_LINE INDENT if a <= M : NEW_LINE INDENT safe . append ( a ) NEW_LINE DEDENT else : NEW_LINE INDENT dangerous . append ( a ) NEW_LINE DEDENT DEDENT safe_pref = [ 0 ] NEW_LINE for s in safe : NEW_LINE INDENT safe_pref . append ( safe_pref [ - 1 ] + s ) NEW_LINE DEDENT dang_pref = [ 0 ] NEW_LINE for d in dangerous : NEW_LINE INDENT dang_pref . append ( dang_pref [ - 1 ] + d ) NEW_LINE DEDENT best = 0 NEW_LINE for x in range ( 1 , min ( ( N - 1 ) // ( D + 1 ) + 2 , len ( dang_pref ) ) ) : NEW_LINE INDENT safe_num = min ( N - x - ( x - 1 ) * D , len ( safe_pref ) - 1 ) NEW_LINE best = max ( best , dang_pref [ x ] + safe_pref [ safe_num ] ) NEW_LINE DEDENT return best NEW_LINE DEDENT print ( solve ( ) ) NEW_LINE

def main ( ) : NEW_LINE INDENT n , day , mood = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE out = [ ] NEW_LINE safe = [ ] NEW_LINE for v in a : NEW_LINE INDENT if v <= mood : NEW_LINE INDENT safe . append ( v ) NEW_LINE DEDENT else : NEW_LINE INDENT out . append ( v ) NEW_LINE DEDENT DEDENT safe . sort ( reverse = True ) NEW_LINE out . sort ( reverse = True ) NEW_LINE if not out : NEW_LINE INDENT print ( sum ( safe ) ) NEW_LINE return NEW_LINE DEDENT safe . insert ( 0 , 0 ) NEW_LINE out . insert ( 0 , 0 ) NEW_LINE for i in range ( 1 , len ( safe ) ) : NEW_LINE INDENT safe [ i ] += safe [ i - 1 ] NEW_LINE DEDENT for i in range ( 1 , len ( out ) ) : NEW_LINE INDENT out [ i ] += out [ i - 1 ] NEW_LINE DEDENT ans = 0 NEW_LINE for l in range ( len ( out ) ) : NEW_LINE INDENT if l == 0 : NEW_LINE INDENT ans = max ( ans , safe [ min ( n , len ( safe ) - 1 ) ] ) NEW_LINE DEDENT else : NEW_LINE INDENT possible = n - 1 - ( day + 1 ) * ( l - 1 ) NEW_LINE if possible >= 0 : NEW_LINE INDENT ans = max ( ans , safe [ min ( possible , len ( safe ) - 1 ) ] + out [ l ] ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE return NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


import java . io . PrintWriter ; import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int n = in . nextInt ( ) ; int pre = 0 ; long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int input = in . nextInt ( ) ; sum += Math . abs ( input - pre ) ; pre = input ; } pw . println ( sum ) ;   pw . close ( ) ; }   }

import java . io . * ; import java . util . * ;   import static java . lang . Math . * ;   public class Main {   public static void main ( String [ ] args ) throws IOException { FastReader in = new FastReader ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int n = in . nextInt ( ) ; long [ ] arr = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = in . nextLong ( ) ; pw . println ( solve ( arr , n ) ) ; pw . close ( ) ; }   static long solve ( long [ ] arr , int n ) { long res = abs ( arr [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { res += abs ( arr [ i ] - arr [ i - 1 ] ) ;

import java . util . Scanner ;   public class WilburAndArray {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long prev , curr ; prev = sc . nextInt ( ) ; long count = Math . abs ( prev ) ; for ( int i = 1 ; i < n ; i ++ ) { curr = sc . nextInt ( ) ; count += Math . abs ( prev - curr ) ; prev = curr ; } System . out . println ( count ) ; sc . close ( ) ; } }

import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ;   public class pblm3 { static int sum ; public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int m = sc . nextInt ( ) ; int [ ] ar = new int [ m ] ; sum = 0 ; for ( int i = 0 ; i < m ; i ++ ) ar [ i ] = sc . nextInt ( ) ; System . out . println ( ( long ) findChange ( ar ) ) ; } public static long findChange ( int [ ] ar ) { long cur = 0 , steps = 0 ; for ( int i = 0 ; i < ar . length ; i ++ ) { long curchange = 0 ; if ( cur == 0 ) cur = curchange = - 1 * ar [ i ] ; else { curchange = cur + ar [ i ] ; if ( curchange == 0 ) continue ; else cur -= curchange ; }

n = int ( input ( ) ) a = [ int ( x ) for x in input ( ) . split ( ) ] c = sorted ( a ) if c == a : print ( c [ n - 1 ] ) else : count = 0 for i in range ( n ) : if i == 0 : count += abs ( a [ 0 ] ) else : count += abs ( a [ i - 1 ] - a [ i ] ) print ( count ) NEW_LINE

n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) s = sum ( abs ( arr [ i ] - arr [ i - 1 ] ) for i in range ( 1 , n ) ) print ( s + abs ( arr [ 0 ] ) ) NEW_LINE

n = int ( input ( ) ) b = list ( map ( int , input ( ) . split ( ) ) ) a = [ 0 ] * ncount = abs ( b [ 0 ] ) for i in range ( 1 , n ) : count += abs ( b [ i ] - b [ i - 1 ] ) print ( count ) NEW_LINE

n = int ( input ( ) ) a = [ int ( i ) for i in input ( ) . split ( ) ] s = abs ( a [ 0 ] )   for i in range ( 1 , n ) : s += abs ( a [ i ] - a [ i - 1 ] )   print ( s ) NEW_LINE

n = int ( input ( ) ) li = list ( map ( int , input ( ) . split ( ) ) ) st = Falseres = 0 for i in range ( n - 1 ) : if i == 0 : res += abs ( li [ i ] ) res += abs ( li [ i ] - li [ i + 1 ] ) print ( res ) NEW_LINE