import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . List ; import java . util . Random ; import java . util . StringTokenizer ;   public class Main implements Runnable {   int INF = ( int ) 1e9 ; int sz [ ] ; int id [ ] ; List < Integer > edges [ ] ;   private void solve ( ) throws IOException { int n = nextInt ( ) ; int a [ ] = new int [ n ] ; int ev = 0 ; for ( int i = 0 ; i < n ; ++ i ) { a [ i ] = nextInt ( ) ; if ( ( ( i + 1 ) & 1 ) == 0 ) ev ++ ; } int dp [ ] [ ] [ ] = new int [ n + 1 ] [ n + 1 ] [ 2 ] ;

def main ( ) : n = int ( input ( ) ) a = readIntArr ( ) arr = [ ] NEW_LINE

a = int ( input ( ) ) z = list ( map ( int , input ( ) . split ( ) ) ) import math   odd = 0 eve = 0 for i in range ( len ( z ) ) : if ( z [ i ] % 2 == 1 ) : odd += 1 elif ( z [ i ] % 2 == 0 and z [ i ] > 0 ) : eve += 1   odd = ( a // 2 ) + ( a % 2 ) - oddeve = ( a // 2 ) - eve + ( ( a % 2 ) ) cnt = 0   dp = [ [ [ math . inf for i in range ( 2 ) ] for i in range ( odd + 2 ) ] for i in range ( len ( z ) ) ]   NEW_LINE

def abc ( l , odd , even , i , x ) : try : return dp [ i , odd , even , x ] except : pass if i == len ( l ) : return 0 if l [ i ] : c = 0 if x != l [ i ] % 2 : c += 1 return c + abc ( l , odd , even , i + 1 , l [ i ] % 2 ) ans = n if odd : c = 0 if not x % 2 : c += 1 ans = min ( ans , c + abc ( l , odd - 1 , even , i + 1 , 1 ) ) if even : c = 0 if x % 2 : c += 1 ans = min ( ans , c + abc ( l , odd , even - 1 , i + 1 , 0 ) ) dp [ i , odd , even , x ] = ans return ansn = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) dp = { } odd = 0 even = 0 d = [ 0 ] * ( n + 1 ) for i in l : d [ i ] += 1 for i in range ( 1 , n + 1 ) : if i % 2 and not d [ i ] : odd += 1 if not i % 2 and not d [ i ] : even += 1 if l [ 0 ] : print ( abc ( l , odd , even , 1 , l [ 0 ] % 2 ) ) else : ans = n if odd : ans = min ( ans , abc ( l , odd - 1 , even , 1 , 1 ) ) if even : ans = min ( ans , abc ( l , odd , even - 1 , 1 , 0 ) ) print ( ans ) NEW_LINE

n = int ( input ( ) ) p = list ( map ( int , input ( ) . split ( ) ) ) odd = ( n + 1 ) // 2 memo = { } def best ( i , odd_count , last ) : if i == n : return 0 key = ( i , odd_count , last ) if key in memo : return memo [ key ] poss = range ( 2 ) if p [ i ] == 0 else [ p [ i ] % 2 ] res = 10 ** 9 for parity in poss : new_odd_count = odd_count - parity new_even_count = n - i - odd_count - ( parity ^ 1 ) if new_odd_count < 0 or new_even_count < 0 : continue res = min ( res , best ( i + 1 , new_odd_count , parity ) + ( 1 if i > 0 and last != parity else 0 ) ) memo [ key ] = res return resprint ( best ( 0 , odd , 0 ) ) NEW_LINE


import java . io . * ; import java . util . * ; public class Main { public static void main ( String args [ ] ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int t = Integer . parseInt ( br . readLine ( ) ) ; while ( t -- > 0 ) { int n = Integer . parseInt ( br . readLine ( ) ) ; int arr [ ] = new int [ n ] ; String s [ ] = br . readLine ( ) . split ( " ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = Integer . parseInt ( s [ i ] ) ; int even = 0 , odd = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 != 0 && i % 2 == 0 ) odd ++ ; else if ( arr [ i ] % 2 == 0 && i % 2 != 0 ) even ++ ; } if ( odd == even ) System . out . println ( even ) ; else if ( odd == 0 && even == 0 ) System . out . println ( "0" ) ; else System . out . println ( " - 1" ) ; } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import static java . lang . Math . * ; import static java . lang . System . out ; import java . util . * ; import java . io . PrintStream ; import java . io . PrintWriter ; public class A { static final int N = ( int ) ( 1e5 + 100 ) ; static final int mod = 1000000007 ; static final long temp = 998244353 ; static final long MOD = 1000000007 ; static final long M = ( long ) 1e9 + 7 ; static class Pair implements Comparable < Pair > { int first , second ; public Pair ( int aa , int bb ) { first = aa ; second = bb ; } public int compareTo ( Pair o ) { if ( this . second < o . second ) return - 1 ; if ( this . second > o . second ) return + 1 ; return this . first - o . first ; } } static class Tuple implements Comparable < Tuple > { long first , second , third ; public Tuple ( long first , long second , long third ) { this . first = first ; this . second = second ; this . third = third ; } public int compareTo ( Tuple o ) { return ( int ) ( o . third - this . third ) ; } } public static class DSU { int [ ] parent ; int [ ] rank ;

import java . util . * ; public class Main { public static void main ( String ared [ ] ) { Scanner sc = new Scanner ( System . in ) ; int test = sc . nextInt ( ) ; while ( test -- > 0 ) { int n = sc . nextInt ( ) ; int b [ ] = new int [ 2 ] ; int a [ ] = new int [ n ] ; b [ 0 ] = 0 ; b [ 1 ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( a [ i ] % 2 != i % 2 ) b [ i % 2 ] ++ ; } if ( b [ 0 ] == b [ 1 ] ) System . out . println ( b [ 0 ] ) ; else System . out . println ( " - 1" ) ; } } }

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 ar [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; } int odd = 0 , even = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ar [ i ] % 2 != i % 2 ) { if ( ar [ i ] % 2 == 1 ) odd ++ ; else even ++ ; } } if ( odd != even ) System . out . println ( " - 1" ) ; else System . out . println ( even ) ; t -- ; } } }

t = int ( input ( ) ) while t : t -= 1 n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) o = 0 e = 0 for i in range ( n ) : if i % 2 != l [ i ] % 2 : if i % 2 == 0 : e += 1 else : o += 1 if e == o : print ( e ) else : print ( - 1 ) NEW_LINE

t = int ( input ( ) ) for _ in range ( t ) : n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) o = 0 e = 0 for i in range ( 0 , len ( l ) , 2 ) : if i % 2 != l [ i ] % 2 : e += 1 for j in range ( 1 , len ( l ) , 2 ) : if j % 2 != l [ j ] % 2 : o += 1 if e == o : print ( e ) else : print ( - 1 ) NEW_LINE

def main ( ) : t = int ( input ( ) ) for _ in range ( t ) : n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) o_cnt = 0 e_cnt = 0 for i in range ( n ) : if i % 2 != 0 and arr [ i ] % 2 == 0 : e_cnt += 1 elif i % 2 == 0 and arr [ i ] % 2 != 0 : o_cnt += 1 if e_cnt == o_cnt : print ( e_cnt ) else : print ( - 1 )     if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE

for t in range ( int ( input ( ) ) ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) e , o = 0 , 0 for x in range ( n ) : if x % 2 == 0 and a [ x ] % 2 != 0 : e += 1 if x % 2 != 0 and a [ x ] % 2 == 0 : o += 1 if e != o : print ( - 1 ) else : print ( e ) NEW_LINE

def evenArray ( arr , n ) : evenIdxOddCount = 0 oddIdxEvenCount = 0 for i in range ( 0 , n ) : if i % 2 == 0 : if arr [ i ] & 1 : evenIdxOddCount += 1 else : if not ( arr [ i ] & 1 ) : oddIdxEvenCount += 1 if evenIdxOddCount == oddIdxEvenCount : print ( evenIdxOddCount ) else : print ( - 1 ) returntc = int ( input ( ) ) for _ in range ( 0 , tc ) : n = int ( input ( ) ) arr = [ int ( i ) for i in input ( ) . split ( ) ] [ : n ] evenArray ( arr , n ) NEW_LINE


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

import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; import java . lang . Math ; public class Account { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] rad = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { rad [ i ] = sc . nextInt ( ) ; } Arrays . sort ( rad ) ; int mul = 1 , sum = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { sum += rad [ i ] * rad [ i ] * mul ; mul *= - 1 ; } System . out . println ( Math . PI * sum ) ; } }

import java . io . * ; import java . util . * ;   public class TheFibonacciSegment { public static void main ( String [ ] args ) { FastReader ( ) ; int t = 1 ; while ( t > 0 ) { solve ( ) ; -- t ; } write . flush ( ) ; write . close ( ) ; } static void solve ( ) { int n = ni ( ) ; List < Integer > arr = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; ++ i ) { arr . add ( ni ( ) ) ; } Collections . sort ( arr ) ; if ( n % 2 != 0 ) { int k = 0 ; long sum = 0 ; for ( int i = 0 ; i < n ; i = i + 2 ) { sum = sum + arr . get ( i ) * arr . get ( i ) - k * k ; if ( i != n - 1 ) { k = arr . get ( i + 1 ) ; } } double ans = Math . PI * ( double ) sum ; out ( ans ) ; } else { int k = arr . get ( 0 ) ; long sum = 0 ; for ( int i = 1 ; i < n ; i = i + 2 ) { sum = sum + arr . get ( i ) * arr . get ( i ) - k * k ; if ( i != n - 1 ) { k = arr . get ( i + 1 ) ; } } double ans = Math . PI * ( double ) sum ; out ( ans ) ; } }

import java . util . Arrays ; import java . util . Scanner ;   public class _0734Trace {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; boolean flag = true ; if ( n % 2 == 0 ) { flag = false ; } int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( arr ) ; double area = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( flag ) { if ( i == 0 ) { area += Math . PI * arr [ i ] * arr [ i ] * 1d ; } else { area += Math . PI * arr [ i ] * arr [ i ] * 1d - Math . PI * arr [ i - 1 ] * arr [ i - 1 ] * 1d ; } } flag = ! flag ; } System . out . println ( area ) ; }   }

import java . util . * ; public class Trace { public static void main ( String arg [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; if ( n == 1 ) { int temp = sc . nextInt ( ) ; System . out . println ( Math . PI * temp * temp ) ; System . exit ( 0 ) ; }    int [ ] ar = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; }   int res = 0 ; Arrays . sort ( ar ) ; for ( int i = n - 1 ; i > 0 ; i = i - 2 ) { res += ( ar [ i ] * ar [ i ] - ar [ i - 1 ] * ar [ i - 1 ] ) ; }   if ( n % 2 != 0 ) { res += ar [ 0 ] * ar [ 0 ] ; }    System . out . println ( Math . PI * res ) ;   } }

import math   n = int ( input ( ) )   a = [ int ( x ) for x in input ( ) . split ( ) ] a . sort ( reverse = True )   area = 0 mult = 1   for i in range ( 0 , n ) : area += mult * ( a [ i ] ** 2 ) mult *= - 1   print ( area * math . pi ) NEW_LINE

import mathI = lambda : list ( map ( int , input ( ) . split ( ) ) ) n = int ( input ( ) ) a = sorted ( I ( ) , reverse = True ) area = 0 for i in range ( len ( a ) ) : if i % 2 == 0 : area += a [ i ] ** 2 * math . pi else : area -= a [ i ] ** 2 * math . piprint ( area ) NEW_LINE

import math   n = int ( input ( ) ) a = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) ans = 0 for i in range ( n ) : if i % 2 != n % 2 : if i == 0 : ans += math . pi * a [ i ] ** 2 else : ans += math . pi * ( a [ i ] ** 2 - a [ i - 1 ] ** 2 ) print ( ans ) NEW_LINE

from math import pi   n = int ( input ( ) ) r = lambda : list ( map ( int , input ( ) . split ( ) ) ) arr = r ( ) arr . sort ( reverse = True ) arr . append ( 0 ) ans = 0.0 i = 0 while i < n : ans += pi * ( arr [ i ] ** 2 - arr [ i + 1 ] ** 2 ) i += 2   print ( f " { ans : .10f } " ) NEW_LINE


