import java . util . ArrayList ; import java . util . Comparator ; import java . util . List ; import java . util . Scanner ; import java . util . stream . Collectors ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; List < Grid > gridList = new ArrayList < > ( ) ; int n = in . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { gridList . add ( new Grid ( Color . RED , in . nextInt ( ) , in . nextInt ( ) ) ) ; } for ( int i = 0 ; i < n ; i ++ ) { gridList . add ( new Grid ( Color . BLUE , in . nextInt ( ) , in . nextInt ( ) ) ) ; } gridList . sort ( Comparator . comparing ( Grid :: getX ) . thenComparing ( Grid :: getColor ) ) ; List < Grid > tmp = new ArrayList < > ( ) ; int ans = 0 ; for ( Grid grid : gridList ) { if ( grid . color == Color . RED ) { tmp . add ( grid ) ; } else { List < Grid > list = tmp . stream ( ) . filter ( g -> g . getY ( ) < grid . getY ( ) ) . collect ( Collectors . toList ( ) ) ; if ( list . size ( ) > 0 ) { ans ++ ; list . sort ( Comparator . comparing ( Grid :: getY ) ) ; tmp . remove ( list . get ( list . size ( ) - 1 ) ) ; } } } System . out . println ( ans ) ; } } class Grid { Color color ; int x ; int y ; public Grid ( Color color , int x , int y ) { this . color = color ; this . x = x ; this . y = y ; } public Color getColor ( ) { return this . color ; } public int getX ( ) { return this . x ; } public int getY ( ) { return this . y ; } public String toString ( ) { return String . format ( color + " ▁ \t " + x + " , ▁ " + y ) ; } } enum Color { BLUE , RED }

