import java . util . HashSet ; import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String str ; HashSet < String > set = new HashSet < String > ( ) ; int ans = 0 ; while ( in . hasNextLine ( ) ) {   str = in . nextLine ( ) ; if ( str . isEmpty ( ) ) break ; if ( str . charAt ( 0 ) == ' + ' || str . charAt ( 0 ) == ' - ' ) { String res = " " ; int m_id = 0 ; for ( int i = 1 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == ' : ' ) { m_id = i ; break ; } res += str . charAt ( i ) ; } if ( str . charAt ( 0 ) == ' + ' ) set . add ( res ) ; if ( str . charAt ( 0 ) == ' - ' ) set . remove ( res ) ; } else { String res = " " ; int m_id = 0 ; for ( int i = 1 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == ' : ' ) { m_id = i ; break ; } } ans += ( str . length ( ) - m_id - 1 ) * set . size ( ) ; }   } System . out . println ( ans ) ; } }

import java . io . * ; import java . util . ArrayList ; import java . util . List ;   public class MAIN {   private static final BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ;   public static void main ( String [ ] args ) throws Exception {   List < String > commands = new ArrayList < > ( 0 ) ;   while ( true ) { String s = reader . readLine ( ) ; if ( s != null && ! s . isEmpty ( ) ) { commands . add ( s ) ; } else { break ; } }   int trafficCount = 0 ; int currentPeopleCount = 0 ;   for ( int i = 0 ; i < commands . size ( ) ; ++ i ) { if ( commands . get ( i ) . startsWith ( " + " ) ) { ++ currentPeopleCount ; } else if ( commands . get ( i ) . startsWith ( " - " ) ) { -- currentPeopleCount ; } else { String [ ] parts = commands . get ( i ) . split ( " : " ) ; int msgLen = parts != null && parts . length > 1 ? parts [ 1 ] . length ( ) : 0 ; trafficCount += currentPeopleCount * msgLen ; } }   System . out . println ( trafficCount ) ;   }   }

import java . util . * ; public class a1 { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int l = 0 ; int c = 0 ; String s ; while ( in . hasNextLine ( ) ) { s = in . nextLine ( ) ; if ( s . charAt ( 0 ) == ' + ' ) c ++ ; else if ( s . charAt ( 0 ) == ' - ' ) c -- ; else { l += c * ( s . length ( ) - s . indexOf ( ' : ' ) - 1 ) ; } } System . out . println ( l ) ; } }

import java . io . * ; import java . util . * ;   public class SecretMessage {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; TreeSet < String > in = new TreeSet ( ) ; int z = 0 ; while ( sc . hasNext ( ) ) { String s = sc . nextLine ( ) ; if ( s . charAt ( 0 ) == ' + ' ) { in . add ( s . substring ( 1 ) ) ; } else if ( s . charAt ( 0 ) == ' - ' ) { in . remove ( s . substring ( 1 ) ) ; } else { String s1 [ ] = s . split ( " : " ) ; if ( s1 . length > 1 ) { z += in . size ( ) * s1 [ 1 ] . length ( ) ; } } } System . out . println ( z ) ; }   }

import java . io . BufferedInputStream ; import java . util . HashSet ; import java . util . Scanner ;   import javax . jws . WebParam . Mode ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( new BufferedInputStream ( System . in ) ) ; String string ; int sum = 0 ; HashSet hs = new HashSet < String > ( ) ; while ( sc . hasNextLine ( ) ) { string = sc . nextLine ( ) ; if ( string . isEmpty ( ) ) break ; if ( string . charAt ( 0 ) == ' + ' ) { hs . add ( string . substring ( 1 , string . length ( ) ) ) ; } else if ( string . charAt ( 0 ) == ' - ' ) { hs . remove ( string . substring ( 1 , string . length ( ) ) ) ; } else { String [ ] str = string . split ( " : " ) ; if ( str . length != 1 ) sum += hs . size ( ) * str [ 1 ] . length ( ) ; } } System . out . println ( sum ) ; } }

arr = set ( ) c = 0 while 1 : try : s = input ( ) NEW_LINE

d = [ ] score = 0 while True : try : line = input ( ) except : print ( score ) break if line [ 0 ] == ' + ' : s = line [ 1 : ] d . append ( s ) elif line [ 0 ] == ' - ' : s = line [ 1 : ] d . remove ( s ) else : s = line . split ( ' : ' ) s = len ( s [ 1 ] ) score += s * len ( d ) NEW_LINE

''' Jana ▁ Goodman 5A ▁ chat ▁ server ''' import sys   ADD = ' + ' REMOVE = ' - ' SEND = ' : ' if __name__ == ' _ _ main _ _ ' : chatters , answer = 0 , 0 for command in sys . stdin : if command [ 0 ] == ADD : chatters += 1 elif command [ 0 ] == REMOVE : chatters -= 1 else : name , message = command . split ( SEND ) answer += chatters * len ( message . strip ( ) ) print ( answer ) NEW_LINE

import sys   users , ans , n = [ ] , 0 , 0   for line in sys . stdin : line = line . rstrip ( ) if ( line [ 0 : 1 ] == ' + ' ) : users . append ( line [ 1 : ] ) elif ( line [ 0 : 1 ] == ' - ' ) : users . remove ( line [ 1 : ] ) else : n = line . index ( ' : ' ) if ( n != 0 ) : ans = ans + len ( line [ n + 1 : ] ) * len ( users ) n = 0 NEW_LINE

import sysimport bisectdef gcd ( a , b ) : if ( a == 0 ) : return b return gcd ( b % a , a ) def input ( ) : return sys . stdin . readline ( ) . strip ( ) def iinput ( ) : return int ( input ( ) ) def minput ( ) : return map ( int , input ( ) . split ( ) ) def listinput ( ) : return list ( map ( str , input ( ) . split ( ) ) ) peeps , tra = 0 , 0 for i in sys . stdin : if i [ 0 ] == ' + ' : peeps += 1 elif i [ 0 ] == ' - ' : peeps -= 1 else : tra += ( len ( i ) - 2 - i . find ( ' : ' ) ) * peepsprint ( tra ) NEW_LINE


import java . io . FileInputStream ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ;   import static java . lang . Math . * ;   public class code0 { private static boolean oj = System . getProperty ( " ONLINE _ JUDGE " ) != null ; private static InputReader in ; private static PrintWriter out ;

from collections import dequeimport osfrom io import BytesIO     input = BytesIO ( os . read ( 0 , os . fstat ( 0 ) . st_size ) ) . readline   def main ( ) : n , m , q = map ( int , input ( ) . split ( ) ) mn = m + n cr = [ [ ] for i in range ( mn ) ] ca = [ - 1 ] * ( mn ) for i in range ( q ) : ri , ci = map ( int , input ( ) . split ( ) ) ri -= 1 ci -= 1 cr [ ci ] += [ ri + m ] cr [ ri + m ] += [ ci ]   ans = - 1 for i in range ( mn ) : if ca [ i ] != - 1 : continue ca [ i ] = 1 stack = deque ( ) for j in cr [ i ] : stack . append ( j ) ca [ j ] = 0   while len ( stack ) != 0 : temp = stack . pop ( ) for j in cr [ temp ] : if ca [ j ] == - 1 : ca [ j ] = 0 stack . append ( j )   ans += 1 print ( ans ) main ( ) NEW_LINE

""" https : / / codeforces . com / contest / 1012 / problem / B  """ from sys import stdin , stdoutclass UnionFind ( ) : def __init__ ( self , arr = [ ] ) : self . rank = { } self . leader = { } for i in arr : self . rank [ i ] = 0 self . leader [ i ] = i def __repr__ ( self ) : return f """ ▁ Ranks ▁ : ▁ { self . rank } , ▁ leaders ▁ : ▁ { self . leader } ▁ """ def find ( self , x ) : leader = self . leader . get ( x , x ) if leader != x : leader = self . find ( leader ) self . leader [ x ] = leader return leader def getRank ( self , x ) : return self . rank . get ( x , 0 ) def union ( self , x , y ) : leader1 = self . find ( x ) leader2 = self . find ( y ) if leader1 == leader2 : return False if self . getRank ( leader1 ) > self . getRank ( leader2 ) : self . leader [ leader2 ] = leader1 elif self . getRank ( leader1 ) < self . getRank ( leader2 ) : self . leader [ leader1 ] = leader2 else : self . leader [ leader1 ] = leader2 self . rank [ leader2 ] = 1 + self . getRank ( leader2 ) return True   n , m , q = tuple ( map ( int , stdin . readline ( ) . split ( ) ) ) uf = UnionFind ( range ( 1 , n + m + 1 ) ) rcs = [ tuple ( map ( int , line . split ( ) ) ) for line in stdin ] grps = n + mfor r , c in rcs : if uf . union ( r , c + n ) : grps -= 1 stdout . write ( str ( grps - 1 ) ) NEW_LINE


import java . io . * ; import java . util . * ;   import static java . lang . Math . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastReader in = new FastReader ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int n = in . nextInt ( ) ; long [ ] arr = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = in . nextLong ( ) ; ArrayList < ArrayList < Long > > ans = solve ( arr , n ) ; for ( int i = 0 ; i < ans . size ( ) ; i ++ ) { for ( Long val : ans . get ( i ) ) pw . print ( val + " ▁ " ) ; pw . println ( ) ; } pw . close ( ) ; } static ArrayList < ArrayList < Long > > solve ( long [ ] arr , int n ) { ArrayList < ArrayList < Long > > list = new ArrayList < > ( ) ; list . add ( new ArrayList < > ( ) ) ; list . get ( 0 ) . add ( arr [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { int indx = - 1 ; int left = 0 ; int right = list . size ( ) - 1 ; while ( left <= right ) { int mid = ( left + right ) / 2 ;

import java . util . * ; import java . io . * ;   public class PreparingforMergeSort {

""" http : / / codeforces . com / contest / 847 / problem / B51 ▁ 3 ▁ 2 ▁ 5 ▁ 4 ▁ should ▁ output1 ▁ 3 ▁ 52 ▁ 4 """ input ( ) numbers = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) groups = [ ] groupTail = [ ]   for elem in a : if not groups : groups . append ( [ elem ] ) groupTail . append ( elem ) else : l = 0 r = len ( groups ) while l <= r : m = ( l + r ) // 2 if m == len ( groups ) : break if l == r : break if groupTail [ m ] < elem : r = m else : l = m + 1 if m == len ( groups ) : groups . append ( [ elem ] ) groupTail . append ( elem ) else : groups [ m ] . append ( elem ) groupTail [ m ] = elem   for line in groups : print ( " ▁ " . join ( map ( str , line ) ) ) NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) ans = [ ] for i in range ( n ) : l = 0 r = len ( ans ) while l < r : mid = l + ( r - l ) // 2 if ans [ mid ] [ - 1 ] < a [ i ] : r = mid else : l = mid + 1 if l == len ( ans ) : ans . append ( [ a [ i ] ] ) else : ans [ l ] . append ( a [ i ] ) for x in ans : print ( * x )     NEW_LINE

def readInt ( ) : return int ( input ( ) )   def readInts ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] n = readInt ( ) a = readInts ( )   nexts = [ - 1 ] * nheads = [ - 1 ] * nlasts = [ - 1 ] * ncnt = 0   for i in range ( n ) : value = a [ i ] left = - 1 right = cnt while right - left > 1 : mid = ( right + left ) // 2 if a [ lasts [ mid ] ] < value : right = mid else : left = mid if right == cnt : heads [ right ] = i cnt += 1 else : last = lasts [ right ] nexts [ last ] = i lasts [ right ] = i   for i in range ( cnt ) : index = heads [ i ] while index != - 1 : print ( a [ index ] , end = ' ▁ ' ) index = nexts [ index ] print ( ) NEW_LINE

""" http : / / codeforces . com / contest / 847 / problem / B51 ▁ 3 ▁ 2 ▁ 5 ▁ 4 ▁ should ▁ output1 ▁ 3 ▁ 52 ▁ 4 """ input ( ) numbers = [ int ( i ) for i in input ( ) . split ( ) ]   runs = [ [ numbers [ 0 ] ] ] for n in numbers [ 1 : ] : if n < runs [ - 1 ] [ - 1 ] : runs . append ( [ n ] ) continue   lo = 0 hi = len ( runs ) - 1 valid = - 1 while lo <= hi : to_search = ( lo + hi ) // 2 if n > runs [ to_search ] [ - 1 ] : valid = to_search hi = to_search - 1 else : lo = to_search + 1 runs [ valid ] . append ( n )   for r in runs : print ( ' ▁ ' . join ( str ( n ) for n in r ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . io . PrintWriter ; import java . util . * ;   public class Main { public static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; public static StringTokenizer st = new StringTokenizer ( " " ) ; public static String nextStr ( ) throws IOException { while ( ! st . hasMoreTokens ( ) ) { st = new StringTokenizer ( br . readLine ( ) ) ; } return st . nextToken ( ) ; } static int nextInt ( ) throws NumberFormatException , IOException { return Integer . parseInt ( nextStr ( ) ) ; } static double nextDouble ( ) throws NumberFormatException , IOException { return Double . parseDouble ( nextStr ( ) ) ; } static long nextLong ( ) throws NumberFormatException , IOException { return Long . parseLong ( nextStr ( ) ) ; } public static PrintWriter pw = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; public static void printf ( String format , Object ... args ) { pw . printf ( format , args ) ; pw . flush ( ) ; } public static void debug ( String out ) { System . out . println ( out ) ; } public static final int maxn = ( int ) 1e5 + 5 ; public static final int inf = 0x7f7f7f7f ; public static int n , k , t ; public static void main ( String [ ] args ) throws IOException { n = nextInt ( ) ; k = nextInt ( ) ; t = nextInt ( ) ; if ( t <= k ) debug ( " " + t ) ; else if ( t <= n ) debug ( " " + k ) ; else debug ( " " + ( n + k - t ) ) ; }

import java . util . * ;   public class questionCF {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; if ( t < k ) { System . out . print ( t ) ; } else if ( t >= k && t <= n ) { System . out . print ( k ) ; } else { System . out . print ( k - ( t - n ) ) ; } } }

import java . util . * ; import java . util . Arrays ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; if ( t <= k ) { System . out . println ( t ) ; } else if ( t >= k && t <= n ) { System . out . println ( k ) ; } else { int d = n + k - t ; System . out . println ( d ) ; } } }

import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int k = s . nextInt ( ) ; int t = s . nextInt ( ) ; int count = 0 ; if ( t <= k ) count = t ; else if ( t > k && t < n ) count = k ; else if ( t >= n ) { count = k - ( t - n ) ; } else if ( n == k && k == t ) count = n ; System . out . println ( count ) ; } }