import java . util . * ; import java . math . * ; public class XXXXX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int runs = sc . nextInt ( ) ; while ( runs -- > 0 ) { int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int sum = 0 ; int ans = - 1 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( ( sum += sc . nextInt ( ) ) % x != 0 ) ans = Math . max ( ans , Math . max ( i , n - i ) ) ; } System . out . println ( ans ) ; } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ;   public class Main implements Runnable { int n , m , k ; static boolean use_n_tests = true ; long [ ] res ;   void solve ( FastScanner in , PrintWriter out , int testNumber ) { n = in . nextInt ( ) ; int x = in . nextInt ( ) ; int [ ] a = in . nextArray ( n ) ; int s = 0 ; int c = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] %= x ; s += a [ i ] ; s %= x ; if ( a [ i ] == 0 ) { c ++ ; } } if ( s != 0 ) { out . println ( n ) ; return ; } if ( c == n ) { out . println ( - 1 ) ; return ; } s = 0 ; int ans = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { s += a [ i ] ; if ( s % x != 0 ) { ans = Math . max ( ans , i + 1 ) ; ans = Math . max ( ans , n - i - 1 ) ; } } out . println ( ans ) ;   }

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

import java . util . * ; import java . io . * ; import java . io . FileInputStream ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class sol { public static void main ( String args [ ] ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] ar = new int [ n ] ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; sum += ar [ i ] ; } int max = Integer . MIN_VALUE ;   int sum1 = sum ; for ( int i = 0 ; i < n ; i ++ ) { if ( sum % x != 0 ) { max = n - i ; break ; } else { sum -= ar [ i ] ; } } for ( int j = n - 1 ; j >= 0 ; j -- ) { if ( sum1 % x != 0 ) { if ( j + 1 > max ) { max = j + 1 ; break ; } } else { sum1 -= ar [ j ] ; } } if ( max == Integer . MIN_VALUE ) { System . out . println ( - 1 ) ; } else { System . out . println ( max ) ; } } } }

t = int ( input ( ) ) for i in range ( t ) : n , x = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) s = 0 left = - 1 for i in range ( n ) : if l [ i ] % x != 0 : if left == - 1 : left = i   r = i s = s + l [ i ] if s % x != 0 : print ( n ) elif left == - 1 : print ( - 1 ) else : pre = left + 1 suf = n - r print ( n - min ( pre , suf ) ) NEW_LINE

def answer ( n , x , a ) : if sum ( a ) % x != 0 : return n NEW_LINE

def longestNonDivisibleSubArray ( arr , n , x ) : s , individual = 0 , True   for i in range ( n ) : if arr [ i ] % x != 0 : individual = False s += arr [ i ] if individual : return - 1 if s % x != 0 : return n ;   s = 0 index = - 1 for i in range ( n ) : s += arr [ i ] if s % x != 0 : index = i prefix = index + 1   s = 0 index = n for i in range ( n - 1 , - 1 , - 1 ) : s += arr [ i ] if s % x != 0 : index = i suffix = n - index   return max ( prefix , suffix ) t = int ( input ( ) ) for i in range ( t ) : [ n , x ] = list ( map ( int , input ( ) . split ( ) ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) print ( longestNonDivisibleSubArray ( arr , n , x ) ) NEW_LINE

t = int ( input ( ) ) for _ in range ( t ) : n , x = map ( int , input ( ) . split ( ) ) a = [ int ( x ) for x in input ( ) . split ( ) ] ok = False for i in a : ok |= ( i % x ) if ( not ok ) : print ( - 1 ) elif ( sum ( a ) % x ) : print ( n ) else : ans = n for i in range ( n ) : if ( a [ i ] % x ) : ans = i + 1 break for i in range ( n - 1 , 0 , - 1 ) : if ( a [ i ] % x ) : ans = min ( ans , n - i ) break print ( n - ans ) NEW_LINE

t = int ( input ( ) ) b = [ ] for k in range ( t ) : n , x = list ( map ( int , input ( ) . split ( ) ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a1 = list ( reversed ( a ) ) suma = sum ( a ) count = 0 if suma % x != 0 : b . append ( n ) else : for i in range ( n ) : number1 = suma - a [ i ] number2 = suma - a1 [ i ] if number1 % x != 0 or number2 % x != 0 : count += 1 b . append ( n - i - 1 ) break if count == 0 : b . append ( - 1 ) for i in b : print ( i )   NEW_LINE


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

import java . util . * ; public class Practice { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char inp [ ] = sc . next ( ) . toCharArray ( ) ; int k = sc . nextInt ( ) ; int max = 0 ; int num [ ] = new int [ 26 ] ; for ( int i = 0 ; i < num . length ; i ++ ) { num [ i ] = sc . nextInt ( ) ; if ( i == 0 ) { max = num [ i ] ; } else { if ( max < num [ i ] ) { max = num [ i ] ; } } } int ans = 0 ; for ( int i = 0 ; i < inp . length ; i ++ ) { ans += num [ inp [ i ] - ' a ' ] * ( i + 1 ) ; } for ( int i = 1 ; i <= k ; i ++ ) { ans += max * ( inp . length + i ) ; } System . out . println ( ans ) ; } }

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

import java . util . * ; public class DZY_loveStrings { public static void main ( String arg [ ] ) { Scanner sc = new Scanner ( System . in ) ; String st = sc . nextLine ( ) ; int n = sc . nextInt ( ) ; int [ ] w = new int [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) { w [ i ] = sc . nextInt ( ) ; } int max = w [ 0 ] ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( max < w [ i ] ) max = w [ i ] ; } int sum = 0 ; int i ; for ( i = 0 ; i < st . length ( ) ; i ++ ) { sum += ( i + 1 ) * w [ st . charAt ( i ) - ' a ' ] ; }   for ( int j = 0 ; j < n ; j ++ ) { sum += ( i + 1 ) * max ; i ++ ; }   System . out . println ( sum ) ; } }

a = input ( ) k = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) t = max ( arr ) count = 0 for i in range ( 1 , len ( a ) + 1 ) : count += arr [ ( ord ( a [ i - 1 ] ) - 97 ) ] * ( i ) for i in range ( 1 , k + 1 ) : count += ( i + len ( a ) ) * tprint ( count ) NEW_LINE

try : s = input ( ) k = int ( input ( ) ) c = list ( map ( int , input ( ) . split ( ) ) ) x = max ( c ) cost = 0 for i in range ( len ( s ) ) : cost += c [ ord ( s [ i ] ) - 97 ] * ( i + 1 ) for i in range ( len ( s ) , len ( s ) + k ) : cost += ( i + 1 ) * max ( c ) print ( cost ) except : pass NEW_LINE

s = input ( ) k = int ( input ( ) ) lst = list ( map ( int , input ( ) . split ( ) ) ) lst2 = [ chr ( i ) for i in range ( 97 , 123 ) ] dct = { } for i in range ( len ( lst2 ) ) : dct [ lst2 [ i ] ] = lst [ i ] value = 0 alpha = max ( dct . values ( ) )   for i in range ( len ( s ) ) : value += ( i + 1 ) * dct [ s [ i ] ] NEW_LINE

s = input ( ) k = int ( input ( ) ) w = list ( map ( int , input ( ) . split ( ) ) ) fs = 0 for i in range ( len ( s ) ) : fs += w [ ord ( s [ i ] ) - 97 ] * ( i + 1 ) m = max ( w ) for i in range ( len ( s ) , len ( s ) + k ) : fs += m * ( i + 1 ) print ( fs ) NEW_LINE

str1 = input ( ' ' ) k = int ( input ( ' ' ) ) w = list ( map ( int , input ( ) . split ( ) ) ) p = max ( w ) pidx = w . index ( p ) + 97 q = chr ( pidx ) str2 = k * qstr3 = str1 + str2f = 0 for i in range ( 0 , len ( str3 ) ) : a = ord ( str3 [ i ] ) - 97 f = f + ( i + 1 ) * w [ a ] print ( f ) NEW_LINE


import java . util . * ; import java . io . * ; public class MainClass { static long INF = Long . MAX_VALUE / 2 ; public static void main ( String [ ] args ) throws IOException { Reader in = new Reader ( ) ; int n = in . nextInt ( ) ; int k = in . nextInt ( ) ; long [ ] A = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) A [ i ] = in . nextLong ( ) ; new MergeSortLong ( ) . sort ( A , 0 , n - 1 ) ; int full = n % k ; if ( full == 0 ) full = k ; int half = k - full ; int fullLength = ( n + k - 1 ) / k ; int halfLength = fullLength - 1 ; long [ ] [ ] dp = new long [ k + 1 ] [ k + 1 ] ; for ( int i = 0 ; i <= k ; i ++ ) Arrays . fill ( dp [ i ] , INF ) ; dp [ 0 ] [ 0 ] = 0L ; for ( int i = 0 ; i <= k ; i ++ ) { for ( int j = 0 ; j <= k ; j ++ ) { int totalLen = i * fullLength + j * halfLength ; if ( totalLen > n ) continue ; if ( i > 0 ) { long mm = A [ totalLen - 1 ] - A [ totalLen - fullLength ] + dp [ i - 1 ] [ j ] ; dp [ i ] [ j ] = Math . min ( dp [ i ] [ j ] , mm ) ; } if ( j > 0 ) { long mm = A [ totalLen - 1 ] - A [ totalLen - halfLength ] + dp [ i ] [ j - 1 ] ; dp [ i ] [ j ] = Math . min ( dp [ i ] [ j ] , mm ) ; } } } System . out . println ( dp [ full ] [ half ] ) ; } } class MergeSortLong {

import java . io . BufferedOutputStream ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . io . Reader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . StringTokenizer ;   public class B2 {   static final long MODULO = ( long ) ( 1e9 + 7 ) ; private static final long INF = Long . MAX_VALUE / 2 ; private static int n , k ; private static int [ ] a ; private static int minLen ;   public static void main ( String [ ] args ) { BufferedScanner scanner = new BufferedScanner ( ) ; PrintWriter writer = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ;   int t = 1 ;

import java . util . * ; import java . io . * ; public class Solution { static void merge ( long arr [ ] , int l , int m , int r ) {

f = lambda : map ( int , input ( ) . split ( ) ) n , k = f ( ) p = sorted ( f ( ) ) m , d = n // k , n % ku , v = d + 1 , k - d + 1 g = [ 0 ] * u * v i = 0 for a in range ( u ) : j = a * m + a - 1 for b in range ( v ) : x = g [ i - 1 ] + p [ j ] - p [ j - m + 1 ] if b else 9e9 y = g [ i - v ] + p [ j ] - p [ j - m ] if a else 9e9 if i : g [ i ] = min ( x , y ) i += 1 j += mprint ( g [ - 1 ] ) NEW_LINE


import java . util . * ;   public class P3 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; if ( t == 0 ) System . out . println ( " O - | - OOOO " ) ; while ( t > 0 ) { int n = t % 10 ; if ( n == 1 ) { System . out . println ( " O - | O - OOO " ) ; } else if ( n == 2 ) { System . out . println ( " O - | OO - OO " ) ; } else if ( n == 3 ) { System . out . println ( " O - | OOO - O " ) ; } else if ( n == 4 ) { System . out . println ( " O - | OOOO - " ) ; } else if ( n == 5 ) { System . out . println ( " - O | - OOOO " ) ; } else if ( n == 6 ) { System . out . println ( " - O | O - OOO " ) ; } else if ( n == 7 ) { System . out . println ( " - O | OO - OO " ) ; } else if ( n == 8 ) { System . out . println ( " - O | OOO - O " ) ; } else if ( n == 9 ) { System . out . println ( " - O | OOOO - " ) ; } else if ( n == 0 ) { System . out . println ( " O - | - OOOO " ) ; } t /= 10 ; } } }

import com . sun . org . apache . bcel . internal . generic . AALOAD ; import com . sun . org . apache . bcel . internal . generic . GOTO ; 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 ; import static jdk . nashorn . internal . runtime . regexp . joni . Syntax . Java ;   public class Main { public static String setNumber ( char n ) { if ( n == '0' ) { return " O - | - OOOO " ; } else if ( n == '1' ) { return " O - | O - OOO " ; } else if ( n == '2' ) { return " O - | OO - OO " ; } else if ( n == '3' ) { return " O - | OOO - O " ; } else if ( n == '4' ) { return " O - | OOOO - " ; } else if ( n == '5' ) { return " - O | - OOOO " ; } else if ( n == '6' ) { return " - O | O - OOO " ; } else if ( n == '7' ) { return " - O | OO - OO " ; } else if ( n == '8' ) { return " - O | OOO - O " ; } else if ( n == '9' ) { return " - O | OOOO - " ; } return " " ; } public static void main ( String [ ] args ) throws IOException {   Scanner input = new Scanner ( System . in ) ; String n = input . next ( ) ; StringBuilder ans = new StringBuilder ( ) ; for ( int i = n . length ( ) - 1 ; i >= 0 ; i -- ) { ans . append ( setNumber ( n . charAt ( i ) ) + " \n " ) ; } System . out . println ( ans ) ; }       }

import java . io . * ; import java . math . * ; import java . security . * ; import java . text . * ; import java . util . * ; import java . util . concurrent . * ; import java . util . regex . * ; import java . util . Arrays ; import java . util . ArrayList ; import java . lang . Math ; public class project { 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 binarySearch ( long a [ ] , long k , int l , int h ) { int min = Integer . MAX_VALUE ; while ( l <= h ) { int mid = ( l + h ) / 2 ; if ( a [ mid ] == k ) return mid ; else if ( a [ mid ] > k ) h = mid - 1 ; else if ( a [ mid ] < k ) l = mid + 1 ; } return min ; } static int gcd ( int a , int b ) {

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

chot = { 0 : " O - | - OOOO " , 1 : " O - | O - OOO " , 2 : " O - | OO - OO " , 3 : " O - | OOO - O " , 4 : " O - | OOOO - " , 5 : " - O | - OOOO " , 6 : " - O | O - OOO " , 7 : " - O | OO - OO " , 8 : " - O | OOO - O " , 9 : " - O | OOOO - " }   num = int ( input ( ) )   divs = [ ]   if num == 0 : print ( chot [ 0 ] ) exit ( )   while num > 0 : divs . append ( ( num % 10 ) ) num //= 10   for i in divs : print ( chot [ i ] ) NEW_LINE


import java . util . Scanner ;   public class Task139A { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int t = scanner . nextInt ( ) ; int [ ] w = new int [ 7 ] ; int sum = 0 ; for ( int i = 0 ; i < w . length ; i ++ ) { w [ i ] = scanner . nextInt ( ) ; sum += w [ i ] ; } int days = 0 ; if ( t % sum != 0 ) t = t % sum ; else t = sum ; if ( t != 0 ) for ( int i : w ) { t -= i ; days ++ ; if ( t <= 0 ) { break ; } } System . out . println ( days ) ; } }

import java . util . Scanner ;   public class PetrandBook { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int [ ] numbers = new int [ 7 ] ;   for ( int i = 0 ; i < 7 ; i ++ ) { numbers [ i ] = scanner . nextInt ( ) ; } System . out . println ( solve ( n , numbers ) ) ;   }   public static int solve ( int n , int [ ] nums ) { while ( n >= 0 ) { for ( int i = 0 ; i < nums . length ; i ++ ) { if ( n > 0 ) { n -= nums [ i ] ; if ( n <= 0 ) { return i + 1 ; } } } } return 0 ; } }

import java . util . Arrays ; import java . util . Scanner ;   public class A139 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   int n ; int [ ] y = new int [ 8 ] ; n = scanner . nextInt ( ) ; for ( int i = 1 ; i <= 7 ; ++ i ) { y [ i ] = scanner . nextInt ( ) ; y [ i ] += y [ i - 1 ] ; } n = ( n - 1 ) % y [ 7 ] + 1 ; for ( int i = 1 ; i <= 7 ; ++ i ) { if ( y [ i ] >= n ) { System . out . print ( i ) ; System . out . print ( " \n " ) ; break ; }   } } }

import java . util . Scanner ;   public class PetrBook { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int length = scanner . nextInt ( ) ; int a [ ] = new int [ 7 ] ; for ( int i = 0 ; i < 7 ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; } while ( length > 0 ) { for ( int j = 0 ; j < 7 ; j ++ ) { length -= a [ j ] ; if ( length <= 0 ) { System . out . println ( j + 1 ) ; return ; } } } } }