N = int ( input ( ) ) NEW_LINE red = [ ] NEW_LINE blue = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE red . append ( ( a , b ) ) NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT c , d = map ( int , input ( ) . split ( ) ) NEW_LINE blue . append ( ( c , d ) ) NEW_LINE DEDENT red = sorted ( red , key = lambda x : - x [ 1 ] ) NEW_LINE blue = sorted ( blue , key = lambda x : x [ 0 ] ) NEW_LINE answer = 0 NEW_LINE for i , b in enumerate ( blue ) : NEW_LINE INDENT for j , r in enumerate ( red ) : NEW_LINE INDENT if r [ 0 ] < b [ 0 ] and r [ 1 ] < b [ 1 ] : NEW_LINE INDENT answer += 1 NEW_LINE red . pop ( j ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT print ( answer ) NEW_LINE


from bisect import bisect_left NEW_LINE n = int ( input ( ) ) NEW_LINE red = sorted ( [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] ) NEW_LINE blue = sorted ( [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] ) NEW_LINE ans = 0 NEW_LINE for x , y , in blue : NEW_LINE INDENT i = bisect_left ( [ a [ 0 ] for a in red ] , x ) NEW_LINE tmp = sorted ( red [ : i ] , key = lambda x : x [ 1 ] , reverse = True ) NEW_LINE for xx , yy in tmp : NEW_LINE INDENT if y > yy : NEW_LINE INDENT ans += 1 NEW_LINE red . remove ( [ xx , yy ] ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE


def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE N = int ( input ( ) ) NEW_LINE red = [ inpl ( ) for _ in range ( N ) ] NEW_LINE blue = [ inpl ( ) for _ in range ( N ) ] NEW_LINE red = sorted ( red , key = lambda x : - x [ 0 ] ) NEW_LINE blue = sorted ( blue , key = lambda x : x [ 1 ] ) NEW_LINE ans = 0 NEW_LINE for a , b in red : NEW_LINE INDENT for c , d in blue : NEW_LINE INDENT if a < c and b < d : NEW_LINE INDENT ans += 1 NEW_LINE blue . remove ( [ c , d ] ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE


N = int ( input ( ) ) NEW_LINE R = [ [ int ( i ) for i in input ( ) . split ( ) ] for i in range ( N ) ] NEW_LINE B = [ [ int ( i ) for i in input ( ) . split ( ) ] for i in range ( N ) ] NEW_LINE List = [ [ ] for i in range ( N ) ] NEW_LINE count = [ 0 ] * N NEW_LINE unpaired = [ True ] * N NEW_LINE for i , r in enumerate ( R ) : NEW_LINE INDENT for j , b in enumerate ( B ) : NEW_LINE INDENT if b [ 0 ] > r [ 0 ] and b [ 1 ] > r [ 1 ] : NEW_LINE INDENT List [ i ] . append ( j ) NEW_LINE count [ j ] += 1 NEW_LINE DEDENT DEDENT DEDENT List . sort ( key = lambda x : len ( x ) ) NEW_LINE ans = 0 NEW_LINE for l in List : NEW_LINE INDENT k = float ( " inf " ) NEW_LINE p = - 1 NEW_LINE for j in l : NEW_LINE INDENT if unpaired [ j ] : NEW_LINE INDENT if k > count [ j ] : NEW_LINE INDENT k = count [ j ] NEW_LINE p = j NEW_LINE DEDENT count [ j ] -= 1 NEW_LINE DEDENT DEDENT if p >= 0 : NEW_LINE INDENT ans += 1 NEW_LINE unpaired [ p ] = False NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE


N = int ( input ( ) ) NEW_LINE r = [ [ 0 , 0 ] for i in range ( N ) ] NEW_LINE b = [ [ 0 , 0 ] for i in range ( N ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT r [ i ] [ 0 ] , r [ i ] [ 1 ] = map ( int , input ( ) . split ( ) ) NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT b [ i ] [ 0 ] , b [ i ] [ 1 ] = map ( int , input ( ) . split ( ) ) NEW_LINE DEDENT r . sort ( key = lambda x : ( x [ 1 ] ) , reverse = True ) NEW_LINE b . sort ( key = lambda x : ( x [ 0 ] ) ) NEW_LINE r_flag = [ False ] * N NEW_LINE b_flag = [ False ] * N NEW_LINE count = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT if r [ j ] [ 0 ] < b [ i ] [ 0 ] and r [ j ] [ 1 ] < b [ i ] [ 1 ] and not r_flag [ j ] : NEW_LINE INDENT r_flag [ j ] = True NEW_LINE count += 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT print ( count ) NEW_LINE


import java . util . * ; public class Main { static void sortpoint ( int [ ] x , int [ ] y , int n ) { for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = n - 1 ; j > i ; j -- ) { if ( x [ j - 1 ] > x [ j ] ) { int t = x [ j - 1 ] ; x [ j - 1 ] = x [ j ] ; x [ j ] = t ; t = y [ j - 1 ] ; y [ j - 1 ] = y [ j ] ; y [ j ] = t ; } } } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] b = new int [ n ] ; int [ ] c = new int [ n ] ; int [ ] d = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { c [ i ] = sc . nextInt ( ) ; d [ i ] = sc . nextInt ( ) ; } sortpoint ( a , b , n ) ; sortpoint ( c , d , n ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int j = 0 ; int ymax = - 1 ; int index = - 1 ; while ( j < n && a [ j ] < c [ i ] ) { if ( a [ j ] >= 0 && b [ j ] < d [ i ] ) { if ( b [ j ] >= ymax ) { ymax = b [ j ] ; index = j ; } } j ++ ; } if ( index >= 0 ) { ans ++ ; a [ index ] = - 1 ; } } System . out . println ( ans ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int [ ] [ ] red = new int [ n ] [ 2 ] ; int [ ] [ ] blue = new int [ n ] [ 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { red [ i ] [ 0 ] = Integer . parseInt ( sc . next ( ) ) ; red [ i ] [ 1 ] = Integer . parseInt ( sc . next ( ) ) ; } for ( int i = 0 ; i < n ; i ++ ) { blue [ i ] [ 0 ] = Integer . parseInt ( sc . next ( ) ) ; blue [ i ] [ 1 ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( red , ( a , b ) -> Integer . compare ( a [ 0 ] , b [ 0 ] ) ) ; Arrays . sort ( blue , ( a , b ) -> Integer . compare ( a [ 0 ] , b [ 0 ] ) ) ; System . out . println ( calc ( red , blue , n ) ) ; sc . close ( ) ; } public static int calc ( int [ ] [ ] red , int [ ] [ ] blue , int n ) { int ret = 0 , maxtemp = - 1 , index = 0 , maxindex = 0 , flag = 0 ; for ( int i = 0 ; i < n ; i ++ ) { index = 0 ; flag = 0 ; maxtemp = - 1 ; while ( index < n && red [ index ] [ 0 ] < blue [ i ] [ 0 ] ) { if ( maxtemp <= red [ index ] [ 1 ] && red [ index ] [ 1 ] < blue [ i ] [ 1 ] ) { maxtemp = red [ index ] [ 1 ] ; maxindex = index ; flag = 1 ; } index ++ ; } if ( flag == 1 ) { ret ++ ; red [ maxindex ] [ 1 ] = 201 ; } } return ret ; } }


import java . util . Arrays ; import java . util . Scanner ; public class Main { public void main ( Scanner sc ) { int n = sc . nextInt ( ) ; int a [ ] [ ] = new int [ n ] [ 2 ] ; int b [ ] [ ] = new int [ n ] [ 2 ] ; boolean used [ ] = new boolean [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] [ 0 ] = sc . nextInt ( ) ; a [ i ] [ 1 ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { b [ i ] [ 0 ] = sc . nextInt ( ) ; b [ i ] [ 1 ] = sc . nextInt ( ) ; } Arrays . sort ( a , ( o1 , o2 ) -> o1 [ 0 ] - o2 [ 0 ] ) ; Arrays . sort ( b , ( o1 , o2 ) -> o1 [ 0 ] - o2 [ 0 ] ) ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int pare = - 1 ; int maxy = 0 ; for ( int j = 0 ; j < n && ( a [ j ] [ 0 ] < b [ i ] [ 0 ] ) ; j ++ ) { if ( used [ j ] ) { continue ; } if ( a [ j ] [ 1 ] < b [ i ] [ 1 ] && maxy <= a [ j ] [ 1 ] ) { pare = j ; maxy = a [ j ] [ 1 ] ; } } if ( pare != - 1 ) { used [ pare ] = true ; cnt ++ ; } } System . out . println ( cnt ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] [ ] r = new int [ n ] [ 2 ] ; int [ ] [ ] b = new int [ n ] [ 2 ] ; boolean [ ] buse = new boolean [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { r [ i ] [ 0 ] = sc . nextInt ( ) ; r [ i ] [ 1 ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { b [ i ] [ 0 ] = sc . nextInt ( ) ; b [ i ] [ 1 ] = sc . nextInt ( ) ; buse [ i ] = false ; } sc . close ( ) ; int ans = 0 ; MyComp comp = new MyComp ( ) ; Arrays . sort ( r , comp ) ; for ( int i = 0 ; i < n ; i ++ ) { int rx = r [ n - i - 1 ] [ 0 ] ; int ry = r [ n - i - 1 ] [ 1 ] ; int bymin = 1000 ; int byminpos = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( b [ j ] [ 0 ] > rx && b [ j ] [ 1 ] > ry && b [ j ] [ 1 ] < bymin && ! buse [ j ] ) { bymin = b [ j ] [ 1 ] ; byminpos = j ; } } if ( bymin != 1000 ) { ans ++ ; buse [ byminpos ] = true ; } } System . out . println ( ans ) ; } } class MyComp implements Comparator { @ Override public int compare ( Object i1 , Object i2 ) { return ( ( int [ ] ) i1 ) [ 0 ] - ( ( int [ ] ) i2 ) [ 0 ] ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .


import java . util . * ; public class Main { public static int h , w ; public static int [ ] [ ] a ; public static int [ ] [ ] memo ; public static final int MOD = ( int ) 1e9 + 7 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; h = sc . nextInt ( ) ; w = sc . nextInt ( ) ; a = new int [ h ] [ w ] ; memo = new int [ h ] [ w ] ; for ( int i = 0 ; i < h ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { a [ i ] [ j ] = Integer . parseInt ( sc . next ( ) ) ; memo [ i ] [ j ] = - 1 ; } } long ans = 0 ; for ( int i = 0 ; i < h ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { ans += saiki ( j , i ) ; ans %= MOD ; } } System . out . println ( ans ) ; } public static int saiki ( int x , int y ) { if ( memo [ y ] [ x ] != - 1 ) return memo [ y ] [ x ] ; long res = 0 ; int [ ] dx = { 0 , 1 , 0 , - 1 } ; int [ ] dy = { 1 , 0 , - 1 , 0 } ; for ( int i = 0 ; i < 4 ; i ++ ) { int nx = x + dx [ i ] ; int ny = y + dy [ i ] ; if ( 0 <= nx && nx < w && 0 <= ny && ny < h && a [ y ] [ x ] > a [ ny ] [ nx ] ) { res += saiki ( nx , ny ) ; } } memo [ y ] [ x ] = ( int ) ( res % MOD ) + 1 ; return memo [ y ] [ x ] ; } }

import subprocess as sp NEW_LINE import sys NEW_LINE code = r ''' STRNEWLINE # include ▁ < algorithm > STRNEWLINE # include ▁ < cstdio > STRNEWLINE using ▁ namespace ▁ std ; STRNEWLINE const ▁ int ▁ M ▁ = ▁ 1000000007 ; STRNEWLINE int ▁ h , ▁ w ; STRNEWLINE int ▁ a [ 1000 ] [ 1000 ] , ▁ cache [ 1000 ] [ 1000 ] ; STRNEWLINE unsigned ▁ f ( int ▁ x , ▁ int ▁ y ) ▁ { STRNEWLINE ▁ ▁ static ▁ int ▁ dx [ ] ▁ = ▁ { 1 , ▁ 0 , ▁ - 1 , ▁ 0 } ; STRNEWLINE ▁ ▁ static ▁ int ▁ dy [ ] ▁ = ▁ { 0 , ▁ 1 , ▁ 0 , ▁ - 1 } ; STRNEWLINE ▁ ▁ int ▁ & c ▁ = ▁ cache [ y ] [ x ] ; STRNEWLINE ▁ ▁ if ▁ ( c ▁ < ▁ 0 ) ▁ { STRNEWLINE ▁ ▁ ▁ ▁ c ▁ = ▁ 1 ; STRNEWLINE ▁ ▁ ▁ ▁ for ▁ ( int ▁ d ▁ = ▁ 0 ; ▁ d ▁ < ▁ 4 ; ▁ + + d ) ▁ { STRNEWLINE ▁ ▁ ▁ ▁ ▁ ▁ int ▁ nx ▁ = ▁ x ▁ + ▁ dx [ d ] ; STRNEWLINE ▁ ▁ ▁ ▁ ▁ ▁ int ▁ ny ▁ = ▁ y ▁ + ▁ dy [ d ] ; STRNEWLINE ▁ ▁ ▁ ▁ ▁ ▁ if ▁ ( 0 ▁ < = ▁ nx ▁ and ▁ nx ▁ < ▁ w ▁ and ▁ 0 ▁ < = ▁ ny ▁ and ▁ ny ▁ < ▁ h ▁ and ▁ a [ ny ] [ nx ] ▁ > ▁ a [ y ] [ x ] ) ▁ { STRNEWLINE ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ c ▁ = ▁ ( c ▁ + ▁ f ( nx , ▁ ny ) ) ▁ % ▁ M ; STRNEWLINE ▁ ▁ ▁ ▁ ▁ ▁ } STRNEWLINE ▁ ▁ ▁ ▁ } STRNEWLINE ▁ ▁ } STRNEWLINE ▁ ▁ return ▁ c ; STRNEWLINE } STRNEWLINE int ▁ main ( ) ▁ { STRNEWLINE ▁ ▁ int ▁ total ▁ = ▁ 0 ; STRNEWLINE ▁ ▁ scanf ( " % d % d " , ▁ & h , ▁ & w ) ; STRNEWLINE ▁ ▁ for ▁ ( int ▁ y ▁ = ▁ 0 ; ▁ y ▁ < ▁ h ; ▁ + + y ) ▁ { STRNEWLINE ▁ ▁ ▁ ▁ for ▁ ( int ▁ x ▁ = ▁ 0 ; ▁ x ▁ < ▁ w ; ▁ + + x ) ▁ { STRNEWLINE ▁ ▁ ▁ ▁ ▁ ▁ scanf ( " % d " , ▁ & a [ y ] [ x ] ) ; STRNEWLINE ▁ ▁ ▁ ▁ } STRNEWLINE ▁ ▁ } STRNEWLINE ▁ ▁ for ▁ ( int ▁ y ▁ = ▁ 0 ; ▁ y ▁ < ▁ h ; ▁ + + y ) ▁ { STRNEWLINE ▁ ▁ ▁ ▁ for ▁ ( int ▁ x ▁ = ▁ 0 ; ▁ x ▁ < ▁ w ; ▁ + + x ) ▁ { STRNEWLINE ▁ ▁ ▁ ▁ ▁ ▁ cache [ y ] [ x ] ▁ = ▁ - 1 ; STRNEWLINE ▁ ▁ ▁ ▁ } STRNEWLINE ▁ ▁ } STRNEWLINE ▁ ▁ for ▁ ( int ▁ y ▁ = ▁ 0 ; ▁ y ▁ < ▁ h ; ▁ + + y ) ▁ { STRNEWLINE ▁ ▁ ▁ ▁ for ▁ ( int ▁ x ▁ = ▁ 0 ; ▁ x ▁ < ▁ w ; ▁ + + x ) ▁ { STRNEWLINE ▁ ▁ ▁ ▁ ▁ ▁ total ▁ = ▁ ( total ▁ + ▁ f ( x , ▁ y ) ) ▁ % ▁ M ; STRNEWLINE ▁ ▁ ▁ ▁ } STRNEWLINE ▁ ▁ } STRNEWLINE ▁ ▁ printf ( " % d \n " , ▁ total ) ; STRNEWLINE ▁ ▁ return ▁ 0 ; STRNEWLINE } STRNEWLINE ''' NEW_LINE filename = ' sense _ of _ guilt . cpp ' NEW_LINE with open ( filename , ' w ' ) as f : NEW_LINE INDENT print ( code , file = f ) NEW_LINE DEDENT sp . Popen ( [ ' g + + ' , ' - std = c + + 11' , ' - O2' , filename ] ) . communicate ( ) NEW_LINE sp . Popen ( [ ' . / a . out ' ] , stdin = sys . stdin , stdout = sys . stdout ) . communicate ( ) NEW_LINE


import java . util . Scanner ; public class Main { static int H , W ; static int [ ] [ ] src ; static int [ ] [ ] dp ; static final int MOD = 1000000007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; H = Integer . parseInt ( sc . next ( ) ) ; W = Integer . parseInt ( sc . next ( ) ) ; src = new int [ H ] [ W ] ; for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { src [ i ] [ j ] = Integer . parseInt ( sc . next ( ) ) ; } } dp = new int [ H ] [ W ] ; int ans = 0 ; for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { ans = ( ans + pattern ( j , i ) ) % MOD ; } } System . out . println ( ans ) ; } static int pattern ( int x , int y ) { if ( dp [ y ] [ x ] > 0 ) return dp [ y ] [ x ] ; int a = src [ y ] [ x ] ; int ret = 1 ; if ( x > 0 && a > src [ y ] [ x - 1 ] ) ret = ( ret + pattern ( x - 1 , y ) ) % MOD ; if ( y > 0 && a > src [ y - 1 ] [ x ] ) ret = ( ret + pattern ( x , y - 1 ) ) % MOD ; if ( x < W - 1 && a > src [ y ] [ x + 1 ] ) ret = ( ret + pattern ( x + 1 , y ) ) % MOD ; if ( y < H - 1 && a > src [ y + 1 ] [ x ] ) ret = ( ret + pattern ( x , y + 1 ) ) % MOD ; return dp [ y ] [ x ] = ret ; } }


import java . util . * ; public class Main { public static final long INF = 1000000000000000000L ; public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; final int N = in . nextInt ( ) ; long [ ] as = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { as [ i ] = in . nextLong ( ) ; } long K = 0 ; while ( true ) { boolean isFinished = true ; for ( int i = 0 ; i < N ; i ++ ) { final long k = as [ i ] / N ; if ( k > 0 ) { isFinished = false ; K += k ; for ( int j = 0 ; j < N ; j ++ ) { if ( j == i ) { as [ j ] = as [ j ] % N ; } else { as [ j ] += k ; } } } } if ( isFinished ) { break ; } } System . out . printf ( " % d \n " , K ) ; } }

import array NEW_LINE from bisect import * NEW_LINE from collections import * NEW_LINE import fractions NEW_LINE import heapq NEW_LINE from itertools import * NEW_LINE import math NEW_LINE import random NEW_LINE import re NEW_LINE import string NEW_LINE import sys NEW_LINE N = int ( input ( ) ) NEW_LINE As = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = 0 NEW_LINE while True : NEW_LINE INDENT taken = [ 0 ] * N NEW_LINE for i , a in enumerate ( As ) : NEW_LINE INDENT taken [ i ] = a // N NEW_LINE As [ i ] -= taken [ i ] * N NEW_LINE DEDENT taken_sum = sum ( taken ) NEW_LINE if taken_sum == 0 : NEW_LINE INDENT break NEW_LINE DEDENT ans += taken_sum NEW_LINE for i in range ( N ) : NEW_LINE INDENT As [ i ] += ( taken_sum - taken [ i ] ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE


import sys NEW_LINE stdin = sys . stdin NEW_LINE sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE def li_ ( ) : return map ( lambda x : int ( x ) - 1 , stdin . readline ( ) . split ( ) ) NEW_LINE def lf ( ) : return map ( float , stdin . readline ( ) . split ( ) ) NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( stdin . readline ( ) ) NEW_LINE def nf ( ) : return float ( stdin . readline ( ) ) NEW_LINE n = ni ( ) NEW_LINE a = list ( li ( ) ) NEW_LINE def judge ( a : list , n : int ) : NEW_LINE INDENT for ai in a : NEW_LINE INDENT if ai >= n : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT ans = 0 NEW_LINE while judge ( a , n ) : NEW_LINE INDENT amax = max ( a ) NEW_LINE argmax = a . index ( amax ) NEW_LINE x = - ( - ( amax - ( n - 1 ) ) // n ) NEW_LINE ans += x NEW_LINE nex = [ ai + x if i != argmax else ai - n * x for ( i , ai ) in enumerate ( a ) ] NEW_LINE a = nex NEW_LINE DEDENT print ( ans ) NEW_LINE


n = int ( input ( ) ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE def f ( x ) : NEW_LINE INDENT k = 0 NEW_LINE for i in a : k += ( i + x - n ) // ( n + 1 ) + 1 NEW_LINE return k <= x NEW_LINE DEDENT for i in range ( max ( 0 , sum ( a ) - n * ( n - 1 ) ) , 51 * ( 10 ** 16 ) ) : NEW_LINE INDENT if f ( i ) : break NEW_LINE DEDENT print ( i ) NEW_LINE


n , * A = map ( int , open ( 0 ) . read ( ) . split ( ) ) NEW_LINE ans = 0 NEW_LINE while 1 : NEW_LINE INDENT A . sort ( reverse = 1 ) NEW_LINE if A [ 0 ] > A [ - 1 ] + n : NEW_LINE INDENT p = ( A [ 0 ] - A [ - 1 ] ) // ( n + 1 ) NEW_LINE for j in range ( n ) : NEW_LINE INDENT A [ j ] += p NEW_LINE DEDENT A [ 0 ] -= p * ( n + 1 ) NEW_LINE ans += p NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if max ( A ) >= 2 * n : NEW_LINE INDENT ans += ( max ( A ) - 2 * n ) * n NEW_LINE ma = max ( A ) - 2 * n NEW_LINE for i in range ( n ) : NEW_LINE INDENT A [ i ] -= ma NEW_LINE DEDENT DEDENT while max ( A ) >= n : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT A [ i ] += 1 NEW_LINE DEDENT A [ A . index ( max ( A ) ) ] -= n + 1 NEW_LINE ans += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE


def check ( _a ) : NEW_LINE INDENT for i in range ( 0 , len ( _a ) ) : NEW_LINE INDENT if N <= _a [ i ] : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE divide_num = [ 0 for i in range ( N ) ] NEW_LINE ans = 0 NEW_LINE while check ( a ) : NEW_LINE INDENT sum_num = 0 NEW_LINE for i in range ( 0 , N ) : NEW_LINE INDENT tmp = a [ i ] // N NEW_LINE divide_num [ i ] = tmp NEW_LINE sum_num += tmp NEW_LINE ans += tmp NEW_LINE DEDENT a = [ ( a [ i ] % N + sum_num - divide_num [ i ] ) for i in range ( 0 , N ) ] NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long [ ] a = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) a [ i ] = sc . nextLong ( ) ; long ans = 0 ; Arrays . sort ( a ) ; for ( int i = 1 ; i < N ; i ++ ) { long op = ( a [ i ] - a [ 0 ] ) / ( N + 1 ) ; ans += op ; a [ i ] -= op * ( N + 1 ) ; } for ( int i = 0 ; i < N ; i ++ ) a [ i ] += ans ; Arrays . sort ( a ) ; long op = Math . max ( 0 , a [ 0 ] - N ) ; for ( int i = 0 ; i < N ; i ++ ) a [ i ] -= op ; ans += op * N ; int idx = N - 1 ; while ( true ) { if ( a [ idx ] <= N - 1 ) break ; ans ++ ; a [ idx ] -= N ; for ( int i = 0 ; i < N ; i ++ ) if ( i != idx ) a [ i ] ++ ; idx = ( idx - 1 + N ) % N ; } System . out . println ( ans ) ; sc . close ( ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextLong ( ) ; sc . close ( ) ; long ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { long min = Math . max ( n , Arrays . stream ( a ) . min ( ) . getAsLong ( ) ) ; long div = ( a [ i ] - min ) / ( n + 1 ) ; ans += div ; a [ i ] -= div * n ; for ( int j = 0 ; j < n ; j ++ ) { if ( i == j ) continue ; a [ j ] += div ; } } long min = Arrays . stream ( a ) . min ( ) . getAsLong ( ) ; if ( min >= n ) { ans += ( min - n + 1 ) * n ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] -= ( min - n + 1 ) ; } } while ( true ) { int maxpos = 0 ; long max = Long . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > max ) { max = a [ i ] ; maxpos = i ; } } if ( max < n ) break ; ans ++ ; a [ maxpos ] -= n ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == maxpos ) continue ; a [ i ] ++ ; } } System . out . println ( ans ) ; } }


import java . util . * ; public class Main { public void main ( Scanner sc ) { int n = sc . nextInt ( ) ; long a [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } long ans = 0 ; while ( true ) { long adivn [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { adivn [ i ] = a [ i ] / n ; } long sum = Arrays . stream ( adivn ) . sum ( ) ; ans += sum ; if ( sum == 0 ) { break ; } for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = a [ i ] % n + sum - adivn [ i ] ; } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextLong ( ) ; long sum = 0 ; for ( long lo : a ) sum += lo ; long res = 0 ; while ( true ) { long [ ] b = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { long sho = a [ i ] / n ; a [ i ] %= n ; for ( int j = 0 ; j < n ; j ++ ) { if ( i == j ) continue ; b [ j ] += sho ; } } for ( int i = 0 ; i < n ; i ++ ) a [ i ] += b [ i ] ; boolean allzero = true ; for ( long lo : b ) if ( lo != 0 ) allzero = false ; if ( allzero ) break ; } for ( long lo : a ) sum -= lo ; System . out . println ( sum ) ; } }


import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = Integer . parseInt ( scanner . nextLine ( ) ) ; String [ ] names = new String [ n ] ; int [ ] popularity = new int [ n ] ; int totalPopularity = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] line = scanner . nextLine ( ) . split ( " ▁ " , 2 ) ; names [ i ] = line [ 0 ] ; popularity [ i ] = Integer . parseInt ( line [ 1 ] ) ; totalPopularity += popularity [ i ] ; } String city = " atcoder " ; for ( int i = 0 ; i < n ; i ++ ) { if ( popularity [ i ] > totalPopularity / 2 ) { city = names [ i ] ; break ; } } System . out . println ( city ) ; } }

n = int ( input ( ) ) NEW_LINE people = 0 NEW_LINE max_a = " hoge " NEW_LINE max_b = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT a , b = map ( str , input ( ) . split ( ) ) NEW_LINE people += int ( b ) NEW_LINE if ( max_b < int ( b ) ) : NEW_LINE INDENT max_b = int ( b ) NEW_LINE max_a = a NEW_LINE DEDENT DEDENT if ( people < 2 * max_b ) : NEW_LINE INDENT print ( max_a ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " atcoder " ) NEW_LINE DEDENT


from statistics import mean , median , variance , stdev NEW_LINE import numpy as np NEW_LINE import sys NEW_LINE import math NEW_LINE import fractions NEW_LINE import itertools NEW_LINE import copy NEW_LINE from operator import itemgetter NEW_LINE def j ( q ) : NEW_LINE INDENT if q == 1 : print ( " Yes " ) NEW_LINE else : print ( " No " ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT def ct ( x , y ) : NEW_LINE INDENT if ( x > y ) : print ( " + " ) NEW_LINE elif ( x < y ) : print ( " - " ) NEW_LINE else : print ( " ? " ) NEW_LINE DEDENT def ip ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT def pne ( n ) : NEW_LINE INDENT print ( n , end = ' ' ) NEW_LINE DEDENT rem = pow ( 10 , 9 ) + 7 NEW_LINE n = ip ( ) NEW_LINE cityname = [ ] NEW_LINE population = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT x , y = input ( ) . split ( ) NEW_LINE cityname . append ( x ) NEW_LINE population . append ( int ( y ) ) NEW_LINE DEDENT if max ( population ) / sum ( population ) > 0.5 : NEW_LINE INDENT a = population . index ( max ( population ) ) NEW_LINE print ( cityname [ a ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " atcoder " ) NEW_LINE DEDENT


def getInt ( ) : return int ( input ( ) ) NEW_LINE def getIntList ( ) : return [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE def zeros ( n ) : return [ 0 ] * n NEW_LINE class Debug ( ) : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . debug = True NEW_LINE DEDENT def off ( self ) : NEW_LINE INDENT self . debug = False NEW_LINE DEDENT def dmp ( self , x , cmt = ' ' ) : NEW_LINE INDENT if self . debug : NEW_LINE INDENT if cmt != ' ' : NEW_LINE INDENT print ( cmt , ' : ▁ ▁ ' , end = ' ' ) NEW_LINE DEDENT print ( x ) NEW_LINE DEDENT return x NEW_LINE DEDENT DEDENT def prob ( ) : NEW_LINE INDENT N = getInt ( ) NEW_LINE s = zeros ( N ) NEW_LINE p = zeros ( N ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT s [ i ] , p [ i ] = [ x for x in input ( ) . split ( ) ] NEW_LINE p [ i ] = int ( p [ i ] ) NEW_LINE DEDENT d = Debug ( ) NEW_LINE d . off ( ) NEW_LINE d . dmp ( ( N ) , ' N ' ) NEW_LINE d . dmp ( ( s ) , ' s ' ) NEW_LINE d . dmp ( ( p ) , ' p ' ) NEW_LINE if max ( p ) * 2 > sum ( p ) : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT if p [ i ] == max ( p ) : NEW_LINE INDENT print ( s [ i ] ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT print ( ' atcoder ' ) NEW_LINE DEDENT DEDENT a = prob ( ) NEW_LINE


def merge ( N : int , cities : list ) -> str : NEW_LINE INDENT max_people = 0 NEW_LINE city = ' atcoder ' NEW_LINE total = 0 NEW_LINE for c , p in cities : NEW_LINE INDENT if max_people < p : NEW_LINE INDENT max_people = p NEW_LINE city = c NEW_LINE DEDENT total += p NEW_LINE DEDENT return city if max_people > total // 2 else ' atcoder ' NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE cities = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT c , p = input ( ) . split ( ) NEW_LINE cities . append ( ( c , int ( p ) ) ) NEW_LINE DEDENT ans = merge ( N , cities ) NEW_LINE print ( ans ) NEW_LINE DEDENT


n = int ( input ( ) ) NEW_LINE s = [ ] NEW_LINE p = [ ] NEW_LINE sum = 0 NEW_LINE newName = " atcoder " NEW_LINE for i in range ( n ) : NEW_LINE INDENT name , population = input ( ) . split ( ) NEW_LINE s . append ( name ) NEW_LINE p . append ( int ( population ) ) NEW_LINE sum += int ( population ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT if p [ i ] > sum / 2 : NEW_LINE INDENT newName = s [ i ] NEW_LINE DEDENT DEDENT print ( newName ) NEW_LINE


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class B { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int n = in . ints ( ) ; long total = 0 ; int max = 0 ; String ml = null ; for ( int i = 0 ; i < n ; i ++ ) { String s = in . string ( ) ; int p = in . ints ( ) ; if ( p > max ) { max = p ; ml = s ; } total += p ; } if ( max * 2 > total ) { out . println ( ml ) ; } else { out . println ( " atcoder " ) ; } } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } } }


import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int size = sc . nextInt ( ) ; List < TownInfo > townList = new ArrayList < > ( ) ; double total = 0 ; for ( int i = 0 ; i < size ; i ++ ) { String townName = sc . next ( ) ; double population = sc . nextDouble ( ) ; total += population ; TownInfo info = new TownInfo ( townName , population ) ; townList . add ( info ) ; } sc . close ( ) ; String newTownName = " atcoder " ; for ( TownInfo townInfo : townList ) { double popu = townInfo . getPopulation ( ) ; double percent = ( popu * 100 / total ) ; if ( percent > 50 ) { newTownName = townInfo . getTownName ( ) ; } } System . out . println ( newTownName ) ; } } class TownInfo { private String townName ; private double population ; public TownInfo ( String townName , double population ) { this . townName = townName ; this . population = population ; } public String getTownName ( ) { return townName ; } public double getPopulation ( ) { return population ; } }


import java . util . Map ; import java . util . Scanner ; import java . util . TreeMap ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Map < String , Integer > map = new TreeMap < > ( ) ; int n = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) map . put ( sc . next ( ) , sc . nextInt ( ) ) ; int sum = 0 ; String ans = " atcoder " ; for ( Integer v : map . values ( ) ) sum += v ; for ( String str : map . keySet ( ) ) if ( map . get ( str ) > sum / 2 ) ans = str ; System . out . println ( ans ) ; } }


import java . util . HashMap ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String [ ] name = new String [ n ] ; int [ ] jinkou = new int [ n ] ; HashMap < Integer , String > map = new HashMap < Integer , String > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { name [ i ] = sc . next ( ) ; jinkou [ i ] = sc . nextInt ( ) ; map . put ( jinkou [ i ] , name [ i ] ) ; } int max = jinkou [ 0 ] ; int total = 0 ; for ( int j = 0 ; j < jinkou . length ; j ++ ) { total += jinkou [ j ] ; if ( max < jinkou [ j ] ) max = jinkou [ j ] ; } if ( ( total / 2 ) < max ) { System . out . println ( map . get ( max ) ) ; } else { System . out . println ( " atcoder " ) ; } } }


