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 ;


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 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


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 ;

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


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 . * ; 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 ) {


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 ( ) ;

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 . 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 ( ) ;


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 ) ;

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 . 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 ;


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" ) ; } } }

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 . 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 ;


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 ( ) ) ; }   } }

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 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" ) ; } } }   }


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 ) ;

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 . 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 ) ; } }


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 ) ] ;

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 . 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 ( ) ;


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 ) ) ; } } }

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 ; 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 ( ) ;


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

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 . 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 ] ;


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" ) ; } } }

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 . * ; 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 ( ) ) {


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 ) ; } }

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 . 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 ) ; } }


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 ( ) ; }   }

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


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 ; }


import java . util . * ;   public class LittlePigsAndWolves_B {   public static boolean isValid ( int n , int m , int x , int y ) { if ( x >= 0 && x <= n - 1 && y >= 0 && y <= m - 1 ) { return true ; } return false ; } public static void main ( String [ ] args ) {

n , m = map ( int , input ( ) . strip ( ) . split ( ) ) grid = [ list ( input ( ) . strip ( ) ) for _ in range ( n ) ] valid = lambda x , y : x >= 0 and y >= 0 and x < n and y < mans = 0 directions = [ [ 1 , 0 ] , [ 0 , 1 ] , [ - 1 , 0 ] , [ 0 , - 1 ] ] for i in range ( n ) : for j in range ( m ) : if grid [ i ] [ j ] == ' W ' : NEW_LINE


n , m = list ( map ( int , input ( ) . split ( ) ) ) a = [ ] for i in range ( n ) : a . append ( [ ] ) c = input ( ) for j in range ( m ) : a [ i ] . append ( c [ j ] ) b = 0 for i in range ( n ) : for j in range ( m ) : if a [ i ] [ j ] == ' P ' : if i > 0 and a [ i - 1 ] [ j ] == ' W ' : b += 1 a [ i - 1 ] [ j ] = ' . ' if i < n - 1 and a [ i + 1 ] [ j ] == ' W ' : b += 1 a [ i + 1 ] [ j ] = ' . ' if j > 0 and a [ i ] [ j - 1 ] == ' W ' : b += 1 a [ i ] [ j - 1 ] = ' . ' if j < m - 1 and a [ i ] [ j + 1 ] == ' W ' : b += 1 a [ i ] [ j + 1 ] = ' . ' print ( b ) NEW_LINE


m , n = map ( int , input ( ) . split ( ) ) a = [ input ( ) for _ in [ 0 ] * m ] y = [ - 1 , 0 , 1 , 0 ] x = [ 0 , - 1 , 0 , 1 ] r = 0 for i in range ( m ) : for j in range ( n ) : if a [ i ] [ j ] == ' W ' : for k in range ( 4 ) : u = i + y [ k ] v = j + x [ k ] if u >= 0 and v >= 0 and u < m and v < n and a [ u ] [ v ] == ' P ' : r += 1 breakprint ( r ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) ) grid = [ ] res = 0 def findPig ( X , Y ) : global res point = grid [ Y ] [ X ] found = False px , py = - 1 , - 1 if Y + 1 < n : if grid [ Y + 1 ] [ X ] == " P " : found = True px , py = X , Y + 1 if not found and Y - 1 >= 0 : if grid [ Y - 1 ] [ X ] == " P " : found = True px , py = X , Y - 1 if not found and X + 1 < m : if grid [ Y ] [ X + 1 ] == " P " : found = True px , py = X + 1 , Y if not found and X - 1 >= 0 : if grid [ Y ] [ X - 1 ] == " P " : found = True px , py = X - 1 , Y if found : grid [ Y ] [ X ] = " . " grid [ py ] [ px ] = " . " res += 1 for i in range ( n ) : grid . append ( list ( input ( ) ) )   for y in range ( n ) : for x in range ( m ) : if grid [ y ] [ x ] == ' W ' : findPig ( x , y ) print ( res ) NEW_LINE


import java . lang . * ; import java . util . * ;   public class Abhishek {   public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; char [ ] [ ] a = new char [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . next ( ) . toCharArray ( ) ; } int c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( a [ i ] [ j ] == ' P ' ) { if ( j != 0 ) { if ( a [ i ] [ j - 1 ] == ' W ' ) { c ++ ; a [ i ] [ j - 1 ] = ' . ' ; } } if ( j != m - 1 ) { if ( a [ i ] [ j + 1 ] == ' W ' ) { c ++ ; a [ i ] [ j + 1 ] = ' . ' ; } } if ( i != 0 ) { if ( a [ i - 1 ] [ j ] == ' W ' ) { c ++ ; a [ i - 1 ] [ j ] = ' . ' ; } } if ( i != n - 1 ) { if ( a [ i + 1 ] [ j ] == ' W ' ) { c ++ ; a [ i + 1 ] [ j ] = ' . ' ; } } } }   } System . out . println ( c ) ;   }   }


