import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; if ( x < a || a + b < x ) { System . out . println ( " NO " ) ; } else { System . out . println ( " YES " ) ; } } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } private void solveA ( ) { Scanner scanner = null ; int numA = 0 ; int numB = 0 ; int numX = 0 ; try { scanner = new Scanner ( System . in ) ; numA = scanner . nextInt ( ) ; numB = scanner . nextInt ( ) ; numX = scanner . nextInt ( ) ; if ( numX - numA <= numB && numA <= numX ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveB ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( " " ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveC ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( " " ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveD ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( " " ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; ABC094_A solver = new ABC094_A ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ABC094_A { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int x = in . nextInt ( ) ; if ( x < a || a + b < x ) { out . print ( " NO " ) ; } else { out . print ( " YES " ) ; } } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; if ( A <= X && X <= A + B ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }

import static java . lang . System . * ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int a = sc . nextInt ( ) , b = sc . nextInt ( ) , x = sc . nextInt ( ) ; if ( x < a ) out . println ( " NO " ) ; else { out . println ( x - a <= b ? " YES " : " NO " ) ; } } }

a , b , x = map ( int , input ( ) . split ( ) ) NEW_LINE print ( " YES " if a <= x and x <= a + b else " NO " ) NEW_LINE

from collections import Counter NEW_LINE from functools import reduce NEW_LINE import fractions NEW_LINE import math NEW_LINE import statistics NEW_LINE import sys NEW_LINE import time NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE INF = 10 ** 18 NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def MI ( ) : return map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def IS ( ) : return input ( ) NEW_LINE def P ( x ) : return print ( x ) NEW_LINE def C ( x ) : return Counter ( x ) NEW_LINE def GCD_LIST ( numbers ) : NEW_LINE INDENT return reduce ( fractions . gcd , numbers ) NEW_LINE DEDENT def LCM_LIST ( numbers ) : NEW_LINE INDENT return reduce ( LCM , numbers ) NEW_LINE DEDENT def LCM ( m , n ) : NEW_LINE INDENT return ( m * n // fractions . gcd ( m , n ) ) NEW_LINE DEDENT a , b , x = MI ( ) NEW_LINE print ( " YES " ) if a <= x <= a + b else print ( " NO " ) NEW_LINE

a , b , x = map ( int , input ( ) . split ( ) ) NEW_LINE if a > x : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT elif ( a + b ) < x : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT

A , B , X = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if A > X : NEW_LINE INDENT print ( " NO " ) NEW_LINE exit ( ) NEW_LINE DEDENT if A + B < X : NEW_LINE INDENT print ( " NO " ) NEW_LINE exit ( ) NEW_LINE DEDENT print ( " YES " ) NEW_LINE

l = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( ' YES ' if ( l [ 0 ] + l [ 1 ] >= l [ 2 ] ) & ( l [ 0 ] <= l [ 2 ] ) else ' NO ' ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int ans = Math . min ( B , D ) - Math . max ( A , C ) ; System . out . println ( ans >= 0 ? ans : 0 ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int A = in . nextInt ( ) ; int B = in . nextInt ( ) ; int C = in . nextInt ( ) ; int D = in . nextInt ( ) ; int start = A > C ? A : C ; int stop = B < D ? B : D ; out . println ( start < stop ? stop - start : 0 ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }

import java . util . Scanner ; class Main { public static void main ( String arg [ ] ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; sc . close ( ) ; System . out . println ( subAbs ( A , B , C , D ) ) ; } public static int subAbs ( int A , int B , int C , int D ) { int sub = Math . min ( B , D ) - Math . max ( A , C ) ; if ( sub > 0 ) { return sub ; } else { return 0 ; } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) { int a = 0 ; int b = 0 ; int c = 0 ; int d = 0 ; String [ ] tmp = null ; try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { tmp = br . readLine ( ) . split ( " \\ s " ) ; a = Integer . parseInt ( tmp [ 0 ] ) ; b = Integer . parseInt ( tmp [ 1 ] ) ; c = Integer . parseInt ( tmp [ 2 ] ) ; d = Integer . parseInt ( tmp [ 3 ] ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; System . exit ( 1 ) ; } int start = 0 ; int end = 0 ; if ( a < c ) { start = c ; } else { start = a ; } if ( b < d ) { end = b ; } else { end = d ; } int result = end - start ; if ( result < 0 ) { result = 0 ; } System . out . print ( result ) ; } }

import java . util . * ; import static java . lang . Math . abs ; public class Main { public static void main ( String ... args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] x = new int [ ] { sc . nextInt ( ) , sc . nextInt ( ) , sc . nextInt ( ) , sc . nextInt ( ) } ; int [ ] tl = new int [ 101 ] ; for ( int i = 0 ; i < 101 ; i ++ ) { if ( i >= x [ 0 ] && i < x [ 1 ] ) tl [ i ] ++ ; if ( i >= x [ 2 ] && i < x [ 3 ] ) tl [ i ] ++ ; } int ans = 0 ; for ( int i = 0 ; i < 101 ; i ++ ) { if ( tl [ i ] == 2 ) ans ++ ; } System . out . println ( ans ) ; } }

a , b , c , d = map ( int , input ( ) . split ( ) ) NEW_LINE if a < c : NEW_LINE INDENT x = c NEW_LINE DEDENT else : NEW_LINE INDENT x = a NEW_LINE DEDENT if b < d : NEW_LINE INDENT y = b NEW_LINE DEDENT else : NEW_LINE INDENT y = d NEW_LINE DEDENT print ( max ( 0 , y - x ) ) NEW_LINE

A , B , C , D = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE Alice = set ( range ( A , B ) ) NEW_LINE Bob = set ( range ( C , D ) ) NEW_LINE print ( len ( Alice & Bob ) ) NEW_LINE

a , b , c , d = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE time = 0 NEW_LINE for i in range ( 100 ) : NEW_LINE INDENT if i >= a and i < b and i >= c and i < d : NEW_LINE INDENT time += 1 NEW_LINE DEDENT DEDENT print ( time ) NEW_LINE

a , b , c , d = map ( int , input ( ) . split ( ) ) NEW_LINE if b <= c or d <= a : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT elif a <= c : NEW_LINE INDENT if b <= d : NEW_LINE INDENT ans = b - c NEW_LINE DEDENT elif d <= b : NEW_LINE INDENT ans = d - c NEW_LINE DEDENT DEDENT elif c <= a : NEW_LINE INDENT if d <= b : NEW_LINE INDENT ans = d - a NEW_LINE DEDENT elif b <= d : NEW_LINE INDENT ans = b - a NEW_LINE DEDENT DEDENT elif a == c and b == d : NEW_LINE INDENT ans = b - a NEW_LINE DEDENT print ( ans ) NEW_LINE

import sys NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE a , b , c , d = nm ( ) NEW_LINE if b <= c or d <= a : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( min ( b , d ) - max ( a , c ) ) NEW_LINE DEDENT


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int num = sc . nextInt ( ) ; int color [ ] = new int [ num ] ; for ( int i = 0 ; i < num ; i ++ ) { color [ i ] = sc . nextInt ( ) ; } int index [ ] = new int [ 2 * ( int ) Math . pow ( 10 , 5 ) + 10 ] ; int same [ ] = new int [ num ] ; for ( int i = 0 ; i < num ; i ++ ) { same [ i ] = index [ color [ i ] ] - 1 ; index [ color [ i ] ] = i + 1 ; } long dp [ ] = new long [ num ] ; dp [ 0 ] = 1 ; for ( int i = 1 ; i < num ; i ++ ) { if ( color [ i - 1 ] == color [ i ] || same [ i ] < 0 ) { dp [ i ] = dp [ i - 1 ] ; } else { dp [ i ] = mod ( dp [ i - 1 ] + dp [ same [ i ] ] ) ; } } System . out . println ( dp [ num - 1 ] ) ; } static long divisor = ( long ) Math . pow ( 10 , 9 ) + 7 ; public static long mod ( long i ) { return i % divisor + ( ( i % divisor ) < 0 ? divisor : 0 ) ; } }

import java . util . HashMap ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; final int M = 1_000_000_007 ; int N = scanner . nextInt ( ) ; int [ ] c = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) c [ i ] = scanner . nextInt ( ) ; HashMap < Integer , Integer > lastPos = new HashMap < > ( ) ; long [ ] dp = new long [ N + 1 ] ; dp [ 0 ] = 1 ; for ( int i = 1 ; i <= N ; i ++ ) { dp [ i ] = dp [ i - 1 ] ; int color = c [ i - 1 ] ; if ( lastPos . containsKey ( color ) && lastPos . get ( color ) < i - 1 ) { dp [ i ] += dp [ lastPos . get ( color ) ] ; if ( dp [ i ] >= M ) dp [ i ] -= M ; } lastPos . put ( color , i ) ; } System . out . println ( dp [ N ] ) ; } }

import java . util . * ; public class Main { int N ; int [ ] C ; Map < Integer , List < Integer > > indexes ; static final long MOD = 1000000007 ; long result ; long [ ] memo ; long add ( long a , long b ) { return ( a + b ) % MOD ; } Main ( ) { Scanner in = new Scanner ( System . in ) ; N = Integer . parseInt ( in . nextLine ( ) ) ; C = new int [ N ] ; int cMax = - 1 ; for ( int i = 0 ; i < N ; ++ i ) { C [ i ] = Integer . parseInt ( in . nextLine ( ) ) ; cMax = Math . max ( cMax , C [ i ] ) ; } in . close ( ) ; this . memo = new long [ cMax + 1 ] ; Arrays . fill ( this . memo , 0 ) ; this . memo [ C [ 0 ] ] = 1 ; for ( int i = 1 ; i < N ; ++ i ) { if ( C [ i - 1 ] != C [ i ] ) { this . memo [ C [ i ] ] = this . add ( this . memo [ C [ i ] ] , this . memo [ C [ i - 1 ] ] ) ; } } this . result = this . memo [ C [ C . length - 1 ] ] ; } public static void main ( String [ ] args ) { Main ins = new Main ( ) ; System . out . println ( ins . result ) ; } }

import java . util . Arrays ; import java . util . Scanner ; public class Main { private static final long DEV_NUM = 1000000000 + 7 ; private static final int MAX_COLOR_NUM = 2 * 100000 ; int [ ] jumpIndex = null ; long [ ] patterns = null ; int N = 0 ; public void solve ( ) { Scanner in = new Scanner ( System . in ) ; N = in . nextInt ( ) ; int [ ] color = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { color [ i ] = in . nextInt ( ) ; } in . close ( ) ; patterns = new long [ N ] ; Arrays . fill ( patterns , - 1 ) ; jumpIndex = new int [ N ] ; Arrays . fill ( jumpIndex , - 1 ) ; int [ ] beforeIndex = new int [ MAX_COLOR_NUM + 1 ] ; Arrays . fill ( beforeIndex , - 1 ) ; for ( int i = 0 ; i < N ; i ++ ) { int c = color [ i ] ; if ( beforeIndex [ c ] == - 1 ) { beforeIndex [ c ] = i ; } else if ( beforeIndex [ c ] == i - 1 ) { beforeIndex [ c ] = i ; } else { jumpIndex [ beforeIndex [ c ] ] = i ; beforeIndex [ c ] = i ; } } for ( int i = N - 1 ; i >= 0 ; i -- ) { patterns [ i ] = getPatterns ( i ) ; } System . out . println ( patterns [ 0 ] ) ; } private long getPatterns ( int index ) { if ( index >= N - 2 ) { return 1 ; } long unjumpPatterns = patterns [ index + 1 ] ; long jumpPatterns = 0 ; if ( jumpIndex [ index ] != - 1 ) { jumpPatterns = patterns [ jumpIndex [ index ] ] ; } return ( unjumpPatterns + jumpPatterns ) % DEV_NUM ; } public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } }

import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] ways = new int [ 200001 ] ; ArrayList < Integer > stones = new ArrayList < > ( ) ; int current = sc . nextInt ( ) ; stones . add ( current ) ; for ( int i = 1 ; i < n ; i ++ ) { current = sc . nextInt ( ) ; if ( current != stones . get ( stones . size ( ) - 1 ) ) { stones . add ( current ) ; } } int [ ] count = new int [ stones . size ( ) ] ; count [ 0 ] = 1 ; ways [ stones . get ( 0 ) ] = 1 ; for ( int i = 1 ; i < stones . size ( ) ; i ++ ) { count [ i ] = ( count [ i - 1 ] + ways [ stones . get ( i ) ] ) % 1_000_000_007 ; ways [ stones . get ( i ) ] = count [ i ] ; } System . out . println ( count [ stones . size ( ) - 1 ] ) ; } }