pages = int ( input ( ) ) page_sum = 0 lst = [ * map ( int , input ( ) . split ( ) ) ] for idx , daily_pages in enumerate ( lst ) : page_sum += daily_pages pages -= daily_pages if pages <= 0 : print ( idx + 1 ) breakelse : if page_sum == 1 : print ( lst . index ( 1 ) + 1 ) else : pages = pages % page_sum if pages > page_sum else pages for idx , daily_pages in enumerate ( lst ) : pages -= daily_pages if pages <= 0 : print ( idx + 1 ) break NEW_LINE

n = int ( input ( ) ) w = list ( map ( int , input ( ) . split ( ) ) ) i = 0 s = 0 while ( 1 ) : s += w [ i ] if ( s >= n ) : print ( i + 1 ) break i = ( i + 1 ) % 7 NEW_LINE

n = int ( input ( ) ) A = list ( map ( int , input ( ) . split ( ) ) ) t = A [ 0 ] i = 0 while t < n : i += 1 i %= 7 t += A [ i ] print ( i + 1 ) NEW_LINE

sum = 0   count = 0   n = int ( input ( ) )   things = [ int ( x ) for x in input ( ) . split ( ) ] while sum < n : sum += things [ count ] count = ( count + 1 ) % 7   if count == 0 : print ( 7 ) else : print ( count ) NEW_LINE


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

import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = Integer . parseInt ( sc . next ( ) ) ; String s = sc . next ( ) ; int [ ] count = new int [ 26 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { count [ s . charAt ( i ) - ' a ' ] ++ ; } for ( int i : count ) { if ( i % k != 0 ) { System . out . println ( " - 1" ) ; return ; } } StringBuilder ans = new StringBuilder ( s . length ( ) ) ; for ( char c = ' a ' ; c <= ' z ' ; c ++ ) { int times = count [ c - ' a ' ] / k ; while ( times -- > 0 ) { ans . append ( c ) ; } } String appender = ans . toString ( ) ; for ( int i = 1 ; i < k ; i ++ ) { ans . append ( appender ) ; } System . out . println ( ans ) ; } }

import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; scan . nextLine ( ) ; String s = scan . nextLine ( ) ; char [ ] temp = s . toCharArray ( ) ; Arrays . sort ( temp ) ; String l = String . valueOf ( temp ) ;

k = int ( input ( ) ) s = str ( input ( ) ) s = list ( s ) d = { } for i in s : d [ i ] = s . count ( i ) cnt = 0 s1 = ' ' for j in d : if d [ j ] % k == 0 : cnt += 1 s1 += ( j * int ( d [ j ] / k ) ) if cnt != len ( d ) : print ( - 1 ) else : print ( s1 * k ) NEW_LINE

def solution ( ) : k = int ( input ( ) )   st = input ( )   cnt = [ 0 ] * 26   for i in st : cnt [ ord ( i ) - ord ( ' a ' ) ] += 1 for cnts in cnt : if cnts % k != 0 : print ( - 1 ) return ans = ' '   for i in range ( 26 ) : ans += chr ( 97 + i ) * ( cnt [ i ] // k ) print ( ans * k )     return         if __name__ == ' _ _ main _ _ ' : solution ( ) NEW_LINE

k = int ( input ( ) ) st = input ( ) s = list ( st ) e = [ ] ec = [ ] f = 0 for i in s : if i not in e : e . append ( i ) ec . append ( s . count ( i ) ) j = 0 while j < len ( ec ) : temp = ec [ j ] if temp % k != 0 : print ( - 1 ) f = 1 break ec [ j ] = int ( ec [ j ] / k ) j += 1 if f != 1 : q = 0 a = ' ' while q < len ( e ) : temp = ec [ q ] while temp > 0 : a += str ( e [ q ] ) temp -= 1 q += 1 print ( a * k ) NEW_LINE

def solve ( s , n ) : d = { } for i in s : if not d . get ( i ) : d [ i ] = 1 else : d [ i ] += 1 res = ' ' for i in d : if d [ i ] % n != 0 : return - 1 for i in d : res += i * ( d [ i ] // n ) return res * n           def main ( ) : NEW_LINE


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 . FileInputStream ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Collection ; import java . util . List ; import java . util . Scanner ; import java . util . function . Function ; import java . util . stream . Collectors ; public class _p000769A { static public void main ( final String [ ] args ) throws IOException { p000769A . _main ( args ) ; }

import java . util . Arrays ; import java . util . Scanner ;   public class UniversityEntrance { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ;   int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = input . nextInt ( ) ;   Arrays . sort ( arr ) ; System . out . println ( arr [ n / 2 ] ) ; } }

import java . util . Scanner ; import java . util . Arrays ; import java . util . * ; import java . lang . * ;   public class Code {   public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; HashSet < Integer > hash = new HashSet < > ( ) ; int result = 0 ; int n = cin . nextInt ( ) ; cin . nextLine ( ) ;   int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = cin . nextInt ( ) ; } if ( n == 1 ) { System . out . println ( arr [ 0 ] ) ; return ; }   Arrays . sort ( arr ) ;  		  System . out . println ( arr [ n / 2 ] ) ;  				   cin . close ( ) ; } }

import java . util . * ; public class P2 {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; System . out . println ( a [ n / 2 ] ) ; } }

