import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   public class Main { public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ; int n = fs . nextInt ( ) ; long [ ] arr = fs . nextArrLong ( n ) ;   long current = 0 ; long answer = 0 ; long counter = 0 ; for ( int i = 0 ; i < n ; i ++ ) { long temp = arr [ i ] ; answer ++ ; if ( i == 0 || temp != current ) { current = temp ; counter = 0 ; } else { counter ++ ; answer += counter ; } } System . out . println ( answer ) ; }   }    class FastScanner { BufferedReader br ; StringTokenizer st ;   public FastScanner ( ) { 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 [ ] nextArrInt ( int n ) { try { int [ ] j = new int [ n + 1 ] ; for ( int k = 0 ; k < n ; k ++ ) { j [ k ] = nextInt ( ) ; } return j ; } catch ( Exception e ) { return null ; }   }   long [ ] nextArrLong ( int n ) { try { long [ ] j = new long [ n ] ; for ( int k = 0 ; k < n ; k ++ ) { j [ k ] = nextLong ( ) ; } return j ; } catch ( Exception e ) { return null ; } }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }    int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } }

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

import java . util . * ;   public class CodeForces83A { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; } int c = a [ 0 ] ; long ans = 0 ; long count = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( c == a [ i ] ) { count ++ ; } else { ans += count * ( count + 1 ) / 2 ; count = 1 ; c = a [ i ] ; } }   ans += count * ( count + 1 ) / 2 ;   System . out . println ( ans ) ; } }

n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a . append ( a [ - 1 ] + 1 ) NEW_LINE r = [ ] NEW_LINE k = 1 NEW_LINE for i in range ( 1 , n + 1 ) : if NEW_LINE a [ i ] == a [ i - 1 ] : k += 1 else : r . append ( k ) NEW_LINE k = 1 NEW_LINE print ( sum ( map ( lambda x : x * ( x + 1 ) // 2 , r ) ) ) NEW_LINE

def magical ( arr ) : curr = None NEW_LINE currn = 0 NEW_LINE ans = [ ] NEW_LINE for i in arr : if NEW_LINE curr != i : ans . append ( currn ) NEW_LINE currn = 1 NEW_LINE curr = i else : currn += 1 NEW_LINE ans . append ( currn ) NEW_LINE cnt = 0 NEW_LINE for i in ans : cnt += ( ( i ) * ( i + 1 ) ) // 2 NEW_LINE return cnt   a = input ( ) NEW_LINE lst = list ( map ( int , input ( ) . strip ( ) . split ( ) ) ) NEW_LINE print ( magical ( lst ) ) NEW_LINE

n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE tot = 0 NEW_LINE cur = 1 NEW_LINE for i in range ( len ( a ) - 1 ) : if NEW_LINE INDENT ( a [ i ] == a [ i + 1 ] ) : cur += 1 else : tot += ( cur * ( cur + 1 ) ) // 2 NEW_LINE DEDENT cur = 1 NEW_LINE tot += ( cur * ( cur + 1 ) ) // 2 NEW_LINE print ( tot ) NEW_LINE

n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = nif NEW_LINE n > 1 : i = 1 NEW_LINE while i < n : count = 0 NEW_LINE if a [ i ] == a [ i - 1 ] : count = 1 NEW_LINE while i <= n - 1 and a [ i ] == a [ i - 1 ] : i += 1 NEW_LINE count += 1 NEW_LINE i -= 1 NEW_LINE if count > 0 : ans += ( count ** 2 - count ) // 2 NEW_LINE i += 1 NEW_LINE print ( ans ) NEW_LINE


import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ;   public class Main {   public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BufferedWriter writer = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ;   int t = Integer . parseInt ( reader . readLine ( ) ) ;

import java . util . * ;   public class A_Tricky_Sum { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int q = sc . nextInt ( ) ; while ( q -- > 0 ) { int n = sc . nextInt ( ) ; long s = 0 ; int x = ( int ) ( Math . log ( n ) / Math . log ( 2 ) ) ; x ++ ;

import java . util . Arrays ; import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long t , a , b = 1 , sum ; t = scanner . nextLong ( ) ; for ( long i = 0 ; i < t ; i ++ ) { a = scanner . nextLong ( ) ; b = 1 ; sum = a * ( a + 1 ) / 2 ; while ( b <= a ) { sum -= 2 * b ; b *= 2 ; } System . out . println ( sum ) ; } } }

import java . io . * ; import java . util . * ;     public class Main { public static Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) , 640000 ) ) ; public static PrintWriter out = new PrintWriter ( System . out ) ;    public static void solve ( ) { int t = in . nextInt ( ) ; for ( int i = 0 ; i < t ; ++ i ) { int n = in . nextInt ( ) ; long totalSum = ( ( long ) n * ( n + 1 ) ) / 2 ; int maxPower = 0 ; while ( Math . pow ( 2 , maxPower ) <= n ) { maxPower ++ ; }   out . println ( totalSum - ( 2 * ( long ) ( Math . pow ( 2 , maxPower ) - 1 ) ) ) ; }   }   public static void main ( String args [ ] ) { solve ( ) ; out . close ( ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; public class er106b {

def power_of_num ( num ) : for i in range ( 1000 ) : yield num ** i     def sum_of_powers ( n , power ) : powers = power_of_num ( power ) power = next ( powers ) sum_of_powers = [ ] while n >= power : sum_of_powers . append ( power ) power = next ( powers ) return sum ( sum_of_powers )     def calculate_sum ( n , power ) : sum_of_pow = sum_of_powers ( n , power ) if n % 2 == 0 : normal_sum = n // 2 * ( n + 1 ) else : normal_sum = n // 2 * ( n + 1 ) + ( n + 1 ) // 2   tricky_sum = normal_sum - 2 * sum_of_pow print ( tricky_sum )     power = 2 t = int ( input ( ) ) for _ in range ( t ) : n = int ( input ( ) ) calculate_sum ( n , power ) NEW_LINE

for i in range ( int ( input ( ) ) ) : n = int ( input ( ) ) print ( n * ( n + 1 ) // 2 - ( 2 * sum ( 2 ** i for i in range ( len ( bin ( n ) [ 2 : ] ) ) ) ) ) NEW_LINE

cases = int ( input ( ) ) powers = set ( )   for i in range ( 32 ) : powers . add ( 2 ** i ) while cases : cases -= 1 num = int ( input ( ) )   ans = num * ( num + 1 ) // 2   for i in powers : if i <= num : ans -= 2 * i   print ( ans )     NEW_LINE

""" In ▁ this ▁ problem ▁ you ▁ are ▁ to ▁ calculate ▁ the ▁ sum ▁ of ▁ all ▁ integers ▁ from ▁ 1 ▁ to ▁ n , ▁ but ▁ you ▁ should ▁ take ▁ all ▁ powers ▁ of ▁ two ▁ with ▁ minus ▁ in ▁ the ▁ sum .  For ▁ example , ▁ for ▁ n  =  4 ▁ the ▁ sum ▁ is ▁ equal ▁ to ▁   -  1  -  2  +  3  -  4  =    -  4 , ▁ because ▁ 1 , ▁ 2 ▁ and ▁ 4 ▁ are ▁ 20 , ▁ 21 ▁ and ▁ 22 ▁ respectively .  Calculate ▁ the ▁ answer ▁ for ▁ t ▁ values ▁ of ▁ n . """ from math import floor , log   t = int ( input ( ) ) for x in range ( t ) : n = int ( input ( ) ) sum_to_n = n * ( n + 1 ) // 2 sum_pow_2 = ( 2 ** ( floor ( log ( n , 2 ) ) + 1 ) ) - 1 res = sum_to_n - 2 * sum_pow_2 print ( int ( res ) ) NEW_LINE

from math import log2   def f ( n ) : return 2 ** ( int ( log2 ( n ) ) + 1 ) - 1 def sum1 ( n ) : return ( n + 1 ) * n // 2 for i in range ( int ( input ( ) ) ) : n = int ( input ( ) ) print ( sum1 ( n ) - 2 * f ( n ) ) NEW_LINE


import java . util . Scanner ;   public class _0735CommentaryBoxes {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; long m = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long cost = 0 ; if ( n % m == 0 ) { System . out . println ( cost ) ; } else { cost += Math . min ( b * ( n % m ) , a * ( m - ( n % m ) ) ) ; System . out . println ( cost ) ; } }   }

import java . util . * ;   public class CodeForces990A { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; long n = input . nextLong ( ) ; long m = input . nextLong ( ) ; int a = input . nextInt ( ) ; int b = input . nextInt ( ) ; if ( n % m == 0 ) { System . out . println ( 0 ) ; } else { if ( n < m ) { System . out . println ( Math . min ( ( m - n ) * a , n * b ) ) ; } else { long count = n % m ; long x = m * ( n / m + 1 ) - n ; long min = ( long ) Math . min ( count * b , x * a ) ; System . out . println ( min ) ; } } } }

import com . sun . security . jgss . GSSUtil ;   import javax . swing . table . AbstractTableModel ; import java . io . * ; import java . util . * ; import java . util . concurrent . atomic . AtomicReferenceFieldUpdater ;

import java . util . Scanner ;   public class CommentaryBoxes { public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ; long n = in . nextLong ( ) , m = in . nextLong ( ) , d = n / m * m ; int a = in . nextInt ( ) , b = in . nextInt ( ) ;   in . close ( ) ; System . out . println ( n % m == 0 ? 0 : Math . min ( ( d + m - n ) * a , ( n - d ) * b ) ) ; } }

import java . util . Scanner ;   public class com_boxers { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; long m = sc . nextLong ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ;   if ( n % m == 0 ) { System . out . println ( "0" ) ; } else { if ( n > m ) { long div = n / m ; long temp = n - m * div ; long cost1 = temp * b ; div ++ ; long temp1 = m * div - n ; long cost2 = temp1 * a ; if ( cost1 > cost2 ) { System . out . println ( cost2 ) ; } else { System . out . println ( cost1 ) ; } } else { long cost1 = n * b ; long cost2 = ( m - n ) * a ; if ( cost1 > cost2 ) { System . out . println ( cost2 ) ; } else { System . out . println ( cost1 ) ; } } } } }

from sys import stdinn , m , a , b = map ( int , stdin . readline ( ) . split ( ) ) x = n % mprint ( min ( a * ( m - x ) , b * x ) ) NEW_LINE

n , m , a , b = map ( int , input ( ) . split ( ) ) print ( min ( ( m - n % m ) * a , n % m * b ) ) NEW_LINE

n , m , a , b = map ( int , input ( ) . split ( ) ) ans = min ( n % m * b , ( m - n % m ) * a ) print ( ans ) NEW_LINE


import java . io . * ; import java . util . * ; import java . lang . * ;   public class Rextester { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st0 = new StringTokenizer ( br . readLine ( ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; StringTokenizer st1 = new StringTokenizer ( br . readLine ( ) ) ; br . close ( ) ; int n = new Integer ( st0 . nextToken ( ) ) ; int m = new Integer ( st0 . nextToken ( ) ) ; int [ ] f = new int [ n + 1 ] ; int [ ] b = new int [ m + 1 ] ; int [ ] finverse = new int [ 100005 ] ; for ( int i = 0 ; i < m ; i ++ ) { b [ i ] = new Integer ( st1 . nextToken ( ) ) ; } Arrays . fill ( finverse , - 2 ) ; for ( int i = 0 ; i < n ; i ++ ) { f [ i ] = new Integer ( st . nextToken ( ) ) ; if ( finverse [ f [ i ] ] == - 2 ) { finverse [ f [ i ] ] = i + 1 ; } else { finverse [ f [ i ] ] = - 1 ; } } boolean flag = false ; StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < m ; i ++ ) { if ( finverse [ b [ i ] ] == - 1 ) { flag = true ; } else if ( finverse [ b [ i ] ] == - 2 ) { System . out . println ( " Impossible " ) ; return ; } else { sb . append ( finverse [ b [ i ] ] ) . append ( " ▁ " ) ; } } if ( flag ) { System . out . println ( " Ambiguity " ) ; return ; } else { System . out . println ( " Possible \n " + sb ) ; } } }

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

def mapin ( ) : return map ( int , input ( ) . split ( ) )   NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) f = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) b1 = set ( b ) f1 = set ( f ) u = 0 for i in b1 : if i not in f1 : print ( ' Impossible ' ) u = 1 breakif not u : d = { } for i in range ( n ) : if f [ i ] not in d : d [ f [ i ] ] = i + 1 else : d [ f [ i ] ] = - 1 w = [ ] v = 0 for i in b : if d [ i ] == - 1 : print ( ' Ambiguity ' ) v = 1 break else : w . append ( d [ i ] ) if not v : print ( ' Possible ' ) print ( * w ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) f = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) a = [ ] b1 = set ( b ) f1 = set ( f ) for i in b1 : if i not in f1 : print ( ' Impossible ' ) breakelse : nikita_pidor = { } for i in range ( n ) : if f [ i ] not in nikita_pidor : nikita_pidor [ f [ i ] ] = [ 1 , i ] else : nikita_pidor [ f [ i ] ] [ 0 ] += 1 for i in range ( m ) : if nikita_pidor [ b [ i ] ] [ 0 ] > 1 : print ( ' Ambiguity ' ) break a . append ( nikita_pidor [ b [ i ] ] [ 1 ] + 1 ) f [ nikita_pidor [ b [ i ] ] [ 1 ] ] = - 15 else : print ( ' Possible ' ) print ( * a ) NEW_LINE