MOD = 10 ** 9 + 7 NEW_LINE N = int ( input ( ) ) NEW_LINE C = [ int ( input ( ) ) for i in range ( N ) ] NEW_LINE dp = [ 0 for i in range ( N ) ] NEW_LINE dp [ 0 ] = 1 NEW_LINE color = { } NEW_LINE for c in C : NEW_LINE INDENT color [ c ] = 0 NEW_LINE DEDENT color [ C [ 0 ] ] = 1 NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT dp [ i ] = dp [ i - 1 ] NEW_LINE if C [ i - 1 ] != C [ i ] : NEW_LINE INDENT dp [ i ] = ( dp [ i ] + color [ C [ i ] ] ) % MOD NEW_LINE DEDENT color [ C [ i ] ] = dp [ i ] NEW_LINE DEDENT print ( dp [ - 1 ] ) NEW_LINE

N = int ( input ( ) ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE memo = { } NEW_LINE prev_num = 1 NEW_LINE prev = None NEW_LINE for _ in range ( N ) : NEW_LINE INDENT c = int ( input ( ) ) NEW_LINE if c == prev : NEW_LINE INDENT continue NEW_LINE DEDENT tmp = prev_num NEW_LINE if c in memo : NEW_LINE INDENT tmp += memo [ c ] NEW_LINE DEDENT tmp %= MOD NEW_LINE memo [ c ] = tmp NEW_LINE prev_num = tmp NEW_LINE prev = c NEW_LINE DEDENT print ( prev_num ) NEW_LINE

n = int ( input ( ) ) NEW_LINE c = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT c . append ( int ( input ( ) ) ) NEW_LINE DEDENT dp = 1 NEW_LINE prev = [ 0 ] * ( max ( c ) + 1 ) NEW_LINE x = 0 NEW_LINE for i in c : NEW_LINE INDENT if x != i : NEW_LINE INDENT dp += prev [ i ] NEW_LINE prev [ i ] = dp NEW_LINE DEDENT x = i NEW_LINE DEDENT print ( dp % ( 10 ** 9 + 7 ) ) NEW_LINE

import sys NEW_LINE MOD = 1000000007 NEW_LINE MAX_N = 200000 NEW_LINE def solve ( N , C ) : NEW_LINE INDENT last = [ - 1 ] * MAX_N NEW_LINE pairs = [ ] NEW_LINE for i , c in enumerate ( C ) : NEW_LINE INDENT try : NEW_LINE INDENT prev = last [ c - 1 ] NEW_LINE DEDENT except : NEW_LINE INDENT if c >= N : NEW_LINE INDENT return NEW_LINE DEDENT else : NEW_LINE INDENT raise Exception ( ) NEW_LINE DEDENT DEDENT if prev >= 0 and prev < i - 1 : NEW_LINE INDENT pairs . append ( ( prev , i ) ) NEW_LINE DEDENT last [ c - 1 ] = i NEW_LINE DEDENT pairs . sort ( ) NEW_LINE count = [ 0 ] * N NEW_LINE count [ 0 ] = 1 NEW_LINE idx = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if i > 0 : NEW_LINE INDENT count [ i ] += count [ i - 1 ] NEW_LINE count [ i ] %= MOD NEW_LINE DEDENT while idx < len ( pairs ) and pairs [ idx ] [ 0 ] == i : NEW_LINE INDENT count [ pairs [ idx ] [ 1 ] ] += count [ i ] NEW_LINE count [ pairs [ idx ] [ 1 ] ] %= MOD NEW_LINE idx += 1 NEW_LINE DEDENT DEDENT print ( count [ N - 1 ] ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE N = int ( next ( tokens ) ) NEW_LINE C = [ int ( next ( tokens ) ) for _ in range ( N ) ] NEW_LINE solve ( N , C ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

import sys NEW_LINE readline = sys . stdin . readline NEW_LINE N = int ( readline ( ) ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE last = [ - 1 ] * ( 3 * 10 ** 5 ) NEW_LINE dp = [ 0 ] * ( N + 1 ) NEW_LINE dp [ 0 ] = 1 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT c = int ( readline ( ) ) NEW_LINE if last [ c ] != - 1 and last [ c ] + 1 < i : NEW_LINE INDENT dp [ i ] = ( dp [ last [ c ] ] + dp [ i - 1 ] ) % MOD NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i ] = dp [ i - 1 ] NEW_LINE DEDENT last [ c ] = i NEW_LINE DEDENT print ( dp [ N ] ) NEW_LINE


import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; long k = sc . nextLong ( ) ; long [ ] values = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { values [ i ] = sc . nextLong ( ) ; if ( values [ i ] == 0 ) { System . out . println ( n ) ; return ; } } int l = 0 , r = 0 , res = 0 ; long prod = 1 ; while ( l < n ) { while ( r < n && prod * values [ r ] <= k ) prod *= values [ r ++ ] ; res = Math . max ( res , r - l ) ; if ( l == r ) prod *= values [ r ++ ] ; prod /= values [ l ++ ] ; } System . out . println ( res ) ; } }

import java . util . * ; import java . awt . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; long k = sc . nextLong ( ) ; long [ ] s = new long [ n ] ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { s [ i ] = sc . nextLong ( ) ; if ( s [ i ] == 0 ) { out . println ( n ) ; exit ( 0 ) ; } else if ( s [ i ] <= k ) { ans = 1 ; } } int r = 0 ; long temp = 1 ; for ( int l = 0 ; l < n ; l ++ ) { while ( r < n && temp * s [ r ] <= k ) { temp *= s [ r ] ; ans = max ( ans , r ++ - l + 1 ) ; } if ( r == l ) r ++ ; else temp /= s [ l ] ; } out . println ( ans ) ; } }

import java . math . BigInteger ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long K = sc . nextLong ( ) ; long [ ] map = new long [ N ] ; long min = Integer . MAX_VALUE ; for ( int i = 0 ; i < N ; i ++ ) { map [ i ] = sc . nextLong ( ) ; if ( map [ i ] == 0 ) { System . out . println ( N ) ; return ; } min = Math . min ( min , map [ i ] ) ; } if ( min > K ) { System . out . println ( 0 ) ; return ; } int ans = 1 ; BigInteger now = BigInteger . valueOf ( map [ 0 ] ) ; int start = 0 ; int end = 0 ; while ( start < map . length ) { while ( true ) { if ( end < map . length - 1 && now . multiply ( BigInteger . valueOf ( map [ end + 1 ] ) ) . compareTo ( BigInteger . valueOf ( K ) ) < 1 ) { end ++ ; now = now . multiply ( BigInteger . valueOf ( map [ end ] ) ) ; ans = Math . max ( ans , end - start + 1 ) ; } else { break ; } } if ( end < map . length - 1 && end == start ) { end ++ ; now = now . multiply ( BigInteger . valueOf ( map [ end ] ) ) ; } now = now . divide ( BigInteger . valueOf ( map [ start ] ) ) ; start ++ ; } System . out . println ( ans ) ; } }

public class Main { public static void main ( String [ ] $ ) { java . util . Scanner c = new java . util . Scanner ( System . in ) ; int n = c . nextInt ( ) , k = c . nextInt ( ) , r = 0 , i = 0 , l = 0 ; long s [ ] = new long [ n ] , a = 0 , t = 1 ; while ( i < n ) if ( ( s [ i ++ ] = c . nextInt ( ) ) == 0 ) { System . out . println ( n ) ; return ; } for ( ; l < n ; l ++ ) { while ( r < n && t * s [ r ] <= k ) { t *= s [ r ] ; a = Math . max ( a , r ++ - l + 1 ) ; } if ( r == l ) r ++ ; else t /= s [ l ] ; } System . out . println ( a ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] nk = sc . nextLine ( ) . split ( " ▁ " ) ; int n = Integer . parseInt ( nk [ 0 ] ) ; int k = Integer . parseInt ( nk [ 1 ] ) ; int [ ] s = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { s [ i ] = Integer . parseInt ( sc . nextLine ( ) ) ; if ( s [ i ] == 0 ) { System . out . println ( n ) ; return ; } } int right = 0 ; long product = 1 ; int answer = 0 ; for ( int left = 0 ; left < n ; left ++ ) { while ( right < n && product * s [ right ] <= k ) { product *= s [ right ] ; right ++ ; } if ( right - left > answer ) { answer = right - left ; } if ( left == right ) { right ++ ; } else { product /= s [ left ] ; } } System . out . println ( answer ) ; } }

N , K = map ( int , input ( ) . split ( ) ) NEW_LINE s_list = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE left = 0 NEW_LINE right = 0 NEW_LINE sum_num = 1 NEW_LINE ans = 0 NEW_LINE if 0 in s_list : NEW_LINE INDENT ans = N NEW_LINE DEDENT else : NEW_LINE INDENT while left < N : NEW_LINE INDENT while right < N and sum_num * s_list [ right ] <= K : NEW_LINE INDENT sum_num *= s_list [ right ] NEW_LINE right += 1 NEW_LINE DEDENT ans = max ( ans , right - left ) NEW_LINE if left == right : NEW_LINE INDENT right += 1 NEW_LINE DEDENT else : NEW_LINE INDENT sum_num //= s_list [ left ] NEW_LINE DEDENT left += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE

def main ( ) : NEW_LINE INDENT result = sub ( ) NEW_LINE print ( result ) NEW_LINE DEDENT def sub ( ) : NEW_LINE INDENT n , k = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE ss = [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE result = 0 NEW_LINE right = 0 NEW_LINE for s in ss : NEW_LINE INDENT if s == 0 : NEW_LINE INDENT return n NEW_LINE DEDENT DEDENT acc = 1 NEW_LINE for left in range ( n ) : NEW_LINE INDENT while ( right < n ) : NEW_LINE INDENT tmp = acc * ss [ right ] NEW_LINE if tmp <= k : NEW_LINE INDENT acc = tmp NEW_LINE right = right + 1 NEW_LINE length = right - left NEW_LINE result = max ( length , result ) NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if left == right : NEW_LINE INDENT right = right + 1 NEW_LINE continue NEW_LINE DEDENT acc = acc / ss [ left ] NEW_LINE if acc <= k : NEW_LINE INDENT length = right - left NEW_LINE result = max ( length , result ) NEW_LINE DEDENT else : NEW_LINE INDENT continue NEW_LINE DEDENT DEDENT return result NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

def sequence ( N : int , K : int , S : list ) -> int : NEW_LINE INDENT S += [ K + 1 ] NEW_LINE if 0 in S : NEW_LINE INDENT return N NEW_LINE DEDENT maxlen = 0 NEW_LINE l , r = 0 , 0 NEW_LINE t = 1 NEW_LINE while r < N : NEW_LINE INDENT while t * S [ r ] <= K : NEW_LINE INDENT t *= S [ r ] NEW_LINE r += 1 NEW_LINE DEDENT maxlen = max ( maxlen , r - l ) NEW_LINE if l < r : NEW_LINE INDENT t //= S [ l ] NEW_LINE l += 1 NEW_LINE DEDENT else : NEW_LINE INDENT l , r = l + 1 , r + 1 NEW_LINE DEDENT DEDENT return maxlen NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = 0 NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE S = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE ans = sequence ( N , K , S ) NEW_LINE print ( ans ) NEW_LINE DEDENT

import sys NEW_LINE n , k = map ( int , input ( ) . split ( ) ) NEW_LINE line = [ int ( i ) for i in sys . stdin ] NEW_LINE flag = False NEW_LINE stack = 1 NEW_LINE start = 0 NEW_LINE ans = 0 NEW_LINE answer = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if line [ i ] == 0 : NEW_LINE INDENT print ( n ) NEW_LINE exit ( ) NEW_LINE DEDENT if stack * line [ i ] <= k : NEW_LINE INDENT stack *= line [ i ] NEW_LINE ans += 1 NEW_LINE DEDENT else : NEW_LINE INDENT answer = max ( answer , ans ) NEW_LINE stack *= line [ i ] NEW_LINE ans += 1 NEW_LINE while stack > k and start <= i : NEW_LINE INDENT stack //= line [ start ] NEW_LINE start += 1 NEW_LINE ans -= 1 NEW_LINE DEDENT DEDENT DEDENT answer = max ( ans , answer ) NEW_LINE print ( answer ) NEW_LINE

import sys NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE s = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT s . append ( int ( input ( ) ) ) NEW_LINE DEDENT if 0 in s : NEW_LINE INDENT print ( len ( s ) ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT elif K == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT left = - 1 NEW_LINE right = 0 NEW_LINE mul = s [ 0 ] NEW_LINE ans = 0 NEW_LINE while right < len ( s ) : NEW_LINE INDENT if left == right : NEW_LINE INDENT right += 1 NEW_LINE if right == len ( s ) : NEW_LINE INDENT break NEW_LINE DEDENT else : NEW_LINE INDENT mul = s [ right ] NEW_LINE DEDENT DEDENT if mul <= K : NEW_LINE INDENT ans = max ( ans , right - left ) NEW_LINE right += 1 NEW_LINE if right <= len ( s ) - 1 : NEW_LINE INDENT mul = mul * s [ right ] NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT elif mul > K : NEW_LINE INDENT left += 1 NEW_LINE if left == right : NEW_LINE INDENT mul = 0 NEW_LINE DEDENT else : NEW_LINE INDENT mul = mul // s [ left ] NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE


public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { int x1 = scanner . nextInt ( ) ; int y1 = scanner . nextInt ( ) ; int x2 = scanner . nextInt ( ) ; int y2 = scanner . nextInt ( ) ; System . out . printf ( " % s ▁ % s ▁ % s ▁ % s " , x2 - y2 + y1 , y2 + x2 - x1 , x1 - y2 + y1 , y1 + x2 - x1 ) ; } }

import java . awt . Point ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] x1y1x2y2 = br . readLine ( ) . split ( " ▁ " ) ; int x1 = Integer . parseInt ( x1y1x2y2 [ 0 ] ) ; int y1 = Integer . parseInt ( x1y1x2y2 [ 1 ] ) ; int x2 = Integer . parseInt ( x1y1x2y2 [ 2 ] ) ; int y2 = Integer . parseInt ( x1y1x2y2 [ 3 ] ) ; Point p1 = new Point ( x1 , y1 ) ; Point p2 = new Point ( x2 , y2 ) ; Square ruinedSquare = new Square ( p1 , p2 ) ; Square recoveredSquare = ruinedSquare . recover ( ) ; System . out . println ( recoveredSquare ) ; } } class Square { private Point p1 , p2 , p3 , p4 ; public Square ( Point p1 , Point p2 ) { this . p1 = p1 ; this . p2 = p2 ; } public Square ( ) { } public Square ( Point p1 , Point p2 , Point p3 , Point p4 ) { this . p1 = p1 ; this . p2 = p2 ; this . p3 = p3 ; this . p4 = p4 ; } private Point nextPointOf ( Point a , Point b ) { int x = b . x - a . x ; int y = b . y - a . y ; return new Point ( b . x - y , b . y + x ) ; } public Square recover ( ) { this . p3 = this . nextPointOf ( this . p1 , this . p2 ) ; this . p4 = this . nextPointOf ( this . p2 , this . p3 ) ; Square recoveredSquare = new Square ( this . p1 , this . p2 , this . p3 , this . p4 ) ; return recoveredSquare ; } @ Override public String toString ( ) { String s = String . format ( " % d ▁ % d ▁ % d ▁ % d \n " , this . p3 . x , this . p3 . y , this . p4 . x , this . p4 . y ) ; return s ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveB ( ) ; } private void solveA ( ) { Scanner scanner = null ; int numK = 0 ; int eqaC = 0 ; int oddC = 0 ; try { scanner = new Scanner ( System . in ) ; numK = scanner . nextInt ( ) ; for ( int i = 1 ; i <= numK ; i ++ ) { if ( i % 2 == 0 ) { eqaC ++ ; } else { oddC ++ ; } } System . out . println ( eqaC * oddC ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveB ( ) { Scanner scanner = null ; int x1 = 0 ; int y1 = 0 ; int x2 = 0 ; int y2 = 0 ; try { scanner = new Scanner ( System . in ) ; x1 = scanner . nextInt ( ) ; y1 = scanner . nextInt ( ) ; x2 = scanner . nextInt ( ) ; y2 = scanner . nextInt ( ) ; int x3 = x2 - ( y2 - y1 ) ; int y3 = y2 + ( x2 - x1 ) ; int x4 = x3 - ( y3 - y2 ) ; int y4 = y3 + ( x3 - x2 ) ; System . out . println ( x3 + " ▁ " + y3 + " ▁ " + x4 + " ▁ " + y4 ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveC ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( " " ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveD ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( " " ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } }

import java . util . * ; import java . lang . Math ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x1 = sc . nextInt ( ) ; int y1 = sc . nextInt ( ) ; int x2 = sc . nextInt ( ) ; int y2 = sc . nextInt ( ) ; double x3 = x2 + ( ( x1 - x2 ) * Math . cos ( - Math . PI / 2 ) - ( y1 - y2 ) * Math . sin ( - Math . PI / 2 ) ) ; double y3 = y2 + ( ( x1 - x2 ) * Math . sin ( - Math . PI / 2 ) + ( y1 - y2 ) * Math . cos ( - Math . PI / 2 ) ) ; double x4 = x1 + ( ( x2 - x1 ) * Math . cos ( Math . PI / 2 ) - ( y2 - y1 ) * Math . sin ( Math . PI / 2 ) ) ; double y4 = y1 + ( ( x2 - x1 ) * Math . sin ( Math . PI / 2 ) + ( y2 - y1 ) * Math . cos ( Math . PI / 2 ) ) ; System . out . println ( ( int ) Math . rint ( x3 ) + " ▁ " + ( int ) Math . rint ( y3 ) + " ▁ " + ( int ) Math . rint ( x4 ) + " ▁ " + ( int ) Math . rint ( y4 ) ) ; sc . close ( ) ; } }

import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { try { Scanner sc = new Scanner ( System . in ) ; int x1 , y1 , x2 , y2 ; x1 = Integer . parseInt ( sc . next ( ) ) ; y1 = Integer . parseInt ( sc . next ( ) ) ; x2 = Integer . parseInt ( sc . next ( ) ) ; y2 = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( ( x2 + y1 - y2 ) + " ▁ " + ( y2 - x1 + x2 ) + " ▁ " + ( x1 + y1 - y2 ) + " ▁ " + ( y1 - x1 + x2 ) ) ; } catch ( Exception e ) { System . out . println ( " out " ) ; } } }

x_1 , y_1 , x_2 , y_2 = map ( int , input ( ) . split ( ) ) NEW_LINE x_3 = x_2 - y_2 + y_1 NEW_LINE y_3 = y_2 + x_2 - x_1 NEW_LINE x_4 = x_3 - x_2 + x_1 NEW_LINE y_4 = y_3 - y_2 + y_1 NEW_LINE print ( x_3 , y_3 , x_4 , y_4 ) NEW_LINE

def main ( ) : NEW_LINE INDENT x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( ) ) NEW_LINE dx = x2 - x1 NEW_LINE dy = y2 - y1 NEW_LINE x3 = x2 - dy NEW_LINE y3 = y2 + dx NEW_LINE x4 = x3 - dx NEW_LINE y4 = y3 - dy NEW_LINE ans = str ( x3 ) + " ▁ " + str ( y3 ) + " ▁ " + str ( x4 ) + " ▁ " + str ( y4 ) NEW_LINE print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( ) ) NEW_LINE vector = ( x2 - x1 , y2 - y1 ) NEW_LINE x3 , y3 = x2 - vector [ 1 ] , y2 - ( - vector [ 0 ] ) NEW_LINE x4 , y4 = x3 - vector [ 0 ] , y3 - vector [ 1 ] NEW_LINE print ( " ▁ " . join ( map ( str , [ x3 , y3 , x4 , y4 ] ) ) ) NEW_LINE

import heapq NEW_LINE def solve ( ) : NEW_LINE INDENT x1 , y1 , x2 , y2 = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE x = x2 - x1 NEW_LINE y = y2 - y1 NEW_LINE print ( x2 - y , y2 + x , x1 - y , y1 + x ) NEW_LINE DEDENT solve ( ) NEW_LINE


import java . util . HashMap ; import java . util . Scanner ; import java . util . TreeSet ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; HashMap < Integer , TreeSet < Integer > > map = new HashMap < > ( ) ; for ( int i = 1 ; i <= h ; i ++ ) { map . put ( i , new TreeSet < > ( ) ) ; } for ( int i = 0 ; i < n ; i ++ ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; map . get ( x ) . add ( y ) ; } int yMax = 1 ; for ( int i = 2 ; i <= h ; i ++ ) { if ( map . get ( i ) . isEmpty ( ) ) { yMax ++ ; } else if ( map . get ( i ) . first ( ) <= yMax ) { System . out . println ( i - 1 ) ; return ; } else if ( map . get ( i ) . first ( ) > yMax + 1 ) { yMax ++ ; } } System . out . println ( h ) ; } }

import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int H = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; LinkedList < Integer > [ ] block = new LinkedList [ W ] ; for ( int w = 0 ; w < W ; w ++ ) { block [ w ] = new LinkedList < > ( ) ; block [ w ] . add ( H ) ; } for ( int n = 0 ; n < N ; n ++ ) { int x = sc . nextInt ( ) - 1 ; int y = sc . nextInt ( ) - 1 ; block [ y ] . add ( x ) ; } for ( int w = 0 ; w < W ; w ++ ) Collections . sort ( block [ w ] ) ; int ans = 1000000 ; int curX = 0 ; for ( int w = 0 ; w < W ; w ++ ) { curX ++ ; while ( block [ w ] . peek ( ) < curX ) block [ w ] . poll ( ) ; ans = Math . min ( ans , block [ w ] . peek ( ) ) ; while ( w < W - 1 && block [ w + 1 ] . contains ( curX ) ) curX ++ ; if ( curX >= block [ w ] . peek ( ) ) break ; } System . out . println ( ans ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .

import java . util . * ; public class Main { static int H = 200000 + 11 ; static int W = 200000 + 11 ; static List < TreeSet < Integer > > heights = new ArrayList < > ( H ) ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; for ( int i = 0 ; i < w ; i ++ ) { if ( i >= heights . size ( ) ) { heights . add ( new TreeSet < Integer > ( ) ) ; } else { heights . get ( i ) . clear ( ) ; } heights . get ( i ) . add ( h ) ; } for ( int i = 0 ; i < n ; i ++ ) { int h_i = sc . nextInt ( ) ; int w_i = sc . nextInt ( ) ; h_i -= 1 ; w_i -= 1 ; heights . get ( w_i ) . add ( h_i ) ; } int current_h = 0 , current_w = 0 ; int ans = h ; while ( current_h < h && current_w < w ) { int hh = heights . get ( current_w ) . higher ( current_h ) ; ans = Math . min ( ans , hh ) ; current_h += 1 ; if ( heights . get ( current_w ) . contains ( current_h ) ) { break ; } if ( current_w + 1 >= w ) { break ; } if ( ! heights . get ( current_w + 1 ) . contains ( current_h ) ) { current_w += 1 ; } } System . out . println ( ans ) ; } }