import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; import java . lang . Math ; public class Account { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; sc . nextLine ( ) ; char [ ] [ ] mat = new char [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { mat [ i ] = ( sc . nextLine ( ) ) . toCharArray ( ) ; } int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( mat [ i ] [ j ] == ' P ' ) { if ( i > 0 ) { if ( mat [ i - 1 ] [ j ] == ' W ' ) { count ++ ; mat [ i - 1 ] [ j ] = ' . ' ; continue ; } } if ( i < n - 1 ) { if ( mat [ i + 1 ] [ j ] == ' W ' ) { count ++ ; mat [ i + 1 ] [ j ] = ' . ' ; continue ; } } if ( j > 0 ) { if ( mat [ i ] [ j - 1 ] == ' W ' ) { count ++ ; mat [ i ] [ j - 1 ] = ' . ' ; continue ; } } if ( j < m - 1 ) { if ( mat [ i ] [ j + 1 ] == ' W ' ) { count ++ ; mat [ i ] [ j + 1 ] = ' . ' ; continue ; } } } } } System . out . println ( count ) ; } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class WolfPigSlaughter { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( reader . readLine ( ) ) ;   int n = Integer . parseInt ( st . nextToken ( ) ) ; int m = Integer . parseInt ( st . nextToken ( ) ) ;   String [ ] pos = new String [ n ] ;   for ( int i = 0 ; i < n ; i ++ ) pos [ i ] = reader . readLine ( ) ;   int death = 0 ;   for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( pos [ i ] . charAt ( j ) == ' W ' ) { if ( i > 0 && pos [ i - 1 ] . charAt ( j ) == ' P ' ) death ++ ; else if ( i < n - 1 && pos [ i + 1 ] . charAt ( j ) == ' P ' ) death ++ ; else if ( j > 0 && pos [ i ] . charAt ( j - 1 ) == ' P ' ) death ++ ; else if ( j < m - 1 && pos [ i ] . charAt ( j + 1 ) == ' P ' ) death ++ ; } } }   System . out . println ( death ) ; } }


import java . util . * ; public class LittlePigsAndWolves { public static void main ( String arg [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ;   char [ ] [ ] ar1 = new char [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { char [ ] line = sc . next ( ) . toCharArray ( ) ; for ( int j = 0 ; j < m ; j ++ ) { ar1 [ i ] [ j ] = line [ j ] ; } }   int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( ar1 [ i ] [ j ] == ' W ' ) { if ( j - 1 >= 0 && ar1 [ i ] [ j - 1 ] == ' P ' ) { ar1 [ i ] [ j - 1 ] = ' . ' ; res ++ ; } else if ( i - 1 >= 0 && ar1 [ i - 1 ] [ j ] == ' P ' ) { ar1 [ i - 1 ] [ j ] = ' . ' ; res ++ ; } else if ( j + 1 < m && ar1 [ i ] [ j + 1 ] == ' P ' ) { ar1 [ i ] [ j + 1 ] = ' . ' ; res ++ ; } else if ( i + 1 < n && ar1 [ i + 1 ] [ j ] == ' P ' ) { ar1 [ i + 1 ] [ j ] = ' . ' ; res ++ ; }   }   } }    System . out . println ( res ) ;    } }


import java . util . Scanner ; public class Repainting_Streets { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String args [ ] ) { int tc = sc . nextInt ( ) ; for ( int i = 0 ; i < tc ; i ++ ) { int [ ] arr = new int [ 100 ] ; arr = findList ( ) ; System . out . println ( findMin ( arr ) ) ; } } static int [ ] findList ( ) { int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] initial = new int [ n ] ; int output [ ] = new int [ 100 ] ; for ( int i = 0 ; i < n ; i ++ ) { initial [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i <= 100 ; i ++ ) { int days = 0 ; int j = 0 ; while ( true ) { if ( j >= n ) break ; if ( initial [ j ] == i ) { j ++ ; continue ; } else { j = j + k ; days ++ ; } } output [ i - 1 ] = days ; } return output ;   } static int findMin ( int [ ] array ) { int min = array [ 0 ] ; for ( int i = 1 ; i < array . length ; i ++ ) { if ( array [ i ] < min ) min = array [ i ] ; } return min ; }   }

import java . util . Scanner ;   public NEW_LINE class B1415 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t + + ) { int N = in . nextInt ( ) ; int K = in . nextInt ( ) ; int [ ] C = new int [ N ] ; for ( int n = 0 ; n < N ; n + + ) { C [ n ] = in . nextInt ( ) ; } int min = Integer . MAX_VALUE ; for ( int c = 1 ; c <= 100 ; c + + ) { int days = 0 ; int pos = 0 ; while ( pos < N ) { if ( C [ pos ] == c ) { pos + + ; } else { pos += K ; days + + ; } } min = Math . min ( days , min ) ; } System . out . println ( min ) ; } }   } NEW_LINE


import sysfor NEW_LINE _ in range ( int ( input ( ) ) ) : n , k = map ( int , input ( ) . split ( ) ) NEW_LINE li = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE tmp = 0 NEW_LINE res = sys . maxsize NEW_LINE mx = max ( li ) NEW_LINE for i in range ( 1 , mx + 1 ) : tmp = 0 NEW_LINE cnt = 0 NEW_LINE while cnt < n : if NEW_LINE li [ cnt ] != i : tmp += 1 NEW_LINE cnt += k else : cnt += 1 NEW_LINE if tmp < res : res = tmp NEW_LINE print ( res ) NEW_LINE


