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

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

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

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

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

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


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

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

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


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

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

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

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

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

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

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

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 . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class a { static int [ ] count , count1 , count2 ; static long [ ] arr ; static char [ ] ch , ch1 ; static long [ ] darr , farr ; static Character [ ] [ ] mat , mat1 ; static long x , h ; static long maxl ; static double dec ; static String s ; static long minl ; static int mx = ( int ) 1e6 ; static long mod = 998244353l ;

import java . util . * ; import java . io . * ; public class A { public static void main ( String args [ ] ) { FastScanner in = new FastScanner ( ) ; int t = in . nextInt ( ) ; while ( -- t >= 0 ) { int n = in . nextInt ( ) ; int x = in . nextInt ( ) ; int y = in . nextInt ( ) ; int d = in . nextInt ( ) ; int diff = Math . abs ( x - y ) ; if ( x != y && diff % d != 0 && ( y - 1 ) % d != 0 && ( n - y ) % d != 0 ) System . out . println ( - 1 ) ; else if ( diff % d == 0 ) System . out . println ( diff / d ) ; else { if ( ( y - 1 ) % d == 0 && ( n - y ) % d == 0 ) System . out . println ( Math . min ( ( y - 1 ) / d + ( x - 1 + d - 1 ) / d , ( n - y ) / d + ( n - x + d - 1 ) / d ) ) ; else if ( ( y - 1 ) % d == 0 ) System . out . println ( ( y - 1 ) / d + ( x - 1 + d - 1 ) / d ) ; else System . out . println ( ( n - y ) / d + ( n - x + d - 1 ) / d ) ; } } }

import java . util . * ; import java . lang . * ; import java . io . * ; import java . math . * ;    public class file {

def do ( ) : import math n , x , y , d = map ( int , input ( ) . split ( ) ) x -= 1 y -= 1 n -= 1 res = 10 ** 18 if x == y : print ( 0 ) return if ( y - x ) % d == 0 : print ( abs ( ( y - x ) ) // d ) return   cnt = 0 cnt = math . ceil ( x / d ) if y % d == 0 : cnt += abs ( y // d ) res = min ( res , cnt )   cnt = 0 cnt = math . ceil ( ( n - x ) / d ) if ( n - y ) % d == 0 : cnt += abs ( ( n - y ) // d ) res = min ( res , cnt )   if res == 10 ** 18 : print ( - 1 ) return else : print ( res ) return   qq = int ( input ( ) ) for _ in range ( qq ) : do ( ) NEW_LINE

from math import ceilfor _ in range ( int ( input ( ) ) ) : n , x , y , d = map ( int , input ( ) . split ( ) ) if abs ( x - y ) % d == 0 : print ( abs ( x - y ) // d ) else : ans = 10 ** 18 if ( y - 1 ) % d == 0 : ans = min ( ans , ( y - 1 ) // d + ( x - 1 + d - 1 ) // d ) if ( n - y ) % d == 0 : ans = min ( ans , ( n - y ) // d + ( n - x + d - 1 ) // d ) if ans == 10 ** 18 : print ( - 1 ) else : print ( ans ) NEW_LINE

from math import ceilfor _ in range ( int ( input ( ) ) ) : n , x , y , d = map ( int , input ( ) . split ( ) ) if abs ( x - y ) % d == 0 : print ( abs ( x - y ) // d ) else : ans = 10 ** 18 if ( y - 1 ) % d == 0 : ans = min ( ans , ( y - 1 ) // d + ceil ( ( x - 1 ) / d ) ) if ( n - y ) % d == 0 : ans = min ( ans , ( n - y ) // d + ceil ( ( n - x ) / d ) ) if ans == 10 ** 18 : print ( - 1 ) else : print ( ans ) NEW_LINE


import java . util . * ;   public class Practise {   static int [ ] [ ] dp ;    public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; boolean tt = false ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; if ( a == 1 ) { tt = true ; } } if ( tt ) System . out . println ( - 1 ) ; else System . out . println ( 1 ) ;     } }

import java . util . * ;   public class StackBracket { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int ans = 1 ;    for ( int i = 0 ; i < n ; i ++ ) { int num = sc . nextInt ( ) ; if ( num == 1 ) { ans = - 1 ;

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

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

import java . util . * ; import java . io . * ; public class Main { static int gcd ( int a , int b ) { if ( b == 0 ) { return a ; } return gcd ( b , a % b ) ; } static boolean check ( int n ) { if ( n % 2 == 0 || n % 6 == 0 ) { return false ; } if ( n % 3 == 0 ) { return false ; } for ( int i = 6 ; i * i <= n ; i += 6 ) { if ( n % ( i - 1 ) == 0 || n % ( i + 1 ) == 0 ) return false ; } return true ; }   public static void main ( String [ ] args ) { FastScanner scan = new FastScanner ( ) ; int t = scan . nextInt ( ) ; int a [ ] = new int [ t ] ; for ( int i = 0 ; i < t ; ++ i ) { a [ i ] = scan . nextInt ( ) ; } Arrays . sort ( a ) ; if ( a [ 0 ] == 1 ) { System . out . print ( " - 1" ) ; } else { System . out . print ( 1 ) ; }        } } ; class FastScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ; String next ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } }

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) )   has_1 = False   for i in a : if i == 1 : has_1 = True breakprint ( - 1 if has_1 else 1 ) NEW_LINE

import sysfrom math import sqrt , log , log2 , ceil , log10 , gcd , floor , pow , sin , cos , tan , pi , inf , factorialfrom copy import copy , deepcopyfrom sys import exit , stdin , stdoutfrom collections import Counter , defaultdict , dequefrom itertools import permutationsimport heapqfrom bisect import bisect_left from bisect import bisect_right NEW_LINE

import sysfrom functools import lru_cache , cmp_to_keyfrom heapq import merge , heapify , heappop , heappushfrom math import * from collections import defaultdict as dd , deque , Counter as Cfrom itertools import combinations as comb , permutations as permfrom bisect import bisect_left as bl , bisect_right as br , bisect , insortfrom time import perf_counterfrom fractions import Fractionimport copyfrom copy import deepcopyimport timestarttime = time . time ( ) mod = int ( pow ( 10 , 9 ) + 7 ) mod2 = 998244353   def data ( ) : return sys . stdin . readline ( ) . strip ( ) def out ( * var , end = " \n " ) : sys . stdout . write ( ' ▁ ' . join ( map ( str , var ) ) + end ) def L ( ) : return list ( sp ( ) ) def sl ( ) : return list ( ssp ( ) ) def sp ( ) : return map ( int , data ( ) . split ( ) ) def ssp ( ) : return map ( str , data ( ) . split ( ) ) def l1d ( n , val = 0 ) : return [ val for i in range ( n ) ] def l2d ( n , m , val = 0 ) : return [ l1d ( n , val ) for j in range ( m ) ] try : NEW_LINE

a = input ( ) b = input ( ) . split ( ) if "1" in b : print ( " - 1" ) else : print ( "1" ) NEW_LINE

n = int ( input ( ) ) notes = list ( map ( int , input ( ) . split ( ) ) ) print ( ( 1 , - 1 ) [ min ( notes ) == 1 ] ) NEW_LINE


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

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . StringTokenizer ;   public class Main { static double inc ; static double dec ; public static void main ( String [ ] arg ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int k = Integer . parseInt ( st . nextToken ( ) ) ; double per = ( ( 100 - k ) / 100.0 ) ; int max = 0 ; int [ ] arr = new int [ n ] ; int min = 10001 ; st = new StringTokenizer ( br . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; max = Math . max ( max , arr [ i ] ) ; min = Math . min ( min , arr [ i ] ) ; } double lo = min ; double hi = max ; double ans = lo ; while ( hi - lo > ( double ) 1e-6 ) { double mid = lo + ( hi - lo ) / 2.0 ; check ( arr , mid ) ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . StringTokenizer ;   public class Main { static double inc ; static double dec ; public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int k = Integer . parseInt ( st . nextToken ( ) ) ; double per = ( ( 100 - k ) / 100.0 ) ; int max = 0 ; int [ ] arr = new int [ n ] ; int min = 10001 ; st = new StringTokenizer ( br . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; max = Math . max ( max , arr [ i ] ) ; min = Math . min ( min , arr [ i ] ) ; } double lo = min ; double hi = max ; double ans = lo ; while ( hi - lo > ( double ) 1e-6 ) { double mid = lo + ( hi - lo ) / 2.0 ; check ( arr , mid ) ;

n , k = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE l = 0 NEW_LINE r = 1001 NEW_LINE while r - l > 0.0000001 : m = ( r + l ) / 2 ; plus = 0 NEW_LINE minus = 0 NEW_LINE for i in range ( n ) : if NEW_LINE a [ i ] <= m : plus += m - a [ i ] else : minus += a [ i ] - m NEW_LINE minus = minus * ( 100 - k ) / 100 NEW_LINE if minus >= plus : NEW_LINE INDENT l = m else : NEW_LINE r = mprint ( l ) NEW_LINE DEDENT

n , k = map ( int , input ( ) . split ( ) ) NEW_LINE l = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE l . sort ( reverse = True ) NEW_LINE s = sum ( l ) NEW_LINE s1 = 0 NEW_LINE s2 = sans = 0 NEW_LINE k = 100 - kfor NEW_LINE i in range ( n - 1 ) : NEW_LINE

n , k = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE arr = list ( map ( int , input ( ) . split ( ) ) )   NEW_LINE def bins ( ) : l = 0 NEW_LINE r = 10000000000000 NEW_LINE for i in range ( 100 ) : mid = ( l + r ) / 2 NEW_LINE if f ( mid ) : NEW_LINE INDENT l = mid else : NEW_LINE r = mid NEW_LINE DEDENT print ( l )     NEW_LINE def f ( s ) : sent = 0 NEW_LINE sentR = 0 NEW_LINE for i in range ( n ) : if NEW_LINE arr [ i ] < s : sentR += ( ( s - arr [ i ] ) * 100 ) / ( 100 - k ) elif arr [ i ] > s : sent += arr [ i ] - s NEW_LINE return sent >= sentRbins ( ) NEW_LINE


import java . util . Scanner ;   public class Stock { public static void main ( String [ ] args ) {   Scanner scn = new Scanner ( System . in ) ; int n = scn . nextInt ( ) ; int m = scn . nextInt ( ) ; int r = scn . nextInt ( ) ; int count = 0 ;   int [ ] a = new int [ n ] ; int [ ] b = new int [ m ] ;   for ( int i = 0 ; i < n ; i ++ ) a [ i ] = scn . nextInt ( ) ;   for ( int i = 0 ; i < m ; i ++ ) b [ i ] = scn . nextInt ( ) ;   int mina = a [ 0 ] ; int maxb = b [ 0 ] ;   for ( int i = 0 ; i < n ; i ++ ) mina = Math . min ( mina , a [ i ] ) ;   for ( int i = 0 ; i < m ; i ++ ) maxb = Math . max ( maxb , b [ i ] ) ; if ( maxb < mina ) System . out . println ( r ) ; else System . out . println ( maxb * ( r / mina ) + r % mina ) ;    } }

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

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

import java . util . * ; import java . io . * ; import java . math . * ; public class Main { static void solve ( ) {

import java . util . * ; public class P2 {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; int s [ ] = new int [ n ] ; int b [ ] = new int [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { s [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < m ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } Arrays . sort ( s ) ; Arrays . sort ( b ) ; int f = 0 ; if ( s [ 0 ] >= b [ m - 1 ] ) { System . out . println ( r ) ; } else { int p = r / s [ 0 ] ; int k = r % s [ 0 ] ; f = b [ m - 1 ] * p ; f += k ; System . out . println ( f ) ; } } }

buy , sell , money = map ( int , input ( ) . split ( ) ) minPrice = min ( list ( map ( int , input ( ) . split ( ) ) ) ) maxPrice = max ( list ( map ( int , input ( ) . split ( ) ) ) ) print ( max ( money , ( money // minPrice ) * maxPrice + money % minPrice ) ) NEW_LINE

i = lambda : map ( int , input ( ) . split ( ) ) _ , _ , r = i ( ) s = min ( i ( ) ) b = max ( s , * i ( ) ) print ( r % s + r // s * b ) NEW_LINE

R = int ( input ( ) . split ( ) [ - 1 ] )   best_buy = min ( map ( int , input ( ) . split ( ) ) ) best_sell = max ( map ( int , input ( ) . split ( ) ) )   num_buy = R // best_buy   print ( max ( R , R + ( best_sell - best_buy ) * num_buy ) ) NEW_LINE

N , M , R = map ( int , input ( ) . split ( ) ) S = list ( map ( int , input ( ) . split ( ) ) ) B = list ( map ( int , input ( ) . split ( ) ) ) ms = min ( S ) mb = max ( B ) print ( max ( mb * ( R // ms ) + R % ms , R ) ) NEW_LINE

def solve ( ) : l = list ( map ( int , input ( ) . split ( ) ) ) l2 = list ( map ( int , input ( ) . split ( ) ) ) l3 = list ( map ( int , input ( ) . split ( ) ) ) l2 . sort ( ) l3 . sort ( ) if ( l2 [ 0 ] < l3 [ len ( l3 ) - 1 ] ) : x = int ( l [ 2 ] / l2 [ 0 ] ) * l3 [ len ( l3 ) - 1 ] + ( l [ 2 ] % l2 [ 0 ] ) print ( x ) else : print ( l [ 2 ] ) solve ( ) NEW_LINE


import java . util . * ; public class FairNumber { public static int check ( long n ) { long x = n ; while ( x != 0 ) { if ( x % 10 != 0 && n % ( x % 10 ) != 0 ) return - 1 ; x /= 10 ; } return 1 ; }   public static void main ( String [ ] args ) {

import java . util . Scanner ;   public class B1411 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { long N = in . nextLong ( ) ; while ( ! isFair ( N ) ) N ++ ; System . out . println ( N ) ; } }   private static boolean isFair ( long N ) { long r = N ; while ( r != 0 ) { long digit = r % 10 ; r /= 10 ; if ( digit != 0 && N % digit != 0 ) { return false ; } } return true ; }   }

import java . util . * ; import java . io . * ; import java . math . * ; public class Main {

import java . util . Scanner ;   public class _0685FairNumbers { static long findFair ( long n ) { boolean flag = true ; while ( flag ) { long temp = n ; flag = false ; while ( temp > 0 ) { long val = temp % 10 ; if ( val == 0 ) { temp = temp / 10 ; continue ; } if ( n % val != 0 ) { flag = true ; n ++ ; break ; } temp = temp / 10 ; } } return n ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cases = sc . nextInt ( ) ; while ( cases > 0 ) { long n = sc . nextLong ( ) ; System . out . println ( findFair ( n ) ) ; cases -- ; } }   }

import java . util . * ; public class fair {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int t = in . nextInt ( ) ; while ( t -- > 0 ) { long n = in . nextLong ( ) ; boolean flag = true ; while ( flag ) { String s = String . valueOf ( n ) ; int x = 0 , y = 0 ; if ( s . indexOf ( "2" ) >= 0 ) { x ++ ; if ( n % 2 == 0 ) y ++ ; } if ( s . indexOf ( "2" ) >= 0 ) { x ++ ; if ( n % 2 == 0 ) y ++ ; } if ( s . indexOf ( "3" ) >= 0 ) { x ++ ; if ( n % 3 == 0 ) y ++ ; } if ( s . indexOf ( "4" ) >= 0 ) { x ++ ; if ( n % 4 == 0 ) y ++ ; } if ( s . indexOf ( "5" ) >= 0 ) { x ++ ; if ( n % 5 == 0 ) y ++ ; } if ( s . indexOf ( "6" ) >= 0 ) { x ++ ; if ( n % 6 == 0 ) y ++ ; } if ( s . indexOf ( "7" ) >= 0 ) { x ++ ; if ( n % 7 == 0 ) y ++ ; } if ( s . indexOf ( "8" ) >= 0 ) { x ++ ; if ( n % 8 == 0 ) y ++ ; } if ( s . indexOf ( "9" ) >= 0 ) { x ++ ; if ( n % 9 == 0 ) y ++ ; } if ( x == y ) { System . out . println ( n ) ; flag = false ; } else n ++ ; } }   }   }

import java . util . * ; public NEW_LINE class FairNumber { public static int check ( long n ) { long x = n ; while ( x != 0 ) { if ( x % 10 != 0 & & n % ( x % 10 ) != 0 ) return - 1 ; x /= 10 ; } return 1 ; }   public static void main ( String [ ] args ) { // TODO Auto - generated method stub Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t - -> 0 ) { long n = sc . nextLong ( ) ; while ( true ) { if ( check ( n ) == 1 ) { System . out . println ( n ) ; break ; } else n + + ; } } }   } NEW_LINE

def is_fair ( n ) : nn = n NEW_LINE while n != 0 : d = n % 10 NEW_LINE if d != 0 and nn % d != 0 : return False NEW_LINE n //= 10 NEW_LINE return True   NEW_LINE def solve ( ) : n = int ( input ( ) ) NEW_LINE while not is_fair ( n ) : n += 1 NEW_LINE print ( n )   t = int ( input ( ) ) NEW_LINE for _ in range ( t ) : solve ( ) NEW_LINE

from sys import stdin , stdoutimport NEW_LINE math , bisectfrom NEW_LINE collections NEW_LINE import Counter , deque , defaultdictL = lambda : list ( map ( int , stdin . readline ( ) . strip ( ) . split ( ) ) ) NEW_LINE M = lambda : map ( int , stdin . readline ( ) . strip ( ) . split ( ) ) NEW_LINE I = lambda : int ( stdin . readline ( ) . strip ( ) ) NEW_LINE S = lambda : stdin . readline ( ) . strip ( ) NEW_LINE C = lambda : stdin . readline ( ) . strip ( ) . split ( ) NEW_LINE def pr ( a ) : return ( " " . join ( list ( map ( str , a ) ) ) ) NEW_LINE

import java . util . * ; public NEW_LINE class sol { static Scanner scr = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { // TODO Auto - generated method stub int t = scr . nextInt ( ) ; while ( t - -> 0 ) { solve ( ) ; } } static void solve ( ) { long n = scr . nextLong ( ) ; while ( ! isValid ( n ) ) { n + + ; } System . out . println ( n ) ; } static boolean isValid ( long n ) { long x = n ; while ( x > 0 ) { long mod = x % 10 ; // System . out . print ( mod + " ▁ " ) ; if ( mod != 0 & & n % mod != 0 ) { return false ; } x /= 10 ; } return true ; } } NEW_LINE

def is_just ( num ) : newnum = num NEW_LINE while newnum > 0 : if NEW_LINE newnum % 10 != 0 : NEW_LINE if num % ( newnum % 10 ) != 0 : return False NEW_LINE newnum //= 10 NEW_LINE return True                   t = int ( input ( ) ) NEW_LINE for ti in range ( t ) : n = int ( input ( ) ) NEW_LINE x = n NEW_LINE while not is_just ( x ) : x += 1 NEW_LINE print ( x ) NEW_LINE


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

import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; String ans = " " ; if ( n == 1 || n == 2 ) { ans = " No " ; System . out . println ( ans ) ; } else { ans = " Yes " ; System . out . println ( ans ) ; System . out . print ( n / 2 + " ▁ " ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( i % 2 == 0 ) System . out . print ( i + " ▁ " ) ; } System . out . println ( ) ; System . out . print ( n - n / 2 + " ▁ " ) ; for ( int j = 1 ; j <= n ; j ++ ) { if ( j % 2 != 0 ) System . out . print ( j + " ▁ " ) ; } } } }

n = int ( input ( ) ) if ( n < 3 ) : print ( " No " ) else : print ( " Yes " ) print ( n // 2 , end = " ▁ " ) for i in range ( 2 , n + 1 , 2 ) : print ( i , end = " ▁ " ) print ( ) print ( n - ( n // 2 ) , end = " ▁ " ) for i in range ( 1 , n + 1 , 2 ) : print ( i , end = " ▁ " ) NEW_LINE

n = int ( input ( ) ) if n < 3 : print ( " No " ) else : print ( " Yes " ) print ( 1 , n ) print ( n - 1 , end = " ▁ " ) for i in range ( 1 , n ) : print ( i , end = " ▁ " ) NEW_LINE

try : n = int ( input ( ) ) if n <= 2 : print ( " No " ) else : e = [ ] o = [ ] for i in range ( 1 , n + 1 ) : if i % 2 == 0 : e . append ( i ) else : o . append ( i ) print ( " Yes " ) print ( len ( e ) , * e ) print ( len ( o ) , * o ) except : pass NEW_LINE

n = int ( input ( ) ) if n < 3 : print ( " No " ) else : print ( " Yes " ) print ( 1 , n ) print ( n - 1 , * range ( 1 , n ) ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; long ans = 0 , negative = 0 , zero = 0 ; for ( int i = 0 ; i < n ; i ++ ) { long k = s . nextLong ( ) ; if ( k > 1 ) { ans += k - 1 ; } else if ( k == 0 ) { ans ++ ; zero ++ ; } else if ( k < 0 ) { ans += Math . abs ( k ) - 1 ; negative ++ ; } } if ( negative % 2 == 1 && zero == 0 ) { ans = ans + 2 ; } System . out . println ( ans ) ;   } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; public class Solution { private static final Scanner sc = new Scanner ( System . in ) ; private static final BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; private static final long MOD = ( long ) ( 1e9 + 7 ) ; private static PrintWriter out = new PrintWriter ( System . out ) ;   static long getAns ( long [ ] a , int n , int prod , long [ ] [ ] dp ) { if ( n == 0 ) { return prod == 1 ? 0 : Long . MAX_VALUE / 2 ; } if ( dp [ n ] [ ( prod % 3 + 3 ) % 3 ] != - 1 ) { return dp [ n ] [ ( prod % 3 + 3 ) % 3 ] ; } long ans1 = Math . abs ( a [ n - 1 ] - 1 ) + getAns ( a , n - 1 , prod , dp ) ; long ans2 = Math . abs ( a [ n - 1 ] + 1 ) + getAns ( a , n - 1 , prod * - 1 , dp ) ; return dp [ n ] [ ( prod % 3 + 3 ) % 3 ] = Math . min ( ans1 , ans2 ) ; } public static void solve ( int T ) throws IOException { int n = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } int prod = 1 ; long [ ] [ ] dp = new long [ n + 1 ] [ 3 ] ; for ( long [ ] i : dp ) { Arrays . fill ( i , - 1 ) ; } long ans = getAns ( a , n , prod , dp ) ; System . out . println ( ans ) ; } public static void main ( String [ ] args ) throws IOException { int t ;

import java . math . BigInteger ; import java . util . * ; import java . lang . * ; import java . util . Arrays ;     public class geek {   public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; try {       StringBuffer sb = new StringBuffer ( ) ; int n = s . nextInt ( ) ; long a [ ] = new long [ n ] ; long neg = 0 , zeroes = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = s . nextLong ( ) ; if ( a [ i ] < 0 ) { neg ++ ; } else if ( a [ i ] == 0 ) { zeroes ++ ; } } Arrays . sort ( a ) ; long ans = 0 ; if ( neg % 2 == 0 ) { for ( int i = 0 ; i < n ; i ++ ) { ans += Math . abs ( Math . abs ( a [ i ] ) - 1 ) ; } } else { for ( int i = 0 ; i < n ; i ++ ) { if ( neg > 1 ) { ans += Math . abs ( Math . abs ( a [ i ] ) - 1 ) ; neg -- ; } else if ( zeroes > 0 && neg == 1 ) {   ans += Math . abs ( Math . abs ( a [ i ] ) - 1 ) + 1 ; neg -- ; i ++ ;   } else { ans += Math . abs ( a [ i ] - 1 ) ;   }

import java . util . Scanner ;   public class MakeProductEqualOne {   public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; long nCnt = 0 ; long ans = 0 ; long zeroCnt = 0 ; int n = s . nextInt ( ) ; long arr [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = s . nextLong ( ) ; if ( arr [ i ] < 0 ) nCnt ++ ; if ( arr [ i ] == 0 ) zeroCnt ++ ; ans += ( Math . abs ( ( Math . abs ( arr [ i ] ) - 1 ) ) ) % 1000000007 ; } if ( ( nCnt & 1 ) == 1 && zeroCnt == 0 ) ans += 2 ; System . out . println ( ans ) ; }   }

totalCost = 0 newArr = [ ] zeroCount = 0 negativeNumCount = 0 numCount = int ( input ( ) ) numArr = list ( map ( int , input ( ) . split ( ) ) ) for num in numArr : if ( num != 1 and num != - 1 ) : if ( num < 0 ) : negativeNumCount += 1 cost = abs ( num ) - 1 newArr . append ( num + cost ) totalCost += cost elif ( num > 0 ) : cost = num - 1 newArr . append ( num - cost ) totalCost += cost else : zeroCount += 1 else : if ( num == - 1 ) : negativeNumCount += 1 if ( zeroCount > 0 ) : totalCost += zeroCountelse : if ( negativeNumCount % 2 != 0 ) : totalCost += 2 print ( totalCost )   NEW_LINE

n = int ( input ( ) ) arr = [ int ( x ) for x in input ( ) . split ( ) ] dp = [ [ 0 for _ in range ( 2 ) ] for _ in range ( n ) ] dp [ 0 ] [ 0 ] = abs ( 1 - arr [ 0 ] ) dp [ 0 ] [ 1 ] = abs ( - 1 - arr [ 0 ] ) for i in range ( 1 , n ) : plus1 = abs ( 1 - arr [ i ] ) minus1 = abs ( - 1 - arr [ i ] ) dp [ i ] [ 0 ] = min ( dp [ i - 1 ] [ 0 ] + plus1 , dp [ i - 1 ] [ 1 ] + minus1 ) dp [ i ] [ 1 ] = min ( dp [ i - 1 ] [ 0 ] + minus1 , dp [ i - 1 ] [ 1 ] + plus1 ) print ( dp [ n - 1 ] [ 0 ] ) NEW_LINE

n = int ( input ( ) ) a = tuple ( map ( int , input ( ) . split ( ) ) ) x , y = abs ( a [ 0 ] - 1 ) , abs ( a [ 0 ] + 1 ) for i in a [ 1 : ] : x , y = min ( x + abs ( i - 1 ) , y + abs ( i + 1 ) ) , min ( y + abs ( i - 1 ) , x + abs ( i + 1 ) ) print ( x ) NEW_LINE

n = int ( input ( ) ) seq = list ( map ( int , input ( ) . split ( " ▁ " ) ) ) change_count = 0 product = 1 zero_count = 0 for i in seq : if i > 1 : change_count += i - 1 elif i < - 1 : change_count += - 1 - i product *= - 1 elif i == 0 : zero_count += 1 elif i == - 1 : product *= - 1   if zero_count > 0 : change_count += zero_count product = 1   if product == - 1 : change_count += 2 print ( change_count ) NEW_LINE


import java . io . * ; import java . util . * ; import java . text . * ; import java . math . * ;   public class MyClass { public static void main ( String args [ ] ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int m = Integer . parseInt ( st . nextToken ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int [ ] [ ] ar = new int [ m ] [ n ] ; for ( int i = 0 ; i < m ; i ++ ) { st = new StringTokenizer ( br . readLine ( ) ) ; for ( int j = 0 ; j < n ; j ++ ) { ar [ i ] [ j ] = Integer . parseInt ( st . nextToken ( ) ) ; } }

import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; import java . lang . Math ; public class Account { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int m = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] [ ] arr = new int [ m ] [ n ] ; int [ ] [ ] res = new int [ m ] [ n ] ; int [ ] rows = new int [ m ] ; int [ ] cols = new int [ n ] ; Arrays . fill ( cols , 0 ) ; for ( int [ ] a : res ) { Arrays . fill ( a , 0 ) ; } int sum = 0 ; boolean flag = false ; for ( int i = 0 ; i < m ; i ++ ) { rows [ i ] = 0 ; for ( int j = 0 ; j < n ; j ++ ) { arr [ i ] [ j ] = sc . nextInt ( ) ; sum += arr [ i ] [ j ] ; cols [ j ] += arr [ i ] [ j ] ; rows [ i ] += arr [ i ] [ j ] ; } } if ( m == 1 && n == 1 ) { System . out . println ( " YES \n " + arr [ 0 ] [ 0 ] ) ; return ; } else if ( m == 1 || n == 1 ) { if ( ( m == 1 && rows [ 0 ] == n ) || ( n == 1 && cols [ 0 ] == m ) ) { System . out . println ( " YES " ) ; for ( int i = 0 ; i < m ; i ++ ) {

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

import java . util . * ;   public class ORinMatrix_B { public static int checker ( int [ ] [ ] ans , int i , int j , int m , int n ) { int temp = 0 ; for ( int a = 0 ; a < m ; a ++ ) { temp += ans [ a ] [ j ] ; } for ( int a = 0 ; a < n ; a ++ ) { temp += ans [ i ] [ a ] ; } if ( temp == 0 ) { return 0 ; } else { return 1 ; } }   public static void main ( String [ ] args ) {

nums = input ( ) . split ( ) rows , colums = int ( nums [ 0 ] ) , int ( nums [ 1 ] ) matrix1 = [ [ 1 ] * colums ] * rowsinputMatrix = [ ] for _ in range ( rows ) : inputMatrix . append ( [ int ( i ) for i in input ( ) . split ( ) ] ) for rowIndex , row in enumerate ( inputMatrix ) : for columIndex , val in enumerate ( row ) : if val == 0 : matrix1 [ rowIndex ] = [ 0 ] * colums for j in range ( rows ) : matrix1 [ j ] [ columIndex ] = 0   def check ( ) : for rowIndex , row in enumerate ( inputMatrix ) : for columIndex , val in enumerate ( row ) : if val == 1 : dic = [ ] for j in range ( rows ) : dic . append ( matrix1 [ j ] [ columIndex ] ) if 1 not in matrix1 [ rowIndex ] and 1 not in dic : return " NO " return " YES " checkVal = check ( ) if checkVal == " NO " : print ( " NO " ) else : print ( " YES " ) for row in matrix1 : print ( " ▁ " . join ( str ( x ) for x in row ) ) NEW_LINE

def check_col ( mat , c ) : for r in mat : if not r [ c ] : return 0 return 1   m , n = map ( int , input ( ) . split ( ) ) a = [ [ 0 ] * n for _ in range ( m ) ] b = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( m ) ] rows , cols = [ ] , [ ] checkedCols = set ( ) for r in range ( m ) : if all ( b [ r ] ) : rows . append ( r ) else : for c in range ( n ) : if b [ r ] [ c ] and c not in checkedCols : checkedCols . add ( c ) if check_col ( b , c ) : cols . append ( c ) else : print ( ' NO ' ) exit ( ) if ( len ( rows ) and len ( rows ) != m and not len ( cols ) ) or ( len ( cols ) and len ( cols ) != n and not len ( rows ) ) : print ( " NO " ) exit ( ) if not len ( rows ) and not len ( cols ) : print ( " YES " ) for i in a : print ( * i ) exit ( ) i = j = 0 if not len ( cols ) : cols . append ( 0 ) while i < len ( rows ) and j < len ( cols ) : a [ rows [ i ] ] [ cols [ j ] ] = 1 i += 1 j += 1 for k in range ( i , len ( rows ) ) : a [ rows [ k ] ] [ cols [ 0 ] ] = 1 for l in range ( j , len ( cols ) ) : a [ rows [ 0 ] ] [ cols [ l ] ] = 1 print ( " YES " ) for i in a : print ( * i ) NEW_LINE

m , n = map ( int , input ( ) . split ( ) ) A = [ [ 1 ] * n ] * mB = [ [ 0 ] * n ] * mC = [ ] for i in range ( m ) : L = list ( map ( int , input ( ) . split ( ) ) ) C . append ( L ) for j in range ( len ( L ) ) : if L [ j ] == 0 : A [ i ] = [ 0 ] * n for k in range ( m ) : A [ k ] [ j ] = 0 ''' for ▁ alpha ▁ in ▁ A : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( * alpha ) ▁ ▁ ▁ ▁ for ▁ alpha ▁ in ▁ C : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( * alpha ) ''' for p in range ( m ) : for w in range ( n ) : if A [ p ] [ w ] == 1 : B [ p ] = [ 1 ] * n for s in range ( m ) : B [ s ] [ w ] = 1 if B == C : print ( " YES " ) for i in A : print ( * i ) else : print ( " NO " ) NEW_LINE


import java . util . * ; import java . io . * ; import java . lang . * ; import java . math . BigInteger ;   public class Main { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; if ( n == 1 ) { int t = sc . nextInt ( ) ; System . out . println ( 0 ) ; } else { int a [ ] [ ] = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) a [ i ] [ j ] = sc . nextInt ( ) ; } int c [ ] = new int [ n ] ; int r [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int t = 0 ; for ( int j = 0 ; j < n ; j ++ ) t = t + a [ i ] [ j ] ; c [ i ] = t ; } for ( int i = 0 ; i < n ; i ++ ) { int t = 0 ; for ( int j = 0 ; j < n ; j ++ ) t = t + a [ j ] [ i ] ; r [ i ] = t ; } int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( r [ i ] > c [ j ] ) ans ++ ; } } System . out . println ( ans ) ; } } }

import java . util . Scanner ;   public class A { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int row [ ] = new int [ n ] ; int col [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) {

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

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; public class C { 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 ( ) ) ; }   int [ ] nextArray ( int n ) { int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextInt ( ) ; return a ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } static class FastWriter extends PrintWriter { FastWriter ( ) { super ( System . out ) ; }   void println ( int [ ] array ) { for ( int i = 0 ; i < array . length ; i ++ ) { print ( array [ i ] + " ▁ " ) ; } println ( ) ; }   void println ( long [ ] array ) { for ( int i = 0 ; i < array . length ; i ++ ) { print ( array [ i ] + " ▁ " ) ; } println ( ) ; } } public static void main ( String [ ] args ) {

def colsum ( matrix , col ) : ans = 0 for i in range ( len ( matrix ) ) : for j in range ( len ( matrix [ 0 ] ) ) : if j == col : ans += matrix [ i ] [ j ] return ans   def rowsum ( matrix , row ) : return sum ( matrix [ row ] )     cases = int ( input ( ) ) mx = [ ] while cases : cases -= 1 arr = list ( map ( int , input ( ) . split ( ) ) ) mx . append ( arr ) ans = 0 for i in range ( len ( mx ) ) : for j in range ( len ( mx [ 0 ] ) ) : if colsum ( mx , i ) > rowsum ( mx , j ) : ans += 1   print ( ans )   NEW_LINE

def input_matrix ( n ) : matrix = [ ] for i in range ( n ) : matrix . append ( list ( map ( int , input ( ) . split ( ) ) ) ) return matrix   def get_sum_in_row ( a , i ) : return sum ( a [ i ] ) def get_sum_in_col ( a , j ) : return sum ( ( a [ i ] [ j ] for i in range ( len ( a ) ) ) )     n = int ( input ( ) ) a = input_matrix ( n ) row_sums = [ get_sum_in_row ( a , i ) for i in range ( n ) ] col_sums = [ get_sum_in_col ( a , j ) for j in range ( n ) ]   n_ceils = 0 for row_sum in row_sums : for col_sum in col_sums : if col_sum > row_sum : n_ceils += 1 print ( n_ceils ) NEW_LINE

a = int ( input ( ) ) b = list ( ) for i in range ( a ) : b . append ( list ( map ( int , input ( ) . split ( ) ) ) ) h = 0 for i in range ( a ) : for j in range ( a ) : if ( sum ( b [ i ] [ j ] for i in range ( a ) ) > sum ( b [ i ] ) ) : h += 1 print ( h )                           NEW_LINE

def judge ( i , j , matrix : list ) :   col , row = 0 , 0   row = sum ( matrix [ i ] )   for k in range ( len ( matrix ) ) : col += matrix [ k ] [ j ]   if col > row : return True else : return False   def counter ( matrix : list ) :   lenth = len ( matrix ) count = 0 for i in range ( lenth ) : for j in range ( lenth ) : if judge ( i , j , matrix ) : count += 1   return count     if __name__ == ' _ _ main _ _ ' : lenth = int ( input ( ) )   matrix = [ list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) for i in range ( lenth ) ]   print ( counter ( matrix ) )     NEW_LINE

n = int ( input ( ) ) arr = [ ] for i in range ( n ) : arr . append ( list ( map ( int , input ( ) . split ( ) ) ) ) row_sum = [ ] col_sum = [ ] for i in range ( n ) : row_sum . append ( sum ( arr [ i ] ) ) for i in range ( n ) : temp = 0 for j in range ( n ) : temp += arr [ j ] [ i ] col_sum . append ( temp ) ans = 0 for i in range ( n ) : for j in range ( n ) : if col_sum [ i ] > row_sum [ j ] : ans += 1 print ( ans ) NEW_LINE


import java . util . * ;    public class Practise {

import java . util . * ;   public class CF102 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; char [ ] s1 = sc . next ( ) . toCharArray ( ) ; char [ ] t1 = sc . next ( ) . toCharArray ( ) ; int min = n ;   String f = " " ; for ( int i = 0 ; i <= m - n ; i ++ ) { int c = 0 ; StringBuilder u = new StringBuilder ( ) ; for ( int j = 0 ; j < n ; j ++ ) {

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   public class Main { public static int match ( String s1 , String s2 , int start ) { int count = 0 ; int j = 0 ; for ( int i = start ; i < start + s1 . length ( ) && ( start + s1 . length ( ) ) <= s2 . length ( ) ; i ++ , j ++ ) { if ( s1 . charAt ( j ) == s2 . charAt ( i ) ) count ++ ; } return count ; }   public static void main ( String [ ] args ) throws IOException {   FastScanner input = new FastScanner ( ) ; int start = 0 ; int n = input . nextInt ( ) ; int m = input . nextInt ( ) ; String s1 = input . next ( ) ; String s2 = input . next ( ) ; int minIndex = 0 ; int max = Integer . MIN_VALUE ; for ( int i = 0 ; i < s2 . length ( ) ; i ++ ) { int mat = match ( s1 , s2 , i ) ;

import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int m = s . nextInt ( ) ; int b [ ] = new int [ n ] ; int c1 [ ] = new int [ n ] ; s . nextLine ( ) ; String s1 = s . nextLine ( ) ; String t = s . nextLine ( ) ; char c = s1 . charAt ( 0 ) ; int count = 0 , min = Integer . MAX_VALUE , k = 0 ; for ( int i = 0 ; i < m - n + 1 ; i ++ ) { int index = i ; count = 0 ; Arrays . fill ( b , 0 ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( index < t . length ( ) && t . charAt ( index ) != s1 . charAt ( j ) ) { count ++ ; b [ j ] = j + 1 ; } index ++ ; } if ( count < min ) { min = count ; c1 = b . clone ( ) ;

import mathimport sysfrom collections import * import itertools def cint ( ) : return list ( map ( int , sys . stdin . readline ( ) . strip ( ) . split ( ) ) ) def cstr ( ) : return list ( map ( str , input ( ) . split ( ' ▁ ' ) ) )     def gcd ( a , b ) : if ( b == 0 ) : return a return gcd ( b , a % b )     def solve ( t ) : n , m = cint ( ) s1 = input ( ) s2 = input ( ) n1 = len ( s1 ) n2 = len ( s2 ) min_count = math . inf min_lst = [ ] for i in range ( n2 - n1 + 1 ) : count = 0 lst = [ ] for j in range ( n1 ) : if s1 [ j ] != s2 [ i + j ] : count += 1 lst . append ( j )   if count < min_count : min_count = count min_lst = lst . copy ( ) print ( min_count ) for item in min_lst : print ( item + 1 , end = ' ▁ ' ) print ( ' ' ) 	 	       if __name__ == " _ _ main _ _ " : NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) s = input ( ) t = input ( ) l = [ ]   for i in range ( len ( t ) - len ( s ) + 1 ) : l . append ( [ ] ) for j in range ( len ( s ) ) : if s [ j ] != t [ i + j ] : l [ - 1 ] . append ( j + 1 ) print ( len ( min ( l , key = lambda x : len ( x ) ) ) ) print ( * min ( l , key = lambda x : len ( x ) ) ) NEW_LINE

def match ( a , b , startingpos ) : assert ( len ( a ) == len ( b ) ) c = [ None ] * ( len ( a ) ) for i in range ( len ( a ) ) : if ( a [ i ] == b [ i ] ) : c [ i ] = a [ i ] else : c [ i ] = ' ? ' return ( [ startingpos , c . count ( ' ? ' ) , c ] )   n , m = [ int ( x ) for x in input ( ) . split ( ' ▁ ' ) ] s = [ x for x in input ( ) ] t = [ x for x in input ( ) ]   poss = [ ]   for i in range ( m - n + 1 ) : poss . append ( match ( s , t [ i : i + n ] , i ) )   poss . sort ( key = ( lambda a : a [ 1 ] ) )   print ( poss [ 0 ] [ 1 ] ) NEW_LINE

a , b = map ( int , input ( ) . split ( ) ) s = input ( ) t = input ( )   ans = float ( ' inf ' ) val = 0 for x in range ( b - a + 1 ) : sub = t [ x : x + a ] c = 0 for i , j in zip ( s , sub ) : if i != j : c += 1 if ( c < ans ) : ans = c val = x   print ( ans )     for x in range ( b - a + 1 ) : sub = t [ x : x + a ] c = 0 for i , j in zip ( s , sub ) : if i != j : c += 1 if ( c == ans ) : val = x break   sub = t [ val : val + a ] for i in range ( val , val + a ) : if t [ i ] != s [ i - val ] : print ( i - val + 1 , end = " ▁ " )                         NEW_LINE


import java . io . * ; import java . util . * ;   public class Main { private static long pow ( int a , int b ) { if ( b == 0 ) { return 1 ; } if ( b % 2 == 0 ) { long temp = pow ( a , b / 2 ) ; return temp * temp ; } return a * pow ( a , b - 1 ) ; } public static void main ( String [ ] args ) throws IOException {

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

import java . util . * ; import java . lang . * ; public class divgame { public static ArrayList < Integer > getPrimes ( int n ) { ArrayList < Integer > primes = new ArrayList < > ( ) ; boolean first = true ; while ( n % 2 == 0 ) { n /= 2 ; if ( first ) { primes . add ( 2 ) ; first = false ; } } for ( int i = 3 ; i <= Math . sqrt ( n ) ; i ++ ) { first = true ; while ( n % i == 0 ) { n /= i ; if ( first ) { primes . add ( i ) ; first = false ; } } } if ( n > 1 ) primes . add ( n ) ; return primes ; } public static int maxPower ( int n , int p ) { int c = 0 ; while ( n % p == 0 ) { c ++ ; n /= p ; } return c ; } public static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;

import java . util . * ; public class OracAndLCM { public static void main ( String [ ] args ) { boolean [ ] sieve = new boolean [ 200001 ] ; ArrayList < Integer > primes = new ArrayList < > ( ) ; for ( int i = 2 ; i <= 200000 ; i ++ ) { if ( ! sieve [ i ] ) { primes . add ( i ) ; for ( int j = i ; j <= 200000 ; j += i ) { sieve [ j ] = true ; } } } Scanner in = new Scanner ( System . in ) ; int N = in . nextInt ( ) ; int [ ] arr = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = in . nextInt ( ) ; } long res = 1 ; for ( int p : primes ) { int min = Integer . MAX_VALUE ; int min2 = Integer . MAX_VALUE ; for ( int i : arr ) { int count = count ( i , p ) ; if ( count < min2 ) { min2 = Math . max ( min , count ) ; } if ( count < min ) { min = count ; } if ( min2 == 0 ) { break ; } } res *= ( long ) Math . pow ( p , min2 ) ; } System . out . println ( res ) ; } public static int count ( int n , int p ) { int count = 0 ; while ( n % p == 0 ) { n /= p ; count ++ ; } return count ; } }

import sysmod = 1000000007 input = lambda : sys . stdin . readline ( ) . rstrip ( " \n " )   from math import sqrtck = [ i for i in range ( 200001 ) ] i = 2 for i in range ( 2 , int ( sqrt ( 200001 ) ) + 1 ) : if ck [ i ] == i : t = i * i for j in range ( t , 200001 , i ) : ck [ j ] = i NEW_LINE

def gcd ( a , b ) : while b : a %= b a , b = b , a return an = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) if n == 1 : print ( l [ 0 ] ) else : g = gcd ( l [ 0 ] , l [ 1 ] ) a = ( l [ 0 ] * l [ 1 ] ) // g for i in range ( 2 , n ) : a , g = gcd ( a , g * l [ i ] // gcd ( g , l [ i ] ) ) , gcd ( l [ i ] , g ) print ( a ) NEW_LINE

from math import gcddef lcm ( a , b ) : return a * b // gcd ( a , b ) input ( ) a = list ( map ( int , input ( ) . split ( ) ) ) t = gcd ( a [ 0 ] , a [ 1 ] ) q = lcm ( a [ 0 ] , a [ 1 ] ) for i in range ( 2 , len ( a ) ) : q = gcd ( q , lcm ( a [ i ] , t ) ) t = gcd ( t , a [ i ] ) print ( q ) NEW_LINE

from sys import stdinfrom collections import defaultdict     def get_prime_nums ( ) : prime_nums = [ 2 ] for i in range ( 3 , 500 ) : is_prime = True for num in prime_nums : if i % num == 0 : is_prime = False break if is_prime : prime_nums . append ( i ) return prime_nums     n = int ( stdin . buffer . readline ( ) )   input_nums = [ int ( _ ) for _ in stdin . buffer . readline ( ) . split ( ) ] prime_nums = get_prime_nums ( )   prime_stats = defaultdict ( lambda : [ 0 ] * 20 )   for input_num in input_nums : for prime_num in prime_nums : power = 1 while input_num % prime_num == 0 : prime_stats [ prime_num ] [ power ] += 1 power += 1 input_num = input_num // prime_num if input_num != 1 : prime_stats [ input_num ] [ 1 ] += 1   ans = 1 for prime_num , stat in prime_stats . items ( ) : i = 0 while stat [ i + 1 ] >= n - 1 : i += 1 ans *= prime_num ** i   print ( ans ) NEW_LINE


import java . util . Scanner ;   public class BearAndBigBrother { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; short a = scanner . nextByte ( ) , b = scanner . nextByte ( ) ; byte count = 0 ; while ( a <= b ) { count ++ ; a *= 3 ; b *= 2 ; } System . out . println ( count ) ; } }

import java . util . Scanner ;   public class main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   int a = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int k = 0 ; while ( ! ( a > b ) ) { a *= 3 ; b *= 2 ; k ++ ; } System . out . println ( k ) ;   } }

import java . util . Scanner ; public class MyClass { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int a = s . nextInt ( ) ; int b = s . nextInt ( ) ; int i = 0 ; while ( a <= b ) { a = a * 3 ; b = b * 2 ; i ++ ; } System . out . println ( i ) ; } }

import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   int l = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ;   int L = l ; int B = b ;   int counter = 0 ; while ( B >= L ) { L *= 3 ; B *= 2 ;   counter ++ ; }   System . out . println ( counter ) ; } }

import java . util . * ;   public class test { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; short a = scanner . nextShort ( ) ; short b = scanner . nextShort ( ) ; short counter = 0 ;   while ( a <= b ) { a = ( short ) ( a * 3 ) ; b = ( short ) ( b * 2 ) ; counter ++ ; } System . out . println ( counter ) ;   }   }

a , b = map ( int , input ( ) . split ( ) ) Limak_age = aBob_age = bn_years = 0 while Limak_age <= Bob_age : Limak_age *= 3 Bob_age *= 2 n_years += 1 print ( n_years ) NEW_LINE

l , b = map ( int , input ( ) . split ( ) ) years = 0 while l <= b : l *= 3 b *= 2 years += 1 print ( years ) NEW_LINE

s , l = map ( int , input ( ) . split ( ) ) i = 0 while ( s <= l ) : s = s * 3 l = l * 2 i = i + 1 print ( i ) NEW_LINE

small , big = map ( int , input ( ) . split ( ) ) count = 0 while small <= big : small *= 3 big *= 2 count += 1 print ( count ) NEW_LINE

num_array = input ( ) . split ( ) b = int ( num_array [ 0 ] ) m = int ( num_array [ 1 ] ) c = 0 while ( b <= m ) : b = b * 3 m = m * 2 c += 1 print ( c ) NEW_LINE


# include < iostream >   using namespace std ;   long long a , i , n ; int main ( ) { cin >> a ;   for ( int i = 0 ; i < a ; ++ i ) {   cin >> n ; if ( n == 2 ) { cout << 2 ; } else if ( n % 2 ) cout << 1 ; else cout << 0 ; cout << endl ; } return 0 ; }

import java . util . Scanner ;   public class CME { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int q = in . nextInt ( ) ; int n ; while ( q -- != 0 ) { n = in . nextInt ( ) ; if ( n == 2 ) System . out . println ( "2" ) ; else if ( n % 2 == 0 ) System . out . println ( "0" ) ; else System . out . println ( "1" ) ; } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class Test {

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class Cv {

for t in range ( int ( input ( ) ) ) : n = int ( input ( ) ) if n < 4 : print ( 4 - n ) else : print ( [ 0 , 1 ] [ n % 2 ] ) NEW_LINE

q = int ( input ( ) ) answer = 0 ch = [ ] for i in range ( q ) : n = int ( input ( ) ) if n == 2 : ch . append ( 2 ) if n % 2 == 0 and n != 2 : ch . append ( 0 ) if n % 2 != 0 : ch . append ( 1 ) for j in ch : print ( j , end = " \n " ) NEW_LINE

t = int ( input ( ) ) for i in range ( t ) : n = int ( input ( ) ) if ( n <= 3 ) : print ( 4 - n ) else : print ( n % 2 ) NEW_LINE


import java . lang . reflect . Array ; import java . text . CollationElementIterator ; import java . util . * ; import java . util . Map . Entry ; import java . io . * ; import java . lang . Math . * ; import java . math . BigInteger ;   import static java . lang . Math . * ; import static java . lang . System . * ; import static java . util . Arrays . fill ; import static java . util . Arrays . spliterator ; public class ContestMain implements Runnable { private static Reader in = new Reader ( ) ; private static StringBuilder ans = new StringBuilder ( ) ; private static long MOD = 998244353 ; private static final int N = ( int ) ( 2e5 + 7 ) ;

import java . io . * ; import java . util . * ; public class Main { static int mod = ( int ) ( Math . pow ( 10 , 9 ) + 7 ) ; public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; int n = sc . nextInt ( ) ; out . println ( 6 * n * ( n - 1 ) + 1 ) ; out . close ( ) ; } static void mergeSort ( int [ ] A ) {

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; long n = s . nextLong ( ) ; long res = 6 * n * ( n - 1 ) + 1 ; System . out . println ( res ) ; } }

import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int temp1 = p6 ( a ) ; int temp2 = p3 ( a * 3 - 2 ) ;   System . out . println ( temp2 * 2 - temp1 ) ; } static int p6 ( int n ) { return p3 ( n ) * 6 - n * 6 + 1 ; } static int p3 ( int n ) { return n * ( n + 1 ) / 2 ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class Solution171B { public static void main ( String [ ] args ) { InputReader in = new InputReader ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; Solver171B solver = new Solver171B ( ) ; solver . solve ( 0 , in , out ) ; out . close ( ) ; }   static class Solver171B { public void solve ( int testNumber , InputReader in , PrintWriter out ) { long n = in . nextInt ( ) ; out . println ( 6L * n * ( n - 1L ) + 1L ) ; } }   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 ( ) ) ; } } }

def tri_len ( n ) : return 3 * n - 2 def triangle ( n ) : return ( n * ( n + 1 ) ) // 2 def star ( n ) : l = tri_len ( n ) return triangle ( n - 1 ) * 3 + triangle ( l ) print ( star ( int ( input ( ) ) ) ) NEW_LINE

n = int ( input ( ) ) print ( 6 * n * n - 6 * n + 1 ) NEW_LINE

import mathimport sysinput = sys . stdin . readline   def inp ( ) : return ( int ( input ( ) ) ) def inlt ( ) : return ( list ( map ( int , input ( ) . split ( ) ) ) )   n = inp ( ) print ( n * ( n - 1 ) * 6 + 1 ) NEW_LINE

n = int ( input ( ) ) print ( 6 * n * ( n - 1 ) + 1 ) NEW_LINE

n = int ( input ( ) ) print ( 1 + 6 * ( n * ( n - 1 ) ) ) NEW_LINE


import java . io . DataInputStream ; import java . io . FileInputStream ; import java . io . IOException ; import java . util . ArrayList ; import java . util . HashMap ; 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 ] ;

# include < bits / stdc ++ . h > # include < ext / pb_ds / assoc_container . hpp > # include < ext / pb_ds / tree_policy . hpp > using namespace __gnu_pbds ; # define ll long long # define ld long double # define el ' \n ' # define _3m_Sevawy ios_base :: sync_with_stdio ( 0 ) ; cin . tie ( 0 ) ; cout . tie ( 0 ) ; # define ordered_set tree < string , null_type , less < string > , rb_tree_tag , tree_order_statistics_node_update > # define error ( args ... ) { string _s = # args ; replace ( _s . begin ( ) , _s . end ( ) , ' , ' , ' ▁ ' ) ; stringstream _ss ( _s ) ; istream_iterator < string > _it ( _ss ) ; err ( _it , args ) ; } using namespace std ; const ll N = 7e3 + 5 , mod = 1e9 + 7 , inf = 1e18 , M = 2 * N ; bool ok [ N ] ; int main ( ) { _3m_Sevawy int tt = 1 ;

from collections import defaultdictN = int ( input ( ) ) if ( N == 1 ) : print ( 0 ) exit ( ) a = [ int ( x ) for x in input ( ) . split ( ) ] b = [ int ( x ) for x in input ( ) . split ( ) ] Dict = defaultdict ( int ) Sum = defaultdict ( int ) for i in range ( N ) : Dict [ a [ i ] ] += 1 Sum [ a [ i ] ] += b [ i ] ans = 0 val = 0 Group = [ ] for i in Dict . keys ( ) : if ( Dict [ i ] > 1 ) : Group . append ( i ) ans += Sum [ i ] val |= ifor i in range ( N ) : if ( Dict [ a [ i ] ] == 1 ) : for k in Group : if ( a [ i ] | k <= k ) : ans += Sum [ a [ i ] ] breakprint ( ans ) NEW_LINE

import sysinput = sys . stdin . readlinefrom collections import defaultdict n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) c = defaultdict ( int ) for i in range ( n ) : c [ a [ i ] ] += 1     s = 0 for i in range ( n ) : for j in c : if c [ j ] > 1 : if j | a [ i ] == j : s += b [ i ] breakprint ( s ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . List ; import java . util . Random ; import java . util . StringTokenizer ;   public class Main implements Runnable {   int sz [ ] ; int id [ ] ; List < Integer > edges [ ] ; long tree [ ] ;   private void solve ( ) throws IOException { long ax = nextLong ( ) ; long ay = nextLong ( ) ; long bx = nextLong ( ) ; long by = nextLong ( ) ; long tx = nextLong ( ) ; long ty = nextLong ( ) ; int n = nextInt ( ) ; long d1 [ ] = new long [ n ] ; long d2 [ ] = new long [ n ] ; long d3 [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { long x = nextLong ( ) ; long y = nextLong ( ) ; d1 [ i ] = ( x - tx ) * ( x - tx ) + ( y - ty ) * ( y - ty ) ; d2 [ i ] = ( x - ax ) * ( x - ax ) + ( y - ay ) * ( y - ay ) ; d3 [ i ] = ( x - bx ) * ( x - bx ) + ( y - by ) * ( y - by ) ; } double min1 , min2 , smin1 , smin2 ; min1 = min2 = smin1 = smin2 = 1e13 ; int ind1 = - 1 , ind2 = - 1 , ind3 = - 1 , ind4 = - 1 ; double tot = 0.0d ; for ( int i = 0 ; i < n ; ++ i ) {

def dis ( x1 , y1 , x2 , y2 ) : return ( ( x1 - x2 ) ** 2 + ( y1 - y2 ) ** 2 ) ** 0.5   ax , ay , bx , by , tx , ty = map ( int , input ( ) . split ( ) ) n = int ( input ( ) ) a , b , s = [ ] , [ ] , 0 for i in range ( n ) : x , y = map ( int , input ( ) . split ( ) ) dist = dis ( tx , ty , x , y ) a . append ( ( dis ( ax , ay , x , y ) - dist , i ) ) b . append ( ( dis ( bx , by , x , y ) - dist , i ) ) s += dist * 2 a . sort ( ) b . sort ( ) if n > 1 and a [ 0 ] [ 1 ] == b [ 0 ] [ 1 ] : res = min ( a [ 0 ] [ 0 ] , b [ 0 ] [ 0 ] , a [ 0 ] [ 0 ] + b [ 1 ] [ 0 ] , a [ 1 ] [ 0 ] + b [ 0 ] [ 0 ] ) else : res = min ( a [ 0 ] [ 0 ] , b [ 0 ] [ 0 ] ) if ( n > 1 ) : res = min ( a [ 0 ] [ 0 ] + b [ 0 ] [ 0 ] , res ) print ( res + s ) NEW_LINE