import sys NEW_LINE def solve ( obstacles ) : NEW_LINE INDENT offset = 0 NEW_LINE obstacles . sort ( ) NEW_LINE for x , y in obstacles : NEW_LINE INDENT if x > y + offset : NEW_LINE INDENT return x - 1 NEW_LINE DEDENT if x == y + offset : NEW_LINE INDENT offset += 1 NEW_LINE DEDENT DEDENT return h NEW_LINE DEDENT h , w , n = map ( int , input ( ) . split ( ) ) NEW_LINE obstacles = [ tuple ( map ( int , line . split ( ) ) ) for line in sys . stdin . readlines ( ) ] NEW_LINE print ( solve ( obstacles ) ) NEW_LINE

from collections import defaultdict NEW_LINE import sys NEW_LINE def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE H , W , N = inpl ( ) NEW_LINE if not N : NEW_LINE INDENT print ( H ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT A = [ ] NEW_LINE B = defaultdict ( lambda : [ ] ) NEW_LINE C = defaultdict ( lambda : H + 1 ) NEW_LINE for _ in range ( N ) : NEW_LINE INDENT x , y = inpl ( ) NEW_LINE A . append ( ( x , y ) ) NEW_LINE B [ y ] . append ( x ) NEW_LINE DEDENT T = [ 0 ] * ( W + 1 ) NEW_LINE T [ 1 ] = 2 NEW_LINE for i in range ( 1 , W ) : NEW_LINE INDENT if not B [ i + 1 ] : NEW_LINE INDENT T [ i + 1 ] = T [ i ] + 1 NEW_LINE continue NEW_LINE DEDENT ctr = T [ i ] NEW_LINE while True : NEW_LINE INDENT if ctr in B [ i + 1 ] : NEW_LINE INDENT ctr += 1 NEW_LINE continue NEW_LINE DEDENT break NEW_LINE DEDENT T [ i + 1 ] = min ( ctr + 1 , H + 1 ) NEW_LINE DEDENT for x , y in A : NEW_LINE INDENT if x >= T [ y ] : NEW_LINE INDENT C [ y ] = min ( C [ y ] , x ) NEW_LINE DEDENT DEDENT print ( min ( [ i - 1 for i in C . values ( ) ] + [ H ] ) ) NEW_LINE

import math , string , itertools , fractions , heapq , collections , re , array , bisect , sys , random , time , copy , functools NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE inf = 10 ** 20 NEW_LINE eps = 1.0 / 10 ** 10 NEW_LINE mod = 10 ** 9 + 7 NEW_LINE dd = [ ( - 1 , 0 ) , ( 0 , 1 ) , ( 1 , 0 ) , ( 0 , - 1 ) ] NEW_LINE ddn = [ ( - 1 , 0 ) , ( - 1 , 1 ) , ( 0 , 1 ) , ( 1 , 1 ) , ( 1 , 0 ) , ( 1 , - 1 ) , ( 0 , - 1 ) , ( - 1 , - 1 ) ] NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def I ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def F ( ) : return float ( sys . stdin . readline ( ) ) NEW_LINE def S ( ) : return input ( ) NEW_LINE def pf ( s ) : return print ( s , flush = True ) NEW_LINE def main ( ) : NEW_LINE INDENT h , w , n = LI ( ) NEW_LINE xy = sorted ( [ LI ( ) for _ in range ( n ) ] ) NEW_LINE mx = h + 1 NEW_LINE p = 0 NEW_LINE for x , y in xy : NEW_LINE INDENT if x - p == y : NEW_LINE INDENT p += 1 NEW_LINE continue NEW_LINE DEDENT if x - p <= y : NEW_LINE INDENT continue NEW_LINE DEDENT mx = x NEW_LINE break NEW_LINE DEDENT return mx - 1 NEW_LINE DEDENT print ( main ( ) ) NEW_LINE

isdbg = False NEW_LINE def dprint ( * value , sep = ' ▁ ' , end = ' \n ' ) : NEW_LINE INDENT if isdbg : NEW_LINE INDENT print ( * value , sep = sep , end = end ) NEW_LINE DEDENT DEDENT H , W , N = map ( int , input ( ) . split ( ) ) NEW_LINE if isdbg : NEW_LINE INDENT XY = [ [ 0 for i in range ( W ) ] for i in range ( H ) ] NEW_LINE DEDENT BL = { } NEW_LINE for i in range ( N ) : NEW_LINE INDENT x1 , y1 = map ( int , input ( ) . split ( ) ) NEW_LINE if isdbg : NEW_LINE INDENT XY [ x1 - 1 ] [ y1 - 1 ] = 1 NEW_LINE DEDENT if x1 - 1 in BL : NEW_LINE INDENT BL [ x1 - 1 ] . append ( y1 - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT BL [ x1 - 1 ] = [ y1 - 1 ] NEW_LINE DEDENT DEDENT TL = sorted ( BL . items ( ) , key = lambda x : x [ 0 ] ) NEW_LINE if isdbg : NEW_LINE INDENT for i in range ( W ) : NEW_LINE INDENT for j in range ( H ) : NEW_LINE INDENT dprint ( XY [ i ] [ j ] , end = ' ' ) NEW_LINE DEDENT dprint ( ) NEW_LINE DEDENT DEDENT maxr = 1 NEW_LINE for i in range ( H - 1 ) : NEW_LINE INDENT if i + 1 in BL : NEW_LINE INDENT l = BL [ i + 1 ] NEW_LINE l . sort ( ) NEW_LINE for ll in l : NEW_LINE INDENT if maxr > ll : NEW_LINE INDENT print ( i + 1 ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT elif maxr == ll : NEW_LINE INDENT maxr -= 1 NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT maxr += 1 NEW_LINE DEDENT print ( H ) NEW_LINE

x , y , num = map ( int , input ( ) . split ( ) ) NEW_LINE gaiz = [ x ] * x NEW_LINE kaisu = x NEW_LINE for _ in range ( num ) : NEW_LINE INDENT xg , yg = map ( int , input ( ) . split ( ) ) NEW_LINE if xg >= yg : NEW_LINE INDENT sa = xg - yg NEW_LINE if yg < gaiz [ sa ] : NEW_LINE INDENT gaiz [ sa ] = ( yg ) NEW_LINE DEDENT DEDENT DEDENT if len ( gaiz ) == 0 : NEW_LINE INDENT print ( kaisu ) NEW_LINE DEDENT else : NEW_LINE INDENT for num , ( maegai , gai ) in enumerate ( zip ( gaiz [ : - 1 ] , gaiz [ 1 : ] ) ) : NEW_LINE INDENT if maegai > gai and num + gai < kaisu : NEW_LINE INDENT kaisu = num + gai NEW_LINE DEDENT DEDENT print ( kaisu ) NEW_LINE DEDENT


import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; if ( A <= C && C <= B ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } }

import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { PrintWriter out = new PrintWriter ( System . out ) ; InputStreamScanner in = new InputStreamScanner ( System . in ) ; new Main ( ) . solve ( in , out ) ; out . flush ( ) ; } private void solve ( InputStreamScanner in , PrintWriter out ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; out . println ( c >= a && c <= b ? " Yes " : " No " ) ; } static class InputStreamScanner { private InputStream in ; private byte [ ] buf = new byte [ 1024 ] ; private int len = 0 ; private int off = 0 ; InputStreamScanner ( InputStream in ) { this . in = in ; } String next ( ) { StringBuilder sb = new StringBuilder ( ) ; for ( int b = skip ( ) ; ! isSpace ( b ) ; ) { sb . appendCodePoint ( b ) ; b = read ( ) ; } return sb . toString ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } char nextChar ( ) { return ( char ) skip ( ) ; } int skip ( ) { for ( int b ; ( b = read ( ) ) != - 1 ; ) { if ( ! isSpace ( b ) ) { return b ; } } return - 1 ; } private boolean isSpace ( int c ) { return c < 33 || c > 126 ; } private int read ( ) { if ( len == - 1 ) { throw new InputMismatchException ( " End ▁ of ▁ Input " ) ; } if ( off >= len ) { off = 0 ; try { len = in . read ( buf ) ; } catch ( IOException e ) { throw new InputMismatchException ( e . getMessage ( ) ) ; } if ( len <= 0 ) { return - 1 ; } } return buf [ off ++ ] ; } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int A = in . nextInt ( ) ; int B = in . nextInt ( ) ; int C = in . nextInt ( ) ; if ( A <= C && C <= B ) { out . println ( " Yes " ) ; } else { out . println ( " No " ) ; } } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; if ( C >= A && C <= B ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } }

import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int N = Integer . parseInt ( sc . next ( ) ) ; int M = Integer . parseInt ( sc . next ( ) ) ; int O = Integer . parseInt ( sc . next ( ) ) ; if ( O >= N && O <= M ) { out . println ( " Yes " ) ; } else { out . println ( " No " ) ; } out . flush ( ) ; } }

A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE print ( ' Yes ' if A <= C <= B else ' No ' ) NEW_LINE

import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if A [ 0 ] <= A [ 2 ] <= A [ 1 ] : NEW_LINE INDENT return ' Yes ' NEW_LINE DEDENT else : NEW_LINE INDENT return ' No ' NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT

from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT a , b , c = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE if c >= a and c <= b : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE print ( " Yes " if c >= a and c <= b else " No " ) NEW_LINE

a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE if a <= c <= b : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT


import java . util . * ; public class Main { static Scanner sc ; static int A , B , N ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; A = sc . nextInt ( ) ; B = sc . nextInt ( ) ; N = A + B ; if ( B >= A ) { System . out . println ( " Impossible " ) ; } else { int honest = getHonest ( ) ; char [ ] ans = new char [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { ans [ i ] = ask ( honest , i ) ? '1' : '0' ; } System . out . println ( " ! ▁ " + String . valueOf ( ans ) ) ; } sc . close ( ) ; } static int getHonest ( ) { int need = B + 1 ; LinkedList < Integer > list = new LinkedList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( list . isEmpty ( ) ) { list . push ( i ) ; } else { if ( ask ( list . peek ( ) , i ) ) { list . push ( i ) ; } else { list . pop ( ) ; need -- ; } } if ( list . size ( ) >= need ) return list . pop ( ) ; } return - 1 ; } static boolean ask ( int a , int b ) { System . out . println ( " ? ▁ " + a + " ▁ " + b ) ; return sc . next ( ) . equals ( " Y " ) ; } }

import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Scanner ; public class Main { static Scanner in ; static PrintWriter out ; static String INPUT = " " ; static boolean get ( int a , int b ) { out . println ( " ? ▁ " + a + " ▁ " + b ) ; out . flush ( ) ; return in . next ( ) . charAt ( 0 ) == ' Y ' ; } static void solve ( ) { int A = ni ( ) , B = ni ( ) ; if ( A <= B ) { out . println ( " Impossible " ) ; return ; } int n = A + B ; int [ ] stack = new int [ n ] ; int sp = 0 ; for ( int i = 0 ; i < n ; i ++ ) { stack [ sp ++ ] = i ; if ( sp >= 2 ) { if ( ! get ( stack [ sp - 2 ] , stack [ sp - 1 ] ) ) { sp -= 2 ; } } } assert sp - 1 >= 0 ; int honest = stack [ sp - 1 ] ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( get ( honest , i ) ) { sb . append ( 1 ) ; } else { sb . append ( 0 ) ; } } out . print ( " ! ▁ " ) ; out . print ( sb ) ; out . println ( ) ; out . flush ( ) ; } public static void main ( String [ ] args ) throws Exception { in = INPUT . isEmpty ( ) ? new Scanner ( System . in ) : new Scanner ( INPUT ) ; out = new PrintWriter ( System . out ) ; solve ( ) ; out . flush ( ) ; } static int ni ( ) { return Integer . parseInt ( in . next ( ) ) ; } static long nl ( ) { return Long . parseLong ( in . next ( ) ) ; } static double nd ( ) { return Double . parseDouble ( in . next ( ) ) ; } static void tr ( Object ... o ) { if ( INPUT . length ( ) != 0 ) System . out . println ( Arrays . deepToString ( o ) ) ; } }