from collections import Counter n , m = map ( int , input ( ) . split ( ) ) F = list ( map ( int , input ( ) . split ( ) ) ) B = list ( map ( int , input ( ) . split ( ) ) ) x = Counter ( F ) y = Counter ( B ) ok = Trueambi = Falseres = [ ] for i in y . keys ( ) : if x [ i ] == 0 : ok = False if x [ i ] >= 2 : ambi = Trued = dict ( ) for i in range ( len ( F ) ) : if F [ i ] in d . keys ( ) : continue else : d [ F [ i ] ] = i + 1 if ok == False : print ( " Impossible " ) elif ambi == True : print ( " Ambiguity " ) else : print ( " Possible " ) res = [ ] for i in range ( len ( B ) ) : res . append ( d [ B [ i ] ] ) print ( * res ) NEW_LINE

import sysimport mathinput = sys . stdin . readlinen , m = map ( int , input ( ) . split ( ) ) f = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) d = { } c = 0 for i in range ( n ) : x = f [ i ] if x in d : d [ x ] . append ( i )   else : d [ x ] = [ i ]   ans = [ ] for i in range ( m ) : x = b [ i ] if x in d : if len ( d [ x ] ) == 1 and c == 0 : ans . append ( d [ x ] [ 0 ] + 1 )   else : c = 1   else : c = 2 break   if c == 2 : print ( " Impossible " ) exit ( )   if c == 1 : print ( " Ambiguity " ) exit ( )   print ( " Possible " ) print ( * ans ) NEW_LINE


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

import sysfrom functools import lru_cache , cmp_to_keyfrom heapq import merge , heapify , heappop , heappush NEW_LINE


import java . util . Scanner ; import java . util . Vector ;   public class p902B { static Vector < Integer > [ ] list ; static boolean visited [ ] ; static int ans , color [ ] ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; createGraph ( n , sc ) ; for ( int i = 1 ; i <= n ; i ++ ) color [ i ] = sc . nextInt ( ) ; dfs ( 1 , 0 ) ; System . out . println ( ans ) ; } static void createGraph ( int n , Scanner sc ) { visited = new boolean [ n + 1 ] ; list = new Vector [ n + 1 ] ; color = new int [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) list [ i ] = new Vector < > ( ) ; for ( int i = 2 ; i <= n ; i ++ ) addEdges ( i , sc . nextInt ( ) ) ; } static void addEdges ( int i , int x ) { list [ i ] . add ( x ) ; list [ x ] . add ( i ) ; } static void dfs ( int i , int c ) { visited [ i ] = true ; if ( color [ i ] != c ) ans ++ ; for ( int x : list [ i ] ) if ( ! visited [ x ] ) dfs ( x , color [ i ] ) ; } }

import java . util . ArrayList ; import java . util . Scanner ;   public class Main { static int n ; static ArrayList < Integer > [ ] adj ; static int [ ] c ; static int sum = 1 ; static void dfs ( int prev , int u ) { if ( c [ u ] != c [ prev ] ) sum ++ ; for ( int v : adj [ u ] ) if ( v != prev ) dfs ( u , v ) ; }   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; adj = new ArrayList [ n ] ; for ( int i = 0 ; i < n ; i ++ ) adj [ i ] = new ArrayList < Integer > ( ) ; for ( int u = 1 ; u < n ; u ++ ) { int v = sc . nextInt ( ) - 1 ; adj [ u ] . add ( v ) ; adj [ v ] . add ( u ) ; } c = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) c [ i ] = sc . nextInt ( ) ; for ( int u : adj [ 0 ] ) dfs ( 0 , u ) ; System . out . println ( sum ) ; } }

n = int ( input ( ) ) p = list ( map ( int , input ( ) . split ( ) ) ) c = list ( map ( int , input ( ) . split ( ) ) ) step = 1 for i in range ( 1 , n ) : if c [ i ] != c [ p [ i - 1 ] - 1 ] : step += 1 print ( step ) NEW_LINE

import syssys . setrecursionlimit ( 100000 )   n = int ( input ( ) ) par = list ( map ( int , input ( ) . split ( ) ) ) kids = [ [ ] for _ in range ( n + 1 ) ] for i in range ( n - 1 ) : kids [ par [ i ] - 1 ] . append ( i + 1 ) c = list ( map ( int , input ( ) . split ( ) ) )   def dfs ( i , color ) : global par global kid global c ans = 0 if c [ i ] != color : ans = 1 for kid in kids [ i ] : ans += dfs ( kid , c [ i ] ) return ans   print ( dfs ( 0 , 0 ) ) NEW_LINE

n = int ( input ( ) ) p = list ( map ( int , input ( ) . split ( ) ) ) c = list ( map ( int , input ( ) . split ( ) ) )   colormap = [ 0 ] * ncount = 0 for i in range ( n ) : if ( i > 0 ) : colormap [ i ] = colormap [ p [ i - 1 ] - 1 ] if ( c [ i ] != colormap [ i ] ) : count += 1 colormap [ i ] = c [ i ] print ( count ) NEW_LINE

import syssys . setrecursionlimit ( 10 ** 9 ) from collections import defaultdict         def dfs ( nd ) : vis [ nd ] = 1 for i in graph [ nd ] : if vis [ i ] == 0 : if col [ i - 1 ] == col [ nd - 1 ] : dfs ( i ) else : q . append ( i )                                             for _ in range ( 1 ) : n = int ( input ( ) ) graph = defaultdict ( list ) l = list ( map ( int , input ( ) . split ( ) ) ) col = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 2 , n + 1 ) : graph [ i ] . append ( l [ i - 2 ] ) graph [ l [ i - 2 ] ] . append ( i ) vis = [ 0 ] * ( n + 1 ) q = [ 1 ] tc = 0 while ( q ) : tc += 1 dfs ( q . pop ( 0 ) ) print ( tc ) NEW_LINE


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

import java . util . Scanner ;   public class B { public static void main ( String args [ ] ) { Scanner cin = new Scanner ( System . in ) ; int n = Integer . parseInt ( cin . nextLine ( ) ) ; int zr = - 1 , zc = - 1 ; int m [ ] [ ] = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) { m [ i ] [ j ] = cin . nextInt ( ) ; if ( m [ i ] [ j ] == 0 ) { zr = i ; zc = j ; } } System . out . println ( solve ( m , n , zr , zc ) ) ; } private static long solve ( int [ ] [ ] m , int n , int zr , int zc ) { long cm = 0 , sol = - 1 ;   if ( n == 1 ) return n ;

def sum_row ( arr ) : ans = sum ( arr [ 0 ] ) for i in range ( 1 , len ( arr ) ) : if sum ( arr [ i ] ) != ans : return [ False ] return [ True , ans ] def sum_col ( arr ) : ans = None for i in range ( len ( arr ) ) : temp = 0 for j in range ( len ( arr [ 0 ] ) ) : temp += arr [ j ] [ i ] if ans == None : ans = temp else : if temp != ans : return [ False ] return [ True , ans ] def sum_diagonal ( arr ) : ans = 0 ans1 = 0 for i in range ( len ( arr ) ) : ans += arr [ i ] [ i ] ans1 += arr [ i ] [ len ( arr ) - i - 1 ] return [ True , ans ] if ans == ans1 else [ False ] def calculate_value ( arr , row ) : return sum ( arr [ row ] ) n = int ( input ( ) ) a = [ ] for i in range ( n ) : a . append ( list ( map ( int , input ( ) . split ( ) ) ) ) if n == 1 : print ( 1 ) exit ( ) flag = Falsefor i in range ( n ) : for j in range ( n ) : if a [ i ] [ j ] == 0 : if i != 0 : want = calculate_value ( a , i - 1 ) - sum ( a [ i ] ) else : want = calculate_value ( a , i + 1 ) - sum ( a [ i ] ) a [ i ] [ j ] = want flag = True break if flag : breakrow = sum_row ( a ) col = sum_col ( a ) dia = sum_diagonal ( a ) if row [ 0 ] and col [ 0 ] and dia [ 0 ] : if want <= 0 : print ( - 1 ) elif row [ 1 ] == col [ 1 ] == dia [ 1 ] : print ( want ) else : print ( - 1 ) else : print ( - 1 ) NEW_LINE

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

fast = lambda : stdin . readline ( ) . strip ( ) zzz = lambda : [ int ( i ) for i in fast ( ) . split ( ) ] z , zz = input , lambda : list ( map ( int , z ( ) . split ( ) ) ) szz , graph , mod , szzz = lambda : sorted ( zz ( ) ) , { } , 10 ** 9 + 7 , lambda : sorted ( zzz ( ) ) from re import * from sys import * from math import * from heapq import * from queue import * from bisect import * from string import * from itertools import * from collections import * from math import factorial as ffrom bisect import bisect as bsfrom bisect import bisect_left as bslfrom collections import Counter as ccfrom itertools import accumulate as acdef lcd ( xnum1 , xnum2 ) : return ( xnum1 * xnum2 // gcd ( xnum1 , xnum2 ) ) def output ( answer ) : stdout . write ( str ( answer ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class BusGame { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int x = Integer . parseInt ( st . nextToken ( ) ) ; int y = Integer . parseInt ( st . nextToken ( ) ) ;   int turn = 0 ;   int xToTake [ ] = { 0 , 1 , 2 } ; int yToTake [ ] = { 22 , 12 , 2 } ; turn : while ( true ) { if ( turn == 0 ) { for ( int i = 2 ; i >= 0 ; i -- ) { if ( x >= xToTake [ i ] && y >= yToTake [ i ] ) { x -= xToTake [ i ] ; y -= yToTake [ i ] ; turn = 1 ; continue turn ; } } break ; } else { for ( int i = 0 ; i <= 2 ; i ++ ) { if ( x >= xToTake [ i ] && y >= yToTake [ i ] ) { x -= xToTake [ i ] ; y -= yToTake [ i ] ; turn = 0 ; continue turn ; } } break ; } }   if ( turn == 0 ) pw . println ( " Hanako " ) ; else pw . println ( " Ciel " ) ;   pw . flush ( ) ; pw . close ( ) ; } }

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

x , y = map ( int , input ( ) . strip ( ) . split ( ) ) NEW_LINE

x , y = map ( int , input ( ) . split ( ) ) NEW_LINE cnt = 0 NEW_LINE while ( True ) : if NEW_LINE INDENT ( cnt % 2 == 0 ) : NEW_LINE DEDENT if ( x >= 2 and y >= 2 ) : x -= 2 NEW_LINE y -= 2 NEW_LINE cnt += 1 elif ( x >= 1 and y >= 12 ) : x -= 1 NEW_LINE y -= 12 NEW_LINE cnt += 1 elif ( y >= 22 ) : y -= 22 NEW_LINE cnt += 1 else : break else : if ( y >= 22 ) : y -= 22 NEW_LINE cnt += 1 elif ( x >= 1 and y >= 12 ) : x -= 1 NEW_LINE y -= 12 NEW_LINE cnt += 1 elif ( x >= 2 and y >= 2 ) : x -= 2 NEW_LINE y -= 2 NEW_LINE cnt += 1 else : breakprint ( " Ciel " if cnt % 2 == 1 else " Hanako " ) NEW_LINE

x , y = map ( int , input ( ) . split ( ) ) NEW_LINE c = 2 NEW_LINE while True : if NEW_LINE c % 2 == 0 : NEW_LINE if x >= 2 and y >= 2 : c = c + 1 NEW_LINE x = x - 2 NEW_LINE y = y - 2 NEW_LINE continue elif x >= 1 and y >= 12 : c = c + 1 NEW_LINE x = x - 1 NEW_LINE y = y - 12 NEW_LINE continue elif x >= 0 and y >= 22 : c = c + 1 NEW_LINE y = y - 22 NEW_LINE continue else : print ( " Hanako " ) NEW_LINE break NEW_LINE if c % 2 == 1 : if NEW_LINE x >= 0 and y >= 22 : c = c + 1 NEW_LINE y = y - 22 NEW_LINE continue elif x >= 1 and y >= 12 : c = c + 1 NEW_LINE x = x - 1 NEW_LINE y = y - 12 NEW_LINE continue elif x >= 2 and y >= 2 : c = c + 1 NEW_LINE x = x - 2 NEW_LINE y = y - 2 NEW_LINE continue else : print ( " Ciel " ) NEW_LINE break NEW_LINE

datos = input ( ) . split ( ) NEW_LINE monedas_cien = int ( datos [ 0 ] ) NEW_LINE monedas_diez = int ( datos [ 1 ] )   rondas_jugadas = min ( monedas_cien // 2 , monedas_diez // 24 ) NEW_LINE monedas_cien = monedas_cien - ( rondas_jugadas * 2 ) NEW_LINE monedas_diez = monedas_diez - ( rondas_jugadas * 24 )   maneras_sacar_cien = [ 2 , 1 , 0 ] NEW_LINE maneras_sacar_diez = [ 2 , 12 , 22 ]   ganando = ' Hanako ' NEW_LINE continua = Truei = 0 NEW_LINE while continua : if NEW_LINE i % 2 == 0 : j = 0 NEW_LINE while j < 3 : if NEW_LINE maneras_sacar_cien [ j ] <= monedas_cien and maneras_sacar_diez [ j ] <= monedas_diez : monedas_cien = monedas_cien - NEW_LINE INDENT maneras_sacar_cien [ j ] NEW_LINE DEDENT monedas_diez = monedas_diez - maneras_sacar_diez [ j ] NEW_LINE ganando = ' Ciel ' NEW_LINE break NEW_LINE j = j + 1 NEW_LINE if j == 3 : continua = False NEW_LINE break else : j = 0 NEW_LINE while j < 3 : if NEW_LINE maneras_sacar_cien [ 2 - j ] <= monedas_cien and maneras_sacar_diez [ 2 - j ] <= monedas_diez : monedas_cien = monedas_cien - NEW_LINE INDENT maneras_sacar_cien [ 2 - j ] NEW_LINE DEDENT monedas_diez = monedas_diez - maneras_sacar_diez [ 2 - j ] NEW_LINE ganando = ' Hanako ' NEW_LINE break NEW_LINE j = j + 1 NEW_LINE if j == 3 : continua = False NEW_LINE break NEW_LINE i = i + 1 NEW_LINE print ( ganando ) NEW_LINE

state = 1 NEW_LINE x , y = map ( int , input ( ) . split ( ) )   while True : state = 1 - state NEW_LINE if state == 0 : if NEW_LINE x >= 2 and y >= 2 : x -= 2 NEW_LINE y -= 2 NEW_LINE continue elif x >= 1 and y >= 12 : x -= 1 NEW_LINE y -= 12 NEW_LINE continue elif x >= 0 and y >= 22 : x -= 0 NEW_LINE y -= 22 NEW_LINE continue else : break elif state == 1 : NEW_LINE if x >= 0 and y >= 22 : x -= 0 NEW_LINE y -= 22 NEW_LINE continue elif x >= 1 and y >= 12 : x -= 1 NEW_LINE y -= 12 NEW_LINE continue elif x >= 2 and y >= 2 : x -= 2 NEW_LINE y -= 2 NEW_LINE continue else : break     print ( [ ' Hanako ' , ' Ciel ' ] [ state ] )     NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; System . out . println ( 2 * x > y ? ( ( - 1 ) + " ▁ " + ( - 1 ) ) : ( x + " ▁ " + x * 2 ) ) ; } } } }