n = int ( input ( ) ) arr = sorted ( map ( int , input ( ) . split ( ) ) )   print ( arr [ n // 2 ] ) NEW_LINE

nennum = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) arr . sort ( ) print ( arr [ ( len ( arr ) - 1 ) // 2 ] ) NEW_LINE

n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) arr . sort ( ) print ( arr [ len ( arr ) // 2 ] ) NEW_LINE

a = int ( input ( ) ) b = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) if a == 1 : print ( b [ 0 ] ) if a == 3 : print ( b [ 1 ] ) if a == 5 : print ( b [ 2 ] ) NEW_LINE


import java . util . * ; public final class Ideone { private static int [ ] solve ( String s , String t ) {

import java . util . HashMap ; import java . util . Scanner ;   public class WorkFile { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; char [ ] s = scanner . next ( ) . toCharArray ( ) ; char [ ] t = scanner . next ( ) . toCharArray ( ) ; HashMap < Character , Integer > d = new HashMap < > ( ) ; int changes = 0 ; HashMap < String , Integer > dict = new HashMap < > ( ) ; int res = 0 , r1 = - 1 , r2 = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { char x = s [ i ] , y = t [ i ] ; if ( x != y ) { changes ++ ; d . putIfAbsent ( x , i ) ; if ( res == 2 ) continue ; String s1 = String . valueOf ( y ) + String . valueOf ( x ) ; if ( dict . get ( s1 ) != null ) { res = 2 ; r1 = dict . get ( s1 ) + 1 ; r2 = i + 1 ; } dict . putIfAbsent ( String . valueOf ( x ) + String . valueOf ( y ) , i ) ; } } if ( res == 2 ) { System . out . println ( changes - res ) ; System . out . println ( r1 + " ▁ " + r2 ) ; System . exit ( 0 ) ; } for ( int i = 0 ; i < n ; i ++ ) { char x = s [ i ] , y = t [ i ] ; if ( x != y ) { if ( d . get ( y ) != null ) { res = 1 ; r1 = i + 1 ; r2 = d . get ( y ) + 1 ; break ; } } } System . out . println ( changes - res ) ; System . out . println ( r1 + " ▁ " + r2 ) ; } }

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

from sys import stdin , stdoutfrom collections import Counterdef ai ( ) : return list ( map ( int , stdin . readline ( ) . split ( ) ) ) def ei ( ) : return map ( int , stdin . readline ( ) . split ( ) ) def ip ( ) : return int ( stdin . readline ( ) . strip ( ) ) def op ( ans ) : return stdout . write ( str ( ans ) + ' \n ' )     n = ip ( ) s = input ( ) t = input ( ) value = { } li = [ ] res1 = 0 res2 = res3 = - 1 for i in range ( n ) : if s [ i ] != t [ i ] : value [ t [ i ] ] = i res1 += 1 li . append ( i ) p = sq = Falsefor i in li : if s [ i ] in value : p = True res2 = i + 1 f = value [ s [ i ] ] res3 = f + 1 if s [ f ] == t [ i ] : sq = True breakprint ( res1 - ( 2 if sq else 1 if p else 0 ) ) print ( res2 , res3 ) NEW_LINE

num = int ( input ( ) )   a = input ( )   b = input ( )   dic = { }   lis = [ ]   ham = 0   swap1 = - 1   swap2 = - 1   p = False   q = False   for i in range ( num ) :   if a [ i ] != b [ i ] :   ham += 1   lis . append ( i )   dic [ b [ i ] ] = i   for i in lis :   if a [ i ] in dic :   p = True   swap1 = i + 1   f = dic [ a [ i ] ]   swap2 = f + 1   if a [ f ] == b [ i ] :   q = True   break   print ( ham - ( 2 if q else 1 if p else 0 ) )   print ( swap1 , swap2 )       NEW_LINE

n = int ( input ( ) ) s = input ( ) t = input ( ) dic , diff = { } , [ ] res , res1 , res2 = 0 , - 1 , - 1 for i in range ( n ) : if s [ i ] != t [ i ] : res += 1 diff . append ( i ) dic [ t [ i ] ] = iswap1 , swap2 = False , Falsefor i in diff : if s [ i ] in dic : swap1 = True res1 = i + 1 j = dic [ s [ i ] ] res2 = j + 1 if s [ j ] == t [ i ] : swap2 = True breakprint ( res - ( 2 if swap2 else 1 if swap1 else 0 ) ) print ( res1 , res2 ) NEW_LINE

__author__ = ' ruckus '   n = int ( input ( ) ) s = input ( ) t = input ( ) dif = { } hem = 0 for i in range ( n ) : if s [ i ] != t [ i ] : dif [ i ] = [ s [ i ] , t [ i ] ] hem += 1   change = [ ] probed = [ ] k = 0 for i in dif . keys ( ) : if dif [ i ] in probed : continue probed . append ( dif [ i ] ) k += 1 for j in list ( dif . keys ( ) ) [ k : ] : if dif [ i ] == dif [ j ] [ : : - 1 ] : print ( hem - 2 ) print ( i + 1 , j + 1 ) quit ( ) if not change and ( dif [ i ] [ 0 ] == dif [ j ] [ 1 ] or dif [ j ] [ 0 ] == dif [ i ] [ 1 ] ) : change = [ i , j ]   if change : print ( hem - 1 ) print ( change [ 0 ] + 1 , change [ 1 ] + 1 ) else : print ( hem ) print ( ' - 1 ▁ - 1' ) NEW_LINE

n = int ( input ( ) ) s = list ( input ( ) ) t = list ( input ( ) ) d = { } ans = 0 x , y = - 1 , - 1 for i in range ( n ) : if s [ i ] != t [ i ] : d [ ( s [ i ] , t [ i ] ) ] = i ans += 1 l = [ chr ( i + 97 ) for i in range ( 26 ) ] for i in l : for j in l : if ( i , j ) in d and ( j , i ) in d : ans -= 2 x = d [ ( i , j ) ] + 1 y = d [ ( j , i ) ] + 1 break if x != - 1 : breakif x == y == - 1 : for i in l : for j in l : for k in l : if ( i , j ) in d and ( j , k ) in d : ans -= 1 x = d [ ( i , j ) ] + 1 y = d [ ( j , k ) ] + 1 break if x != - 1 : breakprint ( ans ) print ( x , y ) NEW_LINE


import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . FileReader ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ;   public class v_tranport {   public static void main ( String [ ] args ) throws IOException { BufferedReader ob = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String c [ ] = ob . readLine ( ) . split ( " ▁ " ) ; int c1 = Integer . parseInt ( c [ 0 ] ) ; int c2 = Integer . parseInt ( c [ 1 ] ) ; int c3 = Integer . parseInt ( c [ 2 ] ) ; int c4 = Integer . parseInt ( c [ 3 ] ) ; String nm [ ] = ob . readLine ( ) . split ( " ▁ " ) ; int n = Integer . parseInt ( nm [ 0 ] ) ; int m = Integer . parseInt ( nm [ 1 ] ) ; String s [ ] = ob . readLine ( ) . split ( " ▁ " ) ; int total = 0 ; long ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int temp = Integer . parseInt ( s [ i ] ) ; int cst = temp * c1 ;

import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) {   Scanner s = new Scanner ( System . in ) ; int c [ ] = new int [ 4 ] ; int m = 0 ; int bus = 0 , tro = 0 ; for ( int i = 0 ; i < c . length ; i ++ ) { c [ i ] = s . nextInt ( ) ; }

import java . util . * ; import java . lang . * ; import java . math . BigInteger ; import java . io . * ; import java . io . * ; import java . util . * ;   public class CodeChef {   public static void main ( String args [ ] ) throws IOException {   BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; String [ ] sr = br . readLine ( ) . split ( " ▁ " ) ; int c1 , c2 , c3 , c4 ; c1 = Integer . parseInt ( sr [ 0 ] ) ; c2 = Integer . parseInt ( sr [ 1 ] ) ; c3 = Integer . parseInt ( sr [ 2 ] ) ; c4 = Integer . parseInt ( sr [ 3 ] ) ; String [ ] ss = br . readLine ( ) . split ( " ▁ " ) ; int n = Integer . parseInt ( ss [ 0 ] ) ; int m = Integer . parseInt ( ss [ 1 ] ) ; int [ ] arr = new int [ n ] ; int [ ] arr1 = new int [ m ] ; int sum1 = 0 , sum2 = 0 ; String [ ] st = br . readLine ( ) . split ( " ▁ " ) ; String [ ] su = br . readLine ( ) . split ( " ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = Integer . parseInt ( st [ i ] ) ; sum1 += Math . min ( c1 * arr [ i ] , c2 ) ; } for ( int i = 0 ; i < m ; i ++ ) { arr1 [ i ] = Integer . parseInt ( su [ i ] ) ; sum2 += Math . min ( c1 * arr1 [ i ] , c2 ) ; } int sum3 = Math . min ( Math . min ( Math . min ( sum1 + c3 , sum2 + c3 ) , sum1 + sum2 ) , 2 * c3 ) ; sum3 = Math . min ( sum3 , c4 ) ; System . out . println ( sum3 ) ; }   }

c1 , c2 , c3 , c4 = map ( int , input ( ) . split ( ) ) n , m = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) ans = 0 for i in range ( 0 , len ( a ) ) : ans += min ( c2 , a [ i ] * c1 ) ans = min ( ans , c3 ) ans1 = 0 for i in range ( 0 , len ( b ) ) : ans1 += min ( c2 , b [ i ] * c1 ) ans1 = min ( c3 , ans1 ) print ( min ( c4 , ans1 + ans ) ) NEW_LINE

c1 , c2 , c3 , c4 = map ( int , input ( ) . split ( ) ) n , m = map ( int , input ( ) . split ( ) ) b = list ( map ( int , input ( ) . split ( ) ) ) t = list ( map ( int , input ( ) . split ( ) ) ) a = 0 for i in range ( n ) : a += min ( c1 * b [ i ] , c2 ) ans = min ( a , c3 ) b = 0 for i in range ( m ) : b += min ( c1 * t [ i ] , c2 ) ans += min ( b , c3 ) print ( min ( ans , c4 ) ) NEW_LINE

c1 , c2 , c3 , c4 = map ( int , input ( ) . split ( ) ) n , m = map ( int , input ( ) . split ( ) ) n1 = list ( map ( int , input ( ) . split ( ) ) ) m1 = list ( map ( int , input ( ) . split ( ) ) ) s1 = 0 r = [ ] for i in range ( n ) : if ( ( n1 [ i ] * c1 ) > ( c2 ) ) : s1 = s1 + c2 else : s1 = s1 + n1 [ i ] * c1r . append ( s1 + c3 ) s2 = 0 for i in range ( m ) : if ( ( m1 [ i ] * c1 ) > ( c2 ) ) : s2 = s2 + c2 else : s2 = s2 + m1 [ i ] * c1r . append ( s2 + c3 ) r . append ( s1 + s2 ) r . append ( 2 * c3 ) r . append ( c4 ) print ( min ( r ) ) NEW_LINE

import sysinput = sys . stdin . readlinel = input ( ) . split ( ) c1 = int ( l [ 0 ] ) c2 = int ( l [ 1 ] ) c3 = int ( l [ 2 ] ) c4 = int ( l [ 3 ] ) l = input ( ) . split ( ) n = int ( l [ 0 ] ) m = int ( l [ 1 ] ) l = input ( ) . split ( ) ai = [ int ( i ) for i in l ] l = input ( ) . split ( ) bi = [ int ( i ) for i in l ] maxa = c4sumi = 0 for i in ai : sumi += min ( i * c1 , c2 ) sumi = min ( sumi , c3 ) sumi1 = 0 for i in bi : sumi1 += min ( i * c1 , c2 ) sumi1 = min ( sumi1 , c3 ) print ( min ( maxa , sumi + sumi1 ) ) NEW_LINE


import java . util . Scanner ; import java . util . Arrays ; public class Codechef { public static void main ( String [ ] args ) throws java . lang . Exception { try { Scanner sc = new Scanner ( System . in ) ; int n , m , i , c ; n = sc . nextInt ( ) ; for ( i = 1 ; i * i <= n ; i ++ ) { if ( i * i > n ) break ; } i -- ; c = 3 * i ; n = n - i * i ; c = c + 2 * ( n / i ) ; if ( n % i == 0 ) c = c + i ; else c = c + i + 2 ; System . out . println ( c ) ; } catch ( Exception e ) { } } }

import java . util . Scanner ;   public class B { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; System . out . println ( 2 * ( ( int ) Math . ceil ( 2 * Math . sqrt ( sc . nextInt ( ) ) ) ) ) ; } }

import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class a { static int [ ] count , count1 , count2 ; static Node [ ] nodes ; static long [ ] arr ; static char [ ] ch , ch1 ; static long [ ] darr , farr ; static Character [ ] [ ] mat , mat1 ; static long x , h ; static long maxl ; static double dec ; static String s ; static long minl ; static int mx = ( int ) 1e9 + 5 ; static long mod = 998244353l ;

import java . util . * ; public class test { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int numberOfBlocks = scanner . nextInt ( ) ; int circuit = - 1 ; int findThatHasSquare = numberOfBlocks ; if ( Math . sqrt ( findThatHasSquare ) % 1 == 0 ) { circuit = ( int ) Math . sqrt ( findThatHasSquare ) * 4 ; } else { findThatHasSquare = numberOfBlocks ; while ( true ) { if ( Math . sqrt ( findThatHasSquare ) % 1 == 0 ) { break ; } findThatHasSquare -- ; } } if ( circuit == - 1 ) { int sqrt = ( int ) Math . sqrt ( findThatHasSquare ) ; circuit = sqrt * 4 ; int restBlocks = numberOfBlocks - findThatHasSquare ; while ( true ) { if ( restBlocks - sqrt > 0 ) { restBlocks = - sqrt ; circuit += 2 ; } else { circuit += 2 ; break ; } } } System . out . println ( circuit ) ; } }

import mathnum = int ( input ( ) )   side = math . ceil ( num ** 0.5 )   if ( side - 1 ) * side >= num : ans = ( side * 2 - 1 ) * 2 else : ans = side * 4 print ( ans )                     NEW_LINE

import math   n = int ( input ( ) )   a = int ( math . sqrt ( n ) ) b = math . ceil ( n / a )   print ( 2 * ( a + b ) ) NEW_LINE

import mathn = int ( input ( ) ) if ( math . sqrt ( n ) ) . is_integer ( ) : print ( int ( math . sqrt ( n ) * 4 ) ) else : n1 = int ( math . sqrt ( n ) ) if ( n - ( math . pow ( n1 , 2 ) ) ) > n1 : print ( n1 * 4 + 4 ) else : print ( n1 * 4 + 2 ) NEW_LINE

n = int ( input ( ) ) x = 1 while x ** 2 < n : x += 1 if x ** 2 > n : x -= 1 t = n - x ** 2 ans = 4 * xif ( t != 0 ) : b = t // x z = t % x ans += ( 2 * b ) if z > 0 : ans += 2 print ( ans ) NEW_LINE

def solve ( n ) : a = n ** 0.5 b = int ( a ) if a == int ( a ) : return 4 * int ( a ) else : if n > b * b and n <= b * ( b + 1 ) : return 4 * b + 2 else : return 4 * ( b + 1 )     n = int ( input ( ) ) print ( solve ( n ) ) NEW_LINE


import java . util . * ; public class P2 {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i == j ) System . out . print ( k + " ▁ " ) ; else System . out . print ( 0 + " ▁ " ) ; } System . out . println ( ) ; } } }

import java . util . Scanner ;   public class LevkoandTable {   public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i == j ) { System . out . print ( k + " ▁ " ) ; } else { System . out . print ( 0 + " ▁ " ) ; } } System . out . println ( ) ; } } }