t = int ( input ( ) ) NEW_LINE for i in range ( t ) : n , k = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE res = [ ] NEW_LINE for i in range ( 1 , 101 ) : j = 0 NEW_LINE c = 0 NEW_LINE while j < n : if NEW_LINE a [ j ] == i : j += 1 else : j += k NEW_LINE c += 1 NEW_LINE res . append ( c ) NEW_LINE print ( min ( res ) ) NEW_LINE


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


import java . util . Scanner ;   public class B1415 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int N = in . nextInt ( ) ; int K = in . nextInt ( ) ; int [ ] C = new int [ N ] ; for ( int n = 0 ; n < N ; n ++ ) { C [ n ] = in . nextInt ( ) ; } int min = Integer . MAX_VALUE ; for ( int c = 1 ; c <= 100 ; c ++ ) { int days = 0 ; int pos = 0 ; while ( pos < N ) { if ( C [ pos ] == c ) { pos ++ ; } else { pos += K ; days ++ ; } } min = Math . min ( days , min ) ; } System . out . println ( min ) ; } }   }


import java . util . * ; public class RoadsideTrees { public static void main ( String arg [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; int i = 0 ; for ( int j = 0 ; j < n ; j ++ ) arr [ j ] = sc . nextInt ( ) ;   int sum = 0 , level = arr [ 0 ] ; sum += arr [ 0 ] ; for ( ; i < n - 1 ; i ++ ) { if ( level == arr [ i ] ) sum ++ ;   if ( i + 1 < n && ( arr [ i ] - arr [ i + 1 ] > 0 ) ) { sum = sum + arr [ i ] - arr [ i + 1 ] + 1 ; level = arr [ i + 1 ] ; } else if ( i + 1 < n && ( arr [ i ] - arr [ i + 1 ] < 0 ) ) { sum = sum + 1 + arr [ i + 1 ] - arr [ i ] ; level = arr [ i + 1 ] ; } else { sum ++ ; } }   if ( level == arr [ i ] ) { sum ++ ; } else { sum = sum + ( arr [ i ] - level ) + 1 ; }   System . out . println ( sum ) ; } }

n = int ( input ( ) ) count = 0 g = int ( input ( ) ) count += g + 1 for i in range ( n - 1 ) : a = int ( input ( ) ) if ( a > g ) : count += a - g + 1 + 1 g = a else : count += g - a + 1 + 1 g = aprint ( count ) NEW_LINE


from __future__ import division , print_functionfrom collections import * from math import * from itertools import * from time import timeimport osimport sysfrom io import BytesIO , IOBase if sys . version_info [ 0 ] < 3 : from __builtin__ import xrange as range from future_builtins import ascii , filter , hex , map , oct , zip ''' Notes : ''' def main ( ) : n = int ( input ( ) ) curr = 1 time = 0 for _ in range ( n ) : height = int ( input ( ) ) time += 1 + abs ( height - curr ) + 1 curr = height print ( time )     NEW_LINE


from __future__ import division , print_functionfrom collections import * from math import * from itertools import * import osimport sysfrom io import BytesIO , IOBase NEW_LINE


for _ in range ( 1 ) : n = int ( input ( ) ) currH = 0 total = 0 for i in range ( n ) : h = int ( input ( ) ) if currH <= h : total += h - currH + 2 currH = h   else : total += currH - h + 2 currH = h   print ( total - 1 ) NEW_LINE


n = int ( input ( ) ) l = [ ] for __ in range ( n ) : a = int ( input ( ) ) l . append ( a )   ans = 2 * n - 1 ans += l [ 0 ]   for i in range ( n - 1 ) : ans += abs ( l [ i + 1 ] - l [ i ] )   print ( ans ) NEW_LINE


import java . util . * ; public class Practice { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] += sc . nextInt ( ) ; } int ans = n + arr [ 0 ] ; for ( int i = 0 ; i < arr . length - 1 ; i ++ ) { ans += Math . abs ( arr [ i + 1 ] - arr [ i ] ) + 1 ; } System . out . println ( ans ) ; } }


import java . util . * ; import java . io . * ;   public class Main {   public static void main ( String [ ] args ) throws IOException {   BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder out = new StringBuilder ( ) ; StringTokenizer tk ;   int oldN = 0 ; int n = Integer . parseInt ( in . readLine ( ) ) ; long minTime = 2 * n - 1 ;   for ( int i = 0 ; i < n ; i ++ ) { int h = Integer . parseInt ( in . readLine ( ) ) ; minTime += Math . abs ( oldN - h ) ; oldN = h ; }   System . out . println ( minTime ) ;   }   }


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


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


import java . util . * ;   public class FoxAndDots {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , x = sc . nextInt ( ) ; int [ ] a = new int [ n ] , b = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int l = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; if ( l > q ) { int t = l ; l = q ; q = t ; } a [ i ] = l ; b [ i ] = q ; } int c = 0 ; int l = a [ 0 ] ; int r = b [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) {   if ( l > b [ i ] || r < a [ i ] ) { System . out . println ( - 1 ) ; System . exit ( 0 ) ; }   l = Math . max ( l , a [ i ] ) ; r = Math . min ( r , b [ i ] ) ; } if ( x < l ) { c = l - x ; } else if ( x > r ) { c = x - r ; } System . out . println ( c ) ; }   }