import java . util . Random ; import java . util . Scanner ; public class Main { static Scanner sc = new Scanner ( System . in ) ; static Random rnd = new Random ( 42 ) ; static int qc = 0 ; static int A , B , N ; public static void main ( String [ ] args ) { A = sc . nextInt ( ) ; B = sc . nextInt ( ) ; N = A + B ; if ( A <= B ) { System . out . println ( " Impossible " ) ; return ; } int start = 0 ; int restA = A ; int honest = - 1 ; OUT : while ( true ) { if ( start == N - 1 ) { honest = start ; break ; } int cur = start ; int next = cur + 1 ; int count = 1 ; while ( true ) { boolean res = query ( cur , next ) ; if ( res ) { ++ count ; if ( count == restA ) { honest = next ; break OUT ; } else { cur = next ; next = cur + 1 ; } } else { if ( next - start + 1 >= count * 2 ) { start = next + 1 ; restA -= count ; break ; } next ++ ; } } } int [ ] result = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { result [ i ] = query ( honest , i ) ? 1 : 0 ; } System . out . print ( " ! ▁ " ) ; for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( result [ i ] ) ; } System . out . println ( ) ; } static boolean query ( int a , int b ) { ++ qc ; System . out . println ( " ? ▁ " + a + " ▁ " + b ) ; String ret = sc . next ( ) ; return ret . charAt ( 0 ) == ' Y ' ; } }

import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Scanner ; import java . util . concurrent . SynchronousQueue ; class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( A <= B ) { System . out . println ( " Impossible " ) ; return ; } ArrayDeque < Integer > stack = new ArrayDeque < > ( ) ; stack . add ( 0 ) ; int Asz = A ; int Bsz = B ; for ( int i = 1 ; stack . size ( ) <= Bsz ; ++ i ) { if ( ! stack . isEmpty ( ) ) System . out . println ( " ? ▁ " + stack . getFirst ( ) + " ▁ " + i ) ; else { stack . addFirst ( i ) ; continue ; } String s = sc . next ( ) ; if ( s . equals ( " Y " ) ) { stack . addFirst ( i ) ; } else { -- Bsz ; stack . removeFirst ( ) ; } } int ori = stack . getFirst ( ) ; boolean [ ] beHonest = new boolean [ A + B ] ; beHonest [ ori ] = true ; for ( int i = 0 ; i < A + B ; ++ i ) { if ( i == ori ) continue ; System . out . println ( " ? ▁ " + ori + " ▁ " + i ) ; String s = sc . next ( ) ; if ( s . equals ( " Y " ) ) { beHonest [ i ] = true ; } } StringBuilder ans = new StringBuilder ( ) ; for ( int i = 0 ; i < A + B ; ++ i ) { if ( beHonest [ i ] ) { ans . append ( "1" ) ; } else { ans . append ( "0" ) ; } } System . out . println ( " ! ▁ " + ans ) ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }

import collections , sys NEW_LINE p = print NEW_LINE def ask ( x , y ) : NEW_LINE INDENT p ( ' ? ' , x , y ) NEW_LINE return input ( ) == ' Y ' NEW_LINE DEDENT A , B = map ( int , input ( ) . split ( ) ) NEW_LINE r = range ( A + B ) NEW_LINE if A <= B : NEW_LINE INDENT p ( ' Impossible ' ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT c = collections . deque ( r ) NEW_LINE while len ( c ) > 2 : NEW_LINE INDENT x , y = c . pop ( ) , c . pop ( ) NEW_LINE if ask ( x , y ) : NEW_LINE INDENT c . appendleft ( y ) NEW_LINE DEDENT DEDENT p ( ' ! ' , ' ' . join ( str ( int ( ask ( c [ 0 ] , i ) ) ) for i in r ) ) NEW_LINE

import bisect NEW_LINE import sys NEW_LINE ( a , b ) = tuple ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) NEW_LINE if a <= b : NEW_LINE INDENT print ( " Impossible " ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT n = a + b NEW_LINE def ask ( i , j ) : NEW_LINE INDENT print ( " ? ▁ " , i , j ) NEW_LINE ans = input ( ) NEW_LINE if ans == ' Y ' : NEW_LINE INDENT return True NEW_LINE DEDENT elif ans == ' N ' : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT path = [ ] NEW_LINE nlen = b + 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if len ( path ) == 0 : NEW_LINE INDENT path . append ( i ) NEW_LINE if len ( path ) >= nlen : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if ask ( path [ - 1 ] , i ) : NEW_LINE INDENT path . append ( i ) NEW_LINE if len ( path ) >= nlen : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT path . pop ( ) NEW_LINE nlen -= 1 NEW_LINE DEDENT DEDENT DEDENT o1 = path [ - 1 ] NEW_LINE result = ' ' NEW_LINE for i in range ( n ) : NEW_LINE INDENT if i != o1 : NEW_LINE INDENT if ask ( o1 , i ) : NEW_LINE INDENT result += '1' NEW_LINE DEDENT else : NEW_LINE INDENT result += '0' NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT result += '1' NEW_LINE DEDENT DEDENT print ( ' ! ' , result ) NEW_LINE

from collections import * NEW_LINE p , i = print , input NEW_LINE q = lambda * a : ( p ( ' ? ' , * a ) , i ( ) == ' Y ' ) [ 1 ] NEW_LINE A , B = map ( int , i ( ) . split ( ) ) NEW_LINE r = range ( A + B ) NEW_LINE c = deque ( r ) NEW_LINE if A > B : NEW_LINE INDENT while len ( c ) > 2 : c . extendleft ( ( [ ] , [ c [ - 2 ] ] ) [ q ( c . pop ( ) , c . pop ( ) ) ] ) NEW_LINE p ( ' ! ' , ' ' . join ( str ( int ( q ( c [ 0 ] , d ) ) ) for d in r ) ) NEW_LINE DEDENT else : p ( ' Impossible ' ) NEW_LINE

import math , string , itertools , fractions , heapq , collections , re , array , bisect , sys , random , time NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE inf = 10 ** 20 NEW_LINE mod = 10 ** 9 + 7 NEW_LINE def LI ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def LF ( ) : return list ( map ( float , input ( ) . split ( ) ) ) NEW_LINE def II ( ) : return int ( input ( ) ) NEW_LINE def LS ( ) : return input ( ) . split ( ) NEW_LINE def S ( ) : return input ( ) NEW_LINE def pf ( s ) : NEW_LINE INDENT print ( s , flush = True ) NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT a , b = LI ( ) NEW_LINE if a <= b : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT l = [ ] NEW_LINE for i in range ( a + b ) : NEW_LINE INDENT if not l : NEW_LINE INDENT l . append ( i ) NEW_LINE continue NEW_LINE DEDENT pf ( ' ? ▁ { } ▁ { } ' . format ( i , l [ - 1 ] ) ) NEW_LINE if S ( ) == ' Y ' : NEW_LINE INDENT l . append ( i ) NEW_LINE DEDENT else : NEW_LINE INDENT l = l [ : - 1 ] NEW_LINE DEDENT DEDENT r = [ ] NEW_LINE ai = l [ 0 ] NEW_LINE for i in range ( a + b ) : NEW_LINE INDENT if i == ai : NEW_LINE INDENT r . append ( '1' ) NEW_LINE continue NEW_LINE DEDENT pf ( ' ? ▁ { } ▁ { } ' . format ( ai , i ) ) NEW_LINE if S ( ) == ' Y ' : NEW_LINE INDENT r . append ( '1' ) NEW_LINE DEDENT else : NEW_LINE INDENT r . append ( '0' ) NEW_LINE DEDENT DEDENT return ' ! ▁ { } ' . format ( ' ' . join ( r ) ) NEW_LINE DEDENT print ( main ( ) , flush = True ) NEW_LINE

import sys NEW_LINE from collections import deque NEW_LINE A , B = map ( int , input ( ) . split ( ) ) NEW_LINE ask = lambda x , y : print ( ' ? ' , x , y , flush = True ) NEW_LINE if A <= B : NEW_LINE INDENT print ( ' Impossible ' , flush = True ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT N = A + B NEW_LINE candidates = deque ( range ( N ) , N ) NEW_LINE while len ( candidates ) > 2 : NEW_LINE INDENT x , y = candidates . pop ( ) , candidates . pop ( ) NEW_LINE ask ( x , y ) NEW_LINE if input ( ) == ' Y ' : NEW_LINE INDENT candidates . appendleft ( y ) NEW_LINE DEDENT DEDENT god = candidates [ 0 ] NEW_LINE result = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT ask ( god , i ) NEW_LINE result . append ( input ( ) == ' Y ' ) NEW_LINE DEDENT print ( ' ! ' , ' ' . join ( str ( int ( s ) ) for s in result ) , flush = True ) NEW_LINE


import java . util . * ; public class Main { static int BridNum ( int n , int [ ] p , int sum ) { if ( sum % n != 0 ) return - 1 ; int pisl = sum / n ; int num = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( p [ i ] != pisl ) { int part = p [ i ] ; for ( int j = 1 ; j < n - i ; j ++ ) { part += p [ i + j ] ; if ( part == pisl * ( j + 1 ) ) { num += j ; i += j ; break ; } } } } return num ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; int asum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; asum += a [ i ] ; } System . out . println ( BridNum ( N , a , asum ) ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . stream . IntStream ; import java . io . UncheckedIOException ; import java . util . Arrays ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class B { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int n = in . ints ( ) ; int [ ] a = in . ints ( n ) ; int total = Arrays . stream ( a ) . sum ( ) ; if ( total % n != 0 ) { out . println ( - 1 ) ; return ; } total /= n ; int pm = 0 ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( a [ i ] + pm ) != total ) { ans ++ ; } pm = a [ i ] + pm - total ; } out . println ( ans ) ; } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } public int [ ] ints ( int length ) { return IntStream . range ( 0 , length ) . map ( x -> ints ( ) ) . toArray ( ) ; } } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = Integer . parseInt ( scanner . nextLine ( ) ) ; String [ ] line = scanner . nextLine ( ) . split ( " ▁ " , n ) ; int [ ] arr = new int [ n ] ; int total = 0 ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = Integer . parseInt ( line [ i ] ) ; total += arr [ i ] ; } if ( total % n != 0 ) { System . out . println ( - 1 ) ; return ; } int bridges = 0 ; int avg = total / n ; int currentTotal = 0 ; int currentSize = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( currentTotal + arr [ i ] ) == avg * ( currentSize + 1 ) ) { currentTotal = 0 ; currentSize = 0 ; } else { currentTotal += arr [ i ] ; currentSize ++ ; bridges ++ ; } } System . out . println ( bridges ) ; } }

import java . util . * ; import java . lang . * ; import java . math . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] pp = new int [ n ] ; int sum = 0 ; int ans = 0 ; int ave = 0 ; for ( int i = 0 ; i < n ; i ++ ) { pp [ i ] = sc . nextInt ( ) ; sum += pp [ i ] ; } if ( sum % n == 0 ) { ave = sum / n ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( pp [ i ] != ave ) { ans ++ ; int tmp = ave - pp [ i ] ; pp [ i + 1 ] = pp [ i + 1 ] - tmp ; pp [ i ] = ave ; } } System . out . println ( ans ) ; } else { System . out . println ( - 1 ) ; } sc . close ( ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int a = scan . nextInt ( ) ; int b [ ] = new int [ a ] ; int count = 0 ; for ( int i = 0 ; i != a ; i ++ ) { b [ i ] = scan . nextInt ( ) ; count += b [ i ] ; } if ( count % a != 0 ) { System . out . println ( - 1 ) ; } else { int ans2 = count / a ; count = 0 ; int ans = 0 ; for ( int i = 0 ; i != a ; i ++ ) { count += b [ i ] ; if ( count != ans2 * ( i + 1 ) ) { ans ++ ; } } System . out . println ( ans ) ; } } }