import java . util . * ; import java . io . * ; import java . math . * ;   public class Main { public static void main ( String ... args ) throws IOException { Scanner sc = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < n ; ++ j ) out . print ( i == j ? m + " ▁ " : "0 ▁ " ) ; out . println ( ) ; } out . flush ( ) ; out . close ( ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; import java . util . StringTokenizer ;   public class code { public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ )   { for ( int j = 0 ; j < n ; j ++ ) { if ( i == j ) { System . out . print ( m + " ▁ " ) ; } else System . out . print ( 0 + " ▁ " ) ; } System . out . println ( ) ; }   } 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 ; } } } class Pair { int x , y ; public Pair ( int x , int y ) { this . x = x ; this . y = y ; } public String toString ( ) { return x + " ▁ " + y ; } }

n , k = map ( int , input ( ) . split ( ) ) for i in range ( n ) : for j in range ( n ) : if ( i == j ) : print ( k , end = " ▁ " ) else : print ( 0 , end = " ▁ " ) print ( ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) arr = [ [ 0 ] * n for i in range ( n ) ] for i in range ( n ) : arr [ i ] [ i ] = kfor i in range ( n ) : print ( * arr [ i ] ) NEW_LINE

n , m = [ int ( x ) for x in input ( ) . split ( ) ] n -= 1 for i in range ( n + 1 ) : print ( '0 ▁ ' * i + str ( m ) + ' ▁ 0' * ( n - i ) ) NEW_LINE

from itertools import permutationsn , k = map ( int , input ( ) . split ( ) ) arr = [ ] count = 0 for m in range ( n ) : lst = [ 0 ] * n lst [ count ] = k count += 1 arr . append ( lst ) for x in arr : print ( * x ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) a = k - n + 1 for i in range ( n ) : for j in range ( n ) : if i == j : print ( a , end = " ▁ " ) else : print ( 1 , end = " ▁ " ) print ( " " ) NEW_LINE


import java . awt . * ; import java . io . * ; import java . math . BigDecimal ; import java . math . BigInteger ; import java . util . * ; import java . util . List ; import java . util . Queue ;   import static java . lang . Math . max ; import static java . lang . Math . min ;    public class B implements Runnable {

from collections import Counter   n , m , p = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) )     def try_from ( start , a , b ) : result = [ ] seq = a [ start : : p ] i = 0 if len ( seq ) < len ( b ) : return [ ]   counts_a = Counter ( seq [ : len ( b ) ] ) counts_b = Counter ( b ) if counts_a == counts_b : result . append ( start )   for i in range ( 1 , len ( seq ) - len ( b ) + 1 ) : counts_a [ seq [ i - 1 ] ] -= 1 counts_a [ seq [ i + len ( b ) - 1 ] ] += 1 if not counts_a [ seq [ i - 1 ] ] : del counts_a [ seq [ i - 1 ] ]   ok = counts_a == counts_b NEW_LINE


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 FileWriter fw ; static PrintWriter pw ; static double eps = ( double ) 1e-6 ; static long oo = Long . MAX_VALUE ;