import java . util . Scanner ; public class A1389 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int t = scanner . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int l = scanner . nextInt ( ) , r = scanner . nextInt ( ) ; if ( r == 2 && l == 1 ) { System . out . println ( l + " ▁ " + r ) ; continue ; } if ( ( r - l ) == 1 || l > r / 2 ) { System . out . println ( - 1 + " ▁ " + ( - 1 ) ) ; } else { if ( r % 2 == 0 ) { System . out . println ( r / 2 + " ▁ " + r ) ; } else { System . out . println ( ( r - 1 ) / 2 + " ▁ " + ( r - 1 ) ) ; } } } } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNextInt ( ) ) { int n = sc . nextInt ( ) ; while ( n -- > 0 ) { int l = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; if ( 2 * l <= r ) { System . out . printf ( " % d ▁ % d \n " , l , 2 * l ) ; } else { System . out . print ( " - 1 ▁ - 1 \n " ) ; } } } } }

import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { int t = in . nextInt ( ) ; for ( int i = 1 ; i <= t ; i ++ ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; if ( b < a * 2 ) { System . out . println ( " - 1" + " ▁ " + " - 1" ) ; } else { System . out . println ( a + " ▁ " + 2 * a ) ; } } } } }

import java . util . Scanner ; public class DigestThread { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int num1 , num2 ; num1 = sc . nextInt ( ) ; num2 = sc . nextInt ( ) ; if ( num1 * 2 > num2 ) System . out . println ( " - 1 ▁ - 1" ) ; else System . out . println ( num1 + " ▁ " + num1 * 2 ) ; } } }

for i in range ( int ( input ( ) ) ) : NEW_LINE INDENT m , n = map ( int , input ( ) . split ( ) ) NEW_LINE if n % m == 0 : NEW_LINE INDENT print ( m , n ) NEW_LINE DEDENT elif m * 2 <= n : NEW_LINE INDENT print ( m , m * 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( - 1 , - 1 ) NEW_LINE DEDENT DEDENT

a = int ( input ( ) ) NEW_LINE for i in range ( a ) : NEW_LINE INDENT l , r = ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if 2 * l > r : NEW_LINE INDENT print ( " - 1 ▁ - 1" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( str ( l ) + " ▁ " + str ( 2 * ( l ) ) ) NEW_LINE DEDENT DEDENT

for _ in range ( int ( input ( ) ) ) : NEW_LINE INDENT l , r = map ( int , input ( ) . split ( ) ) NEW_LINE if 2 * l <= r : NEW_LINE INDENT print ( l , 2 * l ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( - 1 , - 1 ) NEW_LINE DEDENT DEDENT

t = int ( input ( ) ) NEW_LINE for _ in range ( t ) : NEW_LINE INDENT l , r = map ( int , input ( ) . split ( ) ) NEW_LINE if ( r < 2 * l ) : NEW_LINE INDENT print ( " - 1 ▁ - 1" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( l , 2 * l ) NEW_LINE DEDENT DEDENT

t = int ( input ( ) ) NEW_LINE for i in range ( t ) : NEW_LINE INDENT l , r = map ( int , input ( ) . split ( ) ) NEW_LINE if l * 2 > r : NEW_LINE INDENT print ( - 1 , - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( l , l * 2 ) NEW_LINE DEDENT DEDENT


import java . io . * ; import java . util . * ;   public class Main {   static long res = 0 ; static int n , m ;   public static void main ( String [ ] args ) throws Exception { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( System . out ) ;

import java . util . Scanner ; public class Main { public static long pow ( long a , long n ) { if ( n == 0 ) return ( 1 ) ; long ls ; ls = pow ( a , n / 2 ) ; ls = ls * ls % 1000000007 ; if ( n % 2 == 0 ) { return ls ; } else { return ls * a % 1000000007 ; } } public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; long n , m , k ; n = reader . nextLong ( ) ; m = reader . nextLong ( ) ; k = reader . nextLong ( ) ; if ( ( ( n + m ) % 2 == 1 ) && ( k == - 1 ) ) System . out . println ( "0" ) ; else System . out . println ( pow ( pow ( 2 , ( n - 1 ) ) , m - 1 ) ) ; reader . close ( ) ; }   }

import java . io . * ; import java . util . * ; public class Main { public static void main ( String args [ ] ) { FastReader input = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int T = 1 ; while ( T -- > 0 ) { long n = input . nextLong ( ) ; long m = input . nextLong ( ) ; int k = input . nextInt ( ) ; if ( ( n + m ) % 2 == 1 && k == - 1 ) { out . println ( 0 ) ; } else { long mod = 1000000007l ; long val = power ( 2l , m - 1 , mod ) ; val = power ( val , n - 1 , mod ) ; out . println ( val ) ; } } out . close ( ) ; } public static long power ( long a , long b , long m ) { long res = 1l ; while ( b > 0l ) { if ( b % 2l != 0l ) { res = ( res % m * a % m ) % m ; } b = b / 2l ; a = ( a % m * a % m ) % m ; } return res ; } 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 ; } } }

MOD = 1000000007   def modpow ( a , b ) : res = 1 while b > 0 : if b % 2 == 1 : res = ( res * a ) % MOD a = ( a * a ) % MOD b >>= 1 return res % MOD   n , m , k = map ( int , input ( ) . split ( ) ) if ( k == - 1 and ( n % 2 != m % 2 ) ) : print ( 0 ) elif n == 1 or m == 1 : print ( 1 ) else : print ( modpow ( 2 , ( n - 1 ) * ( m - 1 ) ) % MOD ) NEW_LINE

def mod_pow ( a , b , m ) : if b == 0 : return 1 if b == 1 : return a % m tmp = mod_pow ( a , b // 2 , m ) tmp = ( tmp * tmp ) % m if b % 2 == 1 : tmp = ( tmp * a ) % m return tmp     mod = 1000000006 n , m , res = map ( int , input ( ) . split ( ) ) if m % 2 != n % 2 and res == - 1 : print ( 0 ) else : k = ( ( ( m - 1 ) % mod ) * ( ( n - 1 ) % mod ) ) % mod ans = mod_pow ( 2 , k , mod + 1 ) print ( ans ) NEW_LINE

n , m , k = map ( int , input ( ) . split ( ) ) if k == - 1 and n % 2 != m % 2 : print ( 0 ) else : print ( pow ( 2 , ( n - 1 ) * ( m - 1 ) , 10 ** 9 + 7 ) ) NEW_LINE

import sysinput = sys . stdin . readline     def list_input ( ) : return list ( map ( int , input ( ) . split ( ) ) )     def float_compare ( a , b ) : if abs ( a - b ) < float ( 1e-9 ) : return True else : return False     def sub_mod ( x , mod ) : x = x % mod if x < 0 : x += mod return x     def divisor ( n ) : i = 1 dv = [ ] while i * i <= n : if n % i == 0 : dv . append ( i ) if i * i != n : dv . append ( n // i ) i += 1   return dv     def binpow ( a , n ) : ans = 1 MOD = int ( 1e9 ) + 7 while n : if n & 1 : NEW_LINE


import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . HashMap ; import java . util . StringTokenizer ; import java . util . TreeSet ;   public class A { static PrintWriter out = new PrintWriter ( System . out ) ;   static int R , C , b [ ] [ ] ; static int rows [ ] [ ] ; static int [ ] uR , uC ; static int cols [ ] [ ] ; public static void main ( String [ ] args ) { FS in = new FS ( ) ; R = in . nextInt ( ) ; C = in . nextInt ( ) ; b = new int [ R ] [ C ] ; for ( int i = 0 ; i < R ; i ++ ) for ( int j = 0 ; j < C ; j ++ ) b [ i ] [ j ] = in . nextInt ( ) ;

from bisect import bisect_leftimport sysinput = sys . stdin . buffer . readline   n , m = map ( int , input ( ) . split ( ) ) a = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ]     yoko_less = [ [ 0 ] * m for i in range ( n ) ] yoko_more = [ [ 0 ] * m for i in range ( n ) ] for i in range ( n ) : yoko = sorted ( set ( a [ i ] ) ) for j in range ( m ) : idx = bisect_left ( yoko , a [ i ] [ j ] ) yoko_less [ i ] [ j ] = idx yoko_more [ i ] [ j ] = len ( yoko ) - idx - 1   tate_less = [ [ 0 ] * m for i in range ( n ) ] tate_more = [ [ 0 ] * m for i in range ( n ) ] for j in range ( m ) : tate = sorted ( set ( [ a [ i ] [ j ] for i in range ( n ) ] ) ) for i in range ( n ) : idx = bisect_left ( tate , a [ i ] [ j ] ) tate_less [ i ] [ j ] = idx tate_more [ i ] [ j ] = len ( tate ) - idx - 1 ans = [ [ 0 ] * m for i in range ( n ) ] for i in range ( n ) : for j in range ( m ) : less = max ( yoko_less [ i ] [ j ] , tate_less [ i ] [ j ] ) more = max ( yoko_more [ i ] [ j ] , tate_more [ i ] [ j ] ) ans [ i ] [ j ] = 1 + more + less   for res in ans : print ( * res ) NEW_LINE

import osimport sysfrom io import BytesIO , IOBase BUFSIZE = 8192 class FastIO ( IOBase ) : newlines = 0 def __init__ ( self , file ) : self . _fd = file . fileno ( ) self . buffer = BytesIO ( ) self . writable = " x " in file . mode or " r " not in file . mode self . write = self . buffer . write if self . writable else None def read ( self ) : while True : b = os . read ( self . _fd , max ( os . fstat ( self . _fd ) . st_size , BUFSIZE ) ) if not b : break ptr = self . buffer . tell ( ) self . buffer . seek ( 0 , 2 ) , self . buffer . write ( b ) , self . buffer . seek ( ptr ) self . newlines = 0 return self . buffer . read ( ) def readline ( self ) : while self . newlines == 0 : b = os . read ( self . _fd , max ( os . fstat ( self . _fd ) . st_size , BUFSIZE ) ) self . newlines = b . count ( b " \n " ) + ( not b ) ptr = self . buffer . tell ( ) self . buffer . seek ( 0 , 2 ) , self . buffer . write ( b ) , self . buffer . seek ( ptr ) self . newlines -= 1 return self . buffer . readline ( ) def flush ( self ) : if self . writable : os . write ( self . _fd , self . buffer . getvalue ( ) ) self . buffer . truncate ( 0 ) , self . buffer . seek ( 0 ) class IOWrapper ( IOBase ) : def __init__ ( self , file ) : self . buffer = FastIO ( file ) self . flush = self . buffer . flush self . writable = self . buffer . writable self . write = lambda s : self . buffer . write ( s . encode ( " ascii " ) ) self . read = lambda : self . buffer . read ( ) . decode ( " ascii " ) self . readline = lambda : self . buffer . readline ( ) . decode ( " ascii " ) sys . stdin , sys . stdout = IOWrapper ( sys . stdin ) , IOWrapper ( sys . stdout ) input = lambda : sys . stdin . readline ( ) . rstrip ( " \n " ) NEW_LINE


import java . util . * ; public class Practice { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ;   int arr [ ] = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } int count = 0 ; Arrays . sort ( arr ) ;   if ( m == 0 ) { System . out . println ( " YES " ) ; return ; }   if ( arr [ 0 ] == 1 || arr [ m - 1 ] == n ) { System . out . println ( " NO " ) ; } else { for ( int i = 1 ; i < m ; i ++ ) { if ( arr [ i - 1 ] + 1 == arr [ i ] ) { count ++ ; if ( count == 2 ) { System . out . println ( " NO " ) ; return ; } } else { count = 0 ; } }   System . out . println ( " YES " ) ; } } }

import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; import java . lang . Math ; public class Account { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] dirty = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { dirty [ i ] = sc . nextInt ( ) ; } Arrays . sort ( dirty ) ; if ( m == 0 ) { System . out . println ( " YES " ) ; return ; } if ( dirty [ 0 ] == 1 || dirty [ m - 1 ] == n ) { System . out . println ( " NO " ) ; return ; } for ( int i = 0 ; i < m - 2 ; i ++ ) { if ( dirty [ i ] + 1 == dirty [ i + 1 ] ) { if ( dirty [ i + 1 ] + 1 == dirty [ i + 2 ] ) { System . out . println ( " NO " ) ; return ; } } } System . out . println ( " YES " ) ; } }

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

import java . util . * ; public class PetyaandStaircases { public static void main ( String arg [ ] ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int flag = 0 ; long [ ] ar = new long [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { ar [ i ] = sc . nextLong ( ) ; if ( ar [ i ] == 1 || ar [ i ] == n ) flag = 1 ; }   if ( flag == 1 ) { System . out . println ( " NO " ) ; System . exit ( 0 ) ; } Arrays . sort ( ar ) ; int count = 1 ; for ( int i = 1 ; i < m ; i ++ ) { if ( ar [ i ] - ar [ i - 1 ] == 1 ) count ++ ; else count = 1 ;   if ( count == 3 ) { System . out . println ( " NO " ) ; System . exit ( 0 ) ; } }    System . out . println ( " YES " ) ;     }   }

n , m = map ( int , input ( ) . split ( ) ) if m == 0 : print ( " YES " ) exit ( ) else : D = list ( map ( int , input ( ) . split ( ) ) ) D . sort ( ) if m == 1 : if D [ 0 ] != 1 and D [ 0 ] != n : print ( " YES " ) else : print ( " NO " ) else : if D [ 0 ] == 1 or D [ - 1 ] == n : print ( " NO " ) exit ( )   for i in range ( m - 2 ) :   if D [ i ] - D [ i + 1 ] == - 1 and D [ i + 1 ] - D [ i + 2 ] == - 1 : print ( " NO " ) exit ( ) print ( " YES " )             NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) if m == 0 : print ( " YES " ) exit ( ) a = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) if a [ 0 ] == 1 or a [ - 1 ] == n : print ( " NO " ) exit ( ) x = 0 for i in range ( m - 1 ) : if a [ i ] + 1 == a [ i + 1 ] : x += 1 if x == 2 : print ( " NO " ) exit ( ) else : x = 0 print ( " YES " ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) if m : l = list ( map ( int , input ( ) . split ( ) ) ) if not m : print ( " YES " ) exit ( ) if 1 in l or n in l : print ( " NO " ) exit ( ) l . sort ( ) for i in range ( len ( l ) - 2 ) :   if l [ i ] + 1 == l [ i + 1 ] and l [ i + 1 ] + 1 == l [ i + 2 ] : print ( " NO " ) exit ( )   print ( " YES " ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) f = True   if not m == 0 : s = sorted ( [ int ( i ) for i in input ( ) . split ( ) ] )   if s [ 0 ] == 1 or s [ m - 1 ] == n : f = False else : for i in range ( m - 2 ) : if s [ i ] + 2 == s [ i + 1 ] + 1 == s [ i + 2 ] : f = False   print ( ' YES ' if f else ' NO ' ) NEW_LINE

R = lambda : map ( int , input ( ) . split ( ) ) n , m = R ( ) d = sorted ( R ( ) ) if m > 0 else [ 0 ] print ( " NO " if d [ 0 ] == 1 or d [ - 1 ] == n or any ( d [ i + 2 ] - d [ i ] < 3 for i in range ( m - 2 ) ) else " YES " ) NEW_LINE


import java . util . * ; import java . io . * ; import java . math . * ;     public class B {   private static long INF = 2000000000000000000L , M = 1000000007 , MM = 998244353 ; private static int N = 0 ;   public static void process ( ) throws IOException {   int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; String str = sc . next ( ) ; int [ ] arr = new int [ n ] ; arr [ 0 ] = str . charAt ( 0 ) == '0' ? 1 : - 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( str . charAt ( i ) == '1' ) { arr [ i ] = arr [ i - 1 ] - 1 ; } else { arr [ i ] = arr [ i - 1 ] + 1 ; } } int last = arr [ n - 1 ] ; int count = 0 ; if ( x == 0 ) count ++ ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == x && last == 0 ) { out . println ( - 1 ) ; return ; } if ( arr [ i ] == x ) { count ++ ; continue ; } if ( last == 0 ) { continue ; } int curr = arr [ i ] ; int val = x - curr ; if ( Math . abs ( val ) % Math . abs ( last ) == 0 ) { val /= last ; if ( val / Math . abs ( val ) == - 1 ) { continue ; } else { count ++ ; } } } println ( count ) ;   }