import java . util . Scanner ; import org . omg . Messaging . SyncScopeHelper ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { try ( Scanner sc = new Scanner ( System . in ) ) { long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long M = sc . nextLong ( ) ; long g = gcd ( A , B ) ; long ans = 1 ; ans *= f ( A , M ) ; ans %= M ; ans *= g ( B / g , g , M ) ; ans %= M ; System . out . println ( ans ) ; } } long g ( long x , long g , long M ) { if ( x == 0 ) return 0 ; if ( x % 2 == 1 ) return ( mod_pow ( 10 , g , M ) * g ( x - 1 , g , M ) + 1 ) % M ; else return g ( x / 2 , g , M ) * ( 1 + mod_pow ( 10 , g * x / 2 , M ) ) % M ; } long f ( long x , long M ) { if ( x == 0 ) return 0 ; if ( x % 2 == 1 ) return ( 10L * f ( x - 1 , M ) + 1 ) % M ; return f ( x / 2 , M ) * ( 1 + mod_pow ( 10 , x / 2 , M ) ) % M ; } static long gcd ( long a , long b ) { return b == 0 ? a : gcd ( b , a % b ) ; } static long mod_pow ( long a , long b , long p ) { long res = 1 ; while ( b > 0 ) { if ( ( b & 1 ) == 1 ) res = ( res * a ) % p ; a = ( a * a ) % p ; b >>= 1 ; } return res ; } }