import sysimport mathclass DictList ( dict ) : def __setitem__ ( self , key , value ) : try : NEW_LINE


l = 0 ; r = 1E4 n , x = map ( int , input ( ) . split ( ) ) for _ in [ 0 ] * n : a , b = sorted ( map ( int , input ( ) . split ( ) ) ) l = max ( l , a ) r = min ( r , b ) print ( [ [ [ x - r , l - x ] [ x < l ] , 0 ] [ l <= x <= r ] , - 1 ] [ l > r ] ) NEW_LINE


import java . lang . * ; import java . util . * ;   public class Abhishek {   public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] [ ] s = new int [ n ] [ 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( a < b ) { s [ i ] [ 0 ] = a ; s [ i ] [ 1 ] = b ; } else { s [ i ] [ 0 ] = b ; s [ i ] [ 1 ] = a ; } } int maxStart = Integer . MIN_VALUE ; int minEnd = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] [ 0 ] > maxStart ) maxStart = s [ i ] [ 0 ] ; if ( s [ i ] [ 1 ] < minEnd ) minEnd = s [ i ] [ 1 ] ; } if ( maxStart > minEnd ) System . out . println ( - 1 ) ; else if ( maxStart < x && x < minEnd ) System . out . println ( 0 ) ; else if ( x <= maxStart ) { System . out . println ( maxStart - x ) ; } else { System . out . println ( x - minEnd ) ; } }   }


# include < bits / stdc ++ . h > using namespace std ; void solve ( ) { int n ; cin >> n ; int mnX = 1e9 , mxY = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { int x , y ; cin >> x >> y ; mnX = min ( mnX , y ) , mxY = max ( mxY , x ) ; } cout << max ( 0 , mxY - mnX ) ; } int main ( ) { int t ; cin >> t ; while ( t -- ) { solve ( ) , cout << endl ; } return 0 ; }

for _ in range ( int ( input ( ) ) ) : mx = 1 mn = 10 ** 9 for o in range ( int ( input ( ) ) ) : l , r = map ( int , input ( ) . split ( ) ) mx = max ( mx , l ) mn = min ( mn , r ) print ( max ( 0 , mx - mn ) ) NEW_LINE


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


t = int ( input ( ) ) for _ in range ( t ) : n = int ( input ( ) ) maxl , minr = 1 , 10 ** 9 for i in range ( n ) : l , r = map ( int , input ( ) . split ( ) ) maxl , minr = max ( maxl , l ) , min ( minr , r ) if maxl <= minr : print ( 0 ) else : print ( maxl - minr ) NEW_LINE


for _ in " ▁ " * int ( int ( input ( ) ) ) : z = 0 ; z1 = 10 ** 9 for i in range ( int ( input ( ) ) ) : a , b = map ( int , input ( ) . split ( ) ) ; z = max ( a , z ) ; z1 = min ( b , z1 ) print ( max ( 0 , z - z1 ) ) NEW_LINE


t = int ( input ( ) ) left = [ ] right = [ ] for i in range ( t ) : n = int ( input ( ) ) for j in range ( n ) : l , r = map ( int , input ( ) . split ( ) ) left . append ( l ) right . append ( r ) if ( max ( left ) - min ( right ) ) > 0 : print ( max ( left ) - min ( right ) ) else : print ( 0 ) left . clear ( ) right . clear ( ) NEW_LINE


# include < iostream > # include < vector > # include < algorithm > # include < string > # include < cmath > # include < math . h > # define int long long using namespace std ;   int32_t main ( ) { # ifndef ONLINE_JUDGE freopen ( " input . txt " , " r " , stdin ) ; freopen ( " output . txt " , " w " , stdout ) ; # endif int t ; cin >> t ; while ( t -- ) { int n ; cin >> n ; vector < int > a ( n ) ; vector < int > b ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { cin >> a [ i ] ; cin >> b [ i ] ; } sort ( a . begin ( ) , a . end ( ) ) ; sort ( b . begin ( ) , b . end ( ) ) ; int sum = a [ n - 1 ] - b [ 0 ] ; if ( sum > 0 ) cout << sum << endl ; else { cout << 0 << endl ; } } }


import java . io . PrintWriter ; import java . util . Scanner ;   public class MathProblem { static Scanner sc = new Scanner ( System . in ) ; static PrintWriter pw = new PrintWriter ( System . out ) ;   public static void main ( String args [ ] ) { int t = sc . nextInt ( ) ; while ( t -- > 0 ) { solve ( ) ; } }   private static void solve ( ) { int n = sc . nextInt ( ) ; int leftEnd = Integer . MAX_VALUE ; int rightStart = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { int l = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; leftEnd = Math . min ( leftEnd , r ) ; rightStart = Math . max ( rightStart , l ) ; }   int ans = 0 ; if ( leftEnd >= rightStart ) { ans = 0 ; } else { ans = rightStart - leftEnd ; }   System . out . println ( ans ) ; } }