n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = 0 NEW_LINE if sum ( a ) % n != 0 : NEW_LINE INDENT print ( - 1 ) NEW_LINE quit ( ) NEW_LINE DEDENT for i in range ( n - 1 ) : NEW_LINE INDENT if sum ( a [ : i + 1 ] ) != ( i + 1 ) * sum ( a ) / n : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE

N = int ( input ( ) ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE if sum ( a ) % N != 0 : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT x = sum ( a ) // N NEW_LINE left_sum = 0 NEW_LINE bridge = 0 NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT left_sum += a [ i ] NEW_LINE right_sum = sum ( a ) - left_sum NEW_LINE if left_sum != x * ( i + 1 ) or right_sum != x * ( N - i - 1 ) : NEW_LINE INDENT bridge += 1 NEW_LINE DEDENT DEDENT print ( bridge ) NEW_LINE DEDENT

def island_and_bridge ( N : int , A : list ) -> int : NEW_LINE INDENT if sum ( A ) % N > 0 : NEW_LINE INDENT return - 1 NEW_LINE DEDENT s = 0 NEW_LINE goal = sum ( A ) // N NEW_LINE bridges = 0 NEW_LINE for a in A : NEW_LINE INDENT s += a - goal NEW_LINE if s != 0 : NEW_LINE INDENT bridges += 1 NEW_LINE DEDENT DEDENT return bridges NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE A = [ int ( s ) for s in input ( ) . split ( ) ] NEW_LINE ans = island_and_bridge ( N , A ) NEW_LINE print ( ans ) NEW_LINE DEDENT

n = int ( input ( ) ) NEW_LINE hoge = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE kei = sum ( hoge ) NEW_LINE hei = kei / n NEW_LINE nokori = 0 NEW_LINE ans = 0 NEW_LINE if ( kei % n > 0 ) : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT for i in range ( n - 1 ) : NEW_LINE INDENT nokori += hoge [ i ] NEW_LINE if ( nokori != hei * ( i + 1 ) ) : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT

def b_island ( N , A ) : NEW_LINE INDENT s = sum ( A ) NEW_LINE if s % N != 0 : NEW_LINE INDENT return - 1 NEW_LINE DEDENT return sum ( 1 for i in range ( 1 , N ) if sum ( A [ : i ] ) != s // N * i ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE A = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( b_island ( N , A ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; int d = in . nextInt ( ) ; if ( ( Math . abs ( a - b ) <= d && Math . abs ( b - c ) <= d ) || Math . abs ( a - c ) <= d ) { out . println ( " Yes " ) ; } else { out . println ( " No " ) ; } } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }

import static java . lang . System . * ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int a = sc . nextInt ( ) , b = sc . nextInt ( ) , c = sc . nextInt ( ) , d = sc . nextInt ( ) ; int difAB = ( int ) Math . abs ( a - b ) ; int difBC = ( int ) Math . abs ( b - c ) ; int difAC = ( int ) Math . abs ( a - c ) ; if ( difAB <= d && difBC <= d ) { out . println ( " Yes " ) ; } else if ( difAC <= d ) out . println ( " Yes " ) ; else out . println ( " No " ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } private void solveA ( ) { Scanner scanner = null ; int numA = 0 ; int numB = 0 ; int numC = 0 ; int numD = 0 ; try { scanner = new Scanner ( System . in ) ; numA = scanner . nextInt ( ) ; numB = scanner . nextInt ( ) ; numC = scanner . nextInt ( ) ; numD = scanner . nextInt ( ) ; boolean canTalk = false ; canTalk = ( ( Math . abs ( numA - numB ) <= numD && Math . abs ( numB - numC ) <= numD ) || Math . abs ( numA - numC ) <= numD ) ; System . out . println ( canTalk ? " Yes " : " No " ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveB ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( " " ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveC ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( " " ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } private void solveD ( ) { Scanner scanner = null ; int numN = 0 ; int numK = 0 ; int numS = 0 ; try { scanner = new Scanner ( System . in ) ; numN = scanner . nextInt ( ) ; System . out . println ( " " ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int ab = ( int ) Math . abs ( a - b ) ; int bc = ( int ) Math . abs ( b - c ) ; int ca = ( int ) Math . abs ( c - a ) ; if ( ca <= d ) { System . out . println ( " Yes " ) ; return ; } if ( ab <= d && bc <= d ) { System . out . println ( " Yes " ) ; return ; } System . out . println ( " No " ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; ABC097_A solver = new ABC097_A ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ABC097_A { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int a , b , c , d ; a = in . nextInt ( ) ; b = in . nextInt ( ) ; c = in . nextInt ( ) ; d = in . nextInt ( ) ; if ( Math . abs ( c - a ) <= d ) { out . print ( " Yes " ) ; return ; } if ( Math . abs ( c - b ) <= d && Math . abs ( b - a ) <= d ) { out . print ( " Yes " ) ; return ; } out . print ( " No " ) ; } } }

a , b , c , d = map ( int , input ( ) . split ( ) ) NEW_LINE AB = abs ( a - b ) NEW_LINE AC = abs ( a - c ) NEW_LINE BC = abs ( b - c ) NEW_LINE if AC <= d : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT elif AB <= d and BC <= d : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT

l = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( " Yes " if ( ( abs ( l [ 0 ] - l [ 1 ] ) <= l [ 3 ] ) & ( abs ( l [ 1 ] - l [ 2 ] ) <= l [ 3 ] ) ) or ( abs ( l [ 0 ] - l [ 2 ] ) <= l [ 3 ] ) else " No " ) NEW_LINE

a , b , c , d = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE if abs ( a - c ) <= d : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT elif abs ( a - b ) <= d and abs ( b - c ) <= d : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT

A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if ( abs ( A [ 0 ] - A [ 2 ] ) <= A [ 3 ] or ( ( abs ( A [ 0 ] - A [ 1 ] ) <= A [ 3 ] ) and ( abs ( A [ 2 ] - A [ 1 ] ) <= A [ 3 ] ) ) ) : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT

A , B , C , D = map ( int , input ( ) . split ( ) ) NEW_LINE print ( [ " Yes " , " No " ] [ not ( abs ( C - A ) <= D or ( abs ( B - A ) <= D and abs ( C - B ) <= D ) ) ] ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int N = in . nextInt ( ) ; double ans = 0 ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int tmp = in . nextInt ( ) ; if ( 0 < tmp ) { ans += tmp ; count ++ ; } } out . println ( ( int ) Math . ceil ( ans / count ) ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }

import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sum = 0 ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; int num = sc . nextInt ( ) ; for ( int n = 0 ; n < num ; n ++ ) { int bu = sc . nextInt ( ) ; if ( bu != 0 ) { list . add ( bu ) ; sum = sum + bu ; } } float a = ( sum + ( list . size ( ) - 1 ) ) / list . size ( ) ; int answer = ( int ) ( Math . ceil ( a ) ) ; System . out . println ( answer ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = Integer . parseInt ( scanner . nextLine ( ) ) ; String [ ] a = scanner . nextLine ( ) . split ( " ▁ " ) ; scanner . close ( ) ; double haveBug = 0 ; double sumBug = 0 ; for ( String bugNumStr : a ) { int bugNum = Integer . parseInt ( bugNumStr ) ; if ( bugNum != 0 ) { haveBug ++ ; sumBug += bugNum ; } } double avg = sumBug / haveBug ; int avgCeiled = ( int ) Math . ceil ( avg ) ; System . out . println ( avgCeiled ) ; } }

import java . util . Scanner ; public class Main { private static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = scanner . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) A [ i ] = scanner . nextInt ( ) ; int sum = 0 , size = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] != 0 ) { sum += A [ i ] ; ++ size ; } } System . out . println ( sum / size + ( sum % size != 0 ? 1 : 0 ) ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double n = sc . nextInt ( ) ; double tmpN = n ; double a = 0 ; int tmp ; for ( int i = 0 ; i < n ; i ++ ) { tmp = sc . nextInt ( ) ; if ( tmp == 0 ) { tmpN -- ; } else { a += tmp ; } } n = tmpN ; int output = 0 ; while ( true ) { if ( a / n <= output ) { System . out . println ( output ) ; return ; } output ++ ; } } }

N = int ( input ( ) ) NEW_LINE soft = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE while ( True ) : NEW_LINE INDENT try : NEW_LINE INDENT soft . remove ( 0 ) NEW_LINE DEDENT except : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( - ( - sum ( soft ) // len ( soft ) ) ) NEW_LINE

from statistics import mean , median , variance , stdev NEW_LINE import numpy as np NEW_LINE import sys NEW_LINE import math NEW_LINE import fractions NEW_LINE import itertools NEW_LINE import copy NEW_LINE import collections NEW_LINE from operator import itemgetter NEW_LINE def j ( q ) : NEW_LINE INDENT if q == 1 : print ( " Yay ! " ) NEW_LINE else : print ( " : ( " ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT def ct ( x , y ) : NEW_LINE INDENT if ( x > y ) : print ( " + " ) NEW_LINE elif ( x < y ) : print ( " - " ) NEW_LINE else : print ( " ? " ) NEW_LINE DEDENT def ip ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT def printrow ( a ) : NEW_LINE INDENT for i in range ( len ( a ) ) : NEW_LINE INDENT print ( a [ i ] ) NEW_LINE DEDENT DEDENT def combinations ( n , r ) : NEW_LINE INDENT if n < r : return 0 NEW_LINE return math . factorial ( n ) // ( math . factorial ( n - r ) * math . factorial ( r ) ) NEW_LINE DEDENT def permutations ( n , r ) : NEW_LINE INDENT if n < r : return 0 NEW_LINE return math . factorial ( n ) // math . factorial ( n - r ) NEW_LINE DEDENT n = ip ( ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE num = 0 NEW_LINE s = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if a [ i ] : NEW_LINE INDENT num += 1 NEW_LINE s += a [ i ] NEW_LINE DEDENT DEDENT if s / num == s // num : NEW_LINE INDENT print ( s // num ) NEW_LINE DEDENT else : print ( s // num + 1 ) NEW_LINE

import math NEW_LINE n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE print ( math . ceil ( sum ( a ) / ( n - a . count ( 0 ) ) ) ) NEW_LINE

N = int ( input ( ) ) NEW_LINE A = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE dnm = N NEW_LINE bugs = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if A [ i ] == 0 : NEW_LINE INDENT dnm -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT bugs += A [ i ] NEW_LINE DEDENT DEDENT import math NEW_LINE print ( math . ceil ( bugs / dnm ) ) NEW_LINE

import math NEW_LINE import numpy as np NEW_LINE n = int ( input ( ) ) NEW_LINE n_list = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE count = 0 NEW_LINE total = 0 NEW_LINE for i in n_list : NEW_LINE INDENT if i != 0 : NEW_LINE INDENT count += 1 NEW_LINE total += i NEW_LINE DEDENT DEDENT avrage = total / count NEW_LINE print ( math . ceil ( avrage ) ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) , w = sc . nextInt ( ) ; int froml , fromu = 0 ; List < String > s = new ArrayList < > ( ) ; for ( int i = 0 ; i < h ; i ++ ) { froml = 0 ; for ( int j = 0 ; j < w ; j ++ ) { int a = sc . nextInt ( ) ; a += froml ; if ( j == w - 1 ) { a += fromu ; fromu = a % 2 ; if ( fromu == 1 && i + 2 <= h ) { s . add ( ( i + 1 ) + " ▁ " + ( j + 1 ) + " ▁ " + ( i + 2 ) + " ▁ " + ( j + 1 ) ) ; } break ; } froml = a % 2 ; if ( froml == 1 ) { s . add ( ( i + 1 ) + " ▁ " + ( j + 1 ) + " ▁ " + ( i + 1 ) + " ▁ " + ( j + 2 ) ) ; } } } System . out . println ( s . size ( ) ) ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { System . out . println ( s . get ( i ) ) ; } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int [ ] [ ] place = new int [ w ] [ h ] ; for ( int j = 0 ; j < h ; j ++ ) { for ( int i = 0 ; i < w ; i ++ ) { place [ i ] [ j ] = sc . nextInt ( ) ; } } int i = 0 ; int j = 0 ; int ni = 0 ; int nj = 0 ; int count = 0 ; StringBuilder sb = new StringBuilder ( ) ; while ( true ) { if ( j % 2 == 0 ) { if ( i == w - 1 ) { ni = i ; nj = j + 1 ; if ( nj == h ) { break ; } } else { ni = i + 1 ; nj = j ; } } else { if ( i == 0 ) { ni = i ; nj = j + 1 ; if ( nj == h ) { break ; } } else { ni = i - 1 ; nj = j ; } } if ( place [ i ] [ j ] % 2 != 0 ) { sb . append ( j + 1 ) . append ( " ▁ " ) . append ( i + 1 ) . append ( " ▁ " ) . append ( nj + 1 ) . append ( " ▁ " ) . append ( ni + 1 ) . append ( " \n " ) ; place [ i ] [ j ] -= 1 ; place [ ni ] [ nj ] += 1 ; count ++ ; } i = ni ; j = nj ; } System . out . println ( count ) ; System . out . print ( sb ) ; } }

import java . awt . * ; import java . util . * ; import java . util . List ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int H = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; int [ ] [ ] a = new int [ H ] [ W ] ; for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { a [ i ] [ j ] = sc . nextInt ( ) ; } } int cnt = 0 ; List < Point > from = new ArrayList < > ( ) ; List < Point > to = new ArrayList < > ( ) ; for ( int i = 0 ; i < H - 1 ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { if ( a [ i ] [ j ] % 2 != 0 ) { a [ i ] [ j ] -= 1 ; a [ i + 1 ] [ j ] += 1 ; cnt ++ ; from . add ( new Point ( i + 1 , j + 1 ) ) ; to . add ( new Point ( i + 2 , j + 1 ) ) ; } } } for ( int j = 0 ; j < W - 1 ; j ++ ) { if ( a [ H - 1 ] [ j ] % 2 != 0 ) { a [ H - 1 ] [ j ] -= 1 ; a [ H - 1 ] [ j + 1 ] += 1 ; cnt ++ ; from . add ( new Point ( H , j + 1 ) ) ; to . add ( new Point ( H , j + 2 ) ) ; } } out . println ( cnt ) ; for ( int i = 0 ; i < from . size ( ) ; i ++ ) { Point f = from . get ( i ) ; Point t = to . get ( i ) ; out . println ( f . x + " ▁ " + f . y + " ▁ " + t . x + " ▁ " + t . y ) ; } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int height = sc . nextInt ( ) ; int width = sc . nextInt ( ) ; boolean oddCoin [ ] [ ] = new boolean [ height ] [ width ] ; for ( int i = 0 ; i < height ; i ++ ) { for ( int j = 0 ; j < width ; j ++ ) { oddCoin [ i ] [ j ] = sc . nextInt ( ) % 2 == 1 ; } } int count = 0 ; ArrayList < String > output = new ArrayList < String > ( ) ; for ( int i = 0 ; i < height - 1 ; i ++ ) { for ( int j = 0 ; j < width ; j ++ ) { if ( oddCoin [ i ] [ j ] ) { count ++ ; oddCoin [ i ] [ j ] = ! oddCoin [ i ] [ j ] ; oddCoin [ i + 1 ] [ j ] = ! oddCoin [ i + 1 ] [ j ] ; output . add ( ( i + 1 ) + " ▁ " + ( j + 1 ) + " ▁ " + ( i + 1 + 1 ) + " ▁ " + ( j + 1 ) ) ; } } } for ( int j = 0 ; j < width - 1 ; j ++ ) { if ( oddCoin [ height - 1 ] [ j ] ) { count ++ ; oddCoin [ height - 1 ] [ j ] = ! oddCoin [ height - 1 ] [ j ] ; oddCoin [ height - 1 ] [ j + 1 ] = ! oddCoin [ height - 1 ] [ j + 1 ] ; output . add ( height + " ▁ " + ( j + 1 ) + " ▁ " + height + " ▁ " + ( j + 2 ) ) ; } } System . out . println ( count ) ; for ( int i = 0 ; i < output . size ( ) ; i ++ ) { System . out . println ( output . get ( i ) ) ; } } }

import java . util . Scanner ; import java . util . ArrayList ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int [ ] [ ] map = new int [ h ] [ w ] ; ArrayList < String > list = new ArrayList < > ( ) ; int sum = 0 ; for ( int i = 0 ; i < h ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { map [ i ] [ j ] = sc . nextInt ( ) ; } } boolean jud = false ; for ( int i = 0 ; i < h ; i ++ ) { if ( i % 2 == 0 ) { for ( int j = 0 ; j < w ; j ++ ) { if ( jud ) { if ( j == 0 ) { list . add ( i + " ▁ " + ( j + 1 ) + " ▁ " + ( i + 1 ) + " ▁ " + ( j + 1 ) ) ; sum ++ ; } else { list . add ( ( i + 1 ) + " ▁ " + j + " ▁ " + ( i + 1 ) + " ▁ " + ( j + 1 ) ) ; sum ++ ; } } if ( map [ i ] [ j ] % 2 == 1 ) { jud = ! jud ; } } } else { for ( int j = w - 1 ; j >= 0 ; j -- ) { if ( jud ) { if ( j == w - 1 ) { list . add ( i + " ▁ " + ( j + 1 ) + " ▁ " + ( i + 1 ) + " ▁ " + ( j + 1 ) ) ; sum ++ ; } else { list . add ( ( i + 1 ) + " ▁ " + ( j + 2 ) + " ▁ " + ( i + 1 ) + " ▁ " + ( j + 1 ) ) ; sum ++ ; } } if ( map [ i ] [ j ] % 2 == 1 ) { jud = ! jud ; } } } } System . out . println ( sum ) ; for ( String i : list ) { System . out . println ( i ) ; } } }