import java . util . ArrayList ; import java . util . Arrays ; import java . util . Scanner ;   public class Singleton_Pattern { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int t = sc . nextInt ( ) ;   if ( t <= k ) System . out . println ( t ) ; if ( t > k && t <= n ) System . out . println ( k ) ; if ( t > n ) System . out . println ( n + k - t ) ; } }

n , k , t = map ( int , input ( ) . split ( " ▁ " ) ) NEW_LINE

n , k , t = map ( int , input ( ) . split ( ) )             if t < k : print ( t ) elif t > n : NEW_LINE

n , k , t = map ( int , input ( ) . split ( ) ) print ( min ( t , k , n + k - t ) ) NEW_LINE

n , k , t = map ( int , input ( ) . split ( " ▁ " ) ) v = min ( t , k , n + k - t ) print ( v ) NEW_LINE


import java . util . Scanner ;   public class B1476 {   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 [ ] P = new int [ N ] ; for ( int n = 0 ; n < N ; n ++ ) { P [ n ] = in . nextInt ( ) ; } long minPrice = 0 ; for ( int n = N - 1 ; n > 0 ; n -- ) {

import java . util . * ; public class temte { public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; int t = in . nextInt ( ) ; int i , j ; while ( t -- > 0 ) { int n = in . nextInt ( ) ; int k = in . nextInt ( ) ; long a [ ] = new long [ n ] ; long b [ ] = new long [ n ] ; for ( i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextLong ( ) ; if ( i == 0 ) b [ i ] = a [ i ] ; else b [ i ] = b [ i - 1 ] + a [ i ] ; } double inf = 0 ; long sum = 0 ; for ( i = 1 ; i < n ; i ++ ) { inf = ( double ) a [ i ] / ( double ) ( b [ i - 1 ] + sum ) ;

import java . util . * ; import java . math . * ; public class Inflation { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int runs = sc . nextInt ( ) ; while ( runs -- > 0 ) { int n = sc . nextInt ( ) ; double k = sc . nextDouble ( ) ; long out = 0 ; double divisor = 0 ; for ( int i = 0 ; i < n ; i ++ ) { double temp = sc . nextDouble ( ) ; if ( i == 0 ) { divisor = temp ; } else { if ( temp / divisor > ( k / 100.0 ) ) { long num = ( long ) Math . ceil ( ( ( temp * 100 ) / ( k ) ) - divisor ) ;

import java . util . * ;   public class Test { static Scanner sc ; static Set < Integer > set ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ;   set = new HashSet < > ( ) ; set . add ( 0 ) ; set . add ( 1 ) ; set . add ( 2 ) ; set . add ( 5 ) ; set . add ( 8 ) ; int t = Integer . parseInt ( sc . next ( ) ) ;   while ( t -- > 0 ) solve ( ) ;   }   public static void solve ( ) { int n = sc . nextInt ( ) ; double k = sc . nextDouble ( ) ;   double [ ] p = new double [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { p [ i ] = sc . nextDouble ( ) ; }   long ans = 0 ;   double per , x = 0 ; for ( int i = 1 ; i < n ; i ++ ) {   per = p [ i ] * 100 / p [ i - 1 ] ; if ( per > k ) {   x = Math . ceil ( p [ i ] * 100 / k - p [ i - 1 ] ) ; ans += x ; p [ i - 1 ] += x ; }   p [ i ] += p [ i - 1 ] ; }   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 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 ) {

for _ in range ( int ( input ( ) ) ) : n , k = map ( int , input ( ) . split ( ) ) NEW_LINE p = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE res = k / 100 NEW_LINE count = 0 NEW_LINE sm = p [ 0 ] NEW_LINE for i in range ( 1 , n ) : sol = 100 * p [ i ] NEW_LINE if sol % k == 0 : NEW_LINE INDENT sol = sol // k else : NEW_LINE sol = sol // k + 1 NEW_LINE DEDENT

import math   NEW_LINE def read ( ) : return map ( int , input ( ) . split ( ) ) NEW_LINE   for _ in range ( int ( input ( ) ) ) : n , k = read ( ) NEW_LINE a = list ( read ( ) ) NEW_LINE x = [ ] NEW_LINE for i in range ( 1 , n ) : x . append ( math . ceil ( 100 * a [ i ] / k - sum ( a [ 1 : i ] ) ) ) NEW_LINE print ( max ( 0 , max ( x ) - a [ 0 ] ) ) NEW_LINE

import math   NEW_LINE def solve ( ) : n , k = map ( int , input ( ) . split ( ) ) NEW_LINE ps = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE sum1 = ps [ 0 ] NEW_LINE maximum = 0 NEW_LINE for i in range ( 1 , len ( ps ) ) : temp = math . ceil ( ( 100 * ps [ i ] - k * sum1 ) / k ) NEW_LINE if temp > maximum : maximum = temp NEW_LINE sum1 += ps [ i ] NEW_LINE print ( maximum )         t = int ( input ( ) ) NEW_LINE while t > 0 : solve ( ) NEW_LINE t = t - 1 NEW_LINE

import sysimport NEW_LINE mathinf = float ( ' inf ' ) NEW_LINE

import sys , mathfrom NEW_LINE collections NEW_LINE import defaultdict , dequeinput = sys . stdin . readline     t = int ( input ( ) ) NEW_LINE while ( t > 0 ) : n , k = map ( int , input ( ) . split ( ) ) NEW_LINE l = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE total = 0 NEW_LINE s = l [ 0 ] NEW_LINE percneeded = k / 100 NEW_LINE for i in range ( 1 , n ) : cur = l [ i ] / s NEW_LINE if ( cur > percneeded ) : need = math . ceil ( ( 100 * l [ i ] ) / k - s ) NEW_LINE total += need NEW_LINE s += need NEW_LINE s += l [ i ] NEW_LINE


import java . util . * ; import java . io . * ; import java . lang . * ; import java . math . * ;   public class cp { static BufferedReader br ; static StringTokenizer st ;   public static void main ( String [ ] args ) throws IOException {   br = new BufferedReader ( new InputStreamReader ( System . in ) ) ;   st = readLine ( ) ; int n = tokenInt ( ) ; st = readLine ( ) ; int [ ] seq = new int [ n ] ; int i = 0 ; while ( st . hasMoreTokens ( ) ) { seq [ i ] = tokenInt ( ) ; i ++ ; } System . out . println ( new Solver ( ) . solve ( n , seq ) ) ;   }   static StringTokenizer readLine ( ) throws IOException { return new StringTokenizer ( br . readLine ( ) ) ; } static int tokenInt ( ) { return Integer . parseInt ( st . nextToken ( ) ) ; } static long tokenLong ( ) { return Long . parseLong ( st . nextToken ( ) ) ; } static double tokenDouble ( ) { return Double . parseDouble ( st . nextToken ( ) ) ; } static char [ ] tokenChar ( ) { return st . nextToken ( ) . toCharArray ( ) ; }   }    class Solver { public int solve ( int n , int [ ] seq ) throws IOException { int counter = 0 ; int sign = seq [ 0 ] ; List < Integer > arrList = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( seq [ i ] == sign ) { counter ++ ; } else { arrList . add ( counter ) ; sign = seq [ i ] ; counter = 1 ; } } arrList . add ( counter ) ;   int max = - 1 ; int min = 0 ; for ( int i = 0 ; i < arrList . size ( ) - 1 ; i ++ ) { min = Math . min ( arrList . get ( i ) , arrList . get ( i + 1 ) ) ; max = Math . max ( min , max ) ; } return max * 2 ; } }

import java . util . Scanner ;   public class _0501SushiforTwo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } int max = - 1 ; int prev = - 1 ; int len = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] == arr [ i - 1 ] ) { len ++ ; } else { if ( prev == - 1 ) { prev = len ; len = 1 ; } else { max = Math . max ( max , Math . min ( len , prev ) ) ; prev = len ; len = 1 ; } } max = Math . max ( max , Math . min ( len , prev ) ) ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ;   public class SushiForTwo {   static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } }   public static void main ( String [ ] args ) { FastReader fr = new FastReader ( ) ; int n = fr . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = fr . nextInt ( ) ; }   int countOne = 1 , countTwo = 1 ; int prev = - 1 , cur = 1 ; int R = 0 ; int max = 0 ; boolean prevOne = false ;   while ( R <= ( n - 1 ) ) { while ( R < ( n - 1 ) && arr [ R ] == arr [ R + 1 ] ) { R ++ ; cur ++ ; if ( prev == cur && ( cur + prev > max ) ) { max = cur + prev ; } } if ( R == n - 1 ) { if ( Math . min ( cur , prev ) * 2 > max ) max = Math . min ( cur , prev ) * 2 ; System . out . println ( max ) ; return ; } if ( Math . min ( cur , prev ) * 2 > max ) max = 2 * Math . min ( cur , prev ) ;

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { int n = in . nextInt ( ) ; long arr [ ] = new long [ 100005 ] ; long b [ ] = new long [ 100005 ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = in . nextInt ( ) ; b [ i ] = 1 ; } int j = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] == arr [ i - 1 ] ) { b [ j ] ++ ; } else { j ++ ; } } long sum = 0 ; for ( int i = 1 ; i <= j ; i ++ ) { sum = Math . max ( sum , Math . min ( b [ i ] , b [ i - 1 ] ) ) ; } System . out . println ( sum * 2 ) ; } } }

n = int ( input ( ) ) array = [ int ( x ) for x in input ( ) . split ( ) ]   a = [ ] count = 1 Max = 0   for i in range ( len ( array ) - 1 ) : if ( array [ i ] == array [ i + 1 ] ) : count += 1 else : a . append ( count ) count = 1   a . append ( count )   for i in range ( 1 , len ( a ) ) : temp = min ( a [ i - 1 ] , a [ i ] ) Max = max ( temp , Max ) print ( Max * 2 ) NEW_LINE

n_pieces = int ( input ( ) ) sushi_array = map ( int , input ( ) . split ( ) )   previous_len = 1 curr_len = 1 previous_piece = 0 max_sushi = 0   for piece in sushi_array : if previous_piece != piece : max_sushi = max ( max_sushi , 2 * min ( previous_len , curr_len ) ) previous_len = curr_len curr_len = 1 previous_piece = piece   else : curr_len += 1 max_sushi = max ( max_sushi , 2 * min ( previous_len , curr_len ) )   print ( max_sushi ) NEW_LINE

from itertools import groupbyt = input ( ) row = input ( ) . split ( ) row = [ len ( list ( g ) ) for k , g in groupby ( row ) ]   ans = 2 * max ( min ( a , b ) for a , b in zip ( row , row [ 1 : ] ) ) print ( ans ) NEW_LINE

num = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) + [ 10 ]   summ = [ ] ct = 1 for i in range ( num ) : if arr [ i ] == arr [ i + 1 ] : ct += 1 else : summ . append ( ct ) ct = 1 NEW_LINE


import java . util . Scanner ;   public class A1469 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { String S = in . next ( ) ; boolean possible = ( S . length ( ) % 2 == 0 ) && ( S . charAt ( 0 ) != ' ) ' ) && ( S . charAt ( S . length ( ) - 1 ) != ' ( ' ) ; System . out . println ( possible ? " YES " : " NO " ) ; } }   }