import java . io . * ; import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int m = input . nextInt ( ) ; int a [ ] = new int [ n ] ; StringBuilder ans = new StringBuilder ( ) ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; } for ( int i = 0 ; i < m ; i ++ ) { int l = input . nextInt ( ) ; int r = input . nextInt ( ) ; int x = input . nextInt ( ) ; int count = 0 ; for ( int j = l ; j <= r ; j ++ ) { if ( a [ j - 1 ] < a [ x - 1 ] ) count ++ ; } if ( count == x - l ) ans . append ( " Yes \n " ) ; else ans . append ( " No \n " ) ; } System . out . println ( ans ) ; } }

INDENT import mathfor _ in range ( 1 ) : n , k = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( k ) : cnt = 0 a , b , c = map ( int , input ( ) . split ( ) ) for j in range ( a - 1 , b ) : if l [ j ] < l [ c - 1 ] : cnt += 1 if cnt + a == c : print ( " Yes " ) else : print ( " No " ) NEW_LINE DEDENT


import java . util . Arrays ; import java . util . Scanner ;   public class VladikandComplicatedBook {   public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int in = scan . nextInt ( ) ; a [ i ] = in ;   } q : while ( m -- > 0 ) { int l = scan . nextInt ( ) ; int r = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; int p = a [ x - 1 ] ; int mn = 0 ; int mx = 0 ; for ( int i = l - 1 ; i < x - 1 ; i ++ ) { if ( a [ i ] > p ) { ++ mx ; } } for ( int i = x ; i < r ; i ++ ) { if ( a [ i ] < p ) { ++ mn ; } } if ( mx == mn ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } }   }   }


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 ) ; BVladikAndComplicatedBook solver = new BVladikAndComplicatedBook ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class BVladikAndComplicatedBook { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = in . nextInt ( ) ; while ( m -- > 0 ) { int l = in . nextInt ( ) ; int r = in . nextInt ( ) ; int x = in . nextInt ( ) ; l -- ; r -- ; x -- ; int c = 0 ; for ( int i = l ; i <= r ; i ++ ) { if ( a [ i ] < a [ x ] ) c ++ ; }   if ( c == ( x - l ) ) { out . println ( " Yes " ) ; } else { out . println ( " No " ) ; } } }   }   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 java . util . * ;   public class B { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , q = sc . nextInt ( ) ; int [ ] p = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) p [ i ] = sc . nextInt ( ) - 1 ; while ( q -- > 0 ) { int l = sc . nextInt ( ) - 1 , r = sc . nextInt ( ) , pos = sc . nextInt ( ) - 1 ; int cnt = 0 ; for ( int i = l ; i < r ; i ++ ) if ( p [ i ] < p [ pos ] ) cnt ++ ; System . out . println ( cnt == pos - l ? " Yes " : " No " ) ; } } }