h , w = map ( int , input ( ) . split ( ) ) NEW_LINE s = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( h ) ] NEW_LINE p = True NEW_LINE q = [ 0 , 0 ] NEW_LINE d = [ ] NEW_LINE for i in range ( h ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT for j in range ( w ) : NEW_LINE INDENT if p : NEW_LINE INDENT if s [ i ] [ j ] % 2 == 1 : NEW_LINE INDENT q = [ i , j ] NEW_LINE p = False NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT d . append ( [ q [ 0 ] + 1 , q [ 1 ] + 1 , i + 1 , j + 1 ] ) NEW_LINE q = [ i , j ] NEW_LINE if s [ i ] [ j ] % 2 == 1 : NEW_LINE INDENT p = True NEW_LINE DEDENT DEDENT DEDENT DEDENT else : NEW_LINE INDENT for j in range ( w - 1 , - 1 , - 1 ) : NEW_LINE INDENT if p : NEW_LINE INDENT if s [ i ] [ j ] % 2 == 1 : NEW_LINE INDENT q = [ i , j ] NEW_LINE p = False NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT d . append ( [ q [ 0 ] + 1 , q [ 1 ] + 1 , i + 1 , j + 1 ] ) NEW_LINE q = [ i , j ] NEW_LINE if s [ i ] [ j ] % 2 == 1 : NEW_LINE INDENT p = True NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT print ( len ( d ) ) NEW_LINE for i in d : NEW_LINE INDENT print ( i [ 0 ] , i [ 1 ] , i [ 2 ] , i [ 3 ] ) NEW_LINE DEDENT

H , W = ( int ( x ) for x in input ( ) . split ( ) ) NEW_LINE a_mat = [ ] NEW_LINE for _ in range ( H ) : NEW_LINE INDENT a_mat . append ( [ int ( x ) for x in input ( ) . split ( ) ] ) NEW_LINE DEDENT out_op = [ ] NEW_LINE for h in range ( H ) : NEW_LINE INDENT for w in range ( W ) : NEW_LINE INDENT if h % 2 == 0 : NEW_LINE INDENT wd = w NEW_LINE if w == W - 1 : NEW_LINE INDENT next_pos = ( h + 1 , wd ) NEW_LINE DEDENT else : NEW_LINE INDENT next_pos = ( h , wd + 1 ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT wd = W - 1 - w NEW_LINE if w == W - 1 : NEW_LINE INDENT next_pos = ( h + 1 , wd ) NEW_LINE DEDENT else : NEW_LINE INDENT next_pos = ( h , wd - 1 ) NEW_LINE DEDENT DEDENT if h == H - 1 and w == W - 1 : NEW_LINE INDENT break NEW_LINE DEDENT if a_mat [ h ] [ wd ] % 2 == 1 : NEW_LINE INDENT a_mat [ next_pos [ 0 ] ] [ next_pos [ 1 ] ] += 1 NEW_LINE out_op . append ( ( h , wd , next_pos [ 0 ] , next_pos [ 1 ] ) ) NEW_LINE DEDENT DEDENT DEDENT print ( len ( out_op ) ) NEW_LINE for y , x , yn , xn in out_op : NEW_LINE INDENT print ( y + 1 , x + 1 , yn + 1 , xn + 1 ) NEW_LINE DEDENT

import sys NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE INF = 10 ** 18 NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE from itertools import product NEW_LINE def main ( ) : NEW_LINE INDENT H , W = LI ( ) NEW_LINE A = [ ] NEW_LINE for _ in range ( H ) : NEW_LINE INDENT A . append ( LI ( ) ) NEW_LINE DEDENT ans = [ ] NEW_LINE for y , x in product ( range ( 1 , H + 1 ) , range ( 1 , W ) ) : NEW_LINE INDENT j , i = y - 1 , x - 1 NEW_LINE if A [ j ] [ i ] % 2 : NEW_LINE INDENT A [ j ] [ i + 1 ] += 1 NEW_LINE ans . append ( [ y , x , y , x + 1 ] ) NEW_LINE DEDENT DEDENT x = W NEW_LINE i = x - 1 NEW_LINE for y in range ( 1 , H ) : NEW_LINE INDENT j = y - 1 NEW_LINE if A [ j ] [ i ] % 2 : NEW_LINE INDENT A [ j + 1 ] [ i ] += 1 NEW_LINE ans . append ( [ y , x , y + 1 , x ] ) NEW_LINE DEDENT DEDENT print ( len ( ans ) ) NEW_LINE for arr in ans : NEW_LINE INDENT print ( * arr ) NEW_LINE DEDENT return 0 NEW_LINE DEDENT main ( ) NEW_LINE

h , w = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE lists = [ [ 0 ] * w ] * h NEW_LINE for i in range ( h ) : NEW_LINE INDENT lists [ i ] = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE DEDENT count = 0 NEW_LINE operations = " " NEW_LINE for i , l in enumerate ( lists ) : NEW_LINE INDENT for j , a in enumerate ( l ) : NEW_LINE INDENT if j == w - 1 : NEW_LINE INDENT break NEW_LINE DEDENT if a % 2 == 1 : NEW_LINE INDENT lists [ i ] [ j ] -= 1 NEW_LINE lists [ i ] [ j + 1 ] += 1 NEW_LINE count += 1 NEW_LINE operations += str ( i + 1 , ) + " ▁ " + str ( j + 1 ) + " ▁ " + str ( i + 1 ) + " ▁ " + str ( j + 2 ) + " \n " NEW_LINE DEDENT DEDENT DEDENT for i in range ( h ) : NEW_LINE INDENT if i == h - 1 : NEW_LINE INDENT break NEW_LINE DEDENT if lists [ i ] [ w - 1 ] % 2 == 1 : NEW_LINE INDENT lists [ i ] [ j ] -= 1 NEW_LINE lists [ i + 1 ] [ j ] += 1 NEW_LINE count += 1 NEW_LINE operations += str ( i + 1 , ) + " ▁ " + str ( j + 1 ) + " ▁ " + str ( i + 2 ) + " ▁ " + str ( j + 1 ) + " \n " NEW_LINE DEDENT DEDENT print ( count ) NEW_LINE print ( operations ) NEW_LINE

inpl = lambda : list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE H , W = inpl ( ) NEW_LINE A = [ ] NEW_LINE for _ in range ( H ) : NEW_LINE INDENT A . append ( inpl ( ) ) NEW_LINE DEDENT def pos ( n ) : NEW_LINE INDENT q , m = divmod ( n , W ) NEW_LINE if q % 2 : NEW_LINE INDENT m = ( W - 1 ) - m NEW_LINE DEDENT return q , m NEW_LINE DEDENT ans = [ ] NEW_LINE f = 0 NEW_LINE hn , wn = 0 , 0 NEW_LINE for n in range ( H * W - 1 ) : NEW_LINE INDENT h , w = hn , wn NEW_LINE hn , wn = pos ( n + 1 ) NEW_LINE if ( f + A [ h ] [ w ] ) % 2 : NEW_LINE INDENT ans . append ( [ h + 1 , w + 1 , hn + 1 , wn + 1 ] ) NEW_LINE f = 1 NEW_LINE DEDENT else : NEW_LINE INDENT f = 0 NEW_LINE DEDENT DEDENT print ( len ( ans ) ) NEW_LINE for rec in ans : NEW_LINE INDENT print ( rec [ 0 ] , rec [ 1 ] , rec [ 2 ] , rec [ 3 ] ) NEW_LINE DEDENT


import java . util . Arrays ; import java . util . HashMap ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ; ) { new Main ( ) . solve ( sc ) ; } } void solve ( Scanner sc ) { int n = sc . nextInt ( ) ; int [ ] as = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { as [ i ] = sc . nextInt ( ) ; } Arrays . sort ( as ) ; if ( n % 2 == 0 ) { int tmp = 1 ; for ( int i = 0 ; i < n ; i += 2 ) { if ( as [ i ] != tmp || as [ i + 1 ] != tmp ) { System . out . println ( 0 ) ; return ; } tmp += 2 ; } } else { if ( as [ 0 ] != 0 ) { System . out . println ( 0 ) ; return ; } int tmp = 2 ; for ( int i = 1 ; i < n ; i += 2 ) { if ( as [ i ] != tmp || as [ i + 1 ] != tmp ) { System . out . println ( 0 ) ; return ; } tmp += 2 ; } } int ans = 1 ; for ( int i = 0 ; i < n / 2 ; i ++ ) { ans = ( ans * 2 ) % ( 1_000_000_000 + 7 ) ; } System . out . println ( ans ) ; } }

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 Main { private void solve ( ) throws IOException { int n = nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = nextInt ( ) ; } Arrays . sort ( a ) ; long res = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] != ( i + n % 2 ) / 2 * 2 + ( 1 - n % 2 ) ) { out . println ( 0 ) ; return ; } if ( i > 0 && a [ i ] == a [ i - 1 ] ) { res = ( res * 2 ) % ( ( long ) ( 1e9 + 7 ) ) ; } } out . println ( res ) ; } BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st ; PrintWriter out = new PrintWriter ( System . out ) ; String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) { st = new StringTokenizer ( br . readLine ( ) ) ; } return st . nextToken ( ) ; } int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public static void main ( String [ ] args ) throws IOException { new Main ( ) . run ( ) ; } private void run ( ) throws IOException { solve ( ) ; out . close ( ) ; } }