def F ( D , N , X = 1 ) : Z = N and F ( D * D % M , N // 2 , ( X * D + X ) % M ) ; return [ Z , Z * D + X ] [ N % 2 ] NEW_LINE A , B , M = map ( int , input ( ) . split ( ) ) ; K = __import__ ( ' fractions ' ) . gcd ( A , B ) ; print ( F ( 10 , A ) * F ( pow ( 10 , K , M ) , B // K ) % M ) NEW_LINE


A , B , M = map ( int , input ( ) . split ( ) ) NEW_LINE def gcd ( m , n ) : NEW_LINE INDENT r = m % n NEW_LINE return gcd ( n , r ) if r else n NEW_LINE DEDENT G = gcd ( A , B ) NEW_LINE def mul ( A , B ) : NEW_LINE INDENT a , b , c , d = A ; p , q , r , s = B NEW_LINE return ( a * p + b * r ) % M , ( a * q + b * s ) % M , ( c * p + d * r ) % M , ( c * q + d * s ) % M NEW_LINE DEDENT def m_pow ( x , n ) : NEW_LINE INDENT S = pow ( 10 , x , M ) , 1 , 0 , 1 NEW_LINE R = 1 , 0 , 0 , 1 NEW_LINE while n : NEW_LINE INDENT if n & 1 : NEW_LINE INDENT R = mul ( R , S ) NEW_LINE DEDENT S = mul ( S , S ) NEW_LINE n >>= 1 NEW_LINE DEDENT return R [ 1 ] NEW_LINE DEDENT P = m_pow ( G , A // G ) NEW_LINE Q = m_pow ( 1 , B ) NEW_LINE print ( ( P * Q ) % M ) NEW_LINE


def gcd ( x , y ) : NEW_LINE INDENT if y == 0 : NEW_LINE INDENT return x NEW_LINE DEDENT else : NEW_LINE INDENT return gcd ( y , x % y ) NEW_LINE DEDENT DEDENT def oneone ( i , l , M ) : NEW_LINE INDENT if i < 3 : NEW_LINE INDENT return sum ( pow ( 10 , j * l , M ) for j in range ( i ) ) % M NEW_LINE DEDENT else : NEW_LINE INDENT return ( oneone ( 2 , ( i // 2 ) * l , M ) * oneone ( i // 2 , l , M ) + ( i % 2 ) * pow ( 10 , ( i - 1 ) * l , M ) ) % M NEW_LINE DEDENT DEDENT A , B , M = map ( int , input ( ) . split ( ) ) NEW_LINE g = gcd ( A , B ) NEW_LINE x = oneone ( A // g , g , M ) NEW_LINE y = oneone ( B , 1 , M ) NEW_LINE print ( x * y % M ) NEW_LINE


def modpowsum ( a , n , m ) : NEW_LINE INDENT if n == 0 : return 0 NEW_LINE elif n % 2 == 1 : return ( 1 + a * modpowsum ( a , n - 1 , m ) ) % m NEW_LINE else : NEW_LINE INDENT t = modpowsum ( a , n // 2 , m ) NEW_LINE return ( t + ( t * pow ( a , n // 2 , m ) ) % m ) % m NEW_LINE DEDENT DEDENT def gcd ( x , y ) : NEW_LINE INDENT if x > y : x , y = y , x NEW_LINE if x == 0 : return y NEW_LINE else : return gcd ( y % x , x ) NEW_LINE DEDENT a , b , m = map ( int , input ( ) . split ( ) ) NEW_LINE g = gcd ( a , b ) NEW_LINE t1 = modpowsum ( pow ( 10 , g , m ) , a // g , m ) NEW_LINE t2 = modpowsum ( 10 , b , m ) NEW_LINE print ( ( t1 * t2 ) % m ) NEW_LINE


import numpy as np NEW_LINE from fractions import gcd NEW_LINE A , B , M = map ( int , input ( ) . split ( ) ) NEW_LINE D = gcd ( A , B ) NEW_LINE X = np . array ( [ [ 10 , 1 ] , [ 0 , 1 ] ] ) NEW_LINE Y = np . array ( [ [ pow ( 10 , D , M ) , 1 ] , [ 0 , 1 ] ] ) NEW_LINE x = np . array ( [ 0 , 1 ] ) NEW_LINE def f ( a , A ) : NEW_LINE INDENT T = np . array ( [ [ 1 , 0 ] , [ 0 , 1 ] ] ) NEW_LINE U = A NEW_LINE s = a NEW_LINE while s != 0 : NEW_LINE INDENT if s % 2 == 1 : NEW_LINE INDENT T = np . dot ( T , U ) NEW_LINE T = T % M NEW_LINE DEDENT U = np . dot ( U , U ) NEW_LINE U = U % M NEW_LINE s = s // 2 NEW_LINE DEDENT return T % M NEW_LINE DEDENT print ( ( ( np . dot ( f ( A , X ) , x ) ) [ 0 ] * np . dot ( f ( B // D , Y ) , x ) [ 0 ] ) % M ) NEW_LINE


import java . util . * ; class Main { static long gcd ( long x , long y ) { return y == 0 ? x : gcd ( y , x % y ) ; } static long powerMod ( long x , long exponent , long m ) { long prod = 1 ; for ( int i = 63 ; i >= 0 ; -- i ) { prod = ( prod * prod ) % m ; if ( ( exponent & 1L << i ) != 0 ) { prod = ( prod * x ) % m ; } } return prod ; } static long f ( long x , long y , long m ) { long oy = y ; long t = 0 ; long c = x ; long s = 1 ; while ( y > 0 ) { if ( y % 2 == 1 ) { t = ( t + s ) % m ; s = s * ( ( c + c * c ) % m ) % m ; } else s = s * ( 1 + c ) % m ; c = c * c % m ; y /= 2 ; } return t ; } public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long a = scan . nextLong ( ) ; long b = scan . nextLong ( ) ; long m = scan . nextLong ( ) ; long g = gcd ( a , b ) ; long t = f ( 10 , g , m ) ; t = t * f ( powerMod ( 10 , g , m ) , a / g , m ) % m ; t = t * f ( powerMod ( 10 , g , m ) , b / g , m ) % m ; System . out . println ( t ) ; } }


import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int R = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] [ ] cum = new int [ R + 1 ] [ C + 1 ] ; for ( int i = 0 ; i < R ; i ++ ) { String s = sc . next ( ) ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { if ( s . charAt ( j ) == ' x ' ) { cum [ i + 1 ] [ j + 1 ] = 1 ; } } } for ( int r = 1 ; r <= R ; r ++ ) { for ( int c = 1 ; c <= C ; c ++ ) { cum [ r ] [ c ] += cum [ r - 1 ] [ c ] ; } } int ans = 0 ; for ( int x = K ; x <= R - K + 1 ; x ++ ) { for ( int y = K ; y <= C - K + 1 ; y ++ ) { boolean ok = true ; int jLeft = y - ( K - 1 ) ; int jRight = y + ( K - 1 ) ; if ( jLeft < 1 || jRight > C ) { continue ; } for ( int j = jLeft ; j <= jRight ; j ++ ) { int iUp = x + Math . abs ( j - y ) - ( K - 1 ) ; int iDown = x - Math . abs ( j - y ) + ( K - 1 ) ; if ( iUp < 1 || iDown > R || cum [ iDown ] [ j ] - cum [ iUp - 1 ] [ j ] != 0 ) { ok = false ; break ; } } if ( ok ) { ans ++ ; } } } out . println ( ans ) ; } }

import sys NEW_LINE inp = sys . stdin . readline NEW_LINE R , C , K = map ( int , inp ( ) . split ( ) ) NEW_LINE imo = [ [ 0 ] * ( C + 1 ) for _ in range ( R ) ] NEW_LINE for i in range ( R ) : NEW_LINE INDENT s = inp ( ) NEW_LINE for j in range ( C ) : NEW_LINE INDENT if ( s [ j ] == " x " ) : NEW_LINE INDENT for k in range ( K ) : NEW_LINE INDENT if ( i - k >= 0 ) : NEW_LINE INDENT imo [ i - k ] [ max ( 0 , j - K + k + 1 ) ] += 1 NEW_LINE imo [ i - k ] [ min ( C , j + K - k ) ] -= 1 NEW_LINE DEDENT if ( i + k < R ) : NEW_LINE INDENT imo [ i + k ] [ max ( 0 , j - K + k + 1 ) ] += 1 NEW_LINE imo [ i + k ] [ min ( C , j + K - k ) ] -= 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT for i in range ( R ) : NEW_LINE INDENT for j in range ( 1 , C + 1 ) : NEW_LINE INDENT imo [ i ] [ j ] += imo [ i ] [ j - 1 ] NEW_LINE DEDENT DEDENT ans = 0 NEW_LINE for y in range ( K - 1 , C - K + 1 ) : NEW_LINE INDENT for x in range ( K - 1 , R - K + 1 ) : NEW_LINE INDENT if ( imo [ x ] [ y ] == 0 ) : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE


from collections import defaultdict , deque NEW_LINE import sys , heapq , bisect , math , itertools , string , queue , datetime NEW_LINE sys . setrecursionlimit ( 10 ** 8 ) NEW_LINE INF = float ( ' inf ' ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE eps = 10 ** - 7 NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def inpl_s ( ) : return list ( input ( ) . split ( ) ) NEW_LINE H , W , K = inpl ( ) NEW_LINE K -= 1 NEW_LINE MAP = [ list ( input ( ) ) for i in range ( H ) ] NEW_LINE MAP2 = [ [ 0 ] * ( W + 2 * K + 1 ) for i in range ( H ) ] NEW_LINE def Update ( sx , sy ) : NEW_LINE INDENT global MAP2 NEW_LINE for y in range ( sy - K , sy + K + 1 ) : NEW_LINE INDENT if not ( 0 <= y < H ) : NEW_LINE INDENT continue NEW_LINE DEDENT L = K - abs ( sy - y ) NEW_LINE lx = sx - L NEW_LINE rx = sx + L + 1 NEW_LINE MAP2 [ y ] [ lx + K ] += 1 NEW_LINE MAP2 [ y ] [ rx + K ] -= 1 NEW_LINE DEDENT DEDENT for y in range ( H ) : NEW_LINE INDENT for x in range ( W ) : NEW_LINE INDENT if MAP [ y ] [ x ] == ' x ' : NEW_LINE INDENT Update ( x , y ) NEW_LINE DEDENT DEDENT DEDENT ans = 0 NEW_LINE for y in range ( H ) : NEW_LINE INDENT tmp = 0 NEW_LINE for x in range ( W + 2 * K + 1 ) : NEW_LINE INDENT tmp += MAP2 [ y ] [ x ] NEW_LINE MAP2 [ y ] [ x ] = tmp NEW_LINE if tmp == 0 and K <= y < H - K and K * 2 <= x < W : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE


import math NEW_LINE Y , X , K = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ [ 0 if c == " x " else 1 for c in input ( ) ] for i in range ( Y ) ] NEW_LINE for x in range ( X ) : NEW_LINE INDENT fr = 0 NEW_LINE for y in range ( Y + 1 ) : NEW_LINE INDENT if y == Y or a [ y ] [ x ] == 0 : NEW_LINE INDENT for i in range ( math . ceil ( ( y - fr ) / 2 ) ) : NEW_LINE INDENT a [ fr + i ] [ x ] = i + 1 NEW_LINE a [ y - i - 1 ] [ x ] = i + 1 NEW_LINE DEDENT fr = y + 1 NEW_LINE DEDENT DEDENT DEDENT result = 0 NEW_LINE diamond_length = ( K - 1 ) * 2 + 1 NEW_LINE diamond_radius = K NEW_LINE for y in range ( K - 1 , Y - K + 1 ) : NEW_LINE INDENT start = 0 NEW_LINE cnt = a [ y ] . count ( 0 ) NEW_LINE for i in range ( cnt + 1 ) : NEW_LINE INDENT end = a [ y ] . index ( 0 , start ) if i < cnt else X - 1 NEW_LINE range_length = end - start + 1 NEW_LINE if range_length < diamond_length : NEW_LINE INDENT start = end + 1 NEW_LINE continue NEW_LINE DEDENT checked = 0 NEW_LINE for j in range ( range_length - diamond_length + 1 ) : NEW_LINE INDENT checked = max ( 0 , checked - 1 ) NEW_LINE _start = start + j NEW_LINE is_creatable = True NEW_LINE flag = True NEW_LINE for k in range ( checked , diamond_length ) : NEW_LINE INDENT req = k + 1 if k < diamond_radius else 2 * diamond_radius - k - 1 NEW_LINE now = a [ y ] [ _start + k ] NEW_LINE if now < req : NEW_LINE INDENT is_creatable = False NEW_LINE break NEW_LINE DEDENT elif k <= diamond_radius - 1 or flag and now >= diamond_radius : NEW_LINE INDENT checked = k NEW_LINE DEDENT else : NEW_LINE INDENT flag = False NEW_LINE DEDENT DEDENT if is_creatable : NEW_LINE INDENT result += 1 NEW_LINE DEDENT DEDENT start = end + 1 NEW_LINE DEDENT DEDENT print ( result ) NEW_LINE


import numpy as np NEW_LINE from itertools import product NEW_LINE R , C , K = map ( int , input ( ) . split ( ) ) NEW_LINE s = [ input ( ) for i in range ( R ) ] NEW_LINE cs = np . zeros ( ( R + C + 1 , R + C + 1 ) , dtype = np . int16 ) NEW_LINE for i , j in product ( range ( R ) , range ( C ) ) : NEW_LINE INDENT if s [ i ] [ j ] == " x " : NEW_LINE INDENT cs [ C + i - j , i + j + 1 ] = 1 NEW_LINE DEDENT DEDENT cs = np . cumsum ( cs , axis = 0 ) NEW_LINE cs = np . cumsum ( cs , axis = 1 ) NEW_LINE ans = 0 NEW_LINE k = K - 1 NEW_LINE for i , j in product ( range ( R ) [ k : - k ] , range ( C ) [ k : - k ] ) : NEW_LINE INDENT x = C + i - j NEW_LINE y = i + j + 1 NEW_LINE rec = cs [ x + k , y + k ] NEW_LINE rec -= cs [ x + k , y - k - 1 ] NEW_LINE rec -= cs [ x - k - 1 , y + k ] NEW_LINE rec += cs [ x - k - 1 , y - k - 1 ] NEW_LINE if rec == 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE


import sys NEW_LINE input = sys . stdin . readline NEW_LINE inf = 10 ** 18 NEW_LINE R , C , K = map ( int , input ( ) . split ( ) ) NEW_LINE s = [ list ( input ( ) ) for _ in range ( R ) ] NEW_LINE hmat = [ [ 0 ] * C for _ in range ( R ) ] NEW_LINE for x in range ( C ) : NEW_LINE INDENT sum_tmp = 0 NEW_LINE for y in range ( R ) : NEW_LINE INDENT if s [ y ] [ x ] == ' o ' : NEW_LINE INDENT if sum_tmp == 0 : t = y NEW_LINE sum_tmp += 1 NEW_LINE dy = ( sum_tmp - 1 ) // 2 NEW_LINE hmat [ t + dy ] [ x ] = 1 + dy NEW_LINE DEDENT else : NEW_LINE INDENT sum_tmp = 0 NEW_LINE DEDENT DEDENT sum_tmp = 0 NEW_LINE for yi in range ( R ) : NEW_LINE INDENT y = R - 1 - yi NEW_LINE if s [ y ] [ x ] == ' o ' : NEW_LINE INDENT if sum_tmp == 0 : b = y NEW_LINE sum_tmp += 1 NEW_LINE dy = ( sum_tmp - 1 ) // 2 NEW_LINE hmat [ b - dy ] [ x ] = 1 + dy NEW_LINE DEDENT else : NEW_LINE INDENT sum_tmp = 0 NEW_LINE DEDENT DEDENT DEDENT ans = 0 NEW_LINE for yi , hrow in enumerate ( hmat [ ( K - 1 ) : ( R - K + 1 ) ] ) : NEW_LINE INDENT imos = [ 0 ] * C NEW_LINE y = yi + K - 1 NEW_LINE for x in range ( C ) : NEW_LINE INDENT hxy = hmat [ y ] [ x ] NEW_LINE if hxy < K : NEW_LINE INDENT loss = K - 1 - hxy NEW_LINE imos [ max ( 0 , x - loss ) ] += 1 NEW_LINE imos [ min ( C - 1 , x + loss + 1 ) ] -= 1 NEW_LINE DEDENT DEDENT tmp = 0 NEW_LINE dmg = [ 0 ] * C NEW_LINE for i , imosi in enumerate ( imos ) : NEW_LINE INDENT tmp += imosi NEW_LINE dmg [ i ] = tmp NEW_LINE DEDENT ans += dmg [ ( K - 1 ) : ( C - K + 1 ) ] . count ( 0 ) NEW_LINE DEDENT print ( ans ) NEW_LINE


public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int r = scanner . nextInt ( ) , c = scanner . nextInt ( ) , k = scanner . nextInt ( ) , s [ ] [ ] = java . util . stream . IntStream . range ( 0 , r ) . mapToObj ( i -> scanner . next ( ) . chars ( ) . toArray ( ) ) . toArray ( int [ ] [ ] :: new ) , a [ ] [ ] = new int [ r ] [ c ] ; java . util . stream . IntStream . range ( 0 , c ) . map ( i -> java . util . stream . IntStream . range ( 0 , r ) . reduce ( 0 , ( t , j ) -> a [ j ] [ i ] = s [ j ] [ i ] == ' x ' ? 0 : t + 1 ) + java . util . stream . IntStream . range ( 0 , r ) . reduce ( 0 , ( t , j ) -> a [ r - j - 1 ] [ i ] = Math . min ( a [ r - j - 1 ] [ i ] , s [ r - j - 1 ] [ i ] == ' x ' ? 0 : t + 1 ) ) ) . count ( ) ; System . out . println ( java . util . stream . IntStream . rangeClosed ( k - 1 , r - k ) . mapToLong ( i -> java . util . stream . IntStream . range ( 0 , c - k * 2 + 2 ) . filter ( j -> java . util . stream . IntStream . range ( 0 , k * 2 - 1 ) . allMatch ( l -> a [ i ] [ j + l ] >= Math . min ( l + 1 , k * 2 - l - 1 ) ) ) . count ( ) ) . sum ( ) ) ; } }


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; C solver = new C ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class C { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int r = in . nextInt ( ) , c = in . nextInt ( ) , k = in . nextInt ( ) - 1 ; int [ ] [ ] s = new int [ c + 1 ] [ r ] ; for ( int i = 0 ; i < r ; i ++ ) { String l = in . next ( ) ; for ( int j = 0 ; j < c ; j ++ ) { s [ j + 1 ] [ i ] = s [ j ] [ i ] + ( l . charAt ( j ) == ' o ' ? 1 : 0 ) ; } } int ans = 0 ; for ( int i = k ; i < r - k ; i ++ ) { mid : for ( int j = k + 1 ; j <= c - k ; j ++ ) { for ( int l = - k ; l <= k ; l ++ ) { int d = k - Math . abs ( l ) ; if ( s [ j + d ] [ i + l ] - s [ j - d - 1 ] [ i + l ] != 2 * d + 1 ) { continue mid ; } } ans ++ ; } } out . println ( ans ) ; } } }