import java . util . Collections ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ;   public class B159 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int N = in . nextInt ( ) ; int M = in . nextInt ( ) ; Map < Integer , Map < Integer , Integer > > map = new HashMap < > ( ) ; Map < Integer , Integer > countMap = new HashMap < > ( ) ; for ( int n = 0 ; n < N ; n ++ ) { int c = in . nextInt ( ) ; int d = in . nextInt ( ) ; Map < Integer , Integer > im = map . get ( d ) ; if ( im == null ) { im = new HashMap < > ( ) ; map . put ( d , im ) ; } int count = im . getOrDefault ( c , 0 ) ; im . put ( c , count + 1 ) ; count = countMap . getOrDefault ( d , 0 ) ; countMap . put ( d , count + 1 ) ; } int [ ] C = new int [ M ] ; int [ ] D = new int [ M ] ; for ( int m = 0 ; m < M ; m ++ ) { C [ m ] = in . nextInt ( ) ; D [ m ] = in . nextInt ( ) ; } int beautiful = 0 ; for ( int m = 0 ; m < M ; m ++ ) { Map < Integer , Integer > im = map . getOrDefault ( D [ m ] , Collections . emptyMap ( ) ) ; int count = im . getOrDefault ( C [ m ] , 0 ) ; if ( count != 0 ) { beautiful ++ ; im . put ( C [ m ] , count - 1 ) ; countMap . put ( D [ m ] , countMap . get ( D [ m ] ) - 1 ) ; D [ m ] = 0 ;

n , m = map ( int , input ( ) . split ( ) ) m1 = { } m2 = { } c1 = { } c2 = { } for i in range ( n ) : x , y = ( map ( int , input ( ) . split ( ) ) ) m1 [ y ] = m1 . get ( y , 0 ) + 1 m2 [ ( x , y ) ] = m2 . get ( ( x , y ) , 0 ) + 1 for i in range ( m ) : x , y = ( map ( int , input ( ) . split ( ) ) ) c1 [ y ] = c1 . get ( y , 0 ) + 1 c2 [ ( x , y ) ] = c2 . get ( ( x , y ) , 0 ) + 1 r1 = 0 r2 = 0 for i in m1 . keys ( ) : if i in c1 . keys ( ) : t1 = m1 [ i ] t2 = c1 [ i ] r1 = r1 + ( min ( t1 , t2 ) )   for i in m2 . keys ( ) : if i in c2 . keys ( ) : t1 = m2 [ i ] t2 = c2 [ i ] r2 = r2 + ( min ( t1 , t2 ) ) print ( r1 , r2 ) NEW_LINE


import sysfrom collections import Countern , m = map ( int , input ( ) . split ( ) ) l1 = [ ] ; l2 = [ ] ; for i in range ( n ) : l1 . append ( input ( ) ) for i in range ( m ) : l2 . append ( input ( ) ) c1 = Counter ( l1 ) c2 = Counter ( l2 ) c = 0 ; s = 0 ; c3 = c1 & c2 NEW_LINE


from collections import Counter   def read_ints ( ) : return tuple ( int ( x ) for x in input ( ) . split ( ) )   def parse_input ( size ) : data = [ read_ints ( ) for _ in range ( size ) ] by_diam = Counter ( size for diam , size in data ) by_color = Counter ( data ) return by_diam , by_color   n , m = read_ints ( ) pens_by_diam , pens_by_color = parse_input ( n ) caps_by_diam , caps_by_color = parse_input ( m ) closed = sum ( ( pens_by_diam & caps_by_diam ) . values ( ) ) beautiful = sum ( ( pens_by_color & caps_by_color ) . values ( ) ) print ( closed , beautiful ) NEW_LINE


from functools import cmp_to_key     def main ( ) : n , m = map ( int , input ( ) . split ( ) ) markers = [ ] caps = [ ]   for _ in range ( n ) : x , y = map ( int , input ( ) . split ( ) ) markers . append ( ( x , y ) )   for _ in range ( m ) : x , y = map ( int , input ( ) . split ( ) ) caps . append ( ( x , y ) )   marker_sizes = dict ( ) cap_sizes = dict ( ) marker_dict = dict ( ) cap_dict = dict ( )   for m in markers : if marker_sizes . get ( m [ 1 ] ) : marker_sizes [ m [ 1 ] ] += 1 else : marker_sizes [ m [ 1 ] ] = 1 if marker_dict . get ( m ) : marker_dict [ m ] += 1 else : marker_dict [ m ] = 1 for c in caps : if cap_sizes . get ( c [ 1 ] ) : cap_sizes [ c [ 1 ] ] += 1 else : cap_sizes [ c [ 1 ] ] = 1 if cap_dict . get ( c ) : cap_dict [ c ] += 1 else : cap_dict [ c ] = 1 ans1 = 0 for s , c1 in marker_sizes . items ( ) : c2 = cap_sizes . get ( s ) if c2 : ans1 += min ( c1 , c2 ) ans2 = 0 for val , freq in marker_dict . items ( ) : x = cap_dict . get ( val ) if x : ans2 += min ( freq , x )   return ' { } ▁ { } ' . format ( ans1 , ans2 )     if __name__ == ' _ _ main _ _ ' : print ( main ( ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ;    public class Solution { public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( ) ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) ; int p [ ] = new int [ 2005 ] ; int q [ ] [ ] = new int [ 1001 ] [ 1001 ] ; for ( int i = 0 ; i < n ; i ++ ) { int x = sc . nextInt ( ) , y = sc . nextInt ( ) ; p [ y ] ++ ; q [ x ] [ y ] ++ ; } int ans1 = 0 , ans2 = 0 ; for ( int i = 0 ; i < m ; i ++ ) { int x = sc . nextInt ( ) , y = sc . nextInt ( ) ; if ( p [ y ] > 0 ) { ans1 ++ ; p [ y ] -- ; } if ( q [ x ] [ y ] > 0 ) { ans2 ++ ; q [ x ] [ y ] -- ; } } System . out . printf ( " % d ▁ % d \n " , ans1 , ans2 ) ; } static class FastScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ; String next ( ) { while ( ! st . hasMoreTokens ( ) ) try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } Long [ ] readArray ( int n ) { Long [ ] a = new Long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextLong ( ) ; return a ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }


import java . io . InputStreamReader ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . math . BigInteger ; import java . io . InputStream ;   public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } }   class TaskA { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int qSize = 0 ; int maxQSize = 0 ; int timeLast = 0 ; int n = in . nextInt ( ) ; for ( int i = 0 ; i < n ; ++ i ) { int time = in . nextInt ( ) ; int am = in . nextInt ( ) ; if ( timeLast <= time ) { qSize = 0 ; } else { qSize = timeLast - time ; } timeLast = Math . max ( time + am , timeLast + am ) ; qSize += am ; maxQSize = Math . max ( maxQSize , qSize ) ; } out . println ( timeLast + " ▁ " + maxQSize ) ; } }   class InputReader { private BufferedReader reader ; private StringTokenizer stt ;   public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) ) ; }   public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { return null ; } }   public String nextString ( ) { while ( stt == null || ! stt . hasMoreTokens ( ) ) { stt = new StringTokenizer ( nextLine ( ) ) ; } return stt . nextToken ( ) ; }   public int nextInt ( ) { return Integer . parseInt ( nextString ( ) ) ; }   }