import java . math . * ; import java . util . * ; import java . io . * ;   public class CFA { BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; private static final long MOD = 1000L * 1000L * 1000L + 7 ; private static final int [ ] dx = { 0 , - 1 , 0 , 1 } ; private static final int [ ] dy = { 1 , 0 , - 1 , 0 } ; private static final String yes = " Yes " ; private static final String no = " No " ;   void solve ( ) { int T = nextInt ( ) ;

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

import sys , os , iofrom collections import defaultdict NEW_LINE

import sys , os , iodef rs ( ) : return sys . stdin . readline ( ) . rstrip ( ) def ri ( ) : return int ( sys . stdin . readline ( ) ) def ria ( ) : return list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) def ws ( s ) : sys . stdout . write ( s + ' \n ' ) def wi ( n ) : sys . stdout . write ( str ( n ) + ' \n ' ) def wia ( a ) : sys . stdout . write ( ' ▁ ' . join ( [ str ( x ) for x in a ] ) + ' \n ' ) import math , datetime , functools , itertools , operator , bisect , fractions , statisticsfrom collections import deque , defaultdict , OrderedDict , Counterfrom fractions import Fractionfrom decimal import Decimalfrom sys import stdoutfrom heapq import heappush , heappop , heapify , _heapify_max , _heappop_max , nsmallest , nlargest NEW_LINE

def solve ( ) : n , x = map ( int , input ( ) . split ( ) ) s = input ( ) cnt = [ 0 for i in range ( n ) ] prev = 0 for i in range ( n ) : if s [ i ] == "0" : cnt [ i ] = prev + 1 prev = cnt [ i ] else : cnt [ i ] = prev - 1 prev = cnt [ i ] ans = 0 increase = cnt [ - 1 ] for i in range ( n ) : if increase != 0 and ( x - cnt [ i ] ) % increase == 0 : if ( cnt [ i ] < x and increase <= 0 ) : continue elif ( cnt [ i ] > x and increase >= 0 ) : continue else : ans += 1 if cnt [ - 1 ] == 0 : if x in cnt : print ( - 1 ) else : if x != 0 : print ( 0 ) else : print ( 1 ) else : if ans == 0 and x == 0 : print ( 1 ) else : if x == 0 : print ( ans + 1 ) else : print ( ans ) for i in range ( int ( input ( ) ) ) : solve ( ) NEW_LINE

import sys , math , itertoolsfrom collections import Counter , deque , defaultdictfrom bisect import bisect_left , bisect_right from heapq import heappop , heappush , heapify , nlargestmod = 10 ** 9 + 7 INF = float ( ' inf ' ) def inp ( ) : return int ( sys . stdin . readline ( ) ) def inpl ( ) : return list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) for _ in range ( inp ( ) ) : n , X = inpl ( ) s = list ( sys . stdin . readline ( ) ) ; s = s [ : n ] cnt = [ - 1 ] * n now = 0 for i , x in enumerate ( s ) : if x == '0' : now += 1 else : now -= 1 cnt [ i ] = now las = now if las == 0 : if X == 0 or cnt . count ( X ) : print ( - 1 ) else : print ( 0 ) continue res = 0 for i , x in enumerate ( cnt ) : now = X - x if now * las < 0 : continue if abs ( now ) % abs ( las ) == 0 : res += 1 if X == 0 : res += 1 print ( res ) NEW_LINE


import java . util . * ;   public class AprilFoolsDayPrank_A { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String a = in . next ( ) , b = in . next ( ) ; String A [ ] = new String [ a . length ( ) / 2 ] ; String B [ ] = new String [ b . length ( ) / 2 ] ; int k = 0 ; Arrays . fill ( A , " " ) ; Arrays . fill ( B , " " ) ; for ( int i = 0 ; i < a . length ( ) ; i ++ ) { A [ k ] += a . charAt ( i ) ; B [ k ] += b . charAt ( i ) ; if ( i % 2 != 0 ) k ++ ; } int As = 0 , Bs = 0 ; for ( int i = 0 ; i < A . length ; i ++ ) { if ( A [ i ] . equals ( B [ i ] ) ) continue ; else { if ( A [ i ] . equals ( " ( ) " ) ) { if ( B [ i ] . equals ( " [ ] " ) ) Bs ++ ; else if ( B [ i ] . equals ( "8 < " ) ) As ++ ; } else if ( A [ i ] . equals ( " [ ] " ) ) { if ( B [ i ] . equals ( " ( ) " ) ) As ++ ; else if ( B [ i ] . equals ( "8 < " ) ) Bs ++ ; } else if ( A [ i ] . equals ( "8 < " ) ) { if ( B [ i ] . equals ( " [ ] " ) ) As ++ ; else if ( B [ i ] . equals ( " ( ) " ) ) Bs ++ ; } } } if ( As > Bs ) System . out . println ( " TEAM ▁ 1 ▁ WINS " ) ; else if ( Bs == As ) System . out . println ( " TIE " ) ; else System . out . println ( " TEAM ▁ 2 ▁ WINS " ) ; } }

import java . io . FileInputStream ; import java . util . Scanner ;   public class Project_01 {   public static void main ( String [ ] args ) { try {

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . BufferedReader ; import java . io . FileReader ; 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 ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class TaskA { public void solve ( int testNumber , Scanner sc , PrintWriter out ) { char [ ] s1 = sc . next ( ) . toCharArray ( ) ; char [ ] s2 = sc . next ( ) . toCharArray ( ) ; int res = 0 ; for ( int i = 0 ; i < s1 . length ; i += 2 ) if ( s1 [ i ] == ' [ ' ) { if ( s2 [ i ] == '8' ) res ++ ; else if ( s2 [ i ] == ' ( ' ) res -- ; } else if ( s1 [ i ] == '8' ) { if ( s2 [ i ] == ' ( ' ) res ++ ; else if ( s2 [ i ] == ' [ ' ) res -- ; } else { if ( s2 [ i ] == ' [ ' ) res ++ ; else if ( s2 [ i ] == '8' ) res -- ; } out . println ( res < 0 ? " TEAM ▁ 1 ▁ WINS " : res > 0 ? " TEAM ▁ 2 ▁ WINS " : " TIE " ) ; }   }   static class Scanner { StringTokenizer st ; BufferedReader br ;   public Scanner ( InputStream s ) { br = new BufferedReader ( new InputStreamReader ( s ) ) ; }   public Scanner ( FileReader f ) { br = new BufferedReader ( f ) ; }   public String next ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { } return st . nextToken ( ) ; }   } }

import java . util . * ;   public class AprilFool {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t1 = 0 , t2 = 0 ; String a1 = sc . next ( ) ; String a2 = sc . next ( ) ; String a = "8 < " ; String b = " [ ] " ; String c = " ( ) " ; for ( int i = 0 ; i < a1 . length ( ) ; i += 2 ) { if ( a1 . substring ( i , i + 2 ) . equals ( a ) && a2 . substring ( i , i + 2 ) . equals ( b ) ) t1 ++ ; else if ( a2 . substring ( i , i + 2 ) . equals ( a ) && a1 . substring ( i , i + 2 ) . equals ( b ) ) t2 ++ ; else if ( a1 . substring ( i , i + 2 ) . equals ( b ) && a2 . substring ( i , i + 2 ) . equals ( c ) ) t1 += 1 ; else if ( a2 . substring ( i , i + 2 ) . equals ( b ) && a1 . substring ( i , i + 2 ) . equals ( c ) ) t2 += 1 ; else if ( a1 . substring ( i , i + 2 ) . equals ( c ) && a2 . substring ( i , i + 2 ) . equals ( a ) ) t1 += 1 ; else if ( a2 . substring ( i , i + 2 ) . equals ( c ) && a1 . substring ( i , i + 2 ) . equals ( a ) ) t2 += 1 ; } if ( t1 > t2 ) System . out . println ( " TEAM ▁ 1 ▁ WINS " ) ; else if ( t2 > t1 ) System . out . println ( " TEAM ▁ 2 ▁ WINS " ) ; else System . out . println ( " TIE " ) ;   } }