import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int R = Integer . parseInt ( sc . next ( ) ) ; int C = Integer . parseInt ( sc . next ( ) ) ; int K = Integer . parseInt ( sc . next ( ) ) ; String s [ ] = new String [ R ] ; String color [ ] [ ] = new String [ R ] [ C ] ; for ( int i = 0 ; i < R ; i ++ ) { s [ i ] = sc . next ( ) ; for ( int j = 0 ; j < C ; j ++ ) { color [ i ] [ j ] = s [ i ] . substring ( j , j + 1 ) ; } } for ( int i = 0 ; i < R ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { if ( i < K - 1 || i > R - K || j < K - 1 || j > C - K ) { if ( color [ i ] [ j ] . equals ( " o " ) ) { color [ i ] [ j ] = " * " ; } } if ( color [ i ] [ j ] . equals ( " x " ) ) { for ( int y = i - ( K - 1 ) ; y <= i + ( K - 1 ) ; y ++ ) { if ( y < 0 || y >= R ) continue ; int width = ( K - 1 ) - Math . abs ( y - i ) ; for ( int x = j - width ; x <= j + width ; x ++ ) { if ( x < 0 || x >= C ) continue ; if ( color [ y ] [ x ] . equals ( " o " ) ) { color [ y ] [ x ] = " * " ; } } } } } } int ans = 0 ; for ( int i = 0 ; i < R ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { if ( color [ i ] [ j ] . equals ( " o " ) ) ans ++ ; } } System . out . println ( ans ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ans = 0 ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) , k = sc . nextInt ( ) ; boolean po [ ] [ ] = new boolean [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] s = sc . next ( ) . split ( " " , 0 ) ; for ( int j = 0 ; j < m ; j ++ ) po [ i ] [ j ] = ( s [ j ] . equals ( " o " ) ) ? true : false ; } int [ ] [ ] oo = new int [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { int min = 0 , max = 0 ; int in = i ; while ( in >= 0 && po [ in ] [ j ] ) { in -- ; min ++ ; } in = i ; while ( in < n && po [ in ] [ j ] ) { in ++ ; max ++ ; } oo [ i ] [ j ] = Math . min ( min , max ) ; } } for ( int i = k - 1 ; i < n - k + 1 ; i ++ ) for ( int j = k - 1 ; j < m - k + 1 ; j ++ ) { boolean d = true ; for ( int a = 0 ; a < k ; a ++ ) { d = d && ( oo [ i ] [ j - a ] >= k - a ) && ( oo [ i ] [ j + a ] >= k - a ) ; } if ( d ) ans ++ ; } System . out . println ( ans ) ; } }


import java . util . Scanner ; import java . util . StringJoiner ; import java . util . TreeSet ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; if ( scanner . hasNextLine ( ) ) { int N = Integer . parseInt ( scanner . nextLine ( ) ) ; if ( N == 3 ) { System . out . println ( "3 ▁ 5 ▁ 22" ) ; } else { int c6p3 = ( ( N - 1 ) / 8 ) * 2 + 2 ; int c6p2 = ( N - c6p3 - 1 ) / 3 + 1 ; int c6p6 = N - c6p3 - c6p2 - c6p2 ; TreeSet < Integer > set = new TreeSet < > ( ) ; for ( int i = 0 ; i < c6p3 ; ++ i ) { set . add ( i * 6 + 3 ) ; } for ( int i = 0 ; i < c6p2 ; ++ i ) { set . add ( i * 6 + 2 ) ; set . add ( i * 6 + 4 ) ; } for ( int i = 0 ; i < c6p6 ; ++ i ) { set . add ( i * 6 + 6 ) ; } StringJoiner joiner = new StringJoiner ( " ▁ " ) ; for ( Integer v : set ) { joiner . add ( v . toString ( ) ) ; } System . out . println ( joiner . toString ( ) ) ; } } } }