pt , s , vs = 0 , 0 , 0 for i in range ( int ( input ( ) ) ) : t , c = map ( int , input ( ) . split ( ) ) s = max ( s - ( t - pt ) , 0 ) + c vs = max ( vs , s ) pt = tprint ( pt + s , vs ) NEW_LINE


n = int ( input ( ) )   mt = 0 mq = 0   t = 0 q = 0   for i in range ( n ) : ( ti , ci ) = map ( int , input ( ) . split ( ) ) q = max ( 0 , q - ti + t ) t = ti q += ci mq = max ( mq , q ) mt = t + q   print ( mt , mq ) NEW_LINE


n = int ( input ( ) ) q = max_q = t0 = 0 for i in range ( n ) : t , c = map ( int , input ( ) . split ( ) ) q = max ( 0 , q - t + t0 ) + c if q > max_q : max_q = q t0 = tprint ( t0 + q , max_q ) NEW_LINE


n = int ( input ( ) ) ans , p , s = 0 , 0 , 0 for i in range ( n ) : t , c = map ( int , input ( ) . split ( ) ) s -= min ( s , t - p ) p = t s += c if s > ans : ans = sprint ( p + s , ans ) NEW_LINE


import sysimport math   n = int ( input ( ) )   a , b = list ( map ( int , input ( ) . split ( ) ) ) vmax = bfor i in range ( 1 , n ) : c , d = list ( map ( int , input ( ) . split ( ) ) ) b = max ( 0 , b - ( c - a ) ) a = c b += d vmax = max ( b , vmax )   print ( a + b , vmax ) NEW_LINE


import java . util . * ; import java . math . * ;   public class gfg { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int r = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; String [ ] s = new String [ r ] ; for ( int i = 0 ; i < r ; i ++ ) s [ i ] = sc . next ( ) ; char [ ] [ ] a = new char [ r ] [ c ] ; for ( int i = 0 ; i < r ; i ++ ) { for ( int j = 0 ; j < c ; j ++ ) a [ i ] [ j ] = s [ i ] . charAt ( j ) ; } int er = 0 ; int ec = 0 ; for ( int i = 0 ; i < r ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < c ; j ++ ) { if ( a [ i ] [ j ] == ' . ' ) count ++ ; else break ; } if ( count == c ) er ++ ; } for ( int i = 0 ; i < c ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < r ; j ++ ) { if ( a [ j ] [ i ] == ' . ' ) count ++ ; else break ; } if ( count == r ) ec ++ ; }

import sysimport itertoolsimport collections     def rs ( x = ' ' ) : return sys . stdin . readline ( ) . strip ( ) if len ( x ) == 0 else input ( x ) . strip ( ) def ri ( x = ' ' ) : return int ( rs ( x ) ) def rm ( x = ' ' ) : return map ( str , rs ( x ) . split ( ) ) def rl ( x = ' ' ) : return rs ( x ) . split ( ) def rmi ( x = ' ' ) : return map ( int , rs ( x ) . split ( ) ) def rli ( x = ' ' ) : return [ int ( x ) for x in rs ( x ) . split ( ) ] def println ( val ) : sys . stdout . write ( str ( val ) + ' \n ' )     def solve ( testCase ) : r , c = rmi ( ) grid = [ list ( rs ( ) ) for _ in range ( r ) ] visited = [ [ False for _ in range ( c ) ] for _ in range ( r ) ] ans = 0 for i in range ( r ) : monster = False for j in range ( c ) : if grid [ i ] [ j ] == ' S ' : monster = True break if not monster : for j in range ( c ) : if not visited [ i ] [ j ] : ans += 1 visited [ i ] [ j ] = True for i in range ( c ) : monster = False for j in range ( r ) : if grid [ j ] [ i ] == ' S ' : monster = True break if not monster : for j in range ( r ) : if not visited [ j ] [ i ] : ans += 1 visited [ j ] [ i ] = True print ( ans )     for _ in range ( ri ( ) if 0 else 1 ) : solve ( _ + 1 ) NEW_LINE


r , c = map ( int , input ( ) . split ( ) ) l = [ ] for x1 in range ( r ) : l . append ( list ( str ( input ( ) ) ) ) a = 0 e = [ ] for a1 in range ( r ) : s2 = 0 for a2 in range ( c ) : if l [ a1 ] [ a2 ] == " . " : s2 += 1 if s2 == c : a += s2 e . append ( a1 ) b = 0 f = [ ] for b1 in range ( c ) : s3 = 0 for b2 in range ( r ) : if l [ b2 ] [ b1 ] == " . " : s3 += 1 if s3 == r : b += s3 f . append ( b1 ) print ( a + b - len ( e ) * len ( f ) ) NEW_LINE