import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . util . ArrayList ; import java . util . Random ; import java . util . StringTokenizer ;   public class AliceAndListOfPresents { static final int MAXN = 1000_006 ; static final long MOD = ( long ) 1e9 + 7 ; public static void main ( String [ ] args ) throws IOException { MyScanner s = new MyScanner ( ) ; Print p = new Print ( ) ; Helper hp = new Helper ( ) ; int n = s . nextInt ( ) ; int m = s . nextInt ( ) ; long sol = hp . pow ( 2 , m , MOD ) - 1 ; p . println ( hp . pow ( sol , n , MOD ) ) ; p . close ( ) ; } public static class Pair implements Comparable < Pair > { int first ; int second ; public Pair ( int a , int b ) { this . first = a ; this . second = b ; } @ Override public int hashCode ( ) { final int prime = 31 ; int result = 1 ; result = prime * result + first ; result = prime * result + second ; return result ; } @ Override public boolean equals ( Object obj ) { if ( this == obj ) return true ; if ( obj == null ) return false ; if ( getClass ( ) != obj . getClass ( ) ) return false ; Pair other = ( Pair ) obj ; if ( first != other . first ) return false ; if ( second != other . second ) return false ; return true ; } @ Override public int compareTo ( Pair o ) {

import java . util . * ; import java . lang . * ; import java . io . * ; public class Main { PrintWriter out ; FastReader sc ; long mod = ( long ) ( 1e9 + 7 ) ; long maxlong = Long . MAX_VALUE ; long minlong = Long . MIN_VALUE ; long pow ( long a , long b ) { if ( b == 0 ) { return 1 ; } long p = pow ( a , b / 2 ) ; if ( b % 2 == 0 ) return ( p * p ) % mod ; else return ( ( ( p * p ) % mod ) * a ) % mod ; } public void sol ( ) { long a = ni ( ) , b = ni ( ) ; pl ( pow ( pow ( 2 , b ) - 1 , a ) ) ; } public static void main ( String [ ] args ) { Main g = new Main ( ) ; g . out = new PrintWriter ( System . out ) ; g . sc = new FastReader ( ) ; int t = 1 ;

arr = list ( map ( int , input ( ) . split ( ) ) ) n = arr [ 0 ] m = arr [ 1 ] k = ( 10 ** 9 ) + 7 print ( pow ( 2 ** m - 1 , n , k ) ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) mod = pow ( 10 , 9 ) + 7 ans = ( pow ( 2 , m , mod ) - 1 ) % mod   ans = pow ( ans , n , mod )   print ( ans ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) mod = 10 ** 9 + 7 print ( pow ( ( pow ( 2 , m , mod ) + mod - 1 ) % mod , n , 10 ** 9 + 7 ) ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) r = { }   def PsevdoBin ( base , x ) : if x in r : return r [ x ] mod = 10 ** 9 + 7   if x <= 2 : return ( base ** x ) % mod else : a = x // 2 ; b = ( x + 1 ) // 2 r [ x ] = ( PsevdoBin ( base , a ) * PsevdoBin ( base , b ) ) % mod return ( PsevdoBin ( base , a ) * PsevdoBin ( base , b ) ) % mod   one_box = ( PsevdoBin ( 2 , m ) + 10 ** 9 + 7 - 1 ) % ( 10 ** 9 + 7 ) r = { } for_all = PsevdoBin ( one_box , n )   print ( for_all % ( 10 ** 9 + 7 ) ) NEW_LINE


import java . io . * ; import java . util . * ;   public class Task1290B { private static InputReader in ; private static PrintWriter out ; private static boolean autoFlush = false ; static final int inf = ( int ) 1e9 + 7 ;   static class Testcase { public void solve ( int test ) { StringBuilder s = new StringBuilder ( in . next ( ) ) ; int n = s . length ( ) ; int [ ] [ ] cnt = new int [ n + 1 ] [ 26 ] ; Arrays . fill ( cnt [ 0 ] , 0 ) ; for ( int i = 1 ; i <= n ; i ++ ) { int c = s . charAt ( i - 1 ) - ' a ' ; for ( int j = 0 ; j < 26 ; j ++ ) cnt [ i ] [ j ] = cnt [ i - 1 ] [ j ] ; cnt [ i ] [ c ] ++ ; } int m = in . nextInt ( ) ; for ( int i = 0 ; i < m ; i ++ ) { int l = in . nextInt ( ) ; int r = in . nextInt ( ) ; boolean yes = false ; int count = 0 ; for ( int j = 0 ; j < 26 ; j ++ ) if ( cnt [ r ] [ j ] - cnt [ l - 1 ] [ j ] > 0 ) count ++ ; if ( r == l ) yes = true ; else if ( s . charAt ( l - 1 ) != s . charAt ( r - 1 ) ) yes = true ; else if ( count > 2 ) yes = true ; out . println ( yes ? " Yes " : " No " ) ; } } }   public static void main ( String [ ] args ) { in = new InputReader ( System . in ) ; out = new PrintWriter ( System . out , autoFlush ) ; int t = 1 ;

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

import java . util . * ; import java . io . * ; public class EdD {   public static void main ( String [ ] args ) throws Exception { int num = 998244353 ;

def diff ( a , b ) : ans = [ ] for i in range ( len ( a ) ) : ans . append ( a [ i ] - b [ i ] ) return ans   a = input ( ) n = len ( a ) q = int ( input ( ) ) count = [ [ 0 for i in range ( 26 ) ] for j in range ( n ) ] count [ 0 ] [ ord ( a [ 0 ] ) - 97 ] += 1 for i in range ( 1 , n ) : for j in range ( 26 ) : count [ i ] [ j ] = count [ i - 1 ] [ j ] count [ i ] [ ord ( a [ i ] ) - 97 ] += 1   NEW_LINE


import java . util . * ;   public class questionCF {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int day = 0 , time = 0 ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { time += ( 86400 - a [ i ] ) ; day ++ ; if ( time >= t && day <= n ) { System . out . println ( day ) ; return ; } } System . out . println ( n ) ;   } }

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

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long t = sc . nextLong ( ) ; long [ ] arr = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . nextLong ( ) ; }

import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int t = sc . nextInt ( ) , rem = 0 , res = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int num = sc . nextInt ( ) ; rem += ( 86400 - num ) ; if ( rem >= t && res == 0 ) res = i ; } System . out . println ( res ) ; sc . close ( ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; short n = scan . nextShort ( ) , day = 0 ; int [ ] a = new int [ n ] ; int t = scan . nextInt ( ) , i ; for ( i = 0 ; i < n ; i ++ ) { a [ i ] = scan . nextInt ( ) ; t -= 86400 - a [ i ] ; day ++ ; if ( t <= 0 ) break ; } System . out . println ( day ) ; } }

n , t = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) : if 86400 - a [ i ] >= t : print ( i + 1 ) break else : t -= 86400 - a [ i ] NEW_LINE

n , t = map ( int , input ( ) . split ( ) ) A = list ( map ( int , input ( ) . split ( ) ) ) D = 86400 for i in range ( n ) : if D - A [ i ] >= t : print ( i + 1 ) break else : t -= ( D - A [ i ] ) NEW_LINE

from sys import stdininput = stdin . readline   n , t = [ int ( x ) for x in input ( ) . split ( ) ] a = [ int ( x ) for x in input ( ) . split ( ) ] for i in range ( n ) : t -= 86400 - a [ i ] if t <= 0 : print ( i + 1 ) break NEW_LINE

num , t = map ( int , ( input ( ) . split ( ) ) ) arr = list ( map ( int , input ( ) . split ( ) ) )   ct = 0 i = 0 while t > 0 : t -= ( 86400 - arr [ i ] ) i += 1 ct += 1   print ( ct ) NEW_LINE

n , t = map ( int , input ( ) . split ( ) ) lst = [ int ( i ) for i in input ( ) . split ( ) ]   for i , val in enumerate ( lst ) : t -= 86400 - val   if t <= 0 : print ( i + 1 ) break NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ;   public class Zad1119B {   public static void main ( String [ ] args ) {

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

import java . util . * ; import java . io . * ;   public class AnyolaFridge {    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 ( ) ; long h = fr . nextLong ( ) ; long [ ] arr = new long [ n ] ;   for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = fr . nextLong ( ) ;   int ans = 1 ;   for ( int i = 0 ; i < n ; i ++ ) { ArrayList < Long > temp = new ArrayList < > ( ) ; for ( int j = 0 ; j <= i ; j ++ ) { temp . add ( arr [ j ] ) ; } Collections . sort ( temp , Collections . reverseOrder ( ) ) ; long need = 0 ; for ( int j = 0 ; j < temp . size ( ) ; j += 2 ) { need += temp . get ( j ) ; } if ( need <= h ) { ans = Math . max ( ans , i + 1 ) ; } } System . out . println ( ans ) ;   } }

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

def bs ( l , h ) : while l < h : m = ( l + h + 1 ) // 2 if gf ( m ) : l = m else : h = m - 1 return l   def gf ( x ) : if x % 2 : return sum ( sorted ( a [ : x + 1 ] ) [ 1 : : 2 ] ) <= h else : return sum ( sorted ( a [ : x + 1 ] ) [ 0 : : 2 ] ) <= h     n , h = map ( int , input ( ) . split ( ) ) a = tuple ( map ( int , input ( ) . split ( ) ) ) print ( bs ( 0 , n - 1 ) + 1 ) NEW_LINE

def check ( k ) : g = h x = sorted ( l [ : k + 1 ] , reverse = True ) for i in range ( 0 , k + 1 , 2 ) : if g < x [ i ] : return False g -= x [ i ] return True                   n , h = list ( map ( int , input ( ) . split ( ) ) ) l = list ( map ( int , input ( ) . split ( ) ) ) for j in range ( n - 1 , - 1 , - 1 ) : if check ( j ) : print ( j + 1 ) break NEW_LINE

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

def getInput ( ) : temp = input ( ) . split ( " ▁ " ) n , h = int ( temp [ 0 ] ) , int ( temp [ 1 ] ) heights = input ( ) . split ( " ▁ " ) for i in range ( len ( heights ) ) : heights [ i ] = int ( heights [ i ] ) return n , h , heights   def fits ( i ) : height_left = h p = 0 while p < i : if heights [ p ] <= height_left : height_left -= heights [ p ] p += 1 if p < i : p += 1 else : return False return True n , h , heights = getInput ( ) k = nfor i in range ( 1 , n + 1 ) : heights [ : i ] = sorted ( heights [ : i ] , reverse = True ) NEW_LINE

def solve ( n , k , arr ) : final = 0 for x in range ( 1 , n + 1 ) : dup = k times = 0 temp = sorted ( arr [ : x ] , reverse = True ) for ele in range ( 0 , x , 2 ) : if temp [ ele ] <= dup : dup -= temp [ ele ] if ele + 1 < x : times += 2 else : times += 1 else : break if times > final : final = times return final   n , k = list ( map ( int , input ( ) . split ( ) ) ) seq = list ( map ( int , input ( ) . split ( ) ) ) print ( solve ( n , k , seq ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class CF23A { public static void main ( String [ ] args ) throws IOException { FastScanner sc = new FastScanner ( ) ; PrintWriter pw = new PrintWriter ( System . out ) ; char [ ] s = sc . nextToken ( ) . toCharArray ( ) ; pw . println ( solve ( s ) ) ; pw . flush ( ) ; }   static int solve ( char [ ] s ) { for ( int len = s . length - 1 ; len > 0 ; len -- ) for ( int i = 0 ; i <= s . length - len ; i ++ ) for ( int k = i + 1 ; k <= s . length - len ; k ++ ) if ( match ( s , k , i , len ) ) { return len ; } return 0 ; }   static boolean match ( char [ ] s , int st1 , int st2 , int len ) { for ( int i = 0 ; i < len ; i ++ ) if ( s [ st1 + i ] != s [ st2 + i ] ) return false ; return true ; }   static class FastScanner { BufferedReader in ; StringTokenizer st ;   public FastScanner ( ) { this . in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   public String nextToken ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( in . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   public int nextInt ( ) { return Integer . parseInt ( nextToken ( ) ) ; }   public long nextLong ( ) { return Long . parseLong ( nextToken ( ) ) ; }   public double nextDouble ( ) { return Double . parseDouble ( nextToken ( ) ) ; }   public void close ( ) throws IOException { in . close ( ) ; } } }

import java . util . * ; public class LongestRepeatingSequence {

import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ;   public class Main { static Map < String , Integer > map = new HashMap < > ( ) ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { for ( int j = 1 ; j < s . length ( ) ; j ++ ) { if ( i + j <= s . length ( ) ) { String t = s . substring ( i , i + j ) ; if ( ! map . containsKey ( t ) ) map . put ( t , 1 ) ; else map . put ( t , map . get ( t ) + 1 ) ; } } } int ans = 0 ; for ( Map . Entry < String , Integer > entry : map . entrySet ( ) ) { int k = entry . getValue ( ) ; String t = entry . getKey ( ) ; if ( k >= 2 && t . length ( ) > ans ) ans = t . length ( ) ; } System . out . println ( ans ) ; } }

import java . util . * ;   public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String str = s . next ( ) ; int max = 0 ; for ( int k = str . length ( ) ; k >= 0 ; k -- ) { for ( int start = 0 ; start < str . length ( ) - k ; start ++ ) { String substr = str . substring ( start , start + k ) ; if ( str . substring ( start + 1 ) . contains ( substr ) ) { max = substr . length ( ) ; break ; } } if ( max != 0 ) break ; }   System . out . println ( max ) ; s . close ( ) ; } }

import sysfrom random import * from bisect import * from heapq import * NEW_LINE

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

S = input ( ) best = 0 for i in range ( len ( S ) ) : for j in range ( i + 1 , len ( S ) + 1 ) : s = S [ i : j ] c = 0 for k in range ( len ( S ) ) : if S [ k : ] . startswith ( s ) : c += 1 if c >= 2 : best = max ( best , len ( s ) ) print ( best ) NEW_LINE

s = input ( ) n = len ( s ) m = 0   for i in range ( n - 1 ) : for j in range ( 1 , n - i ) : if s [ i : i + j ] in s [ i + 1 : ] : if j > m : m = j   print ( m ) NEW_LINE

cadena = input ( ) n = len ( cadena )   rpta = 0   for i in range ( n - 1 ) : tamanho_cadena = n - i - 1 for j in range ( n - tamanho_cadena ) : subcadena = cadena [ j : j + tamanho_cadena ] contador = 1 for k in range ( n - tamanho_cadena - j ) : if subcadena == cadena [ j + k + 1 : j + k + 1 + tamanho_cadena ] : contador = contador + 1 if contador >= 2 and rpta == 0 : rpta = tamanho_cadena if rpta != 0 : break   print ( rpta ) NEW_LINE


import java . io . * ; import java . lang . * ; import java . util . * ;   public class A471 { public static void main ( String [ ] args ) throws IOException { StringBuffer ans = new StringBuffer ( ) ; StringTokenizer st ; BufferedReader f = new BufferedReader ( new InputStreamReader ( System . in ) ) ; st = new StringTokenizer ( f . readLine ( ) ) ; ArrayList < Integer > arr = new ArrayList < > ( ) ; HashMap < Integer , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < 6 ; i ++ ) { arr . add ( Integer . parseInt ( st . nextToken ( ) ) ) ; if ( ! map . containsKey ( arr . get ( i ) ) ) { map . put ( arr . get ( i ) , 0 ) ; } map . put ( arr . get ( i ) , map . get ( arr . get ( i ) ) + 1 ) ; } f . close ( ) ; boolean flag = false ; int keep = - 1 ; for ( int i = 0 ; i < 6 ; i ++ ) { if ( map . get ( arr . get ( i ) ) >= 4 ) { keep = arr . get ( i ) ; flag = true ; } } if ( ! flag ) { System . out . println ( " Alien " ) ; return ; } arr . remove ( ( Integer ) keep ) ; arr . remove ( ( Integer ) keep ) ; arr . remove ( ( Integer ) keep ) ; arr . remove ( ( Integer ) keep ) ; int first = arr . get ( 0 ) ; int second = arr . get ( 1 ) ; if ( second == first ) { System . out . println ( " Elephant " ) ; } else { System . out . println ( " Bear " ) ; }     System . out . println ( ans ) ; }   }

import java . util . * ; import java . math . * ; public class MuhAndSticks { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] arr = new int [ 6 ] ; for ( int i = 0 ; i < 6 ; i ++ ) arr [ i ] = sc . nextInt ( ) ; Arrays . sort ( arr ) ; int count = 0 ; boolean works = false ; int start = 0 ; int end = 3 ;   outer : for ( int i = 0 ; i < 3 ; i ++ ) { start = end - 3 ; for ( int j = start ; j <= end ; j ++ ) { if ( arr [ j ] != arr [ j + 1 ] ) break ; if ( arr [ j ] == arr [ j + 1 ] && j + 1 == end ) { works = true ; break outer ; }   } end ++ ; } int [ ] nums = new int [ 2 ] ; int dex = 0 ; for ( int i = 0 ; i < 6 ; i ++ ) { if ( i < start || i > end ) { nums [ dex ] = arr [ i ] ; dex ++ ; } } if ( ! works ) System . out . println ( " Alien " ) ; else { if ( nums [ 0 ] == nums [ 1 ] ) System . out . println ( " Elephant " ) ; else System . out . println ( " Bear " ) ; }    } }

import java . util . Scanner ;   public class StickAnimal { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   int [ ] sticks = new int [ 9 ] ; boolean flag = false ;   for ( int i = 0 ; i < 6 ; i ++ ) { if ( sticks [ scanner . nextInt ( ) - 1 ] ++ == 3 ) flag = true ; }   if ( flag ) { for ( int i = 0 ; i < 9 ; i ++ ) { if ( sticks [ i ] == 1 ) { System . out . println ( " Bear " ) ; return ; } } System . out . println ( " Elephant " ) ; } else System . out . println ( " Alien " ) ; } }

sticks = [ int ( asd ) for asd in input ( ) . split ( ) ] if len ( set ( sticks ) ) > 3 : print ( " Alien " ) exit ( ) res = max ( set ( sticks ) , key = sticks . count ) if sticks . count ( res ) < 4 : print ( " Alien " ) exit ( ) sticks2 = [ ] cnt = 4 for x in range ( sticks . count ( res ) - 4 ) : sticks2 . append ( res )   for bruh in sticks : if bruh != res : sticks2 . append ( bruh )   if len ( set ( sticks2 ) ) == 1 : print ( " Elephant " ) elif len ( set ( sticks2 ) ) == 2 : print ( " Bear " ) else : print ( " Alien " ) NEW_LINE

if __name__ == ' _ _ main _ _ ' : Y = lambda : list ( map ( int , input ( ) . split ( ) ) ) P = lambda : map ( int , input ( ) . split ( ) )   a = Y ( ) a = sorted ( a , key = a . count )   if a [ 2 ] != a [ - 1 ] : print ( " Alien " ) elif a [ 0 ] == a [ 1 ] : print ( " Elephant " ) else : print ( " Bear " ) NEW_LINE

from sys import stdin , stdoutfrom collections import Counternmbr = lambda : int ( stdin . readline ( ) ) lst = lambda : list ( map ( int , stdin . readline ( ) . split ( ) ) ) for _ in range ( 1 ) : NEW_LINE

a = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 6 ) : if a . count ( a [ i ] ) >= 4 : v = a [ i ] breakelse : print ( " Alien " ) exit ( ) for i in range ( 4 ) : a . remove ( v ) a . sort ( ) if a [ 0 ] < a [ 1 ] : print ( " Bear " ) elif a [ 0 ] == a [ 1 ] : print ( " Elephant " ) else : print ( " Alien " ) NEW_LINE

t = list ( map ( int , input ( ) . split ( ) ) )   c_max = 0 c_min = 6 for x in range ( 6 ) : c_max = max ( c_max , t . count ( t [ x ] ) ) c_min = min ( c_min , t . count ( t [ x ] ) )   if c_max < 4 : print ( ' Alien ' ) elif c_max == 4 : if c_min == 1 : print ( ' Bear ' ) else : print ( ' Elephant ' ) elif c_max == 5 : print ( ' Bear ' ) elif c_max == 6 : print ( ' Elephant ' ) NEW_LINE


import java . util . Scanner ; public class eqaution { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int t = scn . nextInt ( ) ; while ( t -- > 0 ) { int n = scn . nextInt ( ) ; int [ ] a = new int [ n + 1 ] ; int [ ] b = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = scn . nextInt ( ) ; b [ i ] = scn . nextInt ( ) ; } int [ ] tm = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { tm [ i ] = scn . nextInt ( ) ; } int last = 0 ; int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int arrival = a [ i ] - b [ i - 1 ] + last + tm [ i ] ; ans = arrival ; if ( arrival == a [ i ] ) { last = arrival + b [ i ] - a [ i ] ; } else { last = arrival + ( int ) Math . ceil ( ( b [ i ] - a [ i ] ) / 2.0 ) ; } } System . out . println ( ans ) ; } } }