import java . util . Scanner ;   public class RegularBracketSequence {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int t = in . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int leftB = 0 ; int rightB = 0 ; int qMark = 0 ; String str = in . next ( ) ; for ( int j = 0 ; j < str . length ( ) ; j ++ ) { if ( str . charAt ( j ) == ' ( ' ) { leftB ++ ; } else if ( str . charAt ( j ) == ' ) ' ) { rightB ++ ; } else { qMark ++ ; } } if ( str . charAt ( 0 ) != ' ) ' && str . charAt ( str . length ( ) - 1 ) != ' ( ' ) { if ( leftB == rightB ) { if ( qMark == 0 || qMark % 2 == 0 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } if ( leftB != rightB ) { if ( leftB % 2 == 1 || rightB % 2 == 1 ) { if ( qMark % 2 == 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } else { if ( qMark % 2 == 0 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } } else { System . out . println ( " NO " ) ; } } }   }

import java . util . Scanner ;   public class RegularBracketSequence { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String k = scanner . nextLine ( ) ; int testCases = Integer . parseInt ( k ) ; String s ; String [ ] result = new String [ testCases ] ; for ( int i = 0 ; i < testCases ; i ++ ) { s = scanner . nextLine ( ) ; result [ i ] = solve ( s ) ; }   for ( int i = 0 ; i < testCases ; i ++ ) { System . out . println ( result [ i ] ) ; } }   public static String solve ( String s ) { if ( s . startsWith ( " ) " ) || s . endsWith ( " ( " ) ) return " No " ; if ( s . length ( ) % 2 == 1 ) return " No " ; return " Yes " ; } }

import java . util . Scanner ;   public class RegularBracketSequence { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String testcases = scanner . nextLine ( ) ;   int testcases1 = Integer . parseInt ( testcases ) ; while ( testcases1 -- != 0 ) { String s = scanner . nextLine ( ) ; System . out . println ( solve ( s ) ) ; } }   public static String solve ( String s ) { String response = " " ; if ( s . length ( ) % 2 > 0 || s . charAt ( 0 ) == ' ) ' || s . charAt ( s . length ( ) - 1 ) == ' ( ' ) { return response = " NO " ; } int questionNumbers = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' ? ' ) { questionNumbers ++ ; } } if ( questionNumbers % 2 == 0 ) { response = " YES " ; } else { response = " NO " ; } return response ; } }

import java . util . * ; import java . io . IOException ;   public class Regex { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String s = sc . next ( ) ; char [ ] c = s . toCharArray ( ) ; if ( c . length % 2 == 0 && ( c [ 0 ] == ' ( ' || c [ 0 ] == ' ? ' ) && ( c [ c . length - 1 ] == ' ) ' || c [ c . length - 1 ] == ' ? ' ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } }

for i in range ( int ( input ( ) ) ) : s = str ( input ( ) ) NEW_LINE n = len ( s ) NEW_LINE if n % 2 != 0 : NEW_LINE INDENT print ( " NO " ) elif s [ 0 ] == " ) " or s [ n - 1 ] == " ( " : NEW_LINE print ( " NO " ) else : NEW_LINE print ( " YES " ) NEW_LINE DEDENT

for _ in range ( int ( input ( ) ) ) : s = input ( ) NEW_LINE n = len ( s ) NEW_LINE if n % 2 != 0 or s [ 0 ] == ' ) ' or s [ n - 1 ] == ' ( ' : NEW_LINE INDENT print ( ' No ' ) else : NEW_LINE print ( ' YEs ' ) NEW_LINE DEDENT

import osimport NEW_LINE sysfrom NEW_LINE io NEW_LINE import BytesIO , IOBase     NEW_LINE def main ( ) : pass NEW_LINE     NEW_LINE

def solve ( s ) : if NEW_LINE INDENT ( s [ 0 ] == " ) " or s [ - 1 ] == " ( " or len ( s ) % 2 ) : NEW_LINE DEDENT return ( " NO " ) else : x = s . count ( " ? " ) NEW_LINE if ( x % 2 == 0 ) : return ( " YES " ) NEW_LINE return ( " NO " ) NEW_LINE for i in range ( int ( input ( ) ) ) : print ( solve ( input ( ) ) ) NEW_LINE

t = int ( input ( ) ) NEW_LINE for _ in range ( t ) : s = input ( ) NEW_LINE if ( s [ 0 ] == " ) " or s [ - 1 ] == " ( " or len ( s ) % 2 != 0 ) :     NEW_LINE print ( " NO " ) else : print ( " YES " )               NEW_LINE


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

import java . util . * ;   public class questionCF {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int q = sc . nextInt ( ) ; while ( q -- > 0 ) { String s = sc . next ( ) ; int f = 0 , j = 0 , k = 0 ; int i = s . length ( ) - 1 ; char c = s . charAt ( i ) ; if ( c == ' o ' && s . charAt ( i - 1 ) == ' p ' ) System . out . println ( " FILIPINO " ) ; if ( c == ' u ' && s . charAt ( i - 1 ) == ' s ' && s . charAt ( i - 2 ) == ' e ' && s . charAt ( i - 3 ) == ' d ' ) System . out . println ( " JAPANESE " ) ; if ( c == ' u ' && s . charAt ( i - 1 ) == ' s ' && s . charAt ( i - 2 ) == ' a ' && s . charAt ( i - 3 ) == ' m ' ) System . out . println ( " JAPANESE " ) ;   if ( c == ' a ' && s . charAt ( i - 1 ) == ' d ' && s . charAt ( i - 2 ) == ' i ' && s . charAt ( i - 3 ) == ' n ' && s . charAt ( i - 4 ) == ' m ' ) System . out . println ( " KOREAN " ) ;   }   } }

import java . util . * ; import static java . lang . Math . pow ;   public class Test { public static void main ( String [ ] args ) {   Scanner input = new Scanner ( System . in ) ; int t = input . nextInt ( ) ; while ( t -- > 0 ) {   char [ ] s = input . next ( ) . toCharArray ( ) ; switch ( s [ s . length - 1 ] ) { case ' o ' : System . out . println ( " FILIPINO " ) ; break ; case ' u ' : System . out . println ( " JAPANESE " ) ; break ; default : System . out . println ( " KOREAN " ) ; } } } }

import java . util . Scanner ;   public class SuffixThree {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int size = sc . nextInt ( ) ; for ( int i = 0 ; i < size ; i ++ ) { String value = sc . next ( ) ; int length = value . toCharArray ( ) . length ; if ( length >= 4 ) { if ( value . substring ( length - 2 ) . equals ( " po " ) ) { System . out . println ( " FILIPINO " ) ; } else if ( value . substring ( length - 4 ) . equals ( " desu " ) || value . substring ( length - 4 ) . equals ( " masu " ) ) { System . out . println ( " JAPANESE " ) ; } else if ( value . substring ( length - 5 ) . equals ( " mnida " ) ) { System . out . println ( " KOREAN " ) ; } } else { System . out . println ( " FILIPINO " ) ; } } } }

for x in range ( int ( input ( ) ) ) : a = input ( ) if a . endswith ( " po " ) : print ( " FILIPINO " ) if a . endswith ( " desu " ) or a . endswith ( " masu " ) : print ( " JAPANESE " ) if a . endswith ( " mnida " ) : print ( " KOREAN " ) NEW_LINE

import sys   def main ( ) : inp = sys . stdin . read ( ) . strip ( ) . split ( ' \n ' ) [ 1 : ] d = { ' po ' : ' FILIPINO ' , ' desu ' : ' JAPANESE ' , ' masu ' : ' JAPANESE ' , ' mnida ' : ' KOREAN ' } out = [ ] for s in inp : for k in d : if s . endswith ( k ) : out . append ( d [ k ] ) break return out   print ( * main ( ) , sep = ' \n ' ) NEW_LINE

for cas in range ( int ( input ( ) ) ) : print ( { ' o ' : " FILIPINO " , ' a ' : " KOREAN " , ' u ' : " JAPANESE " } [ input ( ) [ - 1 ] ] ) NEW_LINE


import java . util . * ;   public class A { public static void main ( String ... args ) { final Scanner sc = new Scanner ( System . in ) ; final int a = sc . nextInt ( ) ; final int b = sc . nextInt ( ) ; long max = ( long ) a * a - ( long ) b * b ; int p = 1 ; for ( int i = 1 ; i <= a ; i ++ ) { long ans = ( long ) ( a - i + 1 ) * ( a - i + 1 ) + i - 1 ; final int r = b % ( i + 1 ) ; ans -= ( long ) ( b / ( i + 1 ) ) * ( b / ( i + 1 ) ) * ( i + 1 - r ) + ( long ) ( b / ( i + 1 ) + 1 ) * ( b / ( i + 1 ) + 1 ) * r ; if ( ans > max ) { max = ans ; p = i ; } } System . out . println ( max ) ; final int r = b % ( p + 1 ) ; final int d = b / ( p + 1 ) ; final char [ ] cs = new char [ a + b ] ; for ( int i = 0 , j = 0 ; i <= p ; i ++ ) { if ( i < r ) for ( int k = 0 ; k <= d ; j ++ , k ++ ) cs [ j ] = ' x ' ; else for ( int k = 0 ; k < d ; j ++ , k ++ ) cs [ j ] = ' x ' ;   if ( i == 0 ) for ( int k = 0 ; k <= a - p ; j ++ , k ++ ) cs [ j ] = ' o ' ; else if ( i < p ) { cs [ j ++ ] = ' o ' ; } } System . out . println ( cs ) ; } }

a , b = map ( int , input ( ) . split ( ) )   def sqr ( x ) : return x * x   def work ( num , flag = 0 ) : ans = sqr ( a - num + 1 ) + num - 1 could = min ( b , num + 1 )   cc = b // could res = b % could   ans -= res * sqr ( cc + 1 ) + ( could - res ) * sqr ( cc ) if flag : print ( ans ) list = ' '   res2 = could - res if could == num + 1 : list += ' x ' * cc res2 -= 1   ta = a list += ' o ' * ( a - num + 1 ) ta -= a - num + 1 while ta > 0 : u = cc + int ( res > 0 ) if res > 0 : res -= 1 else : res2 -= 1 list += ' x ' * u list += ' o ' ta -= 1 if res > 0 or res2 > 0 : list += ' x ' * ( cc + int ( res > 0 ) ) print ( str ( list ) ) return ans   if a == 0 : print ( - sqr ( b ) ) print ( ' x ' * b ) elif b == 0 : print ( sqr ( a ) ) print ( ' o ' * a ) else : now = 1 for i in range ( 1 , a + 1 ) : if i - 1 <= b and work ( i ) > work ( now ) : now = i work ( now , 1 ) NEW_LINE