import java . util . * ; import java . io . * ; import java . awt . geom . * ; import java . math . * ; public class Main { static final Scanner in = new Scanner ( System . in ) ; static final PrintWriter out = new PrintWriter ( System . out , false ) ; static boolean debug = false ; static final int MOD = 1_000_000_007 ; public static long modPow ( long x , long n , long mod ) { long res = 1 ; while ( n > 0 ) { if ( ( n & 1 ) == 1 ) res = res * x % mod ; x = x * x % mod ; n >>= 1 ; } return res ; } static void solve ( ) { int n = in . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] x = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; if ( ( n + 1 ) % 2 != a [ i ] % 2 ) { out . println ( 0 ) ; return ; } x [ a [ i ] ] ++ ; if ( x [ a [ i ] ] > 2 ) { out . println ( 0 ) ; return ; } } if ( x [ 0 ] > 1 ) { out . println ( 0 ) ; return ; } out . println ( modPow ( 2 , n / 2 , MOD ) ) ; } public static void main ( String [ ] args ) { debug = args . length > 0 ; long start = System . nanoTime ( ) ; solve ( ) ; out . flush ( ) ; long end = System . nanoTime ( ) ; dump ( ( end - start ) / 1000000 + " ▁ ms " ) ; in . close ( ) ; out . close ( ) ; } static void dump ( Object ... o ) { if ( debug ) System . err . println ( Arrays . deepToString ( o ) ) ; } }

import java . util . * ; public class Main { private static boolean isPossible ( int n , int [ ] counter ) { if ( n % 2 == 0 ) { for ( int i = 1 ; i < n ; i += 2 ) { if ( counter [ i ] != 2 ) { return false ; } } for ( int i = 0 ; i < n ; i += 2 ) { if ( counter [ i ] != 0 ) { return false ; } } return true ; } else { if ( counter [ 0 ] != 1 ) { return false ; } for ( int i = 1 ; i < n ; i += 2 ) { if ( counter [ i ] != 0 ) { return false ; } } for ( int i = 2 ; i < n ; i += 2 ) { if ( counter [ i ] != 2 ) { return false ; } } return true ; } } private static long solve ( int n , int [ ] counter ) { if ( ! isPossible ( n , counter ) ) { return 0 ; } long output = 1 ; for ( int i = 0 ; i < n / 2 ; i ++ ) { output *= 2 ; output %= 1000000007 ; } return output ; } public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = Integer . parseInt ( s . next ( ) ) ; int [ ] counter = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { counter [ Integer . parseInt ( s . next ( ) ) ] ++ ; } System . out . println ( solve ( n , counter ) ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { int n ; int [ ] as ; public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; } void run ( ) { FastReader sc = new FastReader ( ) ; n = sc . nextInt ( ) ; boolean odd = n % 2 == 1 ; int [ ] check = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; if ( a % 2 == 1 == odd ) { System . out . println ( 0 ) ; return ; } check [ a ] ++ ; if ( check [ a ] > 2 ) { System . out . println ( 0 ) ; return ; } } if ( odd && check [ 0 ] != 1 ) { System . out . println ( 0 ) ; return ; } long ans = pow ( 2 , n / 2 , 1000000007 ) ; System . out . println ( ans ) ; } long pow ( long x , int n , int MOD ) { long ans = 1 ; while ( n > 0 ) { if ( ( n & 1 ) == 1 ) { ans = ans * x % MOD ; } x = x * x % MOD ; n >>= 1 ; } return ans ; } 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 ; } } }

def getInt ( ) : return int ( input ( ) ) NEW_LINE def getIntList ( ) : return [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE def db ( x ) : NEW_LINE INDENT global debug NEW_LINE if debug : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT DEDENT def solve ( ) : NEW_LINE INDENT A . sort ( ) NEW_LINE db ( A ) NEW_LINE if A [ 0 ] == 0 : NEW_LINE INDENT n = 1 NEW_LINE DEDENT else : NEW_LINE INDENT n = 0 NEW_LINE DEDENT for i in range ( n , len ( A ) , 2 ) : NEW_LINE INDENT db ( i ) NEW_LINE if A [ i ] != A [ i + 1 ] : NEW_LINE INDENT return 0 NEW_LINE DEDENT DEDENT return 2 ** ( len ( A ) // 2 ) % ( 10 ** 9 + 7 ) NEW_LINE DEDENT debug = False NEW_LINE N = getInt ( ) NEW_LINE A = getIntList ( ) NEW_LINE db ( ( N , A ) ) NEW_LINE print ( solve ( ) ) NEW_LINE

mod = 10 ** 9 + 7 NEW_LINE N = int ( input ( ) ) NEW_LINE l = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if N % 2 == 1 : NEW_LINE INDENT l . append ( 0 ) NEW_LINE N -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT l = list ( map ( lambda x : x - 1 , l ) ) NEW_LINE DEDENT l = sorted ( l ) NEW_LINE i = 0 NEW_LINE for f , s in zip ( l [ 0 : : 2 ] , l [ 1 : : 2 ] ) : NEW_LINE INDENT if f == 2 * i and s == 2 * i : NEW_LINE INDENT i += 1 NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( 2 ** ( N // 2 ) % mod ) NEW_LINE

import sys NEW_LINE import collections NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE nsl = lambda : map ( str , sys . stdin . readline ( ) . split ( ) ) NEW_LINE n = ni ( ) NEW_LINE a = nl ( ) NEW_LINE c = collections . Counter ( a ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE val = list ( c . values ( ) ) NEW_LINE key = list ( c . keys ( ) ) NEW_LINE check = len ( a ) % 2 NEW_LINE if check == 1 : NEW_LINE INDENT if val . count ( 1 ) != 1 : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT if key [ val . index ( 1 ) ] != 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT if val . count ( 2 ) != len ( val ) - 1 : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 2 ** ( val . count ( 2 ) ) % mod ) NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT if val . count ( 2 ) != len ( val ) : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 2 ** ( len ( val ) ) % mod ) NEW_LINE DEDENT DEDENT

import sys NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE INF = 10 ** 18 NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT N = II ( ) NEW_LINE A = LI ( ) NEW_LINE from collections import Counter NEW_LINE cnt = Counter ( A ) NEW_LINE if N % 2 and cnt [ 0 ] < 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT for i in range ( N % 2 + 1 , N , 2 ) : NEW_LINE INDENT if cnt [ i ] != 2 : NEW_LINE INDENT return 0 NEW_LINE DEDENT DEDENT ans = ( 2 ** ( N // 2 ) ) % MOD NEW_LINE return ans NEW_LINE DEDENT print ( main ( ) ) NEW_LINE

N = int ( input ( ) ) NEW_LINE ans = None NEW_LINE tmp = 0 NEW_LINE z = 1 NEW_LINE if ( N % 2 == 0 ) : NEW_LINE INDENT tmp = int ( N / 2 ) NEW_LINE ans = [ 2 for i in range ( tmp ) ] NEW_LINE A = map ( int , input ( ) . split ( ) ) NEW_LINE for i in A : NEW_LINE INDENT if ( int ( i / 2 ) <= int ( N / 2 ) ) : NEW_LINE INDENT ans [ int ( i / 2 ) - 1 ] -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT tmp = int ( N / 2 ) NEW_LINE ans = [ 2 for i in range ( tmp ) ] NEW_LINE z = 0 NEW_LINE A = map ( int , input ( ) . split ( ) ) NEW_LINE for i in A : NEW_LINE INDENT if ( i == 0 ) : NEW_LINE INDENT z = 1 NEW_LINE continue NEW_LINE DEDENT if ( int ( i / 2 ) <= int ( N / 2 ) ) : NEW_LINE INDENT ans [ int ( i / 2 ) - 1 ] -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT output = 2 ** ( tmp ) % ( 10 ** 9 + 7 ) NEW_LINE for i in ans : NEW_LINE INDENT if ( i != 0 ) : NEW_LINE INDENT output = 0 NEW_LINE DEDENT DEDENT print ( output * z ) NEW_LINE