import java . util . * ; public class temp { public static void main ( String str [ ] ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; int arr [ ] = new int [ n ] ; int dep [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; dep [ i ] = sc . nextInt ( ) ; } int del [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { del [ i ] = sc . nextInt ( ) ; } int curr = arr [ 0 ] ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int tem = ( int ) Math . ceil ( ( double ) ( dep [ i ] - arr [ i ] ) / 2 ) ; int ariv = curr + del [ i ] ; curr = arr [ i + 1 ] - dep [ i ] + Math . max ( ariv + tem , dep [ i ] ) ; } System . out . println ( curr + del [ n - 1 ] ) ; } } }

import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int tc = sc . nextInt ( ) ; while ( tc -- > 0 ) { int n = sc . nextInt ( ) ; int a [ ] = new int [ n + 1 ] ; int b [ ] = new int [ n + 1 ] ; int tm [ ] = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i <= n ; i ++ ) { tm [ i ] = sc . nextInt ( ) ; } int prev = 0 ; int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { prev += a [ i ] - b [ i - 1 ] + tm [ i ] ; ans = prev ; prev += Math . ceil ( 1.0 * ( b [ i ] * 1.0 - a [ i ] * 1.0 ) / 2.0 ) ; prev = Math . max ( prev , b [ i ] ) ; } System . out . println ( ans ) ; } } }

import java . util . * ; public class Test { static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; int t = Integer . parseInt ( sc . next ( ) ) ; while ( t -- > 0 ) { solve ( ) ; } } public static void solve ( ) { int n = sc . nextInt ( ) ; int [ ] a = new int [ n + 1 ] ; int [ ] b = new int [ n + 1 ] ; int [ ] extra = new int [ n + 1 ] ; long curr_time = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i <= n ; i ++ ) { extra [ i ] = sc . nextInt ( ) ; } int i = 0 ; for ( i = 1 ; i < n ; i ++ ) { curr_time += ( a [ i ] - b [ i - 1 ] + extra [ i ] ) ; int staying = ( int ) Math . ceil ( ( b [ i ] - a [ i ] ) / 2.0 ) ; curr_time += staying ; if ( curr_time < b [ i ] ) curr_time = b [ i ] ; } curr_time += ( a [ i ] - b [ i - 1 ] + extra [ i ] ) ; System . out . println ( curr_time ) ; } }

import java . util . Scanner ; public class A { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; int [ ] a = new int [ n + 1 ] ; int [ ] b = new int [ n + 1 ] ; int [ ] tm = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i <= n ; i ++ ) { tm [ i ] = sc . nextInt ( ) ; } int ans = 0 , at = 0 , dt = 0 ; for ( int i = 1 ; i < n ; i ++ ) { int rt = a [ i ] - b [ i - 1 ] ; int wt = ( b [ i ] - a [ i ] + 1 ) / 2 ; at = dt + rt + tm [ i ] ; if ( b [ i ] - at >= wt ) dt = b [ i ] ; else dt = at + wt ; } ans = a [ n ] - b [ n - 1 ] + dt + tm [ n ] ; System . out . println ( ans ) ; } sc . close ( ) ; } }

R = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE t , = R ( ) NEW_LINE while t : NEW_LINE INDENT t -= 1 ; NEW_LINE n , = R ( ) ; NEW_LINE a , b = zip ( * ( R ( ) for _ in [ 0 ] * n ) ) ; NEW_LINE s = 0 NEW_LINE for x , y , z , w in zip ( a , b , ( 0 , * b ) , R ( ) ) : p = s + x - z + w ; s = p + max ( y - x + 1 >> 1 , y - p ) NEW_LINE print ( p ) NEW_LINE DEDENT

T = int ( input ( ) ) NEW_LINE for t in range ( T ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE a = [ ] NEW_LINE b = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT ai , bi = map ( int , input ( ) . split ( ) ) NEW_LINE a . append ( ai ) NEW_LINE b . append ( bi ) NEW_LINE DEDENT tm = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE t = a [ 0 ] + tm [ 0 ] NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT dep = max ( b [ i ] , t + ( b [ i ] - a [ i ] + 1 ) // 2 ) NEW_LINE t = dep + a [ i + 1 ] - b [ i ] + tm [ i + 1 ] NEW_LINE DEDENT print ( t ) NEW_LINE DEDENT

for time in range ( int ( input ( ) ) ) : NEW_LINE INDENT n , a , b = int ( input ( ) ) , [ ] , [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT ai , bi = map ( int , input ( ) . split ( ) ) NEW_LINE a . append ( ai ) NEW_LINE b . append ( bi ) NEW_LINE DEDENT tm = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE time = a [ 0 ] + tm [ 0 ] NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT dep = max ( b [ i ] , time + ( b [ i ] - a [ i ] + 1 ) // 2 ) NEW_LINE time = dep + a [ i + 1 ] - b [ i ] + tm [ i + 1 ] NEW_LINE DEDENT print ( time ) NEW_LINE DEDENT

for _ in range ( int ( input ( ) ) ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE a = [ ] NEW_LINE b = [ ] NEW_LINE for _ in range ( n ) : NEW_LINE INDENT i , j = map ( int , input ( ) . split ( ) ) NEW_LINE a += [ i ] NEW_LINE b += [ j ] NEW_LINE DEDENT t = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE c = a [ 0 ] + t [ 0 ] NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT c = max ( c + ( b [ i ] - a [ i ] + 1 ) // 2 , b [ i ] ) NEW_LINE c += a [ i + 1 ] - b [ i ] + t [ i + 1 ] NEW_LINE DEDENT print ( c ) NEW_LINE DEDENT

R = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE t , = R ( ) NEW_LINE while t : NEW_LINE INDENT t -= 1 ; NEW_LINE n , = R ( ) ; NEW_LINE a = [ ] ; NEW_LINE b = [ ] ; NEW_LINE s = 0 NEW_LINE for _ in [ 0 ] * n : x , y = R ( ) ; a += x , ; b += y , NEW_LINE for x , y , z , w in zip ( a , b , [ 0 ] + b , R ( ) ) : p = s + x - z + w ; s = p + max ( y - x + 1 >> 1 , y - p ) NEW_LINE print ( p ) NEW_LINE DEDENT


import java . util . Scanner ;   public class MisterB { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   int c = scanner . nextInt ( ) ; int v = scanner . nextInt ( ) ; int v1 = scanner . nextInt ( ) ; int a = scanner . nextInt ( ) ; int l = scanner . nextInt ( ) ;   System . out . println ( solve ( c , v , v1 , a , l ) ) ;   }   public static int solve ( int c , int v , int v1 , int a , int l ) { int counter = 0 ; for ( int i = 0 ; i < c ; i += v ) { if ( i != 0 ) { if ( v + a < v1 ) { v += a ; } else { v = v1 ; } i -= l ; } counter ++ ; } return counter ; } }

import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) {    Scanner scanner = new Scanner ( System . in ) ;   int pages = scanner . nextInt ( ) ; int initialSpeed = scanner . nextInt ( ) ; int maxSpeed = scanner . nextInt ( ) ; int accelerate = scanner . nextInt ( ) ; int late = scanner . nextInt ( ) ;   System . out . println ( solve ( pages , initialSpeed , maxSpeed , accelerate , late ) ) ;   }   public static int solve ( int pages , int initialSpeed , int maxSpeed , int accelerate , int late ) {   int days = 0 ; int pageCounter = 0 ;   while ( pageCounter < pages ) { pageCounter += initialSpeed ; days ++ ;   if ( days > 1 ) pageCounter -= late ;   initialSpeed += accelerate ;   if ( initialSpeed > maxSpeed ) initialSpeed = maxSpeed ; }   return days ; } }

import java . util . Scanner ;   public class JavaApplication168 < T > {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int c = sc . nextInt ( ) ; int v0 = sc . nextInt ( ) ; int v1 = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int xx = v0 ; int pos = v0 ; int t = 1 ; while ( pos < c ) { xx = Math . min ( v1 , xx + a ) ; pos += xx - l ; t ++ ;   } System . out . println ( t ) ;    } }

import java . io . * ; import java . util . * ; public class C421A { static PrintWriter out = new PrintWriter ( ( System . out ) ) ; public static void main ( String args [ ] ) throws IOException { Reader sc = new Reader ( ) ; int c = sc . nextInt ( ) ; int v0 = sc . nextInt ( ) ; int v1 = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int d = 1 ; int t = c ; c -= v0 ; if ( c > 0 ) { c = Math . min ( t , c + l ) ; int s = Math . min ( v0 + d * a , v1 ) ; while ( c > 0 ) { c -= s ; d ++ ; if ( c <= 0 ) { break ; } s = Math . min ( v0 + d * a , v1 ) ; c = Math . min ( t , c + l ) ; } } out . println ( d ) ; out . close ( ) ; }   static class Reader { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ; public String next ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   public String nextLine ( ) { try { return br . readLine ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return null ; }   public boolean hasNext ( ) { String next = null ; try { next = br . readLine ( ) ; } catch ( Exception e ) { } if ( next == null ) { return false ; } st = new StringTokenizer ( next ) ; return true ; } } }

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

def solve ( c , v0 , v1 , a , l ) : count = 0 c -= v0 count += 1 if c <= 0 : return count d = 1 c += l while True : val = d * a + v0 if val > v1 : val = v1 c -= val count += 1 d += 1 if c <= 0 : return count c += l             def main ( ) : arr = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) NEW_LINE

c , v , max , a , l = map ( int , input ( ) . split ( ) )   i = 1 days = 1 page = v   while page < c : if v + i * a <= max : page = page - l + v + i * a else : page = page - l + max days += 1   i += 1   print ( days ) NEW_LINE

c , v0 , v1 , a , l = list ( map ( int , input ( ) . split ( ) ) ) ans = 0 tmp = 0 fa = 0 while True : temp = ( v0 + ( fa * a ) ) if ( temp >= v1 ) : tmp += v1 else : tmp += temp ans += 1 if ( tmp >= c ) : break fa += 1 tmp -= l NEW_LINE

c , v0 , v1 , a , l = map ( int , input ( ) . split ( ) ) ans = 0 now = 0 while now < c : if now > 0 : now -= l now += v0 v0 = min ( v0 + a , v1 ) ans += 1 print ( ans ) NEW_LINE

c , v0 , v1 , a , l = map ( int , input ( ) . split ( ) )   count = 0 days = 0     while ( 1 ) : if ( days == 0 ) : days += 1 count += v0 index = 0 else : count += min ( v0 + ( ( days ) * a ) , v1 ) - l days += 1 if ( count >= c ) : break ;   print ( days ) NEW_LINE


# include < iostream > # include < iomanip > # include < vector > # include < math . h > # include < string > # include < sstream > # include < stdlib . h > # include < algorithm > # include < unordered_map > # include < unordered_set > # include < cstdlib > # include < climits > # include < cstring > # include < cmath > # include < map > # include < set > # include < stack > # include < queue >  # define fi ( x , y ) for ( size_t i ( x ) ; i < y ; i ++ )

import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Comparator ; import java . util . InputMismatchException ; import java . util . Scanner ;   public class MainTest { public static void main ( String [ ] args ) {

valid = ' AHIMOTUVWXY '   s = input ( )   f = Truefor i in s : if i not in valid : f = False break   if s != s [ : : - 1 ] : f = False   print ( " YES " if f else " NO " ) NEW_LINE

nama = input ( ) status = Falsenama = list ( nama ) for i in nama : if i == " A " or i == " I " or i == " M " or i == " H " or i == " O " or i == " V " or i == " U " or i == " W " or i == " X " or i == " Y " or i == " T " : ind = nama . index ( i ) a = ind + 1 if i != nama [ - a ] : status = False break else : status = True else : status = False break   if status : print ( " YES " ) else : print ( " NO " ) NEW_LINE

def tetap_identik ( nama ) : char_list = [ " A " , " H " , " I " , " M " , " O " , " T " , " U " , " V " , " W " , " X " , " Y " ] matched_list = [ characters in char_list for characters in nama ] if all ( matched_list ) : if nama == nama [ : : - 1 ] : return " YES " else : return " NO " else : return " NO "   nama = input ( ) . upper ( ) print ( tetap_identik ( nama ) ) NEW_LINE

s = input ( ) def solve ( string ) : for i in s : if i not in " AHIMOTUVWXY " : return ( " NO " ) if s [ : : - 1 ] == s : return ( " YES " ) else : return ( " NO " ) print ( solve ( s ) ) NEW_LINE

apa = input ( ) ha = [ " A " , " H " , ' I ' , ' M ' , ' O ' , ' T ' , ' U ' , ' V ' , ' W ' , ' X ' , ' Y ' ] for i in apa : if i not in ha : print ( " NO " ) breakelse : if apa == apa [ : : - 1 ] : print ( " YES " ) else : print ( " NO " ) NEW_LINE


import java . util . ArrayList ; import java . util . Scanner ;   public class Box {   public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int t = scan . nextInt ( ) ; k : while ( t -- > 0 ) { int n = scan . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } int [ ] res = new int [ n ] ; int mx = 0 ; int [ ] b = new int [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( mx < a [ i ] ) { res [ i ] = a [ i ] ; ++ b [ a [ i ] ] ; } else if ( mx > a [ i ] ) { System . out . println ( " - 1" ) ; continue k ; } mx = Math . max ( mx , a [ i ] ) ; } ArrayList < Integer > ar = new ArrayList < Integer > ( ) ;   for ( int i = 1 ; i <= n ; i ++ ) { if ( b [ i ] == 0 ) { ar . add ( i ) ; } } int k = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( res [ i ] == 0 ) { res [ i ] = ar . get ( k ) ; ++ k ; } } mx = 0 ; for ( int i = 0 ; i < n ; i ++ ) { mx = Math . max ( mx , res [ i ] ) ; if ( mx != a [ i ] ) { System . out . println ( " - 1" ) ; continue k ; } }   for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( res [ i ] + " ▁ " ) ; } System . out . println ( ) ;   } } }