import javax . sound . midi . Soundbank ; import java . io . BufferedInputStream ; import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . PriorityQueue ; import java . util . Scanner ;   public class Solution1 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( new BufferedInputStream ( System . in ) ) ; int n = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; Map < Integer , PriorityQueue < Integer > > map = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int party = scanner . nextInt ( ) ; int money = scanner . nextInt ( ) ; map . putIfAbsent ( party , new PriorityQueue < > ( ) ) ; map . get ( party ) . add ( money ) ; } long res = Long . MAX_VALUE ; PriorityQueue < Integer > priorityQueue = map . get ( 1 ) ; PriorityQueue < Integer > ttt ; for ( int k = 1 ; k <= n ; k ++ ) { ttt = new PriorityQueue < > ( ) ; long cur = ( priorityQueue == null ? 0 : priorityQueue . size ( ) ) ; if ( cur <= k ) { long money = 0 ; for ( Map . Entry < Integer , PriorityQueue < Integer > > integerPriorityQueueEntry : map . entrySet ( ) ) { int key = integerPriorityQueueEntry . getKey ( ) ; PriorityQueue < Integer > queue = new PriorityQueue < > ( integerPriorityQueueEntry . getValue ( ) ) ; if ( key == 1 || queue . isEmpty ( ) ) { continue ; } while ( queue . size ( ) >= k ) { money += queue . poll ( ) ; cur ++ ; } if ( ! queue . isEmpty ( ) ) { ttt . addAll ( queue ) ; } if ( cur > k ) { break ; } } if ( cur < k ) { while ( cur < k && ! ttt . isEmpty ( ) ) { money += ttt . poll ( ) ; cur ++ ; } } if ( cur == k ) { res = Math . min ( res , money ) ; } }   } System . out . println ( res ) ; }   }

import sysfrom math import *   def minp ( ) : return sys . stdin . readline ( ) . strip ( )   def mint ( ) : return int ( minp ( ) )   def mints ( ) : return map ( int , minp ( ) . split ( ) )   n , m = mints ( ) A = [ 0 ] * nh = [ 0 ] * mfor i in range ( n ) : a , b = mints ( ) A [ i ] = ( b , a - 1 ) h [ a - 1 ] += 1 A . sort ( ) r = 1e100 for k in range ( 1 , n + 1 ) : b = h [ : : ] w = [ True ] * n c = 0 for i in range ( n ) : p , id = A [ i ] if id != 0 and b [ id ] >= k : b [ 0 ] += 1 b [ id ] -= 1 c += p w [ i ] = False for i in range ( n ) : p , id = A [ i ] if id != 0 and w [ i ] and b [ 0 ] < k : b [ 0 ] += 1 b [ id ] -= 1 c += p w [ i ] = False NEW_LINE

import sys   def pro ( ) : return sys . stdin . readline ( ) . strip ( )   def rop ( ) : return map ( int , pro ( ) . split ( ) )   a , s = rop ( ) q = [ 0 ] * aw = [ 0 ] * sfor i in range ( a ) : n , p = rop ( ) q [ i ] = ( p , n - 1 ) w [ n - 1 ] += 1 q . sort ( ) t = 1e100 for k in range ( 1 , a + 1 ) : p = w [ : : ] r = [ True ] * a m = 0 for i in range ( a ) : po , rty = q [ i ] if rty != 0 and p [ rty ] >= k : p [ 0 ] += 1 p [ rty ] -= 1 m += po r [ i ] = False for i in range ( a ) : po , rty = q [ i ] if rty != 0 and r [ i ] and p [ 0 ] < k : p [ 0 ] += 1 p [ rty ] -= 1 m += po r [ i ] = False t = min ( t , m ) print ( t ) NEW_LINE


import java . util . * ; import java . io . * ;   public class Main {   public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; }   public static int mod = 1_000_000_007 ;   void run ( FastScanner in , PrintWriter out ) {   char [ ] ca = in . next ( ) . toCharArray ( ) ; int n = ca . length ;   int [ ] c = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { c [ i ] = ca [ n - 1 - i ] - '0' ; }   long [ ] dp = new long [ n ] ; dp [ 0 ] = c [ 0 ] == 0 ? 0 : 1 ; int prevOnePos = c [ 0 ] == 0 ? - 1 : 0 ;

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

import java . io . * ; import java . util . * ;   public class A {   static long find ( char [ ] x , int len , int curr ) { if ( len == 0 ) return 0 ;   if ( x [ curr ] == '1' ) { return ( ( pow_2 [ len - 1 ] * pow_2 [ len - 1 ] ) % mod + ( 2 * find ( x , len - 1 , curr + 1 ) ) % mod ) % mod ; } else { return ( 2 * ( find ( x , len - 1 , curr + 1 ) % mod ) ) % mod ; } }   static long [ ] pow_2 ; static long mod = ( int ) 1e9 + 7 ;   public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; char [ ] x = br . readLine ( ) . toCharArray ( ) ; int n = x . length ; pow_2 = new long [ n + 1 ] ; pow_2 [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { pow_2 [ i ] = ( 2 * pow_2 [ i - 1 ] ) % mod ; } long ans = find ( x , n , 0 ) ; System . out . println ( ans ) ; } }

s = input ( ) new_s = " " n = len ( s ) for i in range ( n - 1 , - 1 , - 1 ) : new_s += s [ i ] s = new_skek = 0 for i in range ( n ) : kek += ( 1 << i ) * ( s [ i ] == '1' ) for i in range ( n - 1 ) : kek *= 2 print ( kek % ( 10 ** 9 + 7 ) ) NEW_LINE

MOD = int ( 1e9 + 7 ) x = input ( ) [ : : - 1 ] n = len ( x ) res = 0 for i , t in enumerate ( x ) : if t == '1' : res = ( res + ( 1 << ( n - 1 + i ) ) ) % MODprint ( res ) NEW_LINE

pri = pow ( 10 , 9 ) + 7   s = input ( ) m = len ( s ) val = int ( s , 2 ) print ( ( pow ( 2 , m - 1 , pri ) * val ) % pri ) NEW_LINE


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

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

import java . io . * ; import java . util . * ; import java . lang . * ;   public class B {   public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; int n = in . nextInt ( ) , k = in . nextInt ( ) ; int [ ] arr = in . readArray ( n ) ; long [ ] pre = new long [ n - k + 1 ] ; Pair [ ] dp = new Pair [ n - k + 1 ] ; long ans = 0 ; for ( int i = 0 ; i < k ; i ++ ) { ans += arr [ i ] ; } pre [ 0 ] = ans ; for ( int i = 1 ; i <= n - k ; i ++ ) { ans -= arr [ i - 1 ] ; ans += arr [ i + k - 1 ] ; pre [ i ] = ans ; } dp [ dp . length - 1 ] = new Pair ( pre [ n - k ] , n - k + 1 ) ; for ( int i = pre . length - 2 ; i >= 0 ; i -- ) { if ( pre [ i ] >= dp [ i + 1 ] . a ) dp [ i ] = new Pair ( pre [ i ] , i + 1 ) ; else dp [ i ] = dp [ i + 1 ] ; } ans = 0 ; int first = - 1 , second = - 1 ; for ( int i = 0 ; i <= n - 2 * k ; i ++ ) { if ( ans < pre [ i ] + dp [ i + k ] . a ) { ans = pre [ i ] + dp [ i + k ] . a ; first = i + 1 ; second = ( int ) dp [ i + k ] . b ; } } System . out . println ( first + " ▁ " + second ) ; }   static final Random random = new Random ( ) ;

n , k = map ( int , input ( ) . split ( ) ) x = list ( map ( int , input ( ) . split ( ) ) ) y = [ ] s = sum ( x [ : k ] ) y . append ( s ) for i in range ( k , n ) : s += x [ i ] s -= x [ i - k ] y . append ( s ) u = y [ 0 ] v = y [ k ] ans = u + vl = 0 r = ka , b = l + 1 , r + 1 for i in range ( k + 1 , len ( y ) ) : v = y [ i ] r = i if u < y [ i - k ] : l = i - k u = y [ i - k ] if ans < u + v : a = l + 1 b = r + 1 ans = u + vprint ( a , b ) NEW_LINE

import mathimport timefrom collections import defaultdict , deque , Counterfrom sys import stdin , stdoutfrom bisect import bisect_left , bisect_rightimport sysfrom heapq import heapify , heappush , heappop n , k = map ( int , stdin . readline ( ) . split ( ) ) a = list ( map ( int , stdin . readline ( ) . split ( ) ) ) sarr = [ sum ( a [ : k ] ) ] for i in range ( 1 , n - k + 1 ) : sarr . append ( sarr [ - 1 ] - a [ i - 1 ] + a [ i + k - 1 ] ) l = len ( sarr ) m = [ 0 ] * l m [ l - 1 ] = sarr [ l - 1 ] for i in range ( l - 2 , - 1 , - 1 ) : m [ i ] = max ( m [ i + 1 ] , sarr [ i ] ) ans = 0 for i in range ( l - k ) : if ( sarr [ i ] + m [ i + k ] ) > ans : ans = sarr [ i ] + m [ i + k ] top = isec = sarr [ top + k : ] . index ( max ( sarr [ top + k : ] ) ) + top + kprint ( top + 1 , sec + 1 )   NEW_LINE

def main ( ) : wynik = 0 para = ( 0 , 0 ) n , k = input ( ) . split ( ) n , k = int ( n ) , int ( k ) odl = [ ] tab = list ( map ( int , input ( ) . split ( ) ) ) pocz = tab [ 0 ] odl = [ pocz ] for i in range ( 1 , n ) : if i < k : odl . append ( odl [ i - 1 ] + tab [ i ] ) else : odl . append ( odl [ i - 1 ] + tab [ i ] - tab [ i - k ] ) odl = odl [ k - 1 : ] maks = odl [ - 1 ] maksy = [ ] b = n - k + 1 for i in range ( len ( odl ) - 1 , - 1 , - 1 ) : if odl [ i ] >= maks : maks = odl [ i ] b = i + 1 maksy . append ( ( maks , b ) ) maksy . reverse ( ) for i in range ( 0 , len ( odl ) - k ) : if odl [ i ] + maksy [ i + k ] [ 0 ] > wynik : wynik = odl [ i ] + maksy [ i + k ] [ 0 ] para = ( i + 1 , maksy [ i + k ] [ 1 ] ) return f ' { para [ 0 ] } ▁ { para [ 1 ] } '     print ( main ( ) ) NEW_LINE


import java . io . * ;   import java . util . * ;   public class CodeForce { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; String [ ] s = br . readLine ( ) . split ( " " ) ; int [ ] arr = new int [ 10 ] ; int k = 0 ; HashMap < Integer , Integer > set = new HashMap < > ( ) ; for ( int i = 0 ; i < str . length ; i ++ ) { k = Integer . parseInt ( str [ i ] ) ; if ( k == 5 ) k = 2 ; if ( k == 9 ) k = 6 ; set . put ( k , set . getOrDefault ( k , 0 ) + 1 ) ; } for ( int j = 0 ; j < s . length ; j ++ ) { if ( s [ j ] . equals ( "5" ) || s [ j ] . equals ( "2" ) ) { arr [ 5 ] ++ ; arr [ 2 ] ++ ; } else if ( s [ j ] . equals ( "6" ) || s [ j ] . equals ( "9" ) ) { arr [ 6 ] ++ ; arr [ 9 ] ++ ; } else arr [ Integer . parseInt ( s [ j ] ) ] ++ ; } Set < Integer > map = set . keySet ( ) ; int min = Integer . MAX_VALUE ; for ( int a : map ) { min = Math . min ( min , arr [ a ] / set . get ( a ) ) ; } System . out . println ( min ) ; }   }