N = int ( input ( ) ) NEW_LINE if N == 3 : NEW_LINE INDENT ans = [ 2 , 3 , 25 ] NEW_LINE DEDENT else : NEW_LINE INDENT if N % 2 == 0 : NEW_LINE INDENT As = [ 2 , 10 , 3 , 9 , 4 , 8 , 6 , 12 ] NEW_LINE DEDENT else : NEW_LINE INDENT As = [ 6 , 2 , 10 , 3 , 9 , 4 , 8 , 12 ] NEW_LINE DEDENT ans = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT ans . append ( As [ i % 8 ] + 12 * ( i // 8 ) ) NEW_LINE DEDENT DEDENT print ( ' ▁ ' . join ( map ( str , ans ) ) ) NEW_LINE


import sys NEW_LINE stdin = sys . stdin NEW_LINE def li ( ) : return [ int ( x ) for x in stdin . readline ( ) . split ( ) ] NEW_LINE def li_ ( ) : return [ int ( x ) - 1 for x in stdin . readline ( ) . split ( ) ] NEW_LINE def lf ( ) : return [ float ( x ) for x in stdin . readline ( ) . split ( ) ] NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( ns ( ) ) NEW_LINE def nf ( ) : return float ( ns ( ) ) NEW_LINE def solve ( n : int ) -> list : NEW_LINE INDENT x6o2 = [ ( 6 * i + 2 , 6 * i + 4 ) for i in range ( 5000 ) ] NEW_LINE x6o3 = [ ( 12 * i + 3 , 12 * i + 9 ) for i in range ( 2500 ) ] NEW_LINE o6 = [ 6 * i + 6 for i in range ( 5000 ) ] NEW_LINE x6 = [ ] NEW_LINE for i in range ( 2500 ) : NEW_LINE INDENT x6 . append ( x6o3 [ i ] ) NEW_LINE x6 . append ( x6o2 [ 2 * i ] ) NEW_LINE x6 . append ( x6o2 [ 2 * i + 1 ] ) NEW_LINE DEDENT ans = [ ] NEW_LINE if n == 3 : NEW_LINE INDENT ans = [ 2 , 5 , 63 ] NEW_LINE DEDENT elif n <= 15000 : NEW_LINE INDENT idx = n // 2 NEW_LINE for i , ( mn , mx ) in enumerate ( x6 [ : idx ] ) : NEW_LINE INDENT ans . extend ( [ mn , mx ] ) NEW_LINE DEDENT if n % 2 : NEW_LINE INDENT ans = ans + [ 6 ] NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i , ( mn , mx ) in enumerate ( x6 ) : NEW_LINE INDENT ans . extend ( [ mn , mx ] ) NEW_LINE DEDENT for o6i in o6 [ : n - 15000 ] : NEW_LINE INDENT ans . append ( o6i ) NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT n = ni ( ) NEW_LINE print ( * solve ( n ) ) NEW_LINE


def prime_factors ( n ) : NEW_LINE INDENT i = 2 NEW_LINE factors = [ ] NEW_LINE while i * i <= n : NEW_LINE INDENT if n % i : NEW_LINE INDENT i += 1 NEW_LINE DEDENT else : NEW_LINE INDENT n //= i NEW_LINE factors . append ( i ) NEW_LINE DEDENT DEDENT if n > 1 : NEW_LINE INDENT factors . append ( n ) NEW_LINE DEDENT return factors NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE if n >= 15002 : NEW_LINE INDENT if n % 2 == 0 : NEW_LINE INDENT a = [ i * 2 for i in range ( 1 , 15001 ) ] + [ i * 6 + 3 for i in range ( n - 15000 ) ] NEW_LINE DEDENT else : NEW_LINE INDENT a = [ i * 2 for i in range ( 1 , 15000 ) ] + [ i * 6 + 3 for i in range ( n - 14999 ) ] NEW_LINE DEDENT print ( * a ) NEW_LINE DEDENT elif n == 3 : NEW_LINE INDENT print ( * [ 2 , 5 , 63 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT b = prime_factors ( ( n - 1 ) * ( n - 2 ) ) NEW_LINE b . sort ( ) NEW_LINE c = 0 NEW_LINE for i in b : NEW_LINE INDENT if i >= 3 : NEW_LINE INDENT c = i NEW_LINE break NEW_LINE DEDENT DEDENT d = [ i * 2 for i in range ( 1 , n - 1 ) ] + [ c , c * 3 ] NEW_LINE print ( * d ) NEW_LINE DEDENT


from sys import stdin NEW_LINE d_in = lambda : int ( stdin . readline ( ) ) NEW_LINE MAX = 30000 NEW_LINE N = d_in ( ) NEW_LINE base = [ 3 , 25 , 2 , 35 , 55 ] NEW_LINE cand = [ ] NEW_LINE for i in range ( 4 , MAX // 2 , 2 ) : NEW_LINE INDENT cand . append ( i ) NEW_LINE cand . append ( MAX - i ) NEW_LINE DEDENT for i in range ( 9 , MAX // 2 , 6 ) : NEW_LINE INDENT cand . append ( i ) NEW_LINE cand . append ( MAX - i ) NEW_LINE DEDENT ans = [ ] NEW_LINE if N < 5 : NEW_LINE INDENT ans . extend ( base [ : 3 ] ) NEW_LINE if N == 4 : NEW_LINE INDENT ans . append ( MAX ) NEW_LINE DEDENT DEDENT elif N % 2 == 1 : NEW_LINE INDENT ans . extend ( base ) NEW_LINE ans . extend ( cand [ : N - 5 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT ans . extend ( base ) NEW_LINE ans . append ( MAX ) NEW_LINE ans . extend ( cand [ : N - 6 ] ) NEW_LINE DEDENT print ( * ans ) NEW_LINE


N = int ( input ( ) ) NEW_LINE if N == 3 : NEW_LINE INDENT print ( 2 , 5 , 63 ) NEW_LINE exit ( ) NEW_LINE DEDENT count = 20000 NEW_LINE m2 = list ( i for i in range ( 2 , 30001 , 2 ) if i % 6 != 0 ) NEW_LINE m3 = list ( i for i in range ( 3 , 30001 , 3 ) if i % 6 != 0 ) NEW_LINE m6 = list ( range ( 6 , 30001 , 6 ) ) NEW_LINE if count > N : NEW_LINE INDENT diff = min ( count - N , 9998 ) NEW_LINE if diff % 2 == 1 : NEW_LINE INDENT diff -= 1 NEW_LINE DEDENT if diff : NEW_LINE INDENT m2 = m2 [ : - diff ] NEW_LINE DEDENT count -= diff NEW_LINE DEDENT if count > N : NEW_LINE INDENT diff = min ( count - N , 4998 ) NEW_LINE if diff % 2 == 1 : NEW_LINE INDENT diff -= 1 NEW_LINE DEDENT if diff : NEW_LINE INDENT m3 = m3 [ : - diff ] NEW_LINE DEDENT count -= diff NEW_LINE DEDENT if count > N : NEW_LINE INDENT diff = count - N NEW_LINE count -= diff NEW_LINE if diff : NEW_LINE INDENT m6 = m6 [ : - diff ] NEW_LINE DEDENT DEDENT ans = m2 + m3 + m6 NEW_LINE print ( " ▁ " . join ( map ( str , ans ) ) ) NEW_LINE


import java . util . * ; public class Main { public void main ( Scanner sc ) { int n = sc . nextInt ( ) ; int res [ ] = new int [ n ] ; res [ 0 ] = 2 ; res [ 1 ] = 3 ; int sum = 5 ; if ( n <= 5 ) { for ( int i = 2 ; i < n ; i ++ ) { sum += res [ i - 1 ] + 1 ; for ( int num = res [ i - 1 ] + 1 ; num <= 30000 ; num ++ , sum ++ ) { if ( sum % 6 != 0 ) { continue ; } res [ i ] = num ; boolean isOk = true ; for ( int j = 0 ; j <= i ; j ++ ) { if ( gcd ( res [ j ] , sum ) == 1 ) { isOk = false ; break ; } } if ( isOk ) { break ; } } } } else { for ( int i = 2 ; i < n ; i ++ ) { res [ i ] = 6 * ( i / 4 ) + ( 2 + i % 2 ) * ( 1 + ( i % 4 ) / 2 ) ; sum += res [ i ] ; } switch ( sum % 6 ) { case 2 : res [ 4 ] = 6 * ( ( n + 1 ) / 4 ) + 6 ; sum = sum - 8 + res [ 4 ] ; break ; case 3 : res [ 5 ] = 6 * ( ( n + 1 ) / 4 ) + 6 ; sum = sum - 9 + res [ 5 ] ; break ; case 5 : res [ 5 ] = 6 * ( ( n + 1 ) / 4 ) + 4 ; sum = sum - 9 + res [ 5 ] ; break ; default : break ; } } System . out . println ( Arrays . toString ( res ) . replaceAll ( " [ ^ ▁ 0-9 ] " , " " ) ) ; } private int gcd ( int a , int b ) { return b == 0 ? a : gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; Set < Integer > ans = new HashSet < > ( ) ; int lastAns ; if ( N == 3 ) { System . out . println ( "2 ▁ 3 ▁ 25" ) ; } else if ( N == 4 ) { System . out . println ( "2 ▁ 3 ▁ 5 ▁ 20" ) ; } else if ( N == 5 ) { System . out . println ( "2 ▁ 3 ▁ 4 ▁ 5 ▁ 16" ) ; } else { ans . add ( 2 ) ; ans . add ( 3 ) ; int sum = 5 ; for ( int i = 4 ; ; i ++ ) { if ( i % 2 == 0 || i % 3 == 0 ) { ans . add ( i ) ; sum += i ; lastAns = i ; if ( ans . size ( ) == N ) { break ; } } } if ( sum % 6 == 0 ) { } else if ( sum % 6 == 2 ) { ans . remove ( 8 ) ; for ( int i = lastAns + 1 ; ; i ++ ) { if ( i % 6 == 0 ) { ans . add ( i ) ; break ; } } } else if ( sum % 6 == 3 ) { ans . remove ( 9 ) ; for ( int i = lastAns + 1 ; ; i ++ ) { if ( i % 6 == 0 ) { ans . add ( i ) ; break ; } } } else { ans . remove ( 9 ) ; for ( int i = lastAns + 1 ; ; i ++ ) { if ( i % 6 == 4 ) { ans . add ( i ) ; break ; } } } for ( Integer an : ans ) { System . out . print ( an + " ▁ " ) ; } } } }


import java . util . HashSet ; import java . util . Scanner ; import java . util . stream . Collectors ; public class Main { public static void main ( String [ ] args ) { final Scanner cin = new Scanner ( System . in ) ; final int n = cin . nextInt ( ) ; if ( n == 3 ) { System . out . println ( "2 ▁ 5 ▁ 63" ) ; } else if ( n == 4 ) { System . out . println ( "2 ▁ 5 ▁ 20 ▁ 63" ) ; } else if ( n == 5 ) { System . out . println ( "2 ▁ 5 ▁ 20 ▁ 63 ▁ 30" ) ; } else { HashSet < Integer > nums = new HashSet < > ( ) ; int [ ] offset = new int [ ] { 2 , 3 , 4 , 6 } ; int k = 0 ; int summary = 0 ; for ( int i = 0 ; i < n ; i ++ ) { k = i / 4 ; int ai = k * 6 + offset [ i % 4 ] ; nums . add ( ai ) ; summary += ai ; } int next6k = ( k + 1 ) * 6 ; if ( nums . contains ( next6k ) ) next6k += 6 ; int fraction = summary % 6 ; int [ ] candidateToRemove = new int [ ] { 0 , 0 , 8 , 9 , 0 , 9 } ; int [ ] candidateToAppend = new int [ ] { 0 , 0 , ( k + 1 ) * 6 , ( k + 1 ) * 6 , 0 , k * 6 + 4 } ; if ( fraction != 0 ) { nums . remove ( candidateToRemove [ fraction ] ) ; int append = candidateToAppend [ fraction ] ; if ( nums . contains ( append ) ) append += 6 ; nums . add ( append ) ; } System . out . println ( nums . stream ( ) . map ( ( Integer i ) -> i . toString ( ) ) . collect ( Collectors . joining ( " ▁ " ) ) ) ; } } }


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] e = { 2 , 4 , 3 , 9 , 8 , 10 , 6 , 12 } ; int [ ] o = { 6 , 2 , 4 , 3 , 9 , 8 , 10 , 12 } ; if ( n == 3 ) { System . out . println ( "2 ▁ 5 ▁ 63" ) ; return ; } int m = 0 ; boolean isEven = n % 2 == 0 ; for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( isEven ? e [ i % 8 ] + 12 * m : o [ i % 8 ] + 12 * m ) ; System . out . print ( " ▁ " ) ; if ( i % 8 == 7 ) { m ++ ; } } } }


import java . util . * ; class Main { public static void main ( String [ ] args ) { new Main ( ) . main ( ) ; } public void main ( ) { Scanner scanner = new Scanner ( System . in ) ; int n = Integer . parseInt ( scanner . nextLine ( ) ) ; String s = scanner . nextLine ( ) ; System . out . println ( this . times ( n , s ) ) ; } private int times ( int n , String s ) { if ( n % 2 == 0 ) { return - 1 ; } int ret = ( n - 1 ) / 2 ; char ch ; if ( ret % 3 == 1 ) { ch = ' a ' ; } else if ( ret % 3 == 2 ) { ch = ' c ' ; } else { ch = ' b ' ; } for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) != ch ) { return - 1 ; } if ( ch == ' c ' ) { ch = ' a ' ; } else { ch ++ ; } } return ret ; } }

N = int ( input ( ) ) NEW_LINE S = input ( ) NEW_LINE ans = - 1 NEW_LINE s = ' b ' NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if s == S : NEW_LINE INDENT ans = i - 1 NEW_LINE break NEW_LINE DEDENT s = [ ' b ' , ' a ' , ' c ' ] [ i % 3 ] + s + [ ' b ' , ' c ' , ' a ' ] [ i % 3 ] NEW_LINE DEDENT print ( ans ) NEW_LINE