x = input ( ) y = input ( ) t1 , t2 = 0 , 0 i = 0 while i < len ( x ) : a = x [ i : i + 2 ] NEW_LINE

a = input ( ) b = input ( ) d = 0 s = 0 for i in range ( 0 , len ( a ) , 2 ) : if a [ i ] == " [ " : if b [ i ] == " ( " : s = s + 1 elif b [ i ] == "8" : NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class Petr_and_a_Combination_Lock { private static class InputReader { private final BufferedReader reader ; private StringTokenizer tokenizer ;   public InputReader ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; }   public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { tokenizer = new StringTokenizer ( readLine ( ) ) ; } return tokenizer . nextToken ( ) ; }   public String readLine ( ) { String line ; try { line = reader . readLine ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } return line ; } } static boolean isValid ( int n , int [ ] num ) { int x , limit = 1 << n ; for ( int i = 0 ; i < limit ; i ++ ) { x = 0 ; for ( int j = 0 ; j < n ; j ++ ) { x += ( ( i & ( 1 << j ) ) == 0 ) ? num [ j ] : - num [ j ] ; } if ( x % 360 == 0 ) return true ;   } return false ; } public static void main ( String [ ] args ) { InputReader sc = new InputReader ( System . in ) ; int t = sc . nextInt ( ) ; int [ ] num = new int [ t ] ; for ( int i = 0 ; i < t ; i ++ ) num [ i ] = sc . nextInt ( ) ; System . out . println ( isValid ( t , num ) ? " YES " : " NO " ) ; } }

import java . util . Arrays ; import java . util . Scanner ; import java . util . Vector ;   public class Main {   public static void main ( String [ ] args ) {   Scanner scan = new Scanner ( System . in ) ;   int n = scan . nextInt ( ) ;   int [ ] [ ] dp = new int [ ( int ) Math . pow ( 2 , n ) ] [ n + 1 ] ;   int [ ] a = new int [ n ] ;   String can = " no " ;   for ( int i = 0 ; i < n ; i ++ ) {   a [ i ] = scan . nextInt ( ) ;   }   for ( int i = 0 ; i < Math . pow ( 2 , n ) ; i ++ ) {   int mask = i ;   dp [ i ] [ 0 ] = 0 ;   for ( int j = 1 ; j <= n ; j ++ ) {   if ( mask % 2 == 1 ) {   dp [ i ] [ j ] = dp [ i ] [ j - 1 ] + a [ j - 1 ] ;   }   else {   dp [ i ] [ j ] = dp [ i ] [ j - 1 ] - a [ j - 1 ] ;   }   mask /= 2 ;   }   if ( dp [ i ] [ n ] % 360 == 0 ) {   can = " yes " ;   break ;   }   }   System . out . println ( can ) ;   }   }

import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sca = new Scanner ( System . in ) ; int t = sca . nextInt ( ) ; int [ ] a = new int [ ( int ) Math . pow ( 2 , 15 ) ] ; while ( t -- != 0 ) { int k = sca . nextInt ( ) ; if ( a [ 0 ] == 0 ) a [ ++ a [ 0 ] ] = k ; else { int temp = a [ 0 ] ; for ( int i = temp / 2 + 1 ; i <= temp ; i ++ ) { a [ ++ a [ 0 ] ] = a [ i ] - k ; a [ ++ a [ 0 ] ] = a [ i ] + k ; } } } for ( int i = a [ 0 ] ; i >= a [ 0 ] / 2 + 1 ; i -- ) { if ( a [ i ] == 0 || a [ i ] % 360 == 0 ) { System . out . println ( " YES " ) ; break ; } if ( i == a [ 0 ] / 2 + 1 ) { System . out . println ( " NO " ) ; } } } }

import sysdef f ( i , s ) : if i == n : if s % 360 == 0 : print ( " YES " ) sys . exit ( ) return f ( i + 1 , s + b [ i ] ) f ( i + 1 , s - b [ i ] ) n = int ( input ( ) ) b = [ ] for i in range ( n ) : b . append ( int ( input ( ) ) ) f ( 0 , 0 ) print ( " NO " )   NEW_LINE


import java . util . Scanner ;   public class nk { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; int ans = 0 ; boolean gone = false ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i + 1 < s . length ( ) && s . charAt ( i ) == ' V ' && s . charAt ( i + 1 ) == ' K ' ) { i ++ ; ans ++ ; } else { if ( ! gone ) {   if ( i == s . length ( ) - 2 && s . charAt ( i ) == ' V ' && s . charAt ( i + 1 ) == ' V ' ) { ans ++ ; break ; } else if ( i + 1 < s . length ( ) && i == 0 && s . charAt ( 0 ) == ' K ' && s . charAt ( 1 ) == ' K ' ) { ans ++ ; i ++ ; gone = true ; } else if ( i + 2 < s . length ( ) && s . charAt ( i ) == ' V ' && s . charAt ( i + 1 ) == ' V ' && s . charAt ( i + 2 ) == ' V ' ) { ans ++ ; gone = true ; } else if ( i - 1 >= 0 && i + 1 < s . length ( ) && s . charAt ( i ) == ' K ' && s . charAt ( i + 1 ) == ' K ' && s . charAt ( i - 1 ) == ' K ' ) { ans ++ ; gone = true ; } } } } println ( ans ) ; } public static void print ( Object ob ) { System . out . print ( ob ) ; } public static void println ( ) { print ( ' \n ' ) ; } public static void println ( Object ob ) { print ( ob ) ; println ( ) ; } }

s = input ( ) a = [ s . count ( ' VK ' ) ] for i in range ( len ( s ) ) : if s [ i ] == ' V ' : x = s [ : i ] + ' K ' + s [ i + 1 : ] elif s [ i ] == ' K ' : x = s [ : i ] + ' V ' + s [ i + 1 : ] a . append ( x . count ( ' VK ' ) ) print ( max ( a ) ) NEW_LINE

import sys   arr = list ( sys . stdin . readline ( ) . rstrip ( ) ) st = [ ] ans = 0 idx = 0 while idx < len ( arr ) - 1 : if arr [ idx ] + arr [ idx + 1 ] == ' VK ' : idx += 2 ans += 1 else : st . append ( ( arr [ idx ] , idx ) ) idx += 1 if idx == len ( arr ) - 1 : st . append ( ( arr [ idx ] , idx ) ) can = Falsefor i in range ( len ( st ) - 1 ) : if st [ i ] [ 0 ] == st [ i + 1 ] [ 0 ] : if abs ( st [ i ] [ 1 ] - st [ i + 1 ] [ 1 ] ) == 1 : can = True breakprint ( ans + 1 if can else ans ) NEW_LINE

s = input ( ) a = s . count ( " VK " ) s = s . replace ( " VK " , " ▁ " ) if " VV " in s or " KK " in s : a += 1 print ( a )   NEW_LINE

'''  Welcome ▁ to ▁ GDB ▁ Online . GDB ▁ online ▁ is ▁ an ▁ online ▁ compiler ▁ and ▁ debugger ▁ tool ▁ for ▁ C , ▁ C + + , ▁ Python , ▁ Java , ▁ PHP , ▁ Ruby , ▁ Perl , C # , ▁ VB , ▁ Swift , ▁ Pascal , ▁ Fortran , ▁ Haskell , ▁ Objective - C , ▁ Assembly , ▁ HTML , ▁ CSS , ▁ JS , ▁ SQLite , ▁ Prolog . Code , ▁ Compile , ▁ Run ▁ and ▁ Debug ▁ online ▁ from ▁ anywhere ▁ in ▁ world .   ''' c = input ( ) x = c . count ( " VK " ) c = c . replace ( " VK " , " O " ) if " VV " in c or " KK " in c : x = x + 1 ; print ( x ) NEW_LINE

""" ▁ ▁ ▁ ▁ Vicious ▁ Keyboard """ import syss = input ( ) count = s . count ( ' VK ' ) i = 0 for i in range ( len ( s ) - 1 ) : if ( s [ i ] == ' K ' and s [ i + 1 ] == ' K ' ) : if ( i == 0 ) : count += 1 break elif ( i > 0 ) : if ( s [ i - 1 ] == ' K ' ) : count += 1 break elif ( s [ i ] == ' V ' and s [ i + 1 ] == ' V ' ) : try : if ( s [ i + 2 ] == ' V ' ) : count += 1 break except ( IndexError ) : count += 1 breakprint ( count ) NEW_LINE