row , col = map ( int , input ( ) . split ( ) ) tab = [ [ i for i in input ( ) ] for j in range ( row ) ] num_row = num_col = 0 tab_2 = [ ] for ind , i in enumerate ( tab ) : if ' S ' not in i : num_row += len ( i ) else : tab_2 . append ( i ) tmp = 0 if len ( tab_2 ) == 0 : print ( num_row ) else : for i in range ( len ( tab_2 [ 0 ] ) ) : if tmp == 1 : num_col += len ( tab_2 ) tmp = 0 for j in range ( len ( tab_2 ) ) : if tab_2 [ j ] [ i ] == ' S ' : tmp = 0 break tmp = 1 if tmp == 1 : num_col += len ( tab_2 ) print ( num_row + num_col ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) ) c = 0 s = set ( ) for i in range ( n ) : k = input ( ) if ' S ' not in k : c += 1 continue for j in range ( m ) : if k [ j ] == ' S ' : s . add ( j ) t = ( m - len ( s ) ) * n + c * m - c * ( m - len ( s ) ) print ( t ) NEW_LINE


import java . io . * ; import java . lang . * ; import java . util . ArrayList ;   public class _temp2 { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] st = br . readLine ( ) . split ( " ▁ " ) ; int n = Integer . parseInt ( st [ 0 ] ) ; int m = Integer . parseInt ( st [ 1 ] ) ; ArrayList < Integer > row = new ArrayList < > ( ) ; ArrayList < Integer > col = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { row . add ( i ) ; } for ( int i = 0 ; i < m ; i ++ ) { col . add ( i ) ; } for ( int i = 0 ; i < n ; i ++ ) { st = br . readLine ( ) . split ( " " ) ; for ( int j = 0 ; j < m ; j ++ ) { if ( st [ j ] . equals ( " S " ) ) { row . remove ( new Integer ( i ) ) ; col . remove ( new Integer ( j ) ) ; } } } System . out . println ( ( n * m ) - ( n - row . size ( ) ) * ( m - col . size ( ) ) ) ; } }


import java . util . Scanner ; public class cakeminator { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; int r = s . nextInt ( ) ; int c = s . nextInt ( ) ; int total = r * c ; boolean [ ] row = new boolean [ r ] ; boolean [ ] col = new boolean [ c ] ; s . nextLine ( ) ; int monsC = 0 ; int monsR = 0 ; int k = 0 ; while ( k < r ) { String p = s . nextLine ( ) ; for ( int i = 0 ; i < p . length ( ) ; i ++ ) { if ( p . charAt ( i ) == ' S ' ) { if ( ! row [ k ] ) { monsR ++ ; row [ k ] = true ; } if ( ! col [ i ] ) { monsC ++ ; col [ i ] = true ; } } } k ++ ; } if ( monsC * monsR >= total ) { System . out . println ( 0 ) ; } else { System . out . println ( total - monsC * monsR ) ; } } }


import java . util . * ;   public class Check2 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Long > list = new ArrayList < > ( ) ; for ( long i = 1 ; i <= 1e8 ; i ++ ) { long num = i ; long sum = 0 ; while ( num != 0 ) { long d = num % 10 ; sum += d ; num /= 10 ; } if ( sum == 10 ) { list . add ( i ) ; } if ( list . size ( ) > 10000 ) { break ; } }

def cal ( n ) : s = 0 while n > 0 : s += ( n % 10 ) n //= 10 return s   n = int ( input ( ) ) curr = 1 while n > 0 : curr += 1 if cal ( curr ) == 10 : n -= 1 print ( curr ) NEW_LINE


def find ( num ) : s = 0 while num > 0 : s = s + num % 10 num = num // 10 return sn = int ( input ( ) ) c = 1 num = 19 while c < n : num = num + 9 if find ( num ) == 10 : c = c + 1 print ( num )   NEW_LINE


def is_good ( z ) : t = 0 while z : t += z % 10 z //= 10   return t == 10     n = int ( input ( ) ) dp = [ 0 ] * ndp [ 0 ] = 19   for i in range ( 1 , n ) : s = str ( dp [ i - 1 ] ) m = len ( s ) for j in range ( m - 1 , - 1 , - 1 ) : if s [ j ] != '0' : s = s [ : j ] + s [ j : ] [ : : - 1 ] break   f = 9 NEW_LINE


def digit ( x ) : t = 0 while x : t += x % 10 x = x // 10 return t   k = int ( input ( ) ) x = 19 while k > 1 : x = x + 9 if digit ( x ) == 10 : k -= 1 print ( x ) NEW_LINE


import java . util . Scanner ;   public class _0852PerfectNumber { static int countSum ( int n ) { int sum = 0 ; while ( n > 0 ) { sum += n % 10 ; n = n / 10 ; } return sum ; }   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int n = 0 ; int val = 19 ; int sum = countSum ( val ) ; while ( n < k ) { if ( sum == 10 ) { n ++ ; } val ++ ; sum = countSum ( val ) ; } System . out . println ( val - 1 ) ; }   }


import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int i = 10 , sum = 0 , count = 0 , ans = 0 ; int k = s . nextInt ( ) ; while ( true ) { sum = 0 ; int j = i ; while ( j != 0 ) { int a = j % 10 ; sum = sum + a ; j = j / 10 ; } if ( sum == 10 ) { count ++ ; if ( count == k ) { ans = i ; break ; } } i ++ ; } System . out . println ( ans ) ; } }


import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ;   public class absolute { static int k ; static String ans ; static void process ( char [ ] ch , int cur , int pos ) {