n , s = int ( input ( ) ) , input ( ) NEW_LINE tar = [ ' b ' , ' abc ' , ' cabca ' , ' bcabcab ' , ' abcabcabc ' , ' cabcabcabca ' , ' bcabcabcabcab ' , ' abcabcabcabcabc ' , ' cabcabcabcabcabca ' , ' bcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' , ' cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca ' , ' bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab ' , ' abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc ' ] NEW_LINE if s in tar : NEW_LINE INDENT print ( tar . index ( s ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT


N = int ( input ( ) ) NEW_LINE S = input ( ) NEW_LINE tmp = ' b ' NEW_LINE flg = 1 NEW_LINE count = 0 NEW_LINE if N % 2 == 0 : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT while len ( tmp ) < N : NEW_LINE INDENT if flg == 1 : NEW_LINE INDENT tmp = ' a ' + tmp + ' c ' NEW_LINE flg = 2 NEW_LINE DEDENT elif flg == 2 : NEW_LINE INDENT tmp = ' c ' + tmp + ' a ' NEW_LINE flg = 3 NEW_LINE DEDENT elif flg == 3 : NEW_LINE INDENT tmp = ' b ' + tmp + ' b ' NEW_LINE flg = 1 NEW_LINE DEDENT count += 1 NEW_LINE DEDENT if S == tmp : NEW_LINE INDENT print ( count ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT DEDENT


n = int ( input ( ) ) NEW_LINE hoge = input ( ) NEW_LINE if ( len ( hoge ) % 2 == 0 ) : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT elif ( hoge . count ( " a " ) + hoge . count ( " b " ) + hoge . count ( " c " ) != len ( hoge ) ) : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT elif ( hoge [ len ( hoge ) // 2 ] != " b " ) : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT hoge_r = hoge [ : : - 1 ] NEW_LINE flag = 0 NEW_LINE for i in range ( len ( hoge ) // 2 ) : NEW_LINE INDENT if ( hoge [ i ] == " a " and hoge_r [ i ] == " c " ) : NEW_LINE INDENT flag += 0 NEW_LINE DEDENT elif ( hoge [ i ] == " b " and hoge_r [ i ] == " b " ) : NEW_LINE INDENT flag += 0 NEW_LINE DEDENT elif ( hoge [ i ] == " c " and hoge_r [ i ] == " a " ) : NEW_LINE INDENT flag += 0 NEW_LINE DEDENT else : NEW_LINE INDENT flag += 1 NEW_LINE DEDENT DEDENT if ( flag != 0 ) : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( len ( hoge ) // 2 ) NEW_LINE DEDENT DEDENT


def solve ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE query = " b " NEW_LINE s = input ( ) NEW_LINE if s == query : NEW_LINE INDENT print ( "0" ) NEW_LINE exit ( ) NEW_LINE DEDENT tp = 0 NEW_LINE for i in range ( 50 ) : NEW_LINE INDENT if i % 3 == 2 : NEW_LINE INDENT query = " b " + query + " b " NEW_LINE DEDENT elif i % 3 == 0 : NEW_LINE INDENT query = " a " + query + " c " NEW_LINE DEDENT else : NEW_LINE INDENT query = " c " + query + " a " NEW_LINE DEDENT tp += 1 NEW_LINE if query == s : NEW_LINE INDENT print ( tp ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( " - 1" ) NEW_LINE DEDENT solve ( ) NEW_LINE


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class B { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { in . voids ( ) ; String s = in . string ( ) ; String t = " b " ; for ( int i = 0 ; i < 50 ; i ++ ) { if ( t . equals ( s ) ) { out . println ( i ) ; return ; } switch ( i % 3 ) { case 0 : t = " a " + t + " c " ; break ; case 1 : t = " c " + t + " a " ; break ; case 2 : t = " b " + t + " b " ; break ; } } out . println ( - 1 ) ; } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public void voids ( ) { string ( ) ; } } }


import java . util . * ; public class Main { static int Juzu ( int n , String s ) { if ( n % 2 == 0 ) return - 1 ; if ( n == 1 ) { if ( s . equals ( " b " ) ) return 0 ; else return - 1 ; } if ( s . charAt ( 0 ) == ' b ' ) { for ( int i = 0 ; i < n - 2 ; i += 3 ) { if ( ! s . substring ( i , i + 3 ) . equals ( " bca " ) ) return - 1 ; } if ( s . charAt ( n - 1 ) == ' b ' ) return n / 2 ; } if ( s . charAt ( 0 ) == ' a ' ) { for ( int i = 0 ; i < n - 2 ; i += 3 ) { if ( ! s . substring ( i , i + 3 ) . equals ( " abc " ) ) return - 1 ; } if ( s . charAt ( n - 1 ) == ' c ' ) return n / 2 ; } if ( s . charAt ( 0 ) == ' c ' ) { for ( int i = 0 ; i < n - 2 ; i += 3 ) { if ( ! s . substring ( i , i + 3 ) . equals ( " cab " ) ) return - 1 ; } if ( s . charAt ( n - 1 ) == ' a ' && s . charAt ( n - 2 ) == ' c ' ) return n / 2 ; } return - 1 ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String S = sc . next ( ) ; System . out . println ( Juzu ( N , S ) ) ; } }


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; String S = scanner . next ( ) ; boolean flag = true ; if ( N % 2 == 0 ) { flag = false ; } if ( N % 2 != 0 ) { for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( N % 3 == 1 ) { if ( i % 3 == 0 && S . charAt ( i ) != ' b ' ) { flag = false ; } else if ( i % 3 == 1 && S . charAt ( i ) != ' c ' ) { flag = false ; } else if ( i % 3 == 2 && S . charAt ( i ) != ' a ' ) { flag = false ; } } if ( N % 3 == 0 ) { if ( i % 3 == 0 && S . charAt ( i ) != ' a ' ) { flag = false ; } else if ( i % 3 == 1 && S . charAt ( i ) != ' b ' ) { flag = false ; } else if ( i % 3 == 2 && S . charAt ( i ) != ' c ' ) { flag = false ; } } if ( N % 3 == 2 ) { if ( i % 3 == 0 && S . charAt ( i ) != ' c ' ) { flag = false ; } else if ( i % 3 == 1 && S . charAt ( i ) != ' a ' ) { flag = false ; } else if ( i % 3 == 2 && S . charAt ( i ) != ' b ' ) { flag = false ; } } } } if ( flag == true ) { System . out . println ( S . length ( ) / 2 ) ; } else if ( flag == false ) { System . out . println ( - 1 ) ; } } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String S = sc . next ( ) ; if ( N == 1 ) { if ( S . equals ( " b " ) ) { System . out . println ( 0 ) ; return ; } else { System . out . println ( - 1 ) ; return ; } } for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == ' a ' || S . charAt ( i ) == ' b ' || S . charAt ( i ) == ' c ' ) { } else { System . out . println ( - 1 ) ; return ; } } StringBuilder sb = new StringBuilder ( ) ; sb . append ( " b " ) ; for ( int i = 1 ; i <= 100 ; i ++ ) { if ( i % 3 == 1 ) { sb . insert ( 0 , " a " ) ; sb . append ( " c " ) ; } else if ( i % 3 == 2 ) { sb . insert ( 0 , " c " ) ; sb . append ( " a " ) ; } else if ( i % 3 == 0 ) { sb . insert ( 0 , " b " ) ; sb . append ( " b " ) ; } String str = sb . toString ( ) ; if ( str . length ( ) == N && str . equals ( S ) ) { System . out . println ( i ) ; return ; } else if ( str . length ( ) == N && ! str . equals ( S ) ) { System . out . println ( - 1 ) ; return ; } else if ( str . length ( ) > N ) { System . out . println ( - 1 ) ; return ; } } } }


import java . util . Scanner ; import java . util . stream . IntStream ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; int [ ] a = IntStream . range ( 0 , N ) . map ( i -> scan . nextInt ( ) ) . toArray ( ) ; int index = 0 ; for ( int i = 0 ; i < N ; ++ i ) if ( Math . abs ( a [ index ] ) < Math . abs ( a [ i ] ) ) index = i ; System . out . println ( 2 * N - 1 ) ; for ( int i = 0 ; i < N ; ++ i ) System . out . println ( ( index + 1 ) + " ▁ " + ( i + 1 ) ) ; if ( a [ index ] > 0 ) { for ( int i = 2 ; i <= N ; ++ i ) System . out . println ( ( i - 1 ) + " ▁ " + i ) ; } else { for ( int i = N - 1 ; i >= 1 ; -- i ) System . out . println ( ( i + 1 ) + " ▁ " + i ) ; } } }

def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE N = int ( input ( ) ) NEW_LINE a = inpl ( ) NEW_LINE mini = float ( ' inf ' ) NEW_LINE maxi = - mini NEW_LINE for i in a : NEW_LINE INDENT mini = min ( mini , i ) NEW_LINE maxi = max ( maxi , i ) NEW_LINE DEDENT print ( 2 * N - 1 ) NEW_LINE if maxi > - mini : NEW_LINE INDENT x = a . index ( maxi ) + 1 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT print ( x , i ) NEW_LINE DEDENT for i in range ( 1 , N ) : NEW_LINE INDENT print ( i , i + 1 ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT x = a . index ( mini ) + 1 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT print ( x , i ) NEW_LINE DEDENT for i in range ( N , 1 , - 1 ) : NEW_LINE INDENT print ( i , i - 1 ) NEW_LINE DEDENT DEDENT


import sys NEW_LINE N = int ( input ( ) ) NEW_LINE A = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE a = max ( A ) NEW_LINE b = min ( A ) NEW_LINE if b >= 0 : NEW_LINE INDENT ans = [ ] NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT ans . append ( [ i , i + 1 ] ) NEW_LINE DEDENT print ( N - 1 ) NEW_LINE for a , b in ans : NEW_LINE INDENT print ( a , b ) NEW_LINE DEDENT sys . exit ( ) NEW_LINE DEDENT if a <= 0 : NEW_LINE INDENT ans = [ ] NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT ans . append ( [ N - i + 1 , N - i ] ) NEW_LINE DEDENT print ( N - 1 ) NEW_LINE for a , b in ans : NEW_LINE INDENT print ( a , b ) NEW_LINE DEDENT sys . exit ( ) NEW_LINE DEDENT x = A . index ( a ) + 1 NEW_LINE y = A . index ( b ) + 1 NEW_LINE if abs ( a ) >= abs ( b ) : NEW_LINE INDENT ans = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT ans . append ( [ x , i + 1 ] ) NEW_LINE DEDENT for i in range ( 1 , N ) : NEW_LINE INDENT ans . append ( [ i , i + 1 ] ) NEW_LINE DEDENT print ( 2 * N - 1 ) NEW_LINE for a , b in ans : NEW_LINE INDENT print ( a , b ) NEW_LINE DEDENT sys . exit ( ) NEW_LINE DEDENT if abs ( b ) > abs ( a ) : NEW_LINE INDENT ans = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT ans . append ( [ y , i + 1 ] ) NEW_LINE DEDENT for i in range ( 1 , N ) : NEW_LINE INDENT ans . append ( [ N - i + 1 , N - i ] ) NEW_LINE DEDENT print ( 2 * N - 1 ) NEW_LINE for a , b in ans : NEW_LINE INDENT print ( a , b ) NEW_LINE DEDENT sys . exit ( ) NEW_LINE DEDENT


import sys NEW_LINE sys . stdin . readline ( ) NEW_LINE lst = list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) NEW_LINE N = len ( lst ) NEW_LINE max_val , max_t = lst [ 0 ] , 0 NEW_LINE min_val , min_t = lst [ 0 ] , 0 NEW_LINE for t in range ( 1 , len ( lst ) ) : NEW_LINE INDENT if max_val < lst [ t ] : NEW_LINE INDENT max_val = lst [ t ] NEW_LINE max_t = t NEW_LINE DEDENT if min_val > lst [ t ] : NEW_LINE INDENT min_val = lst [ t ] NEW_LINE min_t = t NEW_LINE DEDENT DEDENT if max_val >= - min_val : NEW_LINE INDENT print ( 2 * N - 2 ) NEW_LINE for i in range ( len ( lst ) ) : NEW_LINE INDENT if i == max_t : NEW_LINE INDENT continue NEW_LINE DEDENT print ( max_t + 1 , i + 1 ) NEW_LINE DEDENT for i in range ( 1 , len ( lst ) ) : NEW_LINE INDENT print ( i , i + 1 ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( 2 * N - 2 ) NEW_LINE for i in range ( len ( lst ) ) : NEW_LINE INDENT if i == min_t : NEW_LINE INDENT continue NEW_LINE DEDENT print ( min_t + 1 , i + 1 ) NEW_LINE DEDENT for i in range ( len ( lst ) , 1 , - 1 ) : NEW_LINE INDENT print ( i , i - 1 ) NEW_LINE DEDENT DEDENT


n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE seq = [ ] NEW_LINE for i in range ( 0 , n + 1 ) : NEW_LINE INDENT b = [ None ] * n NEW_LINE for j in range ( 0 , n ) : b [ j ] = a [ j ] NEW_LINE seq = [ ] NEW_LINE for j in range ( i - 2 , - 1 , - 1 ) : NEW_LINE INDENT seq . append ( ( j + 1 , j ) ) NEW_LINE seq . append ( ( j + 1 , j ) ) NEW_LINE b [ j ] += b [ j + 1 ] * 2 NEW_LINE DEDENT for j in range ( i , n - 1 ) : NEW_LINE INDENT seq . append ( ( j , j + 1 ) ) NEW_LINE seq . append ( ( j , j + 1 ) ) NEW_LINE b [ j + 1 ] += b [ j ] * 2 NEW_LINE DEDENT valid = True NEW_LINE for j in range ( n - 1 ) : NEW_LINE INDENT if b [ j ] > b [ j + 1 ] : NEW_LINE INDENT valid = False NEW_LINE break NEW_LINE DEDENT DEDENT if valid : break NEW_LINE DEDENT print ( len ( seq ) ) NEW_LINE print ( ' \n ' . join ( map ( lambda x : ' % d ▁ % d ' % ( x [ 0 ] + 1 , x [ 1 ] + 1 ) , seq ) ) ) NEW_LINE


import numpy as np NEW_LINE N = int ( input ( ) ) NEW_LINE a_lst = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE a_arr = np . array ( a_lst ) NEW_LINE idx = np . absolute ( a_arr ) . argmax ( ) + 1 NEW_LINE if a_lst [ idx - 1 ] == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 2 * N - 2 ) NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if i != idx : NEW_LINE INDENT print ( idx , i ) NEW_LINE DEDENT DEDENT if a_lst [ idx - 1 ] > 0 : NEW_LINE INDENT for i in range ( 1 , N ) : NEW_LINE INDENT print ( i , i + 1 ) NEW_LINE DEDENT DEDENT elif a_lst [ idx - 1 ] < 0 : NEW_LINE INDENT for i in range ( N , 1 , - 1 ) : NEW_LINE INDENT print ( i , i - 1 ) NEW_LINE DEDENT DEDENT DEDENT


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 ( ) ; int [ ] t = new int [ N ] ; int max = Integer . MIN_VALUE ; int maxIdx = - 1 ; for ( int i = 0 ; i < N ; i ++ ) { t [ i ] = sc . nextInt ( ) ; int abs = Math . abs ( t [ i ] ) ; if ( max < abs ) { max = abs ; maxIdx = i ; } } System . out . println ( N * 2 - 1 ) ; for ( int i = 0 ; i < N ; i ++ ) { System . out . println ( ( maxIdx + 1 ) + " ▁ " + ( i + 1 ) ) ; } for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( t [ maxIdx ] > 0 ) { System . out . println ( ( i + 1 ) + " ▁ " + ( i + 2 ) ) ; } else { System . out . println ( ( N - i ) + " ▁ " + ( N - i - 1 ) ) ; } } } } }