import java . util . Scanner ; import java . util . TreeSet ; public class Main { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; int t = s . nextInt ( ) ; while ( t -- != 0 ) { int n = s . nextInt ( ) ; TreeSet < Integer > pq = new TreeSet < > ( ) ; int arr [ ] = new int [ n ] ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = s . nextInt ( ) ; if ( arr [ i ] < i + 1 ) { ans = - 1 ; } pq . add ( i + 1 ) ; } if ( ans == - 1 ) { System . out . println ( ans ) ; } else { System . out . print ( arr [ 0 ] + " ▁ " ) ; pq . remove ( arr [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] > arr [ i - 1 ] ) { System . out . print ( arr [ i ] + " ▁ " ) ; pq . remove ( arr [ i ] ) ; } else { System . out . print ( pq . pollFirst ( ) + " ▁ " ) ; } } System . out . println ( ) ; } } } }

n = int ( input ( ) ) for i in range ( n ) : length = int ( input ( ) ) content = [ int ( k ) for k in input ( ) . split ( ) ] anslist = [ 0 ] * length poss = [ 1 ] * length index = 0 fail = 0 for j in range ( length ) : if j == 0 : anslist [ j ] = content [ j ] poss [ content [ j ] - 1 ] = 0 elif j != 0 and content [ j ] > content [ j - 1 ] : anslist [ j ] = content [ j ] poss [ content [ j ] - 1 ] = 0 else : while poss [ index ] == 0 : index += 1 if index == length : break if index < length and index + 1 <= content [ j ] : anslist [ j ] = index + 1 poss [ index ] = 0 else : fail = 1 break NEW_LINE

for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = [ ] cond = 0 d = { } e = { } for i in range ( n ) : if ( d . get ( a [ i ] ) == None ) : d [ a [ i ] ] = 1 else : d [ a [ i ] ] += 1 i = 0 cond1 = 0 k = 1 while ( i < n ) : if ( d [ a [ i ] ] <= a [ i ] ) : b . append ( a [ i ] ) e [ a [ i ] ] = 1 o = d [ a [ i ] ] d [ a [ i ] ] -= 1 while ( d [ a [ i ] ] != 0 ) : if ( e . get ( k ) == None ) : b . append ( k ) e [ k ] = 1 d [ a [ i ] ] -= 1 k += 1 if ( k > a [ i ] ) : cond1 = 1 break i += o if ( cond1 ) : cond = 1 break else : cond = 1 break if ( cond ) : print ( - 1 ) else : print ( * b ) NEW_LINE

ll = lambda : map ( int , input ( ) . split ( ) ) t = lambda : int ( input ( ) ) ss = lambda : input ( ) NEW_LINE

a = int ( input ( ) ) for x in range ( a ) : b = int ( input ( ) ) c = list ( map ( int , input ( ) . split ( ) ) ) j = [ ] t = 1 s = { } ma = 0 g = 0 for y in range ( b ) : if y == 0 : s [ c [ y ] ] = 1 j . append ( c [ y ] ) ma = c [ y ]   else : if c [ y ] > ma : s [ c [ y ] ] = 1 j . append ( c [ y ] ) ma = c [ y ]   else : l = 0 while ( t < ma ) : if s . get ( t ) == None : s [ t ] = 1 j . append ( t ) l = - 1 break else : t += 1   if l != - 1 : g = - 1 break     if g == - 1 : print ( - 1 ) else : print ( * j )           NEW_LINE


import java . util . * ; import java . io . * ; public class Counting_Rhombi {   public static void main ( String [ ] args ) throws java . lang . Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int w = Integer . parseInt ( st . nextToken ( ) ) , h = Integer . parseInt ( st . nextToken ( ) ) ; long c = ( long ) ( Math . floor ( w / 2.0 ) * Math . ceil ( w / 2.0 ) * Math . floor ( h / 2.0 ) * Math . ceil ( h / 2.0 ) ) ; System . out . println ( c ) ; }   }

import java . io . BufferedReader ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . Scanner ; import java . util . StringTokenizer ;   public class counting {   public static void main ( String [ ] args ) {

import java . util . * ; import java . io . * ;   public class Solution { public static PrintWriter w = new PrintWriter ( System . out ) ; public static void main ( String args [ ] ) throws Exception { Reader in = new Reader ( ) ; long w = in . nextLong ( ) ; long h = in . nextLong ( ) ; long ans = 0 ; long a = ( h / 2 ) * ( h - h / 2 ) ; for ( int i = 1 ; i <= w ; i ++ ) ans += ( Math . min ( i , w - i ) * a ) ; System . out . println ( ans ) ;

import java . util . Scanner ; import java . util . Arrays ; public class Ishu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int w , h , x , y ; long ans = 0 , ax , ay ; w = scan . nextInt ( ) ; h = scan . nextInt ( ) ; for ( x = 1 ; x < w ; ++ x ) { ax = ( x - 0 ) <= ( w - x ) ? ( x - 0 ) : ( w - x ) ; for ( y = 1 ; y < h ; ++ y ) { ay = ( y - 0 ) <= ( h - y ) ? ( y - 0 ) : ( h - y ) ; ans += ax * ay ; } } System . out . println ( ans ) ; } }

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

x , y = map ( int , input ( ) . split ( ) ) x = x ** 2 y = y ** 2 ans = ( x // 4 ) * ( y // 4 )   print ( ans ) NEW_LINE

x , y = map ( int , input ( ) . split ( ) ) ; ans = 0 for i in range ( 2 , x + 1 , 2 ) : for j in range ( 2 , y + 1 , 2 ) : ans += ( x - i + 1 ) * ( y - j + 1 ) print ( ans ) NEW_LINE

n , w = map ( int , input ( ) . split ( ) ) ans = 0 for x in range ( 1 , n ) : for y in range ( w - 1 ) : ans += ( ( w - y ) // 2 ) * min ( x , n - x ) print ( ans ) NEW_LINE

a , b = map ( int , input ( ) . split ( ) ) ; s = 0 for i in range ( 2 , a + 1 , 2 ) : for j in range ( 2 , b + 1 , 2 ) : s += ( a - i + 1 ) * ( b - j + 1 ) print ( s ) NEW_LINE


import java . util . * ; import java . lang . * ; public class A1481 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int px = sc . nextInt ( ) ; int py = sc . nextInt ( ) ; String s = sc . next ( ) ; int x = 0 , y = 0 ; char ch = ' ▁ ' , ch2 = ' ▁ ' ; char ch3 = ' ▁ ' ; if ( px > 0 ) ch = ' R ' ; else ch = ' L ' ; if ( py > 0 ) ch2 = ' U ' ; else ch2 = ' D ' ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { ch3 = s . charAt ( i ) ; if ( ch3 == ch ) x += 1 ; if ( ch3 == ch2 ) y += 1 ; } if ( ( Math . abs ( px ) <= x ) && ( Math . abs ( py ) <= y ) ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } }

import java . util . * ; public class SpaceNavigation { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t , x , y , u , d , r , l ; String s = " " ; x = y = u = d = r = l = 0 ; t = sc . nextInt ( ) ; while ( t -- > 0 ) { x = sc . nextInt ( ) ; y = sc . nextInt ( ) ; s = sc . next ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' U ' ) u ++ ; else if ( s . charAt ( i ) == ' D ' ) d -- ; else if ( s . charAt ( i ) == ' R ' ) r ++ ; else l -- ; } if ( ( y >= d && y <= u ) && ( x >= l && x <= r ) ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; l = d = r = u = 0 ; } } }

import java . util . * ; public class CodeForces1481A { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int t = input . nextInt ( ) ; for ( int j = 0 ; j < t ; j ++ ) { int px = input . nextInt ( ) ; int py = input . nextInt ( ) ; String s = input . next ( ) ; char x = ' L ' ; char y = ' D ' ; if ( px > 0 ) { x = ' R ' ; } if ( py > 0 ) { y = ' U ' ; } int count_x = 0 ; int count_y = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == x ) { count_x ++ ; } else if ( s . charAt ( i ) == y ) { count_y ++ ; } } if ( count_x >= Math . abs ( px ) && count_y >= Math . abs ( py ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; public class Practice { public static void main ( String [ ] args ) throws NumberFormatException , IOException { Scanner s = new Scanner ( System . in ) ; int t = s . nextInt ( ) ; while ( ( t -- ) > 0 ) { int n = s . nextInt ( ) ; int m = s . nextInt ( ) ; String str = s . next ( ) ; int u = 0 , d = 0 , l = 0 , r = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == ' U ' ) { u ++ ; } else if ( str . charAt ( i ) == ' D ' ) { d -- ; } else if ( str . charAt ( i ) == ' L ' ) { l -- ; } else { r ++ ; } } if ( n >= l && n <= r && m >= d && m <= u ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } }

import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int tt = sc . nextInt ( ) ; while ( tt -- > 0 ) { int x = sc . nextInt ( ) , y = sc . nextInt ( ) ; char [ ] str = sc . next ( ) . toCharArray ( ) ; int maxx = 0 , maxy = 0 , minx = 0 , miny = 0 ; for ( char c : str ) { if ( c == ' R ' ) maxx ++ ; else if ( c == ' L ' ) minx -- ; else if ( c == ' U ' ) maxy ++ ; else miny -- ; } System . out . println ( maxx >= x && minx <= x && maxy >= y && miny <= y ? " Yes " : " No " ) ; } sc . close ( ) ; } }

I = input NEW_LINE exec ( int ( I ( ) ) * " x , y = map ( int , I ( ) . split ( ) ) ; u , d , r , l = map ( I ( ) . count , ' UDRL ' ) ; print ( ' NYOE ▁ S ' [ - d < = y < = u ▁ and - l < = x < = r : :2 ] ) ; " ) NEW_LINE

I = input NEW_LINE for _ in [ 0 ] * int ( I ( ) ) : x , y = map ( int , I ( ) . split ( ) ) ; f = I ( ) . count ; print ( ' YNEOS ' [ f ( ' UD ' [ y < 0 ] ) < abs ( y ) or f ( ' RL ' [ x < 0 ] ) < abs ( x ) : : 2 ] ) NEW_LINE

I = input NEW_LINE exec ( int ( I ( ) ) * " x , y = map ( int , I ( ) . split ( ) ) ; f = I ( ) . count ; print ( ' YNEOS ' [ y > f ( ' U ' ) or - y > f ( ' D ' ) or ▁ x > f ( ' R ' ) or - x > f ( ' L ' ) : :2 ] ) ; " ) NEW_LINE

I = input NEW_LINE exec ( int ( I ( ) ) * " x , y = map ( int , I ( ) . split ( ) ) ; f = I ( ) . count ; print ( ' YNEOS ' [ f ( ' UD ' [ y < 0 ] ) < abs ( y ) or ▁ f ( ' RL ' [ x < 0 ] ) < abs ( x ) : : 2 ] ) ; " ) NEW_LINE