import java . io . * ; import java . util . Arrays ; import java . util . StringTokenizer ;   public class Sheldon { public static void main ( String [ ] args ) {   FastReader in = new FastReader ( ) ; OutputStream outputStream = System . out ; PrintWriter out = new PrintWriter ( outputStream ) ; int i , j , a , b , c , n , k , l , m , l1 ; String s , s1 , s2 ; boolean is1 = false , is = false , was = false ; long sum = 0 ; int [ ] brr = new int [ 10 ] ; int [ ] arr = new int [ 10 ] ; int [ ] crr = new int [ 10 ] ;

def c ( a , b ) : a = a . replace ( '6' , '9' ) a = a . replace ( '2' , '5' ) b = b . replace ( '6' , '9' ) b = b . replace ( '2' , '5' ) n = 10000 for i in '01345789' : t = a . count ( i ) if t != 0 : n = min ( n , b . count ( i ) // t ) return na = input ( ) b = input ( ) print ( c ( a , b ) ) NEW_LINE

from collections import defaultdictimport matht = input ( ) s = input ( ) tomake = defaultdict ( lambda : 0 ) for i in t : if ( i == '5' ) : tomake [ '2' ] += 1 elif ( i == '9' ) : tomake [ '6' ] += 1 else : tomake [ i ] += 1 fro = defaultdict ( lambda : 0 ) for i in s : if ( i == '5' ) : fro [ '2' ] += 1 elif ( i == '9' ) : fro [ '6' ] += 1 else : fro [ i ] += 1 ans = math . inffor i in tomake . keys ( ) : ans = min ( ans , fro [ i ] // tomake [ i ] ) print ( ans ) NEW_LINE

def convert_string ( string_list , len_string_list ) : change_dict = { } change_dict [ '9' ] = '6' change_dict [ '5' ] = '2' for i in range ( len_string_list ) : if string_list [ i ] in change_dict : string_list [ i ] = change_dict [ string_list [ i ] ] NEW_LINE

def re ( s ) : t = " " for i in s : if ( i == "2" or i == "5" ) : t += " a " elif ( i == "6" or i == "9" ) : t += " b " else : t += i return tfrom collections import defaultdict as dddef main ( ) : t = re ( input ( ) ) s = re ( input ( ) ) req = dd ( int ) hv = dd ( int ) ans = 10 ** 9 for i in t : req [ i ] += 1 for j in s : hv [ j ] += 1 for i in t : ans = min ( ans , hv [ i ] // req [ i ] ) print ( ans ) main ( ) NEW_LINE


import java . lang . reflect . Array ; import java . util . * ; import java . util . function . Function ; import java . util . stream . Collectors ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Random ; import java . util . StringTokenizer ; import java . io . * ; import java . math . * ;   public class CC { static class pair implements Comparable < pair > { int x ; long y ; pair ( int x , long y ) { this . x = x ; this . y = y ; } public int compareTo ( pair o ) { return ( int ) ( y - o . y ) ; }   } static ArrayList < Long > num = new ArrayList < > ( ) ; static void printPermutn ( String str , String ans ) {

import java . util . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class a { static long [ ] count , count1 ; static long [ ] arr ; static char [ ] ch , ch1 ; static long [ ] darr ; static long [ ] [ ] mat , mat1 ; static int 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 . Scanner ;   public class _0732MaximandBiology { static int countSteps ( String s ) { String check = " ACTG " ; int steps = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int val = Math . abs ( check . charAt ( i ) - s . charAt ( i ) ) ; steps += Math . min ( val , 26 - val ) ; } return steps ; }   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; sc . nextLine ( ) ; String s = sc . nextLine ( ) ; int minSteps = Integer . MAX_VALUE ; for ( int i = 0 ; i < s . length ( ) - 3 ; i ++ ) { minSteps = Math . min ( minSteps , countSteps ( s . substring ( i , i + 4 ) ) ) ; } System . out . println ( minSteps ) ; }   }

from sys import stdinn = int ( stdin . readline ( ) ) s = stdin . readline ( ) [ : - 1 ] ans = 10000 t = ' ACTG ' for i in range ( n - 3 ) : r = s [ i : i + 4 ] c = 0 for j in range ( 4 ) : x = ( ( ord ( r [ j ] ) - ord ( t [ j ] ) + 26 ) % 26 ) y = ( ( ord ( t [ j ] ) - ord ( r [ j ] ) + 26 ) % 26 ) c = c + min ( x , y ) ans = min ( ans , c ) print ( ans ) NEW_LINE

n = int ( input ( ) ) string = input ( ) gnome = [ ord ( ' A ' ) , ord ( ' C ' ) , ord ( ' T ' ) , ord ( ' G ' ) ] result = [ ] for i in range ( len ( string ) - 3 ) : gnome_new = [ ord ( string [ i ] ) , ord ( string [ i + 1 ] ) , ord ( string [ i + 2 ] ) , ord ( string [ i + 3 ] ) ] a = list ( map ( lambda x : ( 26 - abs ( x [ 0 ] - x [ 1 ] ) ) if abs ( x [ 0 ] - x [ 1 ] ) > 13 else abs ( x [ 0 ] - x [ 1 ] ) , zip ( gnome_new , gnome ) ) ) result . append ( sum ( [ 1 if x == 25 else x for x in a ] ) ) print ( min ( result ) ) NEW_LINE


import java . util . * ; import java . io . * ; import java . math . * ;   public class Practice   { static FastReader sc = new FastReader ( ) ; static int mod = ( int ) Math . pow ( 10 , 9 ) + 7 ; static int dp [ ] [ ] ; ; public static void main ( String [ ] args ) { PrintWriter out = new PrintWriter ( System . out ) ;

import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ;   public class pblm3 { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int st = 1 , i = st ; int c = 0 ; List < Integer > al = new ArrayList < Integer > ( ) ; while ( i <= N ) { al . add ( i ) ; c ++ ;

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ;   import static java . lang . Math . log ; import static java . lang . Math . min ;   public class First {   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 ( ) ; int t ;

import java . util . * ; import java . io . * ; import java . math . * ;   public class First {   public static ArrayList < Integer > getAns ( int m , int in , int shift , int y , int n ) { ArrayList < Integer > list = new ArrayList < Integer > ( ) ; in -= shift ; for ( int i = 0 ; i < m ; i ++ ) { list . add ( in ) ; in += y ; } return list ; } public static void process ( ) throws IOException { int n = ni ( ) ; int k = ni ( ) ; int y = ( 2 * k ) + 1 ; int count = 0 ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; if ( k >= ( ( n + 1 ) / 2 ) ) { count = 1 ; list . add ( ( n + 1 ) / 2 ) ; } else { int m = n / y ; int in = ( y + 1 ) / 2 ; int left = n % y ; ; if ( left == 0 ) { list = getAns ( m , in , 0 , y , n ) ; } else { if ( left <= k + 1 ) { list = getAns ( m , in , k + 1 - left , y , n ) ; list . add ( n ) ; } else { list = getAns ( m , in , 0 , y , n ) ; int h = list . get ( list . size ( ) - 1 ) ; list . add ( h + ( 2 * k ) + 1 ) ; } } count = list . size ( ) ; } pn ( count ) ; StringBuilder sb = new StringBuilder ( " " ) ; for ( Integer i : list ) { sb . append ( i ) . append ( " ▁ " ) ; } pn ( sb . toString ( ) ) ; }    static AnotherReader sc ; static PrintWriter out ; public static void main ( String [ ] args ) throws IOException { out = new PrintWriter ( System . out ) ; sc = new AnotherReader ( ) ; boolean oj = true ;

n , k = map ( int , input ( ) . split ( ) ) l = 2 * k + 1 stack = [ ] if 0 < n % l < ( k + 1 ) : for i in range ( 1 , n + 1 , l ) : stack . append ( i ) else : for i in range ( k + 1 , n + 1 , l ) : stack . append ( i ) print ( len ( stack ) ) print ( * stack ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) )   if n == 1 : print ( 1 ) print ( 1 ) exit ( )   if k >= n // 2 : print ( 1 ) print ( ( n + 1 ) // 2 ) else : m = 1001 temp = - 1 for r1 in range ( 0 , k + 1 ) : for r2 in range ( 0 , k + 1 ) : t = n - ( r1 + 1 + k ) - ( r2 + 1 + k ) if t < 0 : continue if t % ( 2 * k + 1 ) == 0 : x = t // ( 2 * k + 1 ) if x + 2 <= m : m = x + 2 temp = [ r1 , r2 , x ] print ( m ) r1 , r2 , x = temp ans = [ r1 + 1 ] for i in range ( x ) : cur = ans [ - 1 ] ans . append ( cur + 2 * k + 1 ) ans . append ( n - r2 ) print ( * ans ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) c = k + 1 if n % ( 2 * k + 1 ) >= k + 1 or n % ( 2 * k + 1 ) == 0 else 1 ans = [ ] while c <= n : ans . append ( c ) c += 2 * k + 1 if ans [ - 1 ] + k < n : ans . append ( min ( n , ans [ - 1 ] + k * 2 + 1 ) ) print ( len ( ans ) ) print ( * ans ) NEW_LINE

from sys import stdin as ulazinput = ulaz . readlinen , k = map ( int , input ( ) . split ( ) ) naj = float ( " inf " ) koje = [ ] for i in range ( k + 1 ) : ostale = n - k - 1 - i velicina = 1 + ( 2 * k ) if ostale <= 0 : naj = 1 koje = [ i + 1 ] break if ostale % velicina < k + 1 and ostale % velicina != 0 : continue ponavljanja = ( ostale // velicina ) + 2 if ostale % velicina == 0 : ponavljanja -= 1 if ponavljanja < naj : naj = ponavljanja koje = [ ] koje . append ( i + 1 ) for e in range ( ostale // velicina ) : koje . append ( ( i + 1 ) + ( ( e + 1 ) * ( ( 2 * k ) + 1 ) ) ) if ostale % velicina != 0 : koje . append ( n - ( ( ostale % velicina ) - ( k + 1 ) ) ) print ( naj ) print ( * koje ) NEW_LINE

from sys import stdin as ulazinput = ulaz . readlinedef sol ( ) : n , k = map ( int , input ( ) . split ( ) ) naj = float ( " inf " ) koje = [ ] for i in range ( k + 1 ) : ostale = n - k - 1 - i velicina = 1 + ( 2 * k ) if ostale <= 0 : naj = 1 koje = [ i + 1 ] break if ostale % velicina < k + 1 and ostale % velicina != 0 : continue ponavljanja = ( ostale // velicina ) + 2 if ostale % velicina == 0 : ponavljanja -= 1 if ponavljanja < naj : naj = ponavljanja koje = [ ] koje . append ( i + 1 ) for e in range ( ostale // velicina ) : koje . append ( ( i + 1 ) + ( ( e + 1 ) * ( ( 2 * k ) + 1 ) ) ) if ostale % velicina != 0 : koje . append ( n - ( ( ostale % velicina ) - ( k + 1 ) ) ) print ( naj ) print ( * koje ) sol ( ) NEW_LINE


import java . util . Scanner ; import java . util . Arrays ; import java . util . Vector ; import java . util . Collections ; import java . io . PrintWriter ;    public class Solving {   public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; long n ; int q ; n = input . nextLong ( ) ; q = input . nextInt ( ) ; long x , y , res ; for ( int i = 0 ; i < q ; i ++ ) { x = input . nextInt ( ) ; y = input . nextInt ( ) ; long k = ( ( x - 1 ) * n + y + 1 ) / 2 ; long z = ( n * n + 1 ) / 2 ; if ( ( x + y ) % 2 != 0 ) { k += z ; } pw . println ( k ) ; } pw . flush ( ) ; } }

import java . util . Scanner ; import java . util . Arrays ; import java . util . Vector ; import java . util . Collections ; import java . io . PrintWriter ;    public class Solving {   public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; long n ; int q ; n = input . nextLong ( ) ; q = input . nextInt ( ) ; long x , y , res ; for ( int i = 0 ; i < q ; i ++ ) { x = input . nextInt ( ) ; y = input . nextInt ( ) ; if ( ( x + y ) % 2 == 0 ) { res = ( ( ( x - 1 ) * n ) + y + 1 ) / 2 ; pw . println ( res ) ; } else { res = ( ( ( x - 1 ) * n ) + y + 1 ) / 2 + ( n * n + 1 ) / 2 ; pw . println ( res ) ; } } pw . flush ( ) ; } }

import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class B { public static void main ( String args [ ] ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int q = Integer . parseInt ( st . nextToken ( ) ) ; for ( int i = 0 ; i < q ; i ++ ) { st = new StringTokenizer ( br . readLine ( ) ) ; int x = Integer . parseInt ( st . nextToken ( ) ) ; int y = Integer . parseInt ( st . nextToken ( ) ) ; long sum = ( long ) x + y ; if ( sum % 2 == 0 ) {

import java . util . * ; import java . io . * ; public class Main { static PrintWriter w = new PrintWriter ( System . out ) ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextInt ( ) , q = sc . nextInt ( ) ; while ( q -- > 0 ) { long x = sc . nextInt ( ) , y = sc . nextInt ( ) ; long ans = ( ( x - 1 ) * n + y + 1 ) / 2 ; if ( ( x + y ) % 2 == 0 ) w . println ( ans ) ; else w . println ( ( ( n * n + 1 ) / 2 ) + ans ) ; } w . close ( ) ; } }

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

import sys   lst = sys . stdin . readlines ( ) n , q = map ( int , lst [ 0 ] . split ( ) )   for i in range ( q ) : x , y = map ( int , lst [ i + 1 ] . split ( ) ) cnt = ( x - 1 ) * n + y ans = ( cnt + 1 ) // 2 if ( ( x + y ) % 2 == 1 ) : ans += ( n * n + 1 ) // 2 sys . stdout . write ( str ( ans ) + ' \n ' ) NEW_LINE

import sys   inp = sys . stdin . readlines ( ) ii = 0   n , q = map ( int , inp [ ii ] . split ( ) ) ii += 1   for qu in range ( q ) : x , y = map ( int , inp [ ii ] . split ( ) ) ii += 1 c = ( x - 1 ) * n + y a = ( c + 1 ) // 2 if ( x + y ) % 2 == 1 : a += ( n ** 2 + 1 ) // 2 print ( a )     NEW_LINE


import java . util . Scanner ;   public class B { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; long half = k / 2 ; if ( n < half ) { System . out . println ( "0" ) ; } else System . out . println ( ( Math . min ( n , k - 1 ) ) - half ) ; } }

import java . util . Scanner ;   public class maxstack { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; long m = sc . nextLong ( ) ; long c = 0 ; if ( m <= n ) { c = ( m - 1 ) / 2 ; } else c = n - m / 2 ; System . out . println ( c < 0 ? 0 : c ) ; }   }

import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long s1 = scanner . nextLong ( ) ; long s2 = scanner . nextLong ( ) ; if ( s2 == 1 || s2 == 2 ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; } if ( s1 * 2 >= s2 + 1 ) { if ( s2 > s1 + 1 ) { double t1 = s2 - s1 ; double t2 = s1 ; double mx = Math . ceil ( ( t2 - t1 ) / 2 ) ; System . out . printf ( " % .0f " , mx ) ;

import mathn , k = map ( int , input ( ) . split ( ) ) if k % 2 == 1 : mink = ( k + 1 ) // 2 else : mink = k // 2 + 1 print ( max ( 0 , min ( k - 1 , n ) - mink + 1 ) ) NEW_LINE

import sysimport mathfrom collections import OrderedDictdef input ( ) : return sys . stdin . readline ( ) . strip ( ) def iinput ( ) : return int ( input ( ) ) def minput ( ) : return map ( int , input ( ) . split ( ) ) def listinput ( ) : return list ( map ( int , input ( ) . split ( ) ) ) n , k = minput ( ) if n == k : print ( math . ceil ( n / 2 ) - 1 ) elif k > 2 * n : print ( 0 ) else : print ( min ( n , k - 1 ) - k // 2 ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) print ( max ( min ( n , k - 1 ) - k // 2 , 0 ) ) NEW_LINE


import java . util . ArrayList ; import java . util . Arrays ; import java . util . Scanner ;   public class Singleton_Pattern { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; b /= 2 ; c /= 4 ; int res = 7 * ( Integer . min ( Integer . min ( a , b ) , Integer . min ( b , c ) ) ) ; System . out . println ( res ) ;   } }

import java . io . * ; import java . util . * ; import javax . print . attribute . standard . Finishings ;   import java . math . * ;   public class Compote { static final Random random = new Random ( ) ; static PrintWriter out = new PrintWriter ( ( System . out ) ) ; static Reader sc = new Reader ( ) ;   public static void main ( String args [ ] ) throws IOException { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; boolean flag = true ; if ( b < 2 || c < 4 ) { flag = false ; System . out . println ( 0 ) ; } else if ( flag ) { int res = Math . min ( a , Math . min ( b / 2 , c / 4 ) ) ; System . out . println ( res * 7 ) ; }   }

import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int temp = 0 ; while ( a >= 1 && b >= 2 && c >= 4 ) { temp = temp + 7 ; a = a - 1 ; b = b - 2 ; c = c - 4 ; } System . out . println ( temp ) ; } }

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

import java . io . * ; import java . math . * ; import java . util . * ;    public class Main { static final int MAX_N = 100100 ; static final int mod = 1000000007 ; static final int INF = 0x3f3f3f3f ;    public static void main ( String [ ] args ) throws Exception { initReader ( System . in ) ;   solve ( ) ;   printWriter . flush ( ) ; }      public static void solve ( ) throws IOException { int a = nextInt ( ) ; int b = nextInt ( ) ; int c = nextInt ( ) ;   a /= 1 ; b /= 2 ; c /= 4 ;   printWriter . println ( Math . min ( a , Math . min ( b , c ) ) * 7 ) ;   }        static BufferedReader reader ; static StringTokenizer tokenizer ; static PrintWriter printWriter ;    static void initReader ( InputStream input ) { reader = new BufferedReader ( new InputStreamReader ( input ) ) ; tokenizer = new StringTokenizer ( " " ) ; printWriter = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; }   static boolean hasNext ( ) { try { while ( ! tokenizer . hasMoreTokens ( ) ) { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } } catch ( Exception e ) { return false ; } return true ; }   static String next ( ) throws IOException { while ( ! tokenizer . hasMoreTokens ( ) ) { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } return tokenizer . nextToken ( ) ; }   static String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( Exception e ) { return null ; } }   static int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; }   static long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; }   static double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; }   static char nextChar ( ) throws IOException { return next ( ) . charAt ( 0 ) ; } }

a = int ( input ( ) ) b = int ( input ( ) ) c = int ( input ( ) ) print ( 7 * min ( a , b // 2 , c // 4 ) ) NEW_LINE

a = int ( input ( ) ) b = int ( input ( ) ) c = int ( input ( ) )       compotes = c // 4 compotes = min ( compotes , b // 2 ) compotes = min ( compotes , a )   NEW_LINE

a = int ( input ( ) ) b = int ( input ( ) ) c = int ( input ( ) ) d = c // 4 d = min ( d , b // 2 ) d = min ( d , a ) print ( 1 * d + 2 * d + 4 * d ) NEW_LINE

a = int ( input ( ) ) b = int ( input ( ) ) c = int ( input ( ) ) x = 0 while ( 1 ) : if ( a < 1 or b < 2 or c < 4 ) : break x += 1 a -= 1 b -= 2 c -= 4 print ( 7 * x ) NEW_LINE

a = int ( input ( ) ) b = int ( input ( ) ) c = int ( input ( ) ) d = min ( a , b // 2 , c // 4 ) print ( 7 * d ) NEW_LINE


import java . util . * ; public class stringgeneration { public static void main ( String [ ] args ) { int t , n , k , i ;   Scanner sc = new Scanner ( System . in ) ;   t = sc . nextInt ( ) ;   while ( t -- > 0 ) { n = sc . nextInt ( ) ; k = sc . nextInt ( ) ;   for ( i = 0 ; i < n ; i ++ ) { System . out . print ( ( char ) ( ' a ' + ( i % 3 ) ) ) ; }   System . out . println ( ) ;   } } }

import java . util . Scanner ;   public class A1461 {   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 ( ) ; in . nextInt ( ) ;

import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 3 == 0 ) System . out . print ( ' a ' ) ; else if ( i % 3 == 1 ) System . out . print ( ' b ' ) ; else System . out . print ( ' c ' ) ; }   System . out . println ( ) ; } } }

import java . util . Scanner ; public class vivek { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 3 == 0 ) System . out . print ( " a " ) ; else if ( i % 3 == 1 ) System . out . print ( " b " ) ; else System . out . print ( " c " ) ; } System . out . println ( ) ; } } }

for _ in range ( int ( input ( ) ) ) : n , k = map ( int , input ( ) . split ( ) ) NEW_LINE p = n NEW_LINE t = " a " * k NEW_LINE n -= k NEW_LINE while n > 0 : t += " bca " NEW_LINE n -= 3 NEW_LINE print ( t [ : p ] ) NEW_LINE

for t in range ( int ( input ( ) ) ) : n , k = map ( int , input ( ) . split ( " ▁ " ) ) NEW_LINE print ( ( " abc " * n ) [ : n ] ) NEW_LINE

for s in [ * open ( 0 ) ] [ 1 : ] : n = int ( s . split ( ) [ 0 ] ) ; print ( ( ' abc ' * n ) [ : n ] ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashSet ; import java . util . StringTokenizer ;   public class N1242A { static ArrayList < Integer > primes ; static HashSet < Integer > primesH ; public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; primes = new ArrayList ( ) ; primesH = new HashSet ( ) ; sieveOfEratosthenes ( 1000000 ) ; long n = sc . nextLong ( ) ; if ( n == 1 ) out . println ( 1 ) ; else if ( n % 2 == 0 ) { while ( n % 2 == 0 ) { n /= 2 ; } out . println ( n == 1 ? 2 : 1 ) ; } else { if ( isPrime ( n ) ) { out . println ( n ) ; } else { int needed = 1 ; for ( int i = 3 ; i * i * 1l <= n ; i += 2 ) { if ( n % i == 0 ) { if ( needed == - 1 ) { needed = i ; } while ( n % i == 0 ) { n /= i ; } if ( n == 1 ) { needed = i ; } break ; } }

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

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

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

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

import sysfrom math import sqrtinput = lambda : sys . stdin . readline ( ) . rstrip ( " \n " )   n = int ( input ( ) ) t = ns = set ( ) i = 2 while i * i <= n : if n % i == 0 : s . add ( i ) while n % i == 0 : n = n // i i += 1 if n != 1 : s . add ( n ) if len ( s ) >= 2 or t == 1 : print ( 1 ) else : print ( s . pop ( ) )   NEW_LINE

n = int ( input ( ) ) count = 1 divisor = nfor i in range ( 2 , n + 1 ) : if i * i > n : break if n % i == 0 : while n % i == 0 : n //= i if n == 1 : print ( i ) else : print ( 1 ) exit ( 0 ) print ( n ) NEW_LINE


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

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

n , k = [ int ( y ) for y in input ( ) . split ( ) ] if k / n >= 3 : print ( 0 ) else : n = n * 3 print ( n - k ) NEW_LINE

a , b = map ( int , input ( ) . split ( ) ) print ( max ( 3 * a - b , 0 ) ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) print ( max ( 0 , 3 * n - k ) ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) )   if k / n >= 3 : print ( 0 ) else : print ( n - ( k % n ) ) NEW_LINE

import sysimport mathfrom collections import Counter   n , k = list ( map ( int , input ( ) . split ( ) ) )   near = k / nif near . is_integer ( ) : print ( n ) if near == 2 else print ( 0 ) sys . exit ( )   possibles = list ( map ( int , ( n * f ' { math . floor ( near ) } ▁ ' ) . split ( ) ) )   for i , number in enumerate ( possibles ) : possibles [ i ] = possibles [ i ] + 1 if sum ( possibles ) > k : possibles [ i ] = possibles [ i ] - 1 break   r = dict ( Counter ( possibles ) ) print ( r . get ( 2 , 0 ) ) NEW_LINE


import com . sun . org . apache . bcel . internal . generic . AALOAD ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . * ; import java . util . stream . IntStream ; import javafx . util . Pair ;   public class Main { static void sort ( int a [ ] ) { Random ran = new Random ( ) ; for ( int i = 0 ; i < a . length ; i ++ ) { int r = ran . nextInt ( a . length ) ; int temp = a [ r ] ; a [ r ] = a [ i ] ; a [ i ] = temp ; } Arrays . sort ( a ) ; } public static void main ( String [ ] args ) throws IOException { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int one = 0 , two = 0 ; long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int value = input . nextInt ( ) ; sum += value ; if ( value == 100 ) one ++ ; else two ++ ; } for ( int i = 0 ; i <= one ; i ++ ) { for ( int j = 0 ; j <= two ; j ++ ) { if ( ( ( i * 100 ) + ( j * 200 ) ) * 2 == sum ) { System . out . println ( " YES " ) ; return ; } } } System . out . println ( " NO " ) ; } }

import java . io . * ;   public class FairDivison { public static void main ( String [ ] args ) throws IOException {   BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ;   int n = Integer . parseInt ( br . readLine ( ) ) ; String [ ] x = br . readLine ( ) . split ( " ▁ " ) ;   int [ ] a = new int [ n ] ;   for ( int i = 0 ; i < n ; i ++ ) a [ i ] = Integer . parseInt ( x [ i ] ) / 100 ;   System . out . println ( solve ( n , a ) ? " YES " : " NO " ) ; }   static boolean solve ( int n , int [ ] a ) {   int sum = 0 ; int oddCnt = 0 ; int evenCnt = 0 ;   for ( int i = 0 ; i < n ; i ++ ) {   sum += a [ i ] ;   if ( ( a [ i ] & 1 ) == 0 ) evenCnt ++ ;   else oddCnt ++ ; }   if ( ( sum & 1 ) != 0 ) return false ;   if ( ( n & 1 ) == 0 ) { return true ; }   else {   if ( oddCnt == 0 ) return false ; if ( ( evenCnt & 1 ) == 0 ) return false ;   return true ; } } }

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

import java . io . * ; import java . util . * ;   public class round248A { public static void main ( String s [ ] ) throws Exception { Reader r = new Reader ( ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = r . nextInt ( ) ; int h = 0 , t = 0 , arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = r . nextInt ( ) ; if ( arr [ i ] == 100 ) h ++ ; else t ++ ; } if ( ( t % 2 == 0 && h % 2 == 0 ) || ( t % 2 == 1 && h % 2 == 0 && h >= 2 ) ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; }   static class Reader { final private int BUFFER_SIZE = 1 << 16 ; private DataInputStream din ; private byte [ ] buffer ; private int bufferPointer , bytesRead ;   public Reader ( ) { din = new DataInputStream ( System . in ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; }   public Reader ( String file_name ) throws IOException { din = new DataInputStream ( new FileInputStream ( file_name ) ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; }   public String readLine ( ) throws IOException { byte [ ] buf = new byte [ 64 ] ;

import java . util . * ; public class HelloWorld {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int cnt1 = 0 ; int cnt2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int x = in . nextInt ( ) ; if ( x == 100 ) cnt1 ++ ; else cnt2 ++ ; } if ( cnt1 % 2 > 0 || ( cnt2 % 2 > 0 && cnt1 == 0 ) ) { System . out . println ( " NO " ) ; } else { System . out . println ( " YES " ) ; } } }

def solution ( ) : n = int ( input ( ) )   arr = list ( map ( int , input ( ) . split ( ) ) ) hun = 0 two = 0 tot = 0 for i in arr : tot += i if i == 100 : hun += 1 else : two += 1 if tot % 2 != 0 : print ( ' NO ' ) return dp = [ [ False for i in range ( tot // 2 + 1 ) ] for j in range ( n + 1 ) ]   for i in range ( n + 1 ) : dp [ i ] [ 0 ] = True   for i in range ( 1 , n + 1 ) : for j in range ( 1 , tot // 2 + 1 ) : if arr [ i - 1 ] <= j : dp [ i ] [ j ] = dp [ i - 1 ] [ j ] or dp [ i ] [ j - arr [ i - 1 ] ] else : dp [ i ] [ j ] = dp [ i - 1 ] [ j ] if dp [ - 1 ] [ - 1 ] : print ( ' YES ' ) else : print ( ' NO ' )       solution ( ) NEW_LINE

n = int ( input ( ) )   l = list ( map ( int , input ( ) . split ( ) ) )   oh = l . count ( 100 ) th = n - oh   if oh % 2 == 1 : print ( " NO " ) elif oh == 0 and th % 2 == 1 : print ( " NO " ) else : print ( " YES " ) NEW_LINE

def Appel ( arr ) : cont = 0 cont1 = 0 for i in arr : if i == 200 : cont += 1 else : cont1 += 1   if cont1 % 2 != 0 : return " NO " if cont % 2 != 0 and cont1 == 0 : return " NO " return " YES "   aux1 = input ( ) a = int ( aux1 ) arr = [ ] arr = list ( map ( int , input ( ) . strip ( ) . split ( ) ) ) print ( Appel ( arr ) ) NEW_LINE

def Appel ( arr ) : count1 = 0 count2 = 0 for i in arr : if i == 100 : count1 += 1 else : count2 += 1 if ( count1 % 2 != 0 ) : return " NO " elif ( count2 % 2 != 0 and count1 == 0 ) : return " NO " else : return " YES "   aux1 = input ( ) a = int ( aux1 ) arr = [ ] arr = list ( map ( int , input ( ) . strip ( ) . split ( ) ) )   print ( Appel ( arr ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ;    public class Autocomplete {   public static void main ( String [ ] args ) throws IOException , InterruptedException { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; String s = sc . next ( ) ; int n = sc . nextInt ( ) ; String o = " " ; for ( int i = 0 ; i < 100 ; i ++ ) o += " z " ; for ( int i = 0 ; i < n ; i ++ ) { String sm = sc . next ( ) ; if ( sm . length ( ) < s . length ( ) ) continue ; else if ( sm . substring ( 0 , s . length ( ) ) . equals ( s ) ) { o = ( sm . compareTo ( o ) < 0 ) ? sm : o ; } } boolean v = o . length ( ) == 100 ; for ( int i = 0 ; v && i < 100 ; i ++ ) { if ( o . charAt ( i ) != ' z ' ) v = false ; } if ( v ) out . println ( s ) ; else out . println ( o ) ; out . close ( ) ; } static class Scanner { StringTokenizer st ; BufferedReader br ;   public Scanner ( InputStream s ) { br = new BufferedReader ( new InputStreamReader ( s ) ) ; }   public String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return st . nextToken ( ) ; }   public int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; }   public String nextLine ( ) throws IOException { return br . readLine ( ) ; } public boolean ready ( ) throws IOException { return br . ready ( ) ; }    } }

import java . io . * ; import java . util . * ;   import static java . lang . Integer . parseInt ;   public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader read = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter prnt = new PrintWriter ( System . out ) ; String str = read . readLine ( ) ; int n = parseInt ( read . readLine ( ) ) ; ArrayList < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String s = read . readLine ( ) ; int ind = s . indexOf ( str ) ; if ( ind == 0 ) { list . add ( s ) ; } } Collections . sort ( list ) ; if ( list . isEmpty ( ) ) { prnt . println ( str ) ; } else { prnt . println ( list . get ( 0 ) ) ; } prnt . close ( ) ; } }

import java . io . * ; import java . util . * ; public class S { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; int t = in . nextInt ( ) ; String k = s ; int temp = 0 ; while ( t -- != 0 ) { String str = in . next ( ) ; if ( str . indexOf ( s ) == 0 ) { if ( temp == 0 ) { k = str ; temp = 1 ; } else { if ( k . compareTo ( str ) > 0 ) k = str ; } } } System . out . print ( k ) ; } }

import java . io . * ; import java . util . * ; import java . util . stream . IntStream ;   public class CodeForces { public static void main ( String [ ] args ) { FastIO io = FastIO . create ( ) ;   String prefix = io . nextLine ( ) ;   String bestMatch = null ;   int n = io . nextInt ( ) ;   for ( int i = 0 ; i < n ; i ++ ) { String candidate = io . nextLine ( ) ; if ( candidate . startsWith ( prefix ) ) { if ( bestMatch == null || candidate . compareTo ( bestMatch ) < 1 ) { bestMatch = candidate ; } } }   if ( bestMatch == null ) { bestMatch = prefix ; }   io . println ( bestMatch ) ;   io . close ( ) ; }   static class FastIO extends PrintWriter { BufferedReader br ; StringTokenizer st ;   public FastIO ( InputStream is , OutputStream os ) { super ( new BufferedOutputStream ( os ) ) ; br = new BufferedReader ( new InputStreamReader ( is ) ) ; }   public static FastIO create ( ) { return new FastIO ( System . in , System . out ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextToken ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   String nextLine ( ) { try { return br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return " " ; } } }

import java . io . PrintWriter ; import java . util . Scanner ;   public class test {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; String s = sc . nextLine ( ) ; int n = sc . nextInt ( ) ;   String res = null ;   for ( int i = 0 ; i < n ; i ++ ) { String word = sc . next ( ) ; if ( word . startsWith ( s ) ) { if ( res == null || res . compareTo ( word ) > 0 ) { res = word ; } } } if ( res == null ) { res = s ; } System . out . println ( res ) ; } }

s = input ( ) NEW_LINE res = " z " * 1000 NEW_LINE n = int ( input ( ) ) NEW_LINE for i in range ( n ) : t = input ( ) NEW_LINE if ( t [ : len ( s ) ] == s ) : res = min ( res , t ) NEW_LINE print ( s if res == " z " * 1000 else res ) NEW_LINE

s = str ( input ( ) ) NEW_LINE n = int ( input ( ) )   asd = [ ]   for i in range ( n ) : d = str ( input ( ) ) NEW_LINE asd . append ( d ) NEW_LINE flag = 0 NEW_LINE bal = [ ]   for i in asd : if NEW_LINE s not in i [ 0 : len ( s ) ] : flag += 1 else : bal . append ( i ) NEW_LINE if flag == n : print ( s )   else : bal . sort ( ) NEW_LINE print ( bal [ 0 ] ) NEW_LINE

string = input ( ) NEW_LINE n = int ( input ( ) ) NEW_LINE a = [ ] NEW_LINE while n != 0 : a . append ( input ( ) ) NEW_LINE n -= 1 NEW_LINE a . sort ( ) NEW_LINE for x in a : if NEW_LINE x . find ( string ) == 0 : print ( x ) NEW_LINE exit ( ) NEW_LINE print ( string ) NEW_LINE

a = input ( ) . strip ( ) NEW_LINE n = int ( input ( ) ) NEW_LINE k = [ input ( ) for i in range ( n ) ] NEW_LINE p = [ ] NEW_LINE for i in k : if NEW_LINE a in i and i . index ( a ) == 0 : p . append ( i ) NEW_LINE if p : NEW_LINE INDENT print ( min ( p ) ) else : NEW_LINE print ( a ) NEW_LINE DEDENT


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

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Scanner ;   public class Codeforces {   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 ) ;   public static void solve ( int T ) throws IOException { long n = sc . nextLong ( ) ; int ans = 0 ; for ( int i = 26000 ; i >= 1 && n > 0 ; i -- ) { long x = i - 1 ; long val = ( 3 * x * ( x + 1 ) / 2 ) + 2 * ( x + 1 ) ; if ( val <= n ) { ans += n / val ; n %= val ; } } System . out . println ( ans ) ; }   public static void main ( String [ ] args ) throws IOException { int t ; t = sc . nextInt ( ) ;

import java . util . * ; import java . lang . * ; import java . io . * ;   public class codeforces { static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } static int lbound ( int [ ] arr , int target , int end ) { int start = 0 ;   int ans = 0 ; while ( start <= end ) { int mid = ( start + end ) / 2 ; if ( arr [ mid ] == target ) return arr [ mid ] ;   if ( arr [ mid ] > target ) { end = mid - 1 ; }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int t = scan . nextInt ( ) ; while ( t > 0 ) { int n = scan . nextInt ( ) ; t -- ; int size = ( int ) Math . pow ( 10 , 5 ) ; int big = ( int ) Math . pow ( 10 , 9 ) ; long cards [ ] = new long [ size ] ; cards [ 0 ] = 0 ; cards [ 1 ] = 2 ; for ( int i = 2 ; i < size ; i ++ ) { cards [ i ] = cards [ i - 1 ] + 3 * i - 1 ; if ( cards [ i ] > big ) { break ; } } int count = 0 ; while ( n >= cards [ 1 ] ) { int l = 0 , r = 25820 ; int mid = 0 ; while ( l <= r ) { mid = ( l + r ) / 2 ; if ( cards [ mid ] > n ) { r = mid - 1 ; } else { l = mid + 1 ; } } n -= cards [ l - 1 ] ; count ++ ; } System . out . println ( count ) ; } } }

container = [ 2 ] d = 26000 for i in range ( 1 , d + 1 ) : h = i + 1 container . append ( h * 2 + h - 1 + container [ i - 1 ] )   cases = int ( input ( ) ) for t in range ( cases ) : n = int ( input ( ) ) count = 0 while n > 1 : for i in range ( len ( container ) ) : if n < container [ i ] : n -= container [ i - 1 ] count += 1 break   print ( count ) NEW_LINE

t = int ( input ( ) )   for i in range ( t ) : n = int ( input ( ) ) count = 0 while n >= 2 : k = ( - 1 + ( 1 + 24 * n ) ** 0.5 ) // 6 count += 1 n -= ( 3 * k ** 2 + k ) // 2 print ( count ) NEW_LINE

def F ( P ) : i = 1 while i > 0 : if ( 3 * i * i + i ) // 2 < P : i += 1 elif ( 3 * i * i + i ) // 2 == P : return ( 3 * i * i + i ) // 2 else : return ( 3 * ( i - 1 ) * ( i - 1 ) + i - 1 ) // 2 for t in range ( int ( input ( ) ) ) : n = int ( input ( ) ) count = 0 while n >= 0 : if n < 2 : break else : count += 1 n = n - F ( n ) print ( count ) NEW_LINE

tests = [ ] maxh = 0 for t in range ( int ( input ( ) ) ) : n = int ( input ( ) ) if n > maxh : maxh = n tests . append ( n ) cards = 2 h = [ 2 ] x = 0 while cards <= maxh : x += 1 cards += 3 * x + 2 h . append ( cards ) for t in tests : ans = 0 while t >= h [ 0 ] : for b in h [ : : - 1 ] : if b <= t : ans += 1 t -= b break print ( ans ) NEW_LINE


import java . util . Scanner ; import java . util . Arrays ; import java . util . Vector ; import java . util . Collections ;    public class Problem_Solving1 { public static int sumdigits ( long n ) { int sm = 0 ; while ( n > 0 ) { sm += n % 10 ; n /= 10 ; } return sm ; } public static void main ( String [ ] args ) {

import java . util . Scanner ; import java . util . ArrayList ;   public class Main { public static void main ( String [ ] args ) { Scanner puttingvaluesinside = new Scanner ( System . in ) ; int n = puttingvaluesinside . nextInt ( ) ; solve2 ( n ) ;

import java . util . * ; import java . awt . Point ; import java . lang . Math ; import java . util . Arrays ; import java . util . Scanner ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . OutputStream ; import java . util . Comparator ; import java . math . BigInteger ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . stream . IntStream ; import java . io . IOException ; import java . util . ArrayList ; import java . util . Collections ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { FastScanner in = new FastScanner ( ) ; OutputStream outputStream = System . out ; PrintWriter out = new PrintWriter ( outputStream ) ; int N = in . ni ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int sum = 100 ; sum > 0 ; sum -- ) { if ( sumOfDigits ( N - sum ) == sum ) { list . add ( N - sum ) ; } } System . out . println ( list . size ( ) ) ; for ( Integer value : list ) { System . out . println ( value ) ; } } private static int sumOfDigits ( int number ) { if ( number <= 0 ) return 0 ; int sum = 0 ; while ( number > 0 ) { sum += number % 10 ; number /= 10 ; } return sum ; } static void ruffle_sort ( int [ ] a ) {

# include < cstdio > # define re registerusing namespace std ; int n , ans [ 100002 ] , k ; inline void check ( re int x ) { if ( x < 0 ) return ; re int sum = x , xx = x ; while ( x ) sum += x % 10 , x /= 10 ; if ( sum == n ) ans [ ++ k ] = xx ; } int main ( ) { scanf ( " % d " , & n ) ; for ( re int i = n - 100 ; i <= n ; ++ i ) check ( i ) ; printf ( " % d \n " , k ) ; for ( re int i = 1 ; i <= k ; ++ i ) printf ( " % d ▁ " , ans [ i ] ) ; }

n = int ( input ( ) ) output = [ ] for i in range ( max ( n - 80 , 0 ) , n ) : listi = list ( map ( int , str ( i ) ) ) if ( i + sum ( listi ) == n ) : output . append ( i ) print ( len ( output ) ) for i in range ( len ( output ) ) : print ( output [ i ] ) NEW_LINE

n , a , y = int ( input ( ) ) , [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] , [ ] x = n - 99 if n > 99 else 1 for i in range ( x , n ) : sum = 0 for j in str ( i ) : sum += int ( j ) if sum + i == n : y . append ( i ) print ( len ( y ) ) print ( * y ) NEW_LINE

n = int ( input ( ) ) output = [ ] for i in range ( max ( n - 100 , 0 ) , n ) : listi = list ( map ( int , str ( i ) ) ) if ( i + sum ( listi ) == n ) : output . append ( i ) print ( len ( output ) ) for i in range ( len ( output ) ) : print ( output [ i ] ) NEW_LINE

n = int ( input ( ) ) output = [ ] for i in range ( max ( n - 82 , 0 ) , n ) : listi = list ( map ( int , str ( i ) ) ) if ( i + sum ( listi ) == n ) : output . append ( i ) print ( len ( output ) ) for i in range ( len ( output ) ) : print ( output [ i ] ) NEW_LINE

n = int ( input ( ) ) output = [ ] for i in range ( max ( n - 81 , 0 ) , n ) : listi = list ( map ( int , str ( i ) ) ) if ( i + sum ( listi ) == n ) : output . append ( i ) print ( len ( output ) ) for i in range ( len ( output ) ) : print ( output [ i ] ) NEW_LINE


import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; }   public static long mod = 17352642619633L ;   void run ( FastScanner in , PrintWriter out ) {   long [ ] a = new long [ 200_004 ] ; long [ ] d = new long [ 200_004 ] ;   int N = in . nextInt ( ) ;   int ele = 1 ; double sum = 0 ;   while ( N -- > 0 ) {   int t = in . nextInt ( ) ; if ( t == 1 ) { int ai = in . nextInt ( ) ; int x = in . nextInt ( ) ; d [ ai - 1 ] += x ; sum += ai * x ; } else if ( t == 2 ) { int x = in . nextInt ( ) ; a [ ele ] = x ; sum += x ; ele ++ ; } else {   long v = a [ ele - 1 ] + d [ ele - 1 ] ; d [ ele - 2 ] += d [ ele - 1 ] ; d [ ele - 1 ] = 0 ; a [ ele - 1 ] = 0 ; sum -= v ; ele -- ; } out . println ( String . format ( " % .8f " , sum / ele ) ) ; }    }   static class FastScanner { BufferedReader br ; StringTokenizer st ;   public FastScanner ( InputStream in ) { br = new BufferedReader ( new InputStreamReader ( in ) ) ; st = null ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }

import java . util . * ; import java . io . * ; import java . math . * ;   public class Practice   { static FastReader sc = new FastReader ( ) ; static int mod = ( int ) Math . pow ( 10 , 9 ) + 7 ; static int dp [ ] [ ] ; ; public static void main ( String [ ] args ) { PrintWriter out = new PrintWriter ( System . out ) ;

import sys     def main ( ) : n = int ( sys . stdin . readline ( ) ) arr = [ 0 ] * ( n + 1 ) cnt = [ 0 ] * ( n + 1 ) curr_len = 1 curr_sum = 0 for _ in range ( n ) : t = list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) if t [ 0 ] == 1 : curr_sum += t [ 1 ] * t [ 2 ] cnt [ t [ 1 ] - 1 ] += t [ 2 ] elif t [ 0 ] == 2 : curr_sum += t [ 1 ] arr [ curr_len ] = t [ 1 ] curr_len += 1 else : curr_len -= 1 curr_sum -= arr [ curr_len ] + cnt [ curr_len ] cnt [ curr_len - 1 ] += cnt [ curr_len ] cnt [ curr_len ] = 0 print ( curr_sum / curr_len )     main ( ) NEW_LINE

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

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


import java . util . Scanner ;   public class TuringTape {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] arr = sc . nextLine ( ) . toCharArray ( ) ; int prev = 0 ; for ( char c : arr ) { StringBuilder s = new StringBuilder ( Integer . toString ( ( int ) c , 2 ) ) ; while ( s . length ( ) < 8 ) s . insert ( 0 , '0' ) ; s . reverse ( ) ; int x = Integer . parseInt ( s . toString ( ) , 2 ) ; System . out . println ( ( prev - x + 256 ) % 256 ) ; prev = x ; } sc . close ( ) ; } }

# include < cstdio > # include < cstring > # include < algorithm > using namespace std ; int main ( ) { char a [ 105 ] ; int i , n , j , m , c [ 105 ] [ 8 ] , ans [ 105 ] , len ; for ( i = 0 ; i < 105 ; i ++ ) for ( j = 0 ; j < 8 ; j ++ ) c [ i ] [ j ] = 0 ; memset ( ans , 0 , sizeof ( ans ) ) ; gets ( a ) ; len = strlen ( a ) ; for ( i = 0 ; i < len ; i ++ ) { m = 1 ; n = 0 + a [ i ] ; for ( j = 0 ; j < 8 && n != 0 ; j ++ ) { c [ i ] [ j ] = n % 2 ; n = n / 2 ; } for ( j = 7 ; j >= 0 ; j -- ) { ans [ i ] = ans [ i ] + c [ i ] [ j ] * m ; m = m * 2 ; } } printf ( " % d \n " , 256 - ans [ 0 ] ) ; for ( i = 1 ; i < len ; i ++ ) { if ( ans [ i - 1 ] - ans [ i ] >= 0 ) printf ( " % d \n " , ans [ i - 1 ] - ans [ i ] ) ; else printf ( " % d \n " , 256 + ans [ i - 1 ] - ans [ i ] ) ; } }

import java . util . Scanner ; public class Ishu { public static String reverse ( String s ) { char [ ] ch = new char [ 10 ] ; char [ ] ch1 = new char [ 10 ] ; ch = s . toCharArray ( ) ; for ( int i = 0 ; i < s . length ( ) ; ++ i ) ch1 [ i ] = ch [ s . length ( ) - 1 - i ] ; s = new String ( ch1 ) ; return s ; } public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int i , temp , temp1 , n ; String text , str ; char [ ] ch = new char [ 100 ] ; text = scan . nextLine ( ) ; ch = text . toCharArray ( ) ; for ( i = 0 ; i < text . length ( ) ; ++ i ) { temp = ( int ) ch [ i ] ; str = Integer . toBinaryString ( temp ) ; while ( str . length ( ) < 8 ) str = "0" + str ; n = str . length ( ) ; str = reverse ( str ) ; temp = Integer . parseInt ( str . substring ( 0 , n ) , 2 ) ; if ( i == 0 ) temp1 = 0 ; else { temp1 = ( int ) ch [ i - 1 ] ; str = Integer . toBinaryString ( temp1 ) ; while ( str . length ( ) < 8 ) str = "0" + str ; n = str . length ( ) ; str = reverse ( str ) ; temp1 = Integer . parseInt ( str . substring ( 0 , n ) , 2 ) ; } temp = temp1 - temp ; if ( temp < 0 ) { temp *= ( - 1 ) ; temp = 256 - ( temp % 256 ) ; } else temp = temp % 256 ; System . out . println ( temp ) ; } } }

s = input ( ) e = 0 for i in s : a = ord ( i ) b = format ( a , '08b ' ) c = str ( b ) [ : : - 1 ] d = int ( c , 2 ) print ( ( e - d ) % 256 ) e = d NEW_LINE

t = input ( )     f = [ 0 ]     for j in range ( len ( t ) ) :   a = bin ( ord ( t [ j ] ) ) [ 2 : ]   if len ( a ) < 8 : a = '0' * ( 8 - len ( a ) ) + a   b = int ( a [ : : - 1 ] , 2 )     x = ( f [ - 1 ] - b ) % 256 print ( x ) f . append ( b )   NEW_LINE