import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int pmaxnum = 0 ; int pmax = 0 ; int mmaxnum = 0 ; int mmax = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] >= 0 ) { if ( pmax <= A [ i ] ) { pmax = A [ i ] ; pmaxnum = i + 1 ; } } else { if ( mmax >= A [ i ] ) { mmax = A [ i ] ; mmaxnum = i + 1 ; } } } System . out . println ( N * 2 - 2 ) ; if ( Math . abs ( pmax ) >= Math . abs ( mmax ) ) { for ( int i = 1 ; i <= N ; i ++ ) { if ( i != pmaxnum ) System . out . println ( pmaxnum + " ▁ " + i ) ; } for ( int i = 1 ; i < N ; i ++ ) { System . out . println ( i + " ▁ " + ( i + 1 ) ) ; } } else { for ( int i = 1 ; i <= N ; i ++ ) { if ( i != mmaxnum ) System . out . println ( mmaxnum + " ▁ " + i ) ; } for ( int i = N ; i > 1 ; i -- ) { System . out . println ( i + " ▁ " + ( i - 1 ) ) ; } } } }


import java . util . List ; import java . util . ArrayList ; import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Map ; import java . util . Scanner ; import java . util . Set ; import java . util . TreeSet ; import java . util . concurrent . BlockingQueue ; import java . util . concurrent . LinkedBlockingDeque ; public class Main { static Scanner sc = new Scanner ( System . in ) ; static char c ; public static void main ( String [ ] args ) throws Exception { int k = sc . nextInt ( ) ; int [ ] arr = new int [ k ] ; int max = Integer . MIN_VALUE ; int min = Integer . MAX_VALUE ; int maxIdx = - 1 ; int minIdx = - 1 ; for ( int i = 0 ; i < arr . length ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; if ( arr [ i ] > max ) { max = arr [ i ] ; maxIdx = i ; } if ( arr [ i ] < min ) { min = arr [ i ] ; minIdx = i ; } } System . out . println ( k * 2 - 1 ) ; if ( Math . abs ( min ) > max ) { for ( int i = 0 ; i < k ; i ++ ) { System . out . println ( ( minIdx + 1 ) + " ▁ " + ( i + 1 ) ) ; } for ( int i = k ; i > 1 ; i -- ) { System . out . println ( i + " ▁ " + ( i - 1 ) ) ; } } else { for ( int i = 0 ; i < k ; i ++ ) { System . out . println ( ( maxIdx + 1 ) + " ▁ " + ( i + 1 ) ) ; } for ( int i = 1 ; i < k ; i ++ ) { System . out . println ( i + " ▁ " + ( i + 1 ) ) ; } } } }


import java . util . * ; class Main { public static void main ( String [ ] $ ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int [ ] a = new int [ n ] ; Arrays . setAll ( a , i -> s . nextInt ( ) ) ; ArrayList < String > r = new ArrayList < > ( ) ; int m = 0 ; for ( int i = 1 ; i < n ; ++ i ) if ( Math . abs ( a [ m ] ) < Math . abs ( a [ i ] ) ) m = i ; for ( int i = 0 ; i < n ; ++ i ) if ( a [ m ] >= 0 ^ a [ i ] >= 0 ) r . add ( m + 1 + " ▁ " + ( i + 1 ) ) ; if ( a [ m ] >= 0 ) { for ( int i = 1 ; i < n ; ++ i ) r . add ( i + " ▁ " + ( i + 1 ) ) ; } else { for ( int i = n ; i > 1 ; -- i ) r . add ( i + " ▁ " + ( i - 1 ) ) ; } System . out . println ( r . size ( ) ) ; r . forEach ( System . out :: println ) ; } }


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

a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE while n % a > 0 or n % b > 0 : NEW_LINE INDENT n += 1 NEW_LINE DEDENT print ( n ) NEW_LINE


def gcd ( a : int , b : int ) -> int : NEW_LINE INDENT if a < b : NEW_LINE INDENT a , b = b , a NEW_LINE DEDENT return a if b == 0 else gcd ( b , a % b ) NEW_LINE DEDENT def lcm ( a : int , b : int ) -> int : NEW_LINE INDENT return a * b // gcd ( a , b ) NEW_LINE DEDENT def like ( a : int , b : int , n : int ) -> int : NEW_LINE INDENT c = lcm ( a , b ) NEW_LINE d = c NEW_LINE while d < n : NEW_LINE INDENT d += c NEW_LINE DEDENT return d NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE ans = like ( a , b , n ) NEW_LINE print ( ans ) NEW_LINE DEDENT


a , b , n = map ( int , open ( 0 ) ) NEW_LINE while n % a + n % b : n += 1 NEW_LINE print ( n ) NEW_LINE


import math NEW_LINE def gcd ( a , b ) : NEW_LINE INDENT if a < b : NEW_LINE INDENT a , b = b , a NEW_LINE DEDENT while ( b != 0 ) : NEW_LINE INDENT a , b = b , a % b NEW_LINE DEDENT return a NEW_LINE DEDENT a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE t = ( a * b ) / gcd ( a , b ) NEW_LINE ans = t NEW_LINE while ( ans < n ) : NEW_LINE INDENT ans += t NEW_LINE DEDENT ans = int ( ans ) NEW_LINE print ( ans ) NEW_LINE


a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE for i in range ( n , 10000000 ) : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT if i % a == 0 and i % b == 0 : NEW_LINE INDENT print ( i ) NEW_LINE break NEW_LINE DEDENT DEDENT


import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int a = nextInt ( ) , b = nextInt ( ) , n = nextInt ( ) ; int lcm = lcm ( a , b ) ; out . println ( ( lcm * ( int ) Math . ceil ( ( double ) n / ( double ) lcm ) ) ) ; } static int gcd ( int a , int b ) { return b > 0 ? gcd ( b , a % b ) : a ; } static int lcm ( int a , int b ) { return a * b / gcd ( a , b ) ; } }


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( 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 , FastScanner in , PrintWriter out ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int n = in . nextInt ( ) ; while ( n % a != 0 || n % b != 0 ) n ++ ; out . println ( n ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' ▁ ' || c == ' \n ' || c == ' \r ' || c == ' \t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }


import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; while ( c % a != 0 || c % b != 0 ) { c ++ ; } System . out . println ( c ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { 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 ; } } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int g = gcd ( a , b ) ; int x = a * b / g ; System . out . println ( ( n + x - 1 ) / x * x ) ; } static int gcd ( int a , int b ) { if ( b == 0 ) { return a ; } else { return gcd ( b , a % b ) ; } } }


import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class Main implements Runnable { public static void main ( String [ ] args ) { new Thread ( null , new Main ( ) , " " , Runtime . getRuntime ( ) . maxMemory ( ) ) . start ( ) ; } final long MOD = 1_000_000_000 + 7 ; public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; long ans = 1 ; ArrayList < Integer > factor = new ArrayList < > ( ) ; for ( int i = b + 1 ; i <= a ; ++ i ) { int v = i ; for ( int j = 2 ; j * j <= v ; ++ j ) { int c = 0 ; while ( v % j == 0 ) { v /= j ; ++ c ; } if ( c > 0 ) { factor . add ( j ) ; } } if ( v > 1 ) { factor . add ( v ) ; } } Collections . sort ( factor ) ; for ( int i = 0 ; i < factor . size ( ) ; ++ i ) { int j = i ; while ( j + 1 < factor . size ( ) && factor . get ( i ) == factor . get ( j + 1 ) ) ++ j ; int c = 0 ; int v = factor . get ( i ) ; for ( int k = b + 1 ; k <= a ; ++ k ) { int u = k ; while ( u % v == 0 ) { u /= v ; ++ c ; } } ans = ans * ( c + 1 ) % MOD ; i = j ; } System . out . println ( ans ) ; } static void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }

import sys NEW_LINE from collections import defaultdict NEW_LINE input = sys . stdin . readline NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A , B = inpl ( ) NEW_LINE cnt = 1 NEW_LINE num_cnt = defaultdict ( int ) NEW_LINE for n in range ( B + 1 , A + 1 ) : NEW_LINE INDENT i = 2 NEW_LINE while i * i <= n : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT cnt = 0 NEW_LINE while n % i == 0 : NEW_LINE INDENT cnt += 1 NEW_LINE n //= i NEW_LINE DEDENT num_cnt [ i ] += cnt NEW_LINE DEDENT i += 1 NEW_LINE DEDENT if n != 1 : NEW_LINE INDENT num_cnt [ n ] += 1 NEW_LINE DEDENT DEDENT ans = 1 NEW_LINE for key in num_cnt . keys ( ) : NEW_LINE INDENT ans *= num_cnt [ key ] + 1 NEW_LINE ans %= MOD NEW_LINE DEDENT print ( ans ) NEW_LINE