import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; }   void run ( FastScanner in , PrintWriter out ) {

import java . util . * ; import java . io . * ; public class File { public static class FastScanner { BufferedReader br ; StringTokenizer st ; public FastScanner ( ) { 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 ( ) ) ; } } public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; String s = sc . next ( ) ; Deque < Integer > deque = new ArrayDeque < > ( ) ; int L = 0 ; int N = s . length ( ) ; boolean isPossible = true ; for ( int i = N - 1 ; i >= 0 ; i - - ) { if ( s . charAt ( i ) == ' ( ' ) { L + + ; } else if ( s . charAt ( i ) == ' ) ' ) { L - - ; } else { L - - ; deque . addFirst ( 1 ) ; } // Lefts must be paired up , or else it ' s not possible . if ( L > 0 ) { if ( deque . isEmpty ( ) ) { isPossible = false ; break ; } else { // Add the needed right to the leftmost right . int R = deque . pollFirst ( ) ; deque . addFirst ( R + 1 ) ; L - - ; } } } if ( L != 0 ) { isPossible = false ; } if ( isPossible ) { if ( deque . size ( ) == 0 ) { out . println ( 0 ) ; } else { for ( int right : deque ) { out . println ( right ) ; } } } else { out . println ( - 1 ) ; } out . close ( ) ; } } NEW_LINE

s = input ( ) c = 0 ; t = s . rfind ( ' # ' ) ans = [ ] ; b = Truefor i in range ( t ) : if s [ i ] == ' ( ' : c += 1 elif s [ i ] == ' ) ' : c -= 1 else : c -= 1 ans . append ( 1 ) if c < 0 : b = False breakm = cfor i in range ( t + 1 , len ( s ) ) : if s [ i ] == ' ( ' : c += 1 else : c -= 1 m = min ( m , c )   if b and m > 0 and m == c : ans . append ( m ) print ( * ans , sep = ' \n ' ) else : print ( - 1 ) NEW_LINE

s = input ( ) n = len ( s ) p , curr = n - 1 , 0 while s [ p ] != ' # ' : if s [ p ] == ' ) ' : curr += 1 else : curr -= 1 p -= 1 if curr < 0 : print ( - 1 ) exit ( ) cnt_hash , curr = s . count ( ' # ' ) , 0 for i in range ( p ) : if s [ i ] == ' ( ' : curr += 1 else : curr -= 1 if curr < 0 : print ( - 1 ) exit ( ) res = s . count ( ' ( ' ) - s . count ( ' ) ' ) - ( cnt_hash - 1 ) if res <= 0 : print ( - 1 ) exit ( ) cnt_hash -= 1 print ( ' \n ' . join ( '1' * cnt_hash ) ) print ( s . count ( ' ( ' ) - s . count ( ' ) ' ) - cnt_hash ) NEW_LINE


import java . io . * ; import java . math . BigInteger ; import java . util . * ;    public class Equal { static class pair implements Comparable < pair > { int v , w ;   public pair ( int v , int w ) { this . v = v ; this . w = w ; }   @ Override public int compareTo ( pair o ) { if ( v == o . v ) return w - o . w ; return o . v - v ; } }   static ArrayList < Integer > [ ] tree ; static int timer = 0 ; static int [ ] timein ; static int [ ] timeout ; static int [ ] [ ] powerParent ; static int [ ] depth ; static int [ ] [ ] minWeight ;   static void dfs ( int u , int parent ) {   timein [ u ] = ++ timer ;

import java . io . * ; import java . math . BigInteger ; import java . util . * ;   public class D { static class pair implements Comparable < pair > { long f ; int s ;   public pair ( long x , int y ) { f = x ; s = y ; }   @ Override public int compareTo ( pair o ) { if ( o . f == f ) return s - o . s ; else return ( f - o . f ) > 0 ? 1 : - 1 ;   } }   static class myInt implements Comparable < myInt > { long n ;   public myInt ( long x ) { n = x ; }   @ Override public int compareTo ( myInt o ) { if ( o . n - n > 0 ) return 1 ; if ( o . n == n ) return 0 ; return - 1 ;   } }   public static void main ( String [ ] args ) throws IOException {

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . TreeSet ;    public class Main { static int n , m ; static int l , r , x ; static int [ ] k ; static TreeSet < Integer > K , sK , erase ; public static void main ( String [ ] args ) throws IOException { String [ ] data ; BufferedReader f = new BufferedReader ( new InputStreamReader ( System . in ) ) ; data = f . readLine ( ) . split ( " ▁ " ) ; n = Integer . valueOf ( data [ 0 ] ) ; K = new TreeSet < > ( ) ; for ( int i = 0 ; i < n ; ++ i ) { K . add ( i + 1 ) ; } k = new int [ n ] ; m = Integer . valueOf ( data [ 1 ] ) ; for ( int i = 0 ; i < m ; ++ i ) { data = f . readLine ( ) . split ( " ▁ " ) ; l = Integer . valueOf ( data [ 0 ] ) ; r = Integer . valueOf ( data [ 1 ] ) ; x = Integer . valueOf ( data [ 2 ] ) ; sK = ( TreeSet < Integer > ) K . subSet ( l , true , r , true ) ; erase = new TreeSet < > ( ) ; for ( int ki : sK ) { if ( ki != x ) { if ( k [ ki - 1 ] == 0 ) { k [ ki - 1 ] = x ; erase . add ( ki ) ;

n , m = map ( int , input ( ) . split ( ) ) ans = [ 0 ] * ( n + 10 ) mx = list ( range ( n + 10 ) )   def find ( st ) : if mx [ st ] != st : mx [ st ] = find ( mx [ st ] ) return mx [ st ]     for _ in range ( m ) : l , r , x = map ( int , input ( ) . split ( ) ) xt = find ( l ) while xt < x : if xt != x : ans [ xt ] = x mx [ xt ] = x xt = find ( xt + 1 ) xt = find ( x + 1 ) while xt <= r : if xt != x : ans [ xt ] = x mx [ xt ] = r + 1 xt = find ( xt + 1 ) print ( * ans [ 1 : n + 1 ] ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class CF0928B_Chat { static class Scanner { BufferedReader br ; StringTokenizer st ;   public Scanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; }   }   static void print ( Object b ) { System . out . print ( b ) ; }   static void println ( Object b ) { System . out . println ( b ) ; }   static void println ( ) { System . out . println ( ) ; }   public static void main ( String [ ] args ) {

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

import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ;   public class ZadachaB { static List < Integer > messages ; static int n ; static int k ;   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; k = sc . nextInt ( ) ; sc . nextLine ( ) ; messages = new ArrayList < > ( ) ; messages . add ( Integer . MIN_VALUE ) ;   for ( int i = 1 ; i <= n ; i ++ ) { int num = sc . nextInt ( ) ; if ( num == 0 ) { messages . add ( getC ( i ) ) ; } else { messages . add ( getCNonZero ( i , num ) ) ; } if ( i != n ) System . out . print ( messages . get ( i ) + " ▁ " ) ; else System . out . print ( messages . get ( i ) ) ; } }   private static int getC ( int x ) { if ( k == 0 ) return 1 ; int l = Math . max ( 1 , x - k ) ; int r = Math . min ( n , x + k ) ; return r - l + 1 ; }   private static int getCNonZero ( int x , int z ) { int ans = messages . get ( z ) ; int lZan = Math . max ( 1 , z - k ) ; int rZan = Math . min ( n , z + k ) ;   int l = Math . max ( 1 , x - k ) ; int r = Math . min ( n , x + k ) ;   if ( rZan >= l ) l = rZan + 1 ;   return ans + ( r - l ) + 1 ; } }

n , k = map ( int , input ( ) . split ( " ▁ " ) ) l = list ( map ( int , input ( ) . split ( " ▁ " ) ) ) dp = [ ] for i , x in enumerate ( l ) : if x == 0 : z = min ( i + k + 1 , n ) - max ( 0 , i - k ) else : z = dp [ x - 1 ] + max ( 0 , min ( i + k + 1 , n ) - max ( i - k , x + k ) ) dp . append ( z ) print ( * dp ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) dp = [ 0 ] * ndp [ 0 ] = min ( m + 1 , n ) print ( dp [ 0 ] , end = " ▁ " ) for i in range ( 1 , n ) : if l [ i ] == 0 : v2 = min ( n - 1 , i + m ) v1 = max ( 0 , i - m ) dp [ i ] = v2 - v1 + 1 print ( dp [ i ] , end = " ▁ " ) continue   v2 = min ( n - 1 , i + m ) v1 = max ( 0 , i - m ) v3 = max ( 0 , l [ i ] - 1 - m ) v4 = min ( n - 1 , l [ i ] - 1 + m ) dp [ i ] = dp [ l [ i ] - 1 ] + ( v2 - v1 + 1 ) - max ( 0 , min ( v2 , v4 ) - max ( v1 , v3 ) + 1 ) print ( dp [ i ] , end = " ▁ " ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) p = list ( map ( int , input ( ) . split ( ) ) ) arr_d = [ 0 for _ in range ( n ) ] for i in range ( len ( p ) ) : l_space = k if i - k >= 0 else i r_space = k if i + k < len ( p ) else abs ( len ( p ) - i - 1 ) arr_d [ i ] += l_space + r_space + 1 if p [ i ] != 0 : arr_d [ i ] += arr_d [ p [ i ] - 1 ] link_r_pos = p [ i ] - 1 + k if p [ i ] - 1 + k < len ( p ) else len ( p ) - 1 now_l_pos = i - l_space if link_r_pos >= now_l_pos : arr_d [ i ] -= abs ( link_r_pos - now_l_pos ) + 1 print ( * arr_d ) NEW_LINE

n , k = list ( map ( int , input ( ) . split ( ) ) ) a = list ( map ( int , input ( ) . split ( ) ) ) dp = [ 0 for _ in range ( n ) ]   for i in range ( 0 , n ) : if a [ i ] == 0 : dp [ i ] = 1 + min ( i , k ) + min ( n - 1 - i , k ) else : if not ( ( a [ i ] - 1 + k ) < i - k ) : NEW_LINE


import java . io . * ; import java . util . * ; public class MyClass { public static void main ( String args [ ] ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ;

import java . util . Scanner ;   public class A233 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; if ( n % 2 == 1 ) System . out . println ( - 1 ) ; else for ( int i = 1 ; i <= n ; i ++ ) { if ( i % 2 == 1 ) { System . out . print ( ( i + 1 ) + " ▁ " ) ; } else { System . out . print ( ( i - 1 ) + " ▁ " ) ; } } } }

import java . util . * ;   public class Cf233A {   public static void main ( String args [ ] ) {   Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ;   if ( n % 2 == 1 ) { System . out . println ( - 1 ) ; return ; }   for ( int i = 1 ; i <= n ; i ++ ) System . out . print ( i % 2 == 1 ? i + 1 + " ▁ " : i - 1 + " ▁ " ) ;   } }

import java . io . * ; import java . util . * ;   public class PerfectPermutation { public static void main ( String args [ ] ) { FScanner in = new FScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = in . nextInt ( ) ; int arr [ ] = new int [ n + 1 ] ; if ( n % 2 != 0 ) out . println ( " - 1" ) ; else { for ( int i = 1 ; i <= n ; i ++ ) { if ( i % 2 != 0 ) out . print ( i + 1 + " ▁ " ) ; else out . print ( i - 1 + " ▁ " ) ; } }   out . close ( ) ; }   static class FScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer sb = new StringTokenizer ( " " ) ;   String next ( ) { while ( ! sb . hasMoreTokens ( ) ) { try { sb = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { } } return sb . nextToken ( ) ; } String nextLine ( ) { try { return br . readLine ( ) ; } catch ( IOException e ) { } return " " ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   int [ ] readArray ( int n ) { int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextInt ( ) ; return a ; }   float nextFloat ( ) { return Float . parseFloat ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }

n = int ( input ( ) ) if n % 2 == 1 : print ( " - 1" ) else : for i in range ( n ) : if i % 2 == 0 : print ( i + 2 , end = " ▁ " ) else : print ( i , end = " ▁ " ) NEW_LINE

n = int ( input ( ) ) if n % 2 : print ( - 1 ) else : print ( * list ( range ( n , 0 , - 1 ) ) ) NEW_LINE

for _ in range ( 1 ) : n = int ( input ( ) ) a = [ ] q = 0 if ( n % 2 != 0 ) : print ( - 1 ) else : for i in range ( 1 , n + 1 ) : a . append ( i ) for i in range ( 0 , n , 2 ) : t = a [ i ] a [ i ] = a [ i + 1 ] a [ i + 1 ] = t print ( * a )   NEW_LINE


import java . util . * ; import java . util . jar . JarOutputStream ;   public class Practise {   public static int [ ] [ ] dp ; public static void main ( String [ ] args ) {

import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int k = in . nextInt ( ) ; int a [ ] = new int [ n ] ; int c1 = 0 , c2 = 0 ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; if ( a [ i ] == 1 ) c1 ++ ; else c2 ++ ; } m -= c1 ; if ( m < 0 ) ans += Math . abs ( m ) ; c2 = ( m > 0 ) ? c2 - m : c2 ; k -= c2 ; if ( k < 0 ) ans += Math . abs ( k ) ; System . out . println ( ans ) ; } }

import java . util . * ; import java . util . regex . * ;   public class Solution { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int next = scan . nextInt ( ) ; if ( next == 1 ) { if ( m > 0 ) { m -- ; } else { res ++ ; } } else { if ( Math . max ( k , m ) > 0 ) { if ( k > 0 ) { k -- ; } else { m -- ; } } else { res ++ ; } } } System . out . println ( res ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   import java . util . Scanner ;   public class Main { private static FastReader scanner = new FastReader ( ) ; public static void main ( String [ ] args ) { int n = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; int k = scanner . nextInt ( ) ; int [ ] array = new int [ n ] ; readArray ( array ) ;

import java . util . * ;   public class Check2 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int days = sc . nextInt ( ) ; int bowls = sc . nextInt ( ) ; int plates = sc . nextInt ( ) ; int [ ] ar = new int [ days ] ; for ( int i = 0 ; i < days ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; } int c1 = 0 ; int c2 = 0 ; for ( int i = 0 ; i < days ; i ++ ) { if ( ar [ i ] == 1 ) { if ( bowls > 0 ) { bowls -= 1 ; } else { c1 ++ ; } } else { if ( plates > 0 ) { plates -= 1 ; } else if ( bowls > 0 ) { bowls -= 1 ; } else { c1 ++ ; } } } System . out . println ( c1 ) ;     }      public static long power ( long a , long b , long c ) { long ans = 1 ; while ( b != 0 ) { if ( b % 2 == 1 ) { ans = ans * a ; ans %= c ; } a = a * a ; a %= c ; b /= 2 ; } return ans ; }   public static long power1 ( long a , long b , long c ) { long ans = 1 ; while ( b != 0 ) { if ( b % 2 == 1 ) { ans = multiply ( ans , a , c ) ; } a = multiply ( a , a , c ) ; b /= 2 ;   } return ans ;   }   public static long multiply ( long a , long b , long c ) { long res = 0 ; a %= c ; while ( b > 0 ) { if ( b % 2 == 1 ) { res = ( res + a ) % c ; } a = ( a + a ) % c ; b /= 2 ; }   return res % c ;   }   public static long totient ( long n ) { long result = n ; for ( long i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) {

n , b , p = map ( int , input ( ) . split ( ) ) l = [ int ( i ) for i in input ( ) . split ( ) ] w = 0 for i in l : if ( i == 1 ) : if ( b > 0 ) : b = b - 1 else : w = w + 1 else : if ( p > 0 ) : p = p - 1 elif ( b > 0 ) : b = b - 1 else : w = w + 1 print ( w ) NEW_LINE

n , m , k = list ( map ( int , input ( ) . split ( ) ) ) ans = 0 a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) for i in range ( len ( a ) ) : if ( a [ i ] == 1 ) : m -= 1 a [ i ] = 0 if ( m <= 0 ) : breakfor i in range ( len ( a ) ) : if ( k <= 0 and m <= 0 ) : break if ( a [ i ] != 0 ) : if ( a [ i ] == 2 ) : if ( m >= 1 ) : m -= 1 a [ i ] = 0 else : k -= 1 a [ i ] = 0 NEW_LINE

days , bowls , plates = map ( int , input ( ) . split ( ) )   dishes = list ( map ( int , input ( ) . split ( ) ) )   cwash = 0   for i in range ( 0 , days ) : if ( dishes [ i ] == 1 and bowls > 0 ) : bowls -= 1 elif ( dishes [ i ] == 2 and plates > 0 ) : plates -= 1 elif ( dishes [ i ] == 2 and plates == 0 and bowls > 0 ) : bowls -= 1 else : cwash += 1   print ( cwash ) NEW_LINE

n , m , k = list ( map ( int , input ( ) . split ( ) ) ) a = list ( map ( int , input ( ) . split ( ) ) )   no = 0 nt = 0   for i in a : if i == 1 : no += 1 else : nt += 1   ans = ( 0 if no - m < 0 else ( no - m ) ) + ( 0 if ( nt - ( k + ( abs ( no - m ) if no - m < 0 else 0 ) ) ) < 0 else ( nt - ( k + ( abs ( no - m ) if no - m < 0 else 0 ) ) ) )   print ( ans ) NEW_LINE


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

from heapq import *   n , k = map ( int , input ( ) . split ( ) ) p = [ int ( X ) for X in input ( ) . split ( ) ] c = [ int ( x ) for x in input ( ) . split ( ) ] p = [ [ p [ i ] , c [ i ] , i ] for i in range ( n ) ] p . sort ( ) j = 0 an = [ 0 ] * nan [ p [ 0 ] [ 2 ] ] = p [ 0 ] [ 1 ] z = [ ] heapify ( z ) NEW_LINE

import sysinput = sys . stdin . readline   '''   '''   from heapq import heapify , heappush , heappop   n , k = map ( int , input ( ) . split ( ) ) plst = list ( map ( int , input ( ) . split ( ) ) ) clst = list ( map ( int , input ( ) . split ( ) ) )   if k == 0 : print ( * clst ) sys . exit ( )   pc = sorted ( ( ( p , c , i ) for i , ( p , c ) in enumerate ( zip ( plst , clst ) ) ) , key = lambda t : ( t [ 0 ] , t [ 2 ] ) ) res = [ 0 ] * npq = [ ] pq_sum = 0 pq_size = 0   for p , c , i in pc : if i > 0 and plst [ i ] == plst [ i - 1 ] : res [ i ] = res [ i - 1 ] else : res [ i ] = pq_sum + c   NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) P = list ( map ( int , input ( ) . split ( ) ) ) C = list ( map ( int , input ( ) . split ( ) ) ) Q = [ ] for i , p in enumerate ( P ) : Q . append ( ( p , i ) ) Q . sort ( ) q = [ ] import heapqheapq . heapify ( [ ] ) s = 0 ans = [ 0 ] * nif k > 0 : for p , i in Q : ans [ i ] = s + C [ i ] if len ( q ) == k : if q [ 0 ] <= C [ i ] : v = heapq . heappop ( q ) heapq . heappush ( q , C [ i ] ) s -= v s += C [ i ] else : heapq . heappush ( q , C [ i ] ) s += C [ i ] print ( * ans ) else : for p , i in Q : ans [ i ] = C [ i ] print ( * ans ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) knight = list ( map ( int , input ( ) . split ( ) ) ) coins = list ( map ( int , input ( ) . split ( ) ) ) d = { } ; ans = [ 0 ] * nfor i in range ( n ) : knight [ i ] = [ knight [ i ] , i ] for i in coins : d [ i ] = d . get ( i , 0 ) + 1 c = coins [ : ] NEW_LINE


import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int t = in . nextInt ( ) ; Main m = new Main ( ) ; while ( t -- > 0 ) { m . run ( in , out ) ; } out . close ( ) ; }   public static long mod = 17352642619633L ;   int N ; int K ; int [ ] a = new int [ 100_001 ] ; void run ( FastScanner in , PrintWriter out ) {   N = in . nextInt ( ) ; K = in . nextInt ( ) ;   boolean allGood = true ; boolean hasK = false ;   for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = in . nextInt ( ) ; allGood &= a [ i ] == K ; hasK |= a [ i ] == K ; }   if ( allGood ) { out . println ( " yes " ) ; return ; } if ( ! hasK ) { out . println ( " no " ) ; return ; }

import java . util . Arrays ; import java . util . Scanner ;   public class D { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int nums [ ] = new int [ n ] ; int arr [ ] = new int [ n ] ; boolean exist = false ; for ( int i = 0 ; i < nums . length ; i ++ ) { nums [ i ] = sc . nextInt ( ) ; if ( nums [ i ] == k ) { exist = true ; } arr [ i ] = ( nums [ i ] >= k ) ? 1 : 0 ; } if ( n == 1 ) { if ( nums [ 0 ] != k ) { System . out . println ( " no " ) ; } else { System . out . println ( " yes " ) ; } continue ; } if ( ! exist ) { System . out . println ( " no " ) ; continue ; } boolean can = false ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n && j - i <= 2 ; j ++ ) { if ( arr [ i ] > 0 && arr [ j ] > 0 ) { can = true ; break ; } } } if ( can ) { System . out . println ( " yes " ) ; } else { System . out . println ( " no " ) ; } } } }

ans = [ ] for _ in range ( int ( input ( ) ) ) : n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) if k not in a : ans . append ( ' no ' ) continue if n == 1 : ans . append ( ' yes ' if a [ 0 ] == k else ' no ' ) continue good = False for i in range ( n - 1 ) : if a [ i ] >= k and a [ i + 1 ] >= k : good = True for i in range ( 1 , n ) : if a [ i ] >= k and a [ i - 1 ] >= k : good = True for i in range ( 1 , n - 1 ) : if a [ i - 1 ] >= k and a [ i + 1 ] >= k : good = True ans . append ( ' yes ' if good else ' no ' ) print ( ' \n ' . join ( ans ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . List ; import java . util . StringTokenizer ;   public class Main implements Runnable {   int INF = ( int ) 1e9 ; List < Integer > edges [ ] ; int anc [ ] [ ] ; int ts [ ] , te [ ] ; int t ;   private void solve ( ) throws IOException { int n = nextInt ( ) ; int k = nextInt ( ) ; int a [ ] = new int [ k ] ; int cnt [ ] = new int [ n ] ; int fp [ ] = new int [ n ] ; int lp [ ] = new int [ n ] ; Arrays . fill ( fp , - 1 ) ; Arrays . fill ( lp , - 1 ) ; for ( int i = 0 ; i < k ; ++ i ) { a [ i ] = nextInt ( ) ; a [ i ] -- ; if ( cnt [ a [ i ] ] == 0 ) fp [ a [ i ] ] = i ; lp [ a [ i ] ] = i ; cnt [ a [ i ] ] ++ ; } if ( n == 1 ) { pw . println ( 0 ) ; return ; } int ans = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( cnt [ i ] == 0 ) { if ( i == 0 || i == n - 1 ) { ans += 2 ; } else { ans += 3 ; } } else {

import java . util . * ;   public class A1147 { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; int n = cin . nextInt ( ) ; int k = cin . nextInt ( ) ; ArrayList < Integer > [ ] a = new ArrayList [ 100001 ] ; for ( int i = 0 ; i < 100001 ; i ++ ) { a [ i ] = new ArrayList < Integer > ( ) ; } for ( int i = 1 ; i <= k ; i ++ ) { int x = cin . nextInt ( ) ; a [ x ] . add ( i ) ; } int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = i - 1 ; j <= i + 1 ; j ++ ) { if ( j > 0 && j < n + 1 ) { if ( i == j && a [ i ] . isEmpty ( ) ) { ans ++ ; } if ( i != j && ! a [ i ] . isEmpty ( ) && ! a [ j ] . isEmpty ( ) && a [ i ] . get ( 0 ) > a [ j ] . get ( a [ j ] . size ( ) - 1 ) ) { ans ++ ; } if ( ( i != j ) && ( ( a [ i ] . isEmpty ( ) && ! a [ j ] . isEmpty ( ) ) || ( ! a [ i ] . isEmpty ( ) && a [ j ] . isEmpty ( ) ) || ( a [ i ] . isEmpty ( ) && a [ j ] . isEmpty ( ) ) ) ) { ans ++ ; } } } } System . out . println ( ans ) ;   } }

import java . io . * ; import java . util . * ; public class Ishu { static Scanner scan = new Scanner ( System . in ) ; static void tc ( ) { int n = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; int [ ] min = new int [ n ] ; int [ ] max = new int [ n ] ; int i ; for ( i = 0 ; i < k ; ++ i ) { int pos = scan . nextInt ( ) ; if ( min [ pos - 1 ] == 0 ) min [ pos - 1 ] = i + 1 ; max [ pos - 1 ] = i + 1 ; } int ans = 0 ; for ( i = 0 ; i < n ; ++ i ) { if ( min [ i ] == 0 ) { if ( i - 1 >= 0 ) ans ++ ; ans ++ ; if ( i + 1 < n ) ans ++ ; } else { if ( i - 1 >= 0 ) { if ( max [ i - 1 ] < min [ i ] ) ans ++ ; } if ( i + 1 < n ) { if ( max [ i + 1 ] < min [ i ] ) ans ++ ; } } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int t = 1 ;

n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) p = [ - 1 ] * ( n + 1 ) s = [ - 1 ] * ( n + 1 ) for i in range ( k ) : if p [ a [ i ] ] == - 1 : p [ a [ i ] ] = ifor i in range ( k - 1 , - 1 , - 1 ) : if s [ a [ i ] ] == - 1 : s [ a [ i ] ] = icount = 0 for i in range ( 1 , n + 1 ) : if p [ i ] == - 1 : if i == 1 or i == n : count += 2 continue count += 3 else : if i != n and ( s [ i + 1 ] == - 1 or s [ i + 1 ] < p [ i ] ) : count += 1 if i != 1 and ( s [ i - 1 ] == - 1 or s [ i - 1 ] < p [ i ] ) : count += 1 NEW_LINE

import sys   input = lambda : sys . stdin . readline ( ) . strip ( " \n " )   n , k = map ( int , input ( ) . split ( ) ) x = list ( map ( int , input ( ) . split ( ) ) ) first = [ k ] * ( n + 1 ) last = [ - 1 ] * ( n + 1 )   for i in range ( 1 , k + 1 ) : last [ x [ i - 1 ] ] = ifor i in range ( k , 0 , - 1 ) : first [ x [ i - 1 ] ] = i   ans = 0 NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) X = list ( map ( int , input ( ) . split ( ) ) )   fallen = set ( ) pairs = set ( )   for x in X : if ( x - 1 ) in fallen : NEW_LINE


import java . util . * ; import java . io . * ;   public class A_Vasya_and_Socks {   static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } }   public static void main ( String [ ] args ) { FastReader scan = new FastReader ( ) ; int n = scan . nextInt ( ) ; int m = scan . nextInt ( ) ;   int count = 0 ; int day = 0 ; while ( n != 0 ) { count ++ ; day ++ ; if ( day % m == 0 ) { n ++ ; } n -- ; } System . out . println ( count ) ; } }

import java . util . Scanner ;    public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int i ; for ( i = 1 ; i <= n ; i ++ ) { if ( i % m == 0 ) { n ++ ; } } System . out . println ( n ) ; } }

import java . io . * ; import java . util . StringTokenizer ;   public class A460 { public static void main ( String [ ] args ) throws IOException { PrintWriter out = new PrintWriter ( System . out ) ; FastScanner fs = new FastScanner ( ) ; int N , M ; N = fs . nextInt ( ) ; M = fs . nextInt ( ) ; int ans = N ; while ( N >= M && N != 1 ) { ans += ( N / M ) ; N = ( N / M ) + ( N % M ) ; } out . println ( ans ) ; out . close ( ) ; }   static class FastScanner { BufferedReader br ; StringTokenizer st ;   public FastScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   public FastScanner ( String filePath ) throws FileNotFoundException { try { br = new BufferedReader ( new FileReader ( filePath ) ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } }   String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; throw e ; } } return st . nextToken ( ) ; }   String nextLine ( ) throws IOException { String str ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; throw e ; } return str ; }   int nextInt ( ) throws IOException { return Integer . parseInt ( this . next ( ) ) ; }   long nextLong ( ) throws IOException { return Long . parseLong ( this . next ( ) ) ; } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner myObj = new Scanner ( System . in ) ; int x = myObj . nextInt ( ) ; int y = myObj . nextInt ( ) ; int counter = 1 ; while ( x > 0 ) { x -- ;   if ( counter % y == 0 ) { x ++ ; } counter ++ ; } System . out . println ( counter - 1 ) ; } }

n , m = map ( int , input ( ) . split ( ) )   answer = n + n // ( m - 1 )   if n % ( m - 1 ) == 0 : answer -= 1   print ( answer ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) print ( n + ( n - 1 ) // ( m - 1 ) ) NEW_LINE

n , m = map ( float , input ( ) . split ( ) ) dni = 0 cnt = 0 while n > 0 : n = n - 1 dni = dni + 1 cnt = cnt + 1 if cnt == m : n = n + 1 cnt = 0 print ( dni ) NEW_LINE

n1 , m1 = input ( ) . split ( ) n = int ( n1 ) m = int ( m1 ) a = n + ( ( n - 1 ) / ( m - 1 ) ) print ( int ( a ) ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) days = 0 while n > 0 : n -= 1 days += 1 if days % m == 0 : n += 1 print ( days ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . HashSet ; import java . util . List ; import java . util . Map ; import java . util . Set ; import java . util . StringTokenizer ; import java . util . TreeMap ;   public class Main implements Runnable { int n , m , k ; static boolean use_n_tests = false ;   void solve ( FastScanner in , PrintWriter out , int testNumber ) { int x = in . nextInt ( ) ; k = in . nextInt ( ) ; Set < Integer > contest = new HashSet < > ( ) ; for ( int i = 0 ; i < k ; i ++ ) { int type = in . nextInt ( ) ; int id = in . nextInt ( ) ; contest . add ( id ) ; if ( type == 1 ) { int id1 = in . nextInt ( ) ; contest . add ( id1 ) ; } } int mx = 0 ; for ( int i = 1 ; i < x ; i ++ ) { if ( contest . contains ( i ) ) { continue ; } mx ++ ; } int mn = 0 ; for ( int i = 1 ; i < x ; i ++ ) { if ( i + 1 < x ) { if ( ! contest . contains ( i ) && ! contest . contains ( i + 1 ) ) { mn ++ ; i ++ ; } else if ( ! contest . contains ( i ) ) { mn ++ ; } } else { if ( ! contest . contains ( i ) ) { mn ++ ; } } } out . println ( mn + " ▁ " + mx ) ; }

import java . io . * ; import java . math . * ; import java . security . * ; import java . text . * ; import java . util . * ;    public class CodeForce { public static int findmin ( int [ ] arr ) { int sum = 0 ; for ( int i = 1 ; i < arr . length ; i ++ ) { int count = 0 ; while ( i < arr . length && arr [ i ] == 0 ) { i ++ ; count ++ ; } if ( count % 2 != 0 ) { sum = sum + count / 2 + 1 ; } else sum = sum + count / 2 ; } return sum ; } public static int findmax ( int [ ] arr ) { int sum = 0 ; for ( int i = 1 ; i < arr . length ; i ++ ) { int count = 0 ; while ( i < arr . length && arr [ i ] == 0 ) { i ++ ; count ++ ; } sum = sum + count ; } return sum ; } public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ;

import java . util . Scanner ;   public class SREUJA_AND_CONTEST {   public static void main ( String [ ] args ) {   Scanner nik = new Scanner ( System . in ) ; int n = nik . nextInt ( ) ; int x = nik . nextInt ( ) ;   boolean b [ ] = new boolean [ n + 1 ] ; for ( int i = 0 ; i < x ; i ++ ) { int t = nik . nextInt ( ) ; if ( t == 2 ) { b [ nik . nextInt ( ) ] = true ; } else { b [ nik . nextInt ( ) ] = true ; b [ nik . nextInt ( ) ] = true ; } } int min = 0 , max = 0 ;   for ( int i = 1 ; i < n ; i ++ ) { if ( i + 1 < n && b [ i ] == false && b [ i + 1 ] == false ) {   min += 1 ; max += 2 ; i += 1 ; } else if ( b [ i ] == false ) { max += 1 ; min ++ ; }   } System . out . println ( min + " ▁ " + max ) ; }   }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ;   import javafx . util . Pair ;   public class Main {       public static void main ( String [ ] args ) { FastScanner input = new FastScanner ( ) ; int x = input . nextInt ( ) ; int k = input . nextInt ( ) ; boolean xx [ ] = new boolean [ x + 1 ] ; for ( int i = 0 ; i < k ; i ++ ) { int type = input . nextInt ( ) ; if ( type == 1 ) { int div2 = input . nextInt ( ) ; int div1 = input . nextInt ( ) ; xx [ div1 ] = xx [ div2 ] = true ; } else { int div2 = input . nextInt ( ) ; xx [ div2 ] = true ; } } xx [ x ] = true ;

import sys   inp = sys . stdin . readlines ( ) ; ii = 0   out = [ ]   x , k = map ( int , inp [ ii ] . split ( ) ) ii += 1   roundshappened = [ ] for round in range ( k ) : data = [ int ( d ) for d in inp [ ii ] . split ( ) ] ii += 1 for d in data [ 1 : ] : roundshappened . append ( d )   skipped = [ ]   for x in range ( 1 , x ) : if x not in roundshappened : skipped . append ( x )   used = [ ]   minimum = 0   for i in range ( 1 , len ( skipped ) ) : if skipped [ i - 1 ] + 1 == skipped [ i ] and skipped [ i ] not in used and skipped [ i - 1 ] not in used : minimum += 1 used . append ( skipped [ i - 1 ] ) used . append ( skipped [ i ] )   minimum += len ( skipped ) - len ( used )   maximum = len ( skipped ) sys . stdout . write ( str ( minimum ) + ' ▁ ' + str ( maximum ) )         NEW_LINE

import mathx , k = map ( int , input ( ) . split ( " ▁ " ) ) given = [ 0 for x in range ( x - 1 ) ] for _ in range ( k ) : a = list ( map ( int , input ( ) . split ( " ▁ " ) ) ) if a [ 0 ] == 2 : given [ a [ 1 ] - 1 ] = 1 else : given [ a [ 2 ] - 1 ] = 1 given [ a [ 1 ] - 1 ] = 1 cmax = 0 for y in range ( x - 1 ) : if given [ y ] == 0 : cmax = cmax + 1 pp = 0 t = 0 ss = x - 1 while t < ss : if t < ss - 1 and given [ t ] == 0 and given [ t + 1 ] == 0 : pp = pp + 1 t = t + 2 else : t = t + 1 print ( cmax - pp , cmax )                         NEW_LINE

x , k = list ( map ( int , input ( ) . split ( ) ) ) r = [ ] for i in range ( k ) : l = list ( map ( int , input ( ) . split ( ) ) ) for i in l [ 1 : ] : r . append ( i ) r . sort ( ) f = [ ] j = 0 for i in range ( 1 , x ) : if j <= len ( r ) - 1 : if i == r [ j ] : j = j + 1 else : f . append ( i ) else : f . append ( i ) m1 , m2 = 0 , len ( f ) i = 0 while i < len ( f ) : if i + 1 <= len ( f ) - 1 and f [ i + 1 ] - f [ i ] == 1 : i = i + 2 m1 = m1 + 1 else : m1 = m1 + 1 i = i + 1 print ( m1 , m2 ) NEW_LINE

x , k = list ( map ( int , input ( ) . split ( ) ) ) arr = [ 1 ] * ( x - 1 ) for i in range ( k ) : a = list ( map ( int , input ( ) . split ( ) ) ) if a [ 0 ] == 1 : arr [ a [ 2 ] - 1 ] = 0 arr [ a [ 1 ] - 1 ] = 0 maxv = sum ( arr ) arrn = [ ] cl = 0 for i in range ( x - 1 ) : if arr [ i ] == 1 : arrn . append ( i ) cl += 1 minv = 0 if arrn : c = 0 i = 0 while i < cl - 1 : if arrn [ i + 1 ] - arrn [ i ] == 1 : c += 1 i += 2 else : i += 1 minv = maxv - cprint ( minv , maxv ) NEW_LINE

x , k = [ int ( i ) for i in input ( ) . split ( ) ] missed = [ 0 ] * x   for i in range ( k ) : divs = [ int ( i ) for i in input ( ) . split ( ) ] if divs [ 0 ] == 1 : missed [ divs [ 1 ] ] = 1 missed [ divs [ 2 ] ] = 1 else : missed [ divs [ 1 ] ] = 1   max_answer = missed . count ( 0 ) - 1 good_subarrs = 0 i = 1 while i <= x - 1 : if i < x - 1 and missed [ i ] == 0 and missed [ i + 1 ] == 0 : good_subarrs += 1 i += 2 else : i += 1   print ( max_answer - good_subarrs , max_answer ) NEW_LINE


import java . util . Scanner ;   public class PrimitiveRoot { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   int n = scanner . nextInt ( ) ;   if ( n == 2 ) { System . out . println ( 1 ) ; return ; } int count = 0 ;   for ( int i = 2 ; i < n ; i ++ ) { int power = 1 ; long root = i * i ; boolean check = true ;   while ( power < n - 2 ) { if ( root % n == 1 ) { check = false ; break ; }   root = ( root * i ) % n ; power ++ ; }   if ( check ) count ++ ; }   System . out . println ( count ) ; } }

import java . util . Scanner ;   public class CowsAndPrimitiveRoots { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int result = 0 ;   for ( int i = 1 ; i < n ; i ++ ) { int x = 1 ; boolean flag = true ; for ( int j = 1 ; j < n - 1 ; j ++ ) { x = x * i ; x %= n ; if ( x == 1 ) { flag = false ; break ; } } if ( flag ) { x = x * i ; x %= n ; if ( x == 1 ) { result ++ ; } } }   System . out . println ( result ) ;   sc . close ( ) ; } }

import java . util . Scanner ;   public class Test { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ;   int p ; p = input . nextInt ( ) ; int ans = 0 ; for ( int x = 1 ; x < p ; x ++ ) { boolean flag = true ; int tmp = 1 ; for ( int i = 1 ; i < p - 1 ; i ++ ) { tmp *= x ; if ( ( tmp - 1 ) % p == 0 ) { flag = false ; break ; } tmp %= p ; } if ( flag ) { if ( ( tmp * x - 1 ) % p == 0 ) { ans ++ ; } } } System . out . println ( ans ) ; } }

import java . io . BufferedReader ; import java . io . File ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . * ;     public class Main { public static void main ( String [ ] args ) { FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i < n ; i ++ ) { TreeSet < Integer > set = new TreeSet < > ( ) ; int j = 1 ; int sum = i ; while ( j < n ) { sum = sum % n ; set . add ( sum ) ; sum *= i ; j ++ ; } if ( set . size ( ) == n - 1 ) count ++ ; } System . out . println ( count ) ; }   static class FastScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ; String next ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }

def f ( n ) : m = 1 for i in range ( 1 , p - 1 ) : m = ( m * n ) % p if ( m - 1 ) % p : pass else : return False if ( m * n - 1 ) % p : return False return Truep = int ( input ( ) ) cnt = 0 for i in range ( 1 , p ) : if f ( i ) : cnt += 1 print ( cnt ) NEW_LINE

from math import * p = int ( input ( ) ) cnt = 0 c = 0 d = 0 for i in range ( 1 , p ) : if gcd ( i , p - 1 ) == 1 : cnt += 1 print ( cnt ) NEW_LINE

from math import gcd   a = int ( input ( ) ) - 1   aux = 1   for i in range ( 2 , a ) : if gcd ( i , a ) == 1 : aux = aux + 1 print ( aux ) NEW_LINE

from math import gcd   def solve ( p ) : total = 0 for i in range ( 2 , p ) : if gcd ( i , p ) == 1 : total += 1   print ( total + 1 )     n = int ( input ( ) ) solve ( n - 1 ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ;   public class Main {    public static void main ( String [ ] args ) throws IOException { FastScanner input = new FastScanner ( ) ; long a = input . nextLong ( ) ; long b = input . nextLong ( ) ; long c = input . nextLong ( ) ; long ans = 0 ; ans = ( a * b * c ) - ( ( a - 1 ) * ( b - 1 ) * ( c - 1 ) ) ; System . out . println ( ans ) ; } static class FastScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ; String next ( ) { while ( ! st . hasMoreTokens ( ) ) try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } int [ ] readArray ( int n ) { int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextInt ( ) ; return a ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } }   }

import java . util . Scanner ;   public class TileArea { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ;   int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ;   System . out . println ( ( b + a - 1 ) * ( c + a - 1 ) - a * ( a - 1 ) ) ; } }

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

a , b , c = sorted ( map ( int , input ( ) . split ( ) ) ) print ( a * ( 2 * c + a - 1 ) + ( c + a - 1 ) * ( b - a - 1 ) ) NEW_LINE

try : a , b , c = list ( map ( int , input ( ) . split ( " ▁ " ) ) ) print ( a * b * c - ( ( a - 1 ) * ( b - 1 ) * ( c - 1 ) ) )                   except : pass NEW_LINE

a , b , c = list ( map ( int , input ( ) . split ( ) ) ) print ( b * c + ( ( a - 1 ) * ( c + b - 1 ) ) ) NEW_LINE

a , b , c = map ( int , input ( ) . split ( ) ) print ( b * c + ( a - 1 ) * ( c + b - 1 ) ) NEW_LINE

x , y , z = map ( int , input ( ) . split ( ) ) print ( ( x - 1 ) * ( y - 1 ) + z * ( x + y - 1 ) ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner src = new Scanner ( System . in ) ; int x = src . nextInt ( ) ; int y = src . nextInt ( ) ; int z = src . nextInt ( ) ; int a = 0 , b = 0 ; double min = 1 ; for ( int den = ( y <= z ) ? y : z ; den > 0 ; den -- ) { int num = ( ( ( ( double ) x / y ) * den ) - 0.5 ) == ( ( int ) ( ( double ) x / y ) * den ) ? ( ( int ) ( ( double ) x / y ) * den ) : ( int ) Math . round ( ( ( double ) x / y ) * den ) ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . List ; import java . util . PriorityQueue ; import java . util . Random ; import java . util . StringTokenizer ;   public class A {   public static void main ( String [ ] args ) throws IOException {   FastScanner sc = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int x = sc . nextInt ( ) , y = sc . nextInt ( ) , n = sc . nextInt ( ) ;

import java . io . * ; import java . util . * ; public class f10 { static public void process ( double x , double y , int n ) { double max = 100001 ; int a = 0 , b = 0 ; for ( int den = 1 ; den <= n ; den ++ ) { double num = ( x / y ) * den ;

from fractions import Fractionx , y , n = map ( int , input ( ) . split ( ) ) v = Fraction ( x , y ) . limit_denominator ( n ) print ( v . numerator , v . denominator , sep = ' / ' ) NEW_LINE

from fractions import Fraction   x , y , n = map ( int , input ( ) . split ( ) )   v = Fraction ( x , y ) . limit_denominator ( n ) print ( str ( v . numerator ) + ' / ' + str ( v . denominator ) ) NEW_LINE