import java . util . Scanner ;   public class A1077 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int t = scanner . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { long a = scanner . nextLong ( ) , res = 0 , b = scanner . nextLong ( ) , k = scanner . nextLong ( ) ; if ( k % 2 == 0 ) { res += k / 2 * ( a - b ) ; } else { res += ( k + 1 ) / 2 * a - k / 2 * b ; } System . out . println ( res ) ; } } }

import java . util . Scanner ;   public class Main {   public static Scanner sc = new Scanner ( System . in ) ;   public static void main ( String [ ] args ) { int cases = sc . nextInt ( ) ; for ( int i = cases ; i != 0 ; i -- ) { long n = 0 , res = 0 ; long a = sc . nextLong ( ) , b = sc . nextLong ( ) , k = sc . nextLong ( ) ; if ( k % 2 == 1 ) { n = k / 2 + 1 ; res += n * a - ( n - 1 ) * b ; } else { n = k / 2 ; res += n * a - n * b ; } System . out . println ( res ) ; } } }

import java . util . ArrayList ; import java . util . Scanner ;    public class ForgJumping {   public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int cases = scan . nextInt ( ) ; long a , b , k ; long x = 0 ; ArrayList < Long > results = new ArrayList ( ) ; for ( int i = 0 ; i < cases ; i ++ ) { a = scan . nextLong ( ) ; b = scan . nextLong ( ) ; k = scan . nextLong ( ) ; if ( k % 2 == 0 ) x = ( a * ( k / 2 ) - b * ( k / 2 ) ) ; elsex = ( a * ( k / 2 + 1 ) - b * ( k / 2 ) ) ; results . add ( x ) ; x = 0 ; } for ( int i = 0 ; i < results . size ( ) ; i ++ ) System . out . println ( results . get ( i ) ) ;     } }

import java . util . ArrayList ; import java . util . Scanner ;   public class Frogjump {   public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int cases = scan . nextInt ( ) ; long a , b , k ; long x = 0 ; ArrayList < Long > results = new ArrayList ( ) ; for ( int i = 0 ; i < cases ; i ++ ) { a = scan . nextLong ( ) ; b = scan . nextLong ( ) ; k = scan . nextLong ( ) ; if ( k % 2 == 0 ) x = ( a * ( k / 2 ) - b * ( k / 2 ) ) ; else x = ( a * ( k / 2 + 1 ) - b * ( k / 2 ) ) ; results . add ( x ) ; x = 0 ; } for ( int i = 0 ; i < results . size ( ) ; i ++ ) System . out . println ( results . get ( i ) ) ; } }

for x in range ( int ( input ( ) ) ) : a , b , k = map ( int , input ( ) . split ( ) ) pos = 0 if k % 2 == 0 : pos = a * k // 2 - b * k // 2 else : pos = a * ( k // 2 + 1 ) - b * ( k // 2 ) print ( pos ) NEW_LINE

for _ in range ( int ( input ( ) ) ) : a , b , k = map ( int , input ( ) . split ( ) ) c = a * ( k // 2 ) c -= b * ( k // 2 ) if k % 2 : c += a print ( c ) NEW_LINE

from typing import Iterator     def get_num_input ( ) -> Iterator [ int ] : return map ( int , input ( ) . split ( ) )     def main ( ) -> None : right : int left : int times : int right , left , times = get_num_input ( )   print ( ( right - left ) * ( times // 2 ) + right * ( times % 2 ) )     if __name__ == " _ _ main _ _ " : ONLY_ONCE : bool = False for _ in range ( 1 if ONLY_ONCE else int ( input ( ) ) ) : main ( ) NEW_LINE

for _ in range ( int ( input ( ) ) ) : n , m , k = map ( int , input ( ) . split ( ) ) d = n - m if k % 2 == 0 : print ( d * ( k // 2 ) ) else : print ( d * ( k // 2 ) + n ) NEW_LINE


import java . io . BufferedOutputStream ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ;   public class B_v2 { private static class Solver { private void solve ( ) throws Exception { int n = in . nextInt ( ) ; int k = in . nextInt ( ) ; int [ ] g = new int [ k ] ; int x4 = n ; int x2 = 2 * n ; int x1 = 0 ; for ( int i = 0 ; i < k ; i ++ ) { g [ i ] = in . nextInt ( ) ; int g4 = g [ i ] / 4 ; int cost = Math . min ( g4 , x4 ) ; x4 -= cost ; g [ i ] -= cost * 4 ; } x2 += x4 ; x1 += x4 ; for ( int i = 0 ; i < k ; i ++ ) { int g2 = g [ i ] / 2 ; int cost = Math . min ( g2 , x2 ) ; x2 -= cost ; g [ i ] -= cost * 2 ; } x1 += x2 ; if ( Arrays . stream ( g ) . sum ( ) > x1 ) { out . println ( " NO " ) ; } else { out . println ( " YES " ) ; } } }

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

import java . io . * ; import java . util . * ; public class Solution { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int k = Integer . parseInt ( st . nextToken ( ) ) ; int [ ] a = new int [ k ] ; st = new StringTokenizer ( br . readLine ( ) ) ; for ( int i = 0 ; i < k ; i ++ ) a [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; int fourSize = n , twoSize = 2 * n ; Arrays . sort ( a ) ; int one = 0 , two = 0 , three = 0 ; for ( int i = a . length - 1 ; i >= 0 ; i -- ) { if ( a [ i ] >= 4 ) { int countOfFours = a [ i ] / 4 ; int size = Math . min ( countOfFours , fourSize ) ; countOfFours -= size ; fourSize -= size ; if ( countOfFours > 0 ) { size = Math . min ( 2 * countOfFours , twoSize ) ; twoSize -= size ; } int rem = a [ i ] % 4 ; if ( rem == 1 ) one ++ ; else if ( rem == 2 ) { if ( twoSize > 0 ) twoSize -- ; else two ++ ; } else if ( rem == 3 ) three ++ ; } else if ( a [ i ] == 2 ) { if ( twoSize > 0 ) twoSize -- ; else two ++ ; } else if ( a [ i ] == 3 ) three ++ ; else one ++ ; }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayDeque ; import java . util . Arrays ; import java . util . Comparator ; import java . util . Random ; import java . util . StringTokenizer ;   public class Solution { public static void main ( String [ ] args ) throws IOException { FastScanner fs = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int tt = 1 ; while ( tt -- > 0 ) { int n = fs . nextInt ( ) , k = fs . nextInt ( ) ; int [ ] have = new int [ 5 ] ; have [ 4 ] = n ; have [ 2 ] = 2 * n ; int [ ] cnt = new int [ 5 ] ; for ( int i = 0 ; i < k ; i ++ ) { int x = fs . nextInt ( ) ; while ( x >= 3 ) { if ( have [ 4 ] > 0 ) { x -= 4 ; have [ 4 ] -- ; } else if ( have [ 2 ] > 0 ) { x -= 2 ; have [ 2 ] -- ; } else { out . println ( " No " ) ; out . flush ( ) ; return ; } } if ( x > 0 ) { cnt [ x ] ++ ; } } while ( cnt [ 2 ] > 0 ) { if ( have [ 2 ] > 0 ) { cnt [ 2 ] -- ; have [ 2 ] -- ; } else if ( have [ 4 ] > 0 ) { cnt [ 2 ] -- ; have [ 4 ] -- ; have [ 1 ] ++ ; } else { cnt [ 2 ] -- ; cnt [ 1 ] += 2 ; } } if ( cnt [ 1 ] > have [ 1 ] + have [ 2 ] + 2 * have [ 4 ] ) { out . println ( " No " ) ; } else { out . println ( " Yes " ) ; } } out . close ( ) ; }    static final Random random = new Random ( ) ; static void ruffleSort ( int [ ] a ) { int n = a . length ;

n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) s2 = 2 * ns4 = ns1 = 0 fail = 0 for i in range ( k ) : while a [ i ] >= 4 : if s4 > 0 : s4 -= 1 a [ i ] -= 4 elif s2 > 0 : s2 -= 1 a [ i ] -= 2 elif s1 > 0 : s1 -= 1 a [ i ] -= 1 else : fail = 1 breakfor i in range ( k ) : while a [ i ] >= 2 : if s4 > 0 : s4 -= 1 a [ i ] -= 2 s1 += 1 elif s2 > 0 : s2 -= 1 a [ i ] -= 2 elif s1 > 0 : s1 -= 1 a [ i ] -= 1 else : fail = 1 breakfor i in range ( k ) : while a [ i ] >= 1 : if s4 > 0 : s4 -= 1 a [ i ] -= 1 s1 += 1 elif s2 > 0 : s2 -= 1 a [ i ] -= 1 elif s1 > 0 : s1 -= 1 a [ i ] -= 1 else : fail = 1 breakif fail : print ( ' NO ' ) else : print ( ' YES ' ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) fours , twos , ones = n , 2 * n , 0 NEW_LINE

from sys import stdin   n , k = [ int ( x ) for x in stdin . readline ( ) . split ( ) ] a = [ int ( x ) for x in stdin . readline ( ) . split ( ) ]   four = ntwo = 2 * none = 0   for i , x in enumerate ( a ) : f = min ( four , x // 4 ) four -= f a [ i ] -= f * 4   if four : a . sort ( reverse = True ) v = True for x in a : if x == 3 : if four : four -= 1 elif two >= 2 : two -= 2 else : v = False break elif x == 2 : if four : four -= 1 one += 1 elif two : two -= 1 elif one >= 2 : one -= 2 else : v = False break elif x == 1 : if four : four -= 1 two += 1 elif two : two -= 1 elif one : one -= 1 else : v = False break if v : print ( ' YES ' ) else : print ( ' NO ' ) else : for x in a : two -= x // 2 + x % 2 if two >= 0 : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE


import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ;   public class Main {   public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; int testCases = Integer . parseInt ( br . readLine ( ) ) ; for ( int i = 0 ; i < testCases ; i ++ ) { String str [ ] = br . readLine ( ) . split ( " ▁ " ) ; int n = Integer . parseInt ( str [ 0 ] ) ; int k = Integer . parseInt ( str [ 1 ] ) ; if ( n == k ) { bw . write ( "1 \n " ) ; } else if ( n > k ) { int aux = ( n / k ) ; if ( k * aux == n ) { bw . write ( "1 \n " ) ; } else { bw . write ( "2 \n " ) ; } } else { int aux = ( k / n ) ; if ( k == n * aux ) { bw . write ( aux + " \n " ) ; } else { bw . write ( ( aux + 1 ) + " \n " ) ; } } } br . close ( ) ; bw . close ( ) ;   }   }

import java . util . Scanner ;   public class A1476 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int N = in . nextInt ( ) ; int K = in . nextInt ( ) ; int reminder = Math . floorMod ( K - N , K ) ; int answer = 1 + ( reminder + N - 1 ) / N ; System . out . println ( answer ) ; } }   }

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

import java . util . * ; import java . lang . * ; import java . io . * ;   public class Main { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } int [ ] na ( int n ) { int ar [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { ar [ i ] = nextInt ( ) ; } return ar ; } void print ( int ar [ ] ) { for ( int i = 0 ; i < ar . length ; i ++ ) { System . out . print ( ar [ i ] + " ▁ " ) ; } } } public static long gcd ( long a , long b ) { if ( b == 0 ) { return a ; } if ( a == 0 ) { return b ; } return gcd ( b , a % b ) ; } public static void main ( String [ ] args ) throws java . lang . Exception { FastReader sc = new FastReader ( ) ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; public class C { static class FastScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ;   String next ( ) { while ( ! st . hasMoreTokens ( ) ) try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   int [ ] nextArray ( int n ) { int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextInt ( ) ; return a ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } static class FastWriter extends PrintWriter { FastWriter ( ) { super ( System . out ) ; }   void println ( int [ ] array ) { for ( int i = 0 ; i < array . length ; i ++ ) { print ( array [ i ] + " ▁ " ) ; } println ( ) ; }   void println ( long [ ] array ) { for ( int i = 0 ; i < array . length ; i ++ ) { print ( array [ i ] + " ▁ " ) ; } println ( ) ; } } public static void main ( String [ ] args ) {

t = int ( input ( ) ) NEW_LINE for i in range ( t ) : n , k = map ( int , ( input ( ) . split ( ) ) ) NEW_LINE if n > k : if NEW_LINE n % k == 0 : print ( 1 ) else : print ( 2 ) elif k % n == 0 : print ( k // n ) else : print ( k // n + 1 ) NEW_LINE

import matht = int ( input ( ) ) NEW_LINE while t > 0 : a = input ( ) . split ( ) NEW_LINE n = int ( a [ 0 ] ) NEW_LINE k = int ( a [ 1 ] ) NEW_LINE if k == 1 : NEW_LINE INDENT print ( 1 ) else : NEW_LINE k = math . ceil ( n / k ) * k NEW_LINE DEDENT print ( math . ceil ( k / n ) ) NEW_LINE t -= 1 NEW_LINE

for i in range ( 0 , int ( input ( ) ) ) : n , k = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE c = n // k NEW_LINE if n % k != 0 : c += 1 NEW_LINE s = k * c NEW_LINE if s % n == 0 : NEW_LINE INDENT print ( s // n ) else : NEW_LINE print ( s // n + 1 ) NEW_LINE DEDENT

for _ in range ( int ( input ( ) ) ) : n , k = map ( int , input ( ) . split ( ) ) NEW_LINE if k % n == 0 : NEW_LINE INDENT print ( k // n ) else : NEW_LINE if NEW_LINE DEDENT k > n : print ( k // n + 1 ) else : t = n // k NEW_LINE if n % k != 0 : t = t + 1 NEW_LINE if ( t * k ) % n == 0 : NEW_LINE INDENT print ( ( t * k ) // n ) else : NEW_LINE print ( ( t * k ) // n + 1 ) NEW_LINE DEDENT

t = int ( input ( ) ) NEW_LINE for i in range ( t ) : n , k = map ( int , ( input ( ) . split ( ) ) ) NEW_LINE cf = ( n + k - 1 ) // k NEW_LINE k *= cf NEW_LINE print ( ( k + n - 1 ) // n ) NEW_LINE


import java . util . * ; public class B_520 { public static void main ( String [ ] args ) { Scanner omkar = new Scanner ( System . in ) ; int n = omkar . nextInt ( ) ; int m = omkar . nextInt ( ) ; int u = gcd ( m , n ) ; int [ ] b = new int [ n ] ; int [ ] g = new int [ m ] ; int x = omkar . nextInt ( ) ; for ( int i = 0 ; i < x ; i ++ ) { b [ omkar . nextInt ( ) ] = 1 ; } int y = omkar . nextInt ( ) ; for ( int i = 0 ; i < y ; i ++ ) { g [ omkar . nextInt ( ) ] = 1 ; } for ( int i = 0 ; i < u ; i ++ ) { if ( ! test ( b , g , u , i ) ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } public static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } public static boolean test ( int [ ] b , int [ ] g , int u , int ind ) { for ( int i = ind ; i < b . length ; i += u ) { if ( b [ i ] == 1 ) { return true ; } } for ( int i = ind ; i < g . length ; i += u ) { if ( g [ i ] == 1 ) { return true ; } } return false ; } }

import java . io . * ; import java . math . * ; import java . util . * ;     public class Main {   private static int dx [ ] = { 1 , 0 , - 1 , 0 } ; private static int dy [ ] = { 0 , - 1 , 0 , 1 } ;   private static final long INF = Long . MAX_VALUE ; private static final int INT_INF = Integer . MAX_VALUE ; private static final long NEG_INF = Long . MIN_VALUE ; private static final int NEG_INT_INF = Integer . MIN_VALUE ; private static final double EPSILON = 1e-10 ;   private static final long MAX = ( long ) 1e12 ; private static final long MOD = 100000007 ;   private static final int MAXN = 1000003 ; private static final int MAXA = 2000007 ; private static final int MAXLOG = 22 ; private static final double PI = Math . acos ( - 1 ) ; public static void main ( String [ ] args ) throws IOException {   InputReader in = new InputReader ( System . in ) ;

import java . util . Scanner ;   public class Main { public static Scanner scan = new Scanner ( System . in ) ;   public static void DrazilAndHisHappyFriends ( ) { int n = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; boolean [ ] boys = new boolean [ n ] ; boolean [ ] girls = new boolean [ m ] ;   int happy_boys = scan . nextInt ( ) ; while ( happy_boys -- > 0 ) { boys [ scan . nextInt ( ) ] = true ; } int happy_girls = scan . nextInt ( ) ; while ( happy_girls -- > 0 ) { girls [ scan . nextInt ( ) ] = true ; } for ( int i = 0 ; i < ( n + m ) * n * m ; i ++ ) { if ( boys [ i % n ] || girls [ i % m ] ) { boys [ i % n ] = girls [ i % m ] = true ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( ! boys [ i ] ) { System . out . println ( " No " ) ; return ; } } for ( int i = 0 ; i < m ; i ++ ) { if ( ! girls [ i ] ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; }   public static void main ( String [ ] args ) { DrazilAndHisHappyFriends ( ) ; } }

import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ;   public class DrazilAndHisHappyFriends { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] input = br . readLine ( ) . split ( " ▁ " ) ; int boys = Integer . parseInt ( input [ 0 ] ) ; int girls = Integer . parseInt ( input [ 1 ] ) ; int gcd = calcGCD ( boys , girls ) ; if ( gcd == 1 ) { System . out . println ( " Yes " ) ; } else { input = br . readLine ( ) . split ( " ▁ " ) ; int [ ] happyBoys = new int [ input . length ] ; for ( int i = 0 ; i < input . length ; i ++ ) { happyBoys [ i ] = Integer . parseInt ( input [ i ] ) ; } input = br . readLine ( ) . split ( " ▁ " ) ; int [ ] happyGirls = new int [ input . length ] ; for ( int i = 0 ; i < input . length ; i ++ ) { happyGirls [ i ] = Integer . parseInt ( input [ i ] ) ; } for ( int i = 0 ; i < gcd ; i ++ ) { boolean found = false ; for ( int j = 0 ; j < happyBoys [ 0 ] ; j ++ ) { if ( ( happyBoys [ j + 1 ] - i ) % gcd == 0 ) { found = true ; } } for ( int j = 0 ; j < happyGirls [ 0 ] ; j ++ ) { if ( ( happyGirls [ j + 1 ] - i ) % gcd == 0 ) { found = true ; } } if ( ! found ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } System . out . println ( " Yes " ) ; } } public static int calcGCD ( int x , int y ) { if ( x == 0 ) { return y ; } else if ( y == 0 ) { return x ; } else { if ( x >= y ) { return calcGCD ( x % y , y ) ; } else { return calcGCD ( y % x , x ) ; } } } }

from math import gcdn , m = map ( int , input ( ) . split ( ) ) gcdd = gcd ( n , m ) l = list ( map ( int , input ( ) . split ( ) ) ) ; r = [ 0 ] * gcddfor i in l [ 1 : ] : r [ i % gcdd ] = 1 l1 = list ( map ( int , input ( ) . split ( ) ) ) for j in l1 [ 1 : ] : r [ j % gcdd ] = 1 for i in r : if i == 0 : exit ( print ( " No " ) ) print ( " Yes " ) NEW_LINE

def GCD ( x , y ) : while y != 0 : remainder = x % y x = y y = remainder return x   def LCM ( x , y ) : return x * y // GCD ( x , y )   n , m = map ( int , input ( ) . split ( ) ) b , * boys = list ( map ( int , input ( ) . split ( ) ) ) g , * girls = list ( map ( int , input ( ) . split ( ) ) ) isHappy = [ False ] * ( n + m ) for boy in boys : isHappy [ boy ] = Truefor girl in girls : isHappy [ girl + n ] = True   for i in range ( 2 * LCM ( m , n ) ) : if isHappy [ i % n ] or isHappy [ i % m + n ] : isHappy [ i % n ] = isHappy [ i % m + n ] = True   flag = Truefor check in isHappy : if not check : flag = False breakprint ( " Yes " if flag else " No " ) NEW_LINE

from math import gcdn , m = map ( int , input ( ) . split ( ) ) b = list ( map ( int , input ( ) . split ( ) ) ) g = list ( map ( int , input ( ) . split ( ) ) ) bn , gn = b [ 0 ] , g [ 0 ] hpyb , hpyg = set ( b [ 1 : : ] ) , set ( g [ 1 : : ] ) d = ( n + m ) * n * mfor i in range ( d + 1 ) : boy = i % n girl = i % m if boy in hpyb or girl in hpyg : hpyb . add ( boy ) hpyg . add ( girl ) f = Truefor i in range ( n ) : if i not in hpyb : f = False breakfor i in range ( m ) : if i not in hpyg : f = False breakif not f : print ( " No " ) else : print ( " Yes " ) NEW_LINE

def f ( b , g ) : change = i = j = 0 p = 1 while p or not ( i == 0 and j == 0 ) : if boys [ i ] + girls [ j ] == 1 : if boys [ i ] == 0 : boys [ i ] = 1 change = 1 else : girls [ j ] = 1 change = 1 i = ( i + 1 ) % n j = ( j + 1 ) % m p = 0 return changen , m = map ( int , input ( ) . split ( ) ) b , * x = list ( map ( int , input ( ) . split ( ) ) ) g , * y = list ( map ( int , input ( ) . split ( ) ) ) boys = [ 0 ] * ngirls = [ 0 ] * mchange = 1 for i in x : boys [ i ] = 1 for i in y : girls [ i ] = 1 c = 0 while f ( b , g ) : passif boys . count ( 1 ) + girls . count ( 1 ) == n + m : print ( " Yes " ) else : print ( " No " ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) if len ( l ) == 1 : boys = [ 0 ] * nelse : boys = [ 0 ] * n for i in l [ 1 : ] : boys [ i ] = 1 l1 = list ( map ( int , input ( ) . split ( ) ) ) if len ( l1 ) == 1 : girl = [ 0 ] * melse : girl = [ 0 ] * m for i in l1 [ 1 : ] : girl [ i ] = 1 for i in range ( 10 ** 5 + 1 ) : n1 = i % n ; m1 = i % m NEW_LINE


from math import gcdn , m = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) d = 0f or i in range ( 1 , n ) : d = gcd ( d , abs ( a [ i ] - a [ i - 1 ] ) ) ans = [ gcd ( d , a [ 0 ] + elm ) for elm in b ] print ( * ans )

import java . io . * ; import java . lang . * ; import java . util . * ; import java . io . * ; import java . util . * ; public class Main { static Scanner scanner = new Scanner ( System . in ) ; static Set < Long > set = new HashSet < Long > ( ) ; static int a [ ] ; static long b [ ] ; public static void main ( String [ ] args ) { int n = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; long a1 = scanner . nextLong ( ) ; long s = 0 ; for ( int i = 1 ; i < n ; i ++ ) { s = gcd ( s , Math . abs ( scanner . nextLong ( ) - a1 ) ) ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < m ; i ++ ) { sb . append ( gcd ( s , a1 + scanner . nextLong ( ) ) + " ▁ " ) ; } System . out . println ( sb ) ; } static long gcd ( long gcd , long l ) { if ( l == 0 ) return gcd ; else return gcd ( l , gcd % l ) ; } }

import java . io . BufferedOutputStream ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ;

import sys , os , ioimport math , bisect , operatorinf , mod = float ( ' inf ' ) , 10 * * 9 + 7 # sys . setrecursionlimit ( 10 * * 6 ) from itertools import groupby , accumulatefrom heapq import heapify , heappop , heappushfrom collections import deque , Counter , defaultdictinput = iter ( sys . stdin . buffer . read ( ) . decode ( ) . splitlines ( ) ) . __next__Neo = lambda : list ( map ( int , input ( ) . split ( ) ) ) # test , = Neo ( ) n , m = Neo ( ) A = Neo ( ) B = Neo ( ) A . sort ( ) for i in range ( 1 , n ) : A [ i ] -= A [ 0 ] if n == 1 : for i in B : print ( i + A [ 0 ] , end = ' ▁ ' ) else : gcd = A [ 1 ] for i in range ( 1 , n ) : gcd = math . gcd ( gcd , A [ i ] ) for i in B : t = math . gcd ( gcd , A [ 0 ] + i ) print ( t , end = ' ▁ ' )

import sys   input = lambda : sys . stdin . readline ( ) . rstrip ( " \n " ) NEW_LINE from math import sqrt , ceil , gcd     n , m = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE t = a [ 0 ] NEW_LINE for i in range ( n ) : a [ i ] -= tans = 0 NEW_LINE

from math import gcdn , m = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE d = 0 NEW_LINE for i in range ( 1 , n ) : d = gcd ( d , abs ( a [ i ] - a [ i - 1 ] ) ) NEW_LINE ans = [ gcd ( d , a [ 0 ] + elm ) for elm in b ] NEW_LINE print ( * ans ) NEW_LINE

n , m = tuple ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ) ) )   NEW_LINE def gcd ( a , b ) : while NEW_LINE b : a , b = b , a % b NEW_LINE return a   temp = 0 NEW_LINE for i in range ( 1 , len ( a ) ) : temp = gcd ( temp , abs ( a [ i ] - a [ i - 1 ] ) )   for i in range ( len ( b ) ) : print ( gcd ( b [ i ] + a [ 0 ] , temp ) , end = ' ▁ ' ) NEW_LINE

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


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner puttingvaluesinside = new Scanner ( System . in ) ; int n = puttingvaluesinside . nextInt ( ) ; if ( n == 1 ) { if ( puttingvaluesinside . nextInt ( ) == 1 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } else { int count = 0 ; while ( n -- > 0 ) { if ( puttingvaluesinside . nextInt ( ) == 0 ) count ++ ; } if ( count == 1 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } }

import java . util . * ; import java . util . Scanner ; import java . io . * ; import javax . lang . model . util . ElementScanner6 ; import static java . lang . System . out ; import java . util . Stack ; import java . util . Queue ; import java . util . LinkedList ;   public class A691 {   public static void main ( String args [ ] ) {   FastReader in = new FastReader ( ) ; PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; int tc = 1 ;

import java . util . Scanner ;   public class acmTest5 { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int [ ] nums = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { nums [ i ] = scan . nextInt ( ) ; }   System . out . println ( getRes ( nums ) ) ; }   public static String getRes ( int [ ] nums ) { if ( nums . length == 1 && nums [ 0 ] == 1 ) { return " YES " ; } if ( nums . length == 1 && nums [ 0 ] == 0 ) { return " NO " ; } int res = 0 ; for ( int i = 0 ; i < nums . length ; i ++ ) { if ( nums [ i ] == 0 ) { res ++ ; } } return res == 1 ? " YES " : " NO " ; }   }

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) if n == 1 and a [ 0 ] == 1 or n > 1 and a . count ( 0 ) == 1 : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) )   cnt = a . count ( 1 ) if n == 1 : if cnt == 1 : print ( ' YES ' ) else : print ( ' NO ' ) elif n > 1 : if cnt == n - 1 : print ( ' YES ' ) else : print ( ' NO ' )   NEW_LINE


import java . util . Arrays ; import java . util . Collections ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ;   public class Problem1042B { static long finalCost = Long . MAX_VALUE ;   public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; Map < String , Integer > vitaminCostMap = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int cost = s . nextInt ( ) ; char arr [ ] = s . next ( ) . toCharArray ( ) ; Arrays . sort ( arr ) ; vitaminCostMap . computeIfPresent ( new String ( arr ) , ( k , val ) -> Math . min ( val , cost ) ) ; vitaminCostMap . computeIfAbsent ( new String ( arr ) , ( k ) -> cost ) ; } int [ ] finalCostArr = new int [ 7 ] ; String [ ] vitaminArr = new String [ 7 ] ; int size = 0 ; for ( Map . Entry < String , Integer > entry : vitaminCostMap . entrySet ( ) ) { finalCostArr [ size ] = entry . getValue ( ) ; vitaminArr [ size ] = entry . getKey ( ) ; size ++ ; }   getFinalCost ( finalCostArr , size , 0 , " " , 0 , vitaminArr ) ; System . out . println ( finalCost == Long . MAX_VALUE ? - 1 : finalCost ) ; }   private static void getFinalCost ( int [ ] finalCostArr , int size , int ind , String currentVitamins , int currentVitaminCost , String [ ] vitaminArr ) { if ( ind >= size ) { if ( currentVitamins . contains ( " A " ) && currentVitamins . contains ( " B " ) && currentVitamins . contains ( " C " ) ) finalCost = Math . min ( currentVitaminCost , finalCost ) ; return ; } getFinalCost ( finalCostArr , size , ind + 1 , currentVitamins + vitaminArr [ ind ] , currentVitaminCost + finalCostArr [ ind ] , vitaminArr ) ; getFinalCost ( finalCostArr , size , ind + 1 , currentVitamins , currentVitaminCost , vitaminArr ) ;   }   }

import java . util . * ; import java . io . * ; import java . math . * ;   public class First { public static boolean func ( String x , String y ) { boolean a = false , b = false , c = false ; if ( ( x . indexOf ( ' A ' ) != - 1 ) || ( y . indexOf ( ' A ' ) != - 1 ) ) { a = true ; } if ( ( x . indexOf ( ' B ' ) != - 1 ) || ( y . indexOf ( ' B ' ) != - 1 ) ) { b = true ; } if ( ( x . indexOf ( ' C ' ) != - 1 ) || ( y . indexOf ( ' C ' ) != - 1 ) ) { c = true ; } if ( a && b && c ) { return true ; } return false ; } public static void process ( ) throws IOException { int n = ni ( ) ; int [ ] price = new int [ n ] ; String [ ] vit = new String [ n ] ;      for ( int i = 0 ; i < n ; i ++ ) { String [ ] x = nln ( ) . trim ( ) . split ( " ▁ " ) ; price [ i ] = Integer . parseInt ( x [ 0 ] ) ; vit [ i ] = x [ 1 ] ; }

""" practice ▁ mode """ n = int ( input ( ) ) m = float ( " inf " ) d = { " A " : m , " B " : m , " C " : m , " AB " : m , " BC " : m , " AC " : m , " ABC " : m } ans = mfor i in range ( n ) : a , b = input ( ) . split ( ) a = int ( a ) b = " " . join ( sorted ( list ( b ) ) ) d [ b ] = min ( d [ b ] , a ) NEW_LINE

t = int ( input ( ) ) price = [ 0 ] + [ 10 ** 9 ] * 7 for _ in range ( t ) : c , s = input ( ) . split ( ) c = int ( c )   a = sum ( [ 1 << ( ord ( x ) - ord ( ' A ' ) ) for x in s ] ) for i in range ( 8 ) : price [ i | a ] = min ( price [ i | a ] , price [ i ] + c ) if price [ - 1 ] == 10 ** 9 : print ( - 1 ) else : print ( price [ - 1 ] ) NEW_LINE

n = int ( input ( ) ) dp = [ 10 ** 18 ] * 8 dp [ 0 ] = 0 for i in range ( n ) : c , s = input ( ) . split ( " ▁ " ) s = list ( s ) x = 0 if " A " in s : x += 1 if " B " in s : x += 2 if " C " in s : x += 4 c = int ( c ) for i in range ( 8 ) : y = 0 for j in range ( 3 ) : if ( i >> j ) & 1 == 1 or ( x >> j ) & 1 == 1 : y += 2 ** j dp [ y ] = min ( dp [ i ] + c , dp [ y ] ) if dp [ 7 ] == 10 ** 18 : print ( - 1 ) else : print ( dp [ 7 ] ) NEW_LINE

n = int ( input ( ) ) d = { " A " : float ( " inf " ) , " B " : float ( " inf " ) , " C " : float ( " inf " ) , " AB " : float ( " inf " ) , " AC " : float ( " inf " ) , " BC " : float ( " inf " ) , " ABC " : float ( " inf " ) } for _ in range ( n ) : cost , vits = input ( ) . split ( ) cost = int ( cost ) if ( len ( vits ) == 1 ) : if ( d [ vits ] > cost ) : d [ vits ] = cost elif ( len ( vits ) == 2 ) : if ( " A " in vits and " B " in vits ) : if ( d [ " AB " ] > cost ) : d [ " AB " ] = cost elif ( " A " in vits and " C " in vits ) : if ( d [ " AC " ] > cost ) : d [ " AC " ] = cost else : if ( d [ " BC " ] > cost ) : d [ " BC " ] = cost else : if ( d [ " ABC " ] > cost ) : d [ " ABC " ] = cost val = min ( d [ " A " ] + d [ " B " ] + d [ " C " ] , d [ " A " ] + d [ " BC " ] , d [ " B " ] + d [ " AC " ] , d [ " C " ] + d [ " AB " ] , d [ " AB " ] + d [ " AC " ] , d [ " AB " ] + d [ " BC " ] , d [ " AC " ] + d [ " BC " ] , d [ " ABC " ] ) if ( val == float ( " inf " ) ) : print ( - 1 ) else : print ( val ) NEW_LINE


import java . util . * ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] a = new int [ n + 1 ] ; for ( int i = 1 ; i < n + 1 ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int min = 0 , dis = 100 ; for ( int i = 1 ; i < n + 1 ; i ++ ) { if ( a [ i ] == 0 ) { continue ; } else { if ( k >= a [ i ] ) { if ( m > i ) { min = m - i ; } else { min = i - m ; } } else { continue ; } } dis = Math . min ( dis , min ) ; } System . out . println ( dis * 10 ) ; } }

import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int m = s . nextInt ( ) ; int k = s . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = s . nextInt ( ) ; m = m - 1 ; int min = Integer . MAX_VALUE , min1 = Integer . MAX_VALUE ; for ( int j = 0 ; j < m ; j ++ ) { if ( k >= a [ j ] && a [ j ] != 0 ) { if ( ( m - j ) < min ) min = m - j ; } } for ( int j1 = m + 1 ; j1 < n ; j1 ++ ) { if ( k >= a [ j1 ] && a [ j1 ] != 0 ) { if ( ( j1 - m ) < min1 ) min1 = j1 - m ; } } int p = Math . min ( min , min1 ) ; System . out . println ( p * 10 ) ; } }

import java . io . * ; import java . util . * ; import javax . print . attribute . standard . Finishings ;   import java . math . * ;   public class Exam { static final Random random = new Random ( ) ; static PrintWriter out = new PrintWriter ( ( System . out ) ) ; static Reader sc = new Reader ( ) ;   public static void main ( String args [ ] ) throws IOException {

n , m , k = [ int ( x ) for x in input ( ) . split ( ) ] m -= 1 houses = [ int ( x ) for x in input ( ) . split ( ) ]   will_buy = - 1 house_away = nfor i in range ( n ) : price = houses [ i ] this_away = abs ( i - m ) if ( price != 0 and k >= price and this_away <= house_away ) : will_buy = i house_away = this_away   print ( 10 * ( abs ( will_buy - m ) ) ) NEW_LINE

n , m , k = map ( int , input ( ) . split ( ) ) houses = [ int ( i ) for i in input ( ) . split ( ) ] frwd , bcwd = 999 , - 999   for i in range ( m , n ) : if 0 < houses [ i ] <= k : frwd = i + 1 break   for i in range ( m - 2 , - 1 , - 1 ) : if 0 < houses [ i ] <= k : bcwd = i + 1 break   print ( min ( frwd - m , m - bcwd ) * 10 ) NEW_LINE

""" # ▁ Do ▁ not ▁ remove ▁ the ▁ below ▁ import ▁ statementimport ▁ sys  ''' This ▁ function ▁ provides ▁ the ▁ capacity , ▁ size ▁ and ▁ space ▁ left ▁ in ▁ the ▁ list . You ▁ can ▁ invoke ▁ it ▁ to ▁ get ▁ the ▁ details ▁ of ▁ the ▁ list '''   def ▁ list _ details ( lst ) : ▁ ▁ ▁ ▁ # ▁ Number ▁ of ▁ elements ▁ that ▁ can ▁ be ▁ stored ▁ in ▁ the ▁ list ▁ ▁ ▁ ▁ print ( " Capacity : " , ▁ ( sys . getsizeof ( lst ) -36 ) / /4 )   ▁ ▁ ▁ ▁ # ▁ Number ▁ of ▁ elements ▁ in ▁ the ▁ list ▁ ▁ ▁ ▁ print ( " Size : " , ▁ len ( lst ) )   ▁ ▁ ▁ ▁ # ▁ Number ▁ of ▁ elements ▁ that ▁ can ▁ be ▁ accommodated ▁ in ▁ the ▁ space ▁ left ▁ ▁ ▁ ▁ print ( " Space ▁ Left : " , ▁ ( ( sys . getsizeof ( lst ) -36 ) ▁ - ▁ len ( lst * 4 ) ) / / 4 )   ▁ ▁ ▁ ▁ # ▁ formula ▁ changes ▁ based ▁ on ▁ the ▁ system ▁ architecture ▁ ▁ ▁ ▁ # ▁ ( size - 36 ) / 4 ▁ for ▁ 32 ▁ bit ▁ machines ▁ and ▁ ▁ ▁ ▁ # ▁ ( size - 64 ) / 8 ▁ for ▁ 64 ▁ bit ▁ machines  ▁ ▁ ▁ ▁ # ▁ 36 , ▁ 64 ▁ - ▁ size ▁ of ▁ an ▁ empty ▁ list ▁ based ▁ on ▁ machine ▁ ▁ ▁ ▁ # ▁ 4 , ▁ 8 ▁ - ▁ size ▁ of ▁ a ▁ single ▁ element ▁ in ▁ the ▁ list ▁ based ▁ on ▁ machine  marias _ lst ▁ = ▁ [ ] for ▁ i ▁ in ▁ range ( 1500 ) : ▁ ▁ ▁ ▁ marias _ lst . append ( i ) print ( " Empty ▁ list ▁ created ! ! ! " ) print ( " List ▁ details : " ) list _ details ( marias _ lst ) marias _ lst . append ( 1 ) marias _ lst . append ( 2 ) print ( marias _ lst ) """ n , m , k = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) mind = len ( l ) - 1 for i in range ( len ( l ) ) : if i != m - 1 and 0 < l [ i ] <= k and abs ( i - m + 1 ) < mind : mind = abs ( i - m + 1 ) print ( mind * 10 ) NEW_LINE

n , m , k = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) min_d = float ( ' inf ' ) for i in range ( n ) : if l [ i ] <= k and l [ i ] != 0 : if abs ( ( ( m - 1 ) - i ) * 10 ) < min_d : min_d = abs ( ( ( m - 1 ) - i ) * 10 ) print ( min_d ) NEW_LINE

import sys   def main ( ) : n , m , k , * l = map ( int , sys . stdin . read ( ) . strip ( ) . split ( ) ) return min ( abs ( i - m ) for i , j in enumerate ( l , 1 ) if j and k >= j ) * 10 print ( main ( ) ) NEW_LINE


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

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

import java . io . * ; import java . util . * ; import java . lang . * ; import java . math . * ; import java . text . DecimalFormat ; import java . lang . reflect . Array ; import java . io . BufferedOutputStream ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigDecimal ; public class B { public static PrintWriter out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; static long MOD = ( long ) ( 1e9 + 7 ) ; static long MOD2 = MOD * MOD ;

import java . io . * ; import java . util . * ;   public class ColoredBalls { public static int mod = 1000000007 ; public static int MAXN = 1010 ; public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out , true ) ; long [ ] [ ] comb = new long [ MAXN ] [ MAXN ] ; comb [ 0 ] [ 0 ] = 1 ; for ( int i = 1 ; i < MAXN ; i ++ ) { comb [ i ] [ 0 ] = 1 ; for ( int j = 1 ; j <= i ; j ++ ) { comb [ i ] [ j ] = ( comb [ i - 1 ] [ j ] + comb [ i - 1 ] [ j - 1 ] ) % mod ; } } int K = in . nextInt ( ) ; int [ ] color = new int [ K ] ; for ( int i = 0 ; i < K ; i ++ ) color [ i ] = in . nextInt ( ) ; long res = 1 ; int total = 0 ; for ( int i = 0 ; i < K ; i ++ ) { res = ( res * comb [ total + color [ i ] - 1 ] [ color [ i ] - 1 ] ) % mod ; total += color [ i ] ; } out . println ( res ) ; out . close ( ) ; System . exit ( 0 ) ; } }

k = int ( input ( ) ) mod = 10 ** 9 + 7 f = [ 0 ] * ( 10 ** 6 + 1 ) f [ 0 ] = f [ 1 ] = 1 for i in range ( 2 , 10 ** 6 + 1 ) : f [ i ] = ( f [ i - 1 ] * i ) % moddef comb ( n , r ) : return ( f [ n ] * pow ( f [ r ] , mod - 2 , mod ) * pow ( f [ n - r ] , mod - 2 , mod ) ) % modans = 1 cc = int ( input ( ) ) for i in range ( 1 , k ) : c = int ( input ( ) ) cc += c ans *= comb ( cc - 1 , c - 1 ) ans %= modprint ( ans ) NEW_LINE

from sys import stdin , stdoutfrom collections import Counternmbr = lambda : int ( stdin . readline ( ) ) lst = lambda : list ( map ( int , stdin . readline ( ) . split ( ) ) ) M = 10 ** 9 + 7 fact = [ 1 ] for i in range ( 1 , 1005 ) : fact += [ ( fact [ - 1 ] * i ) % M ] def ncr ( n , r ) : num = fact [ n ] den = ( fact [ r ] * fact [ n - r ] ) % M ans = ( num * pow ( den , M - 2 , M ) ) % M return ansfor _ in range ( 1 ) : NEW_LINE

t = int ( input ( ) ) c = 1 s = int ( input ( ) ) for _ in range ( t - 1 ) : n = int ( input ( ) ) s += n   k = 1 for i in range ( 1 , n ) : k = k * ( s - i ) // i c = ( c * k ) % ( 10 ** 9 + 7 ) print ( c ) NEW_LINE

''' ▁ ▁ ▁ ▁ Auther : ▁ ghoshashis545 ▁ Ashis ▁ Ghosh ▁ ▁ ▁ ▁ College : ▁ jalpaiguri ▁ Govt ▁ Enggineering ▁ College  ''' from os import pathfrom io import BytesIO , IOBaseimport sysfrom heapq import heappush , heappopfrom functools import cmp_to_key as ctkfrom collections import deque , Counter , defaultdict as dd from bisect import bisect , bisect_left , bisect_right , insort , insort_left , insort_rightfrom itertools import permutationsfrom datetime import datetimefrom math import ceil , sqrt , log , gcddef ii ( ) : return int ( input ( ) ) def si ( ) : return input ( ) . rstrip ( ) def mi ( ) : return map ( int , input ( ) . split ( ) ) def li ( ) : return list ( mi ( ) ) abc = ' abcdefghijklmnopqrstuvwxyz ' mod = 1000000007 NEW_LINE

from sys import stdinc = [ [ 0 ] * 1002 for _ in range ( 0 , 1002 ) ] MOD = int ( 1e9 + 7 )   for i in range ( 0 , 1002 ) : c [ i ] [ 0 ] = c [ i ] [ i ] = 1 for j in range ( 0 , i ) : c [ i ] [ j ] = ( c [ i - 1 ] [ j - 1 ] + c [ i - 1 ] [ j ] ) % MOD   r = map ( int , stdin . read ( ) . split ( ) )   n = next ( r ) ans = 1 sum = 0   for _ in range ( 0 , n ) : x = next ( r ) ans = ( ans * c [ sum + x - 1 ] [ sum ] ) % MOD sum += x   print ( ans ) NEW_LINE


import java . util . Scanner ;   public class Draw { public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) , i , x = 0 , y = 0 , o = 1 ;   for ( i = 0 ; i < n ; i ++ ) { int a = in . nextInt ( ) , b = in . nextInt ( ) ; o += Math . max ( 0 , Math . min ( a , b ) - Math . max ( x , y ) + ( x != y ? 1 : 0 ) ) ; x = a ; y = b ; } in . close ( ) ; System . out . println ( o ) ; } }

import java . util . * ; import java . io . * ; public class Main { static FastScanner sc = new FastScanner ( System . in ) ; static PrintWriter pw = new PrintWriter ( System . out ) ; static StringBuilder sb = new StringBuilder ( ) ; public static void main ( String [ ] args ) throws Exception { int n = sc . nextInt ( ) ; int a = 0 ; int b = 0 ; int bar = - 1 ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int na = sc . nextInt ( ) ; int nb = sc . nextInt ( ) ; ans += Math . max ( 0 , Math . min ( na , nb ) - Math . max ( Math . max ( b , a ) - 1 , bar ) ) ; a = na ; b = nb ; bar = Math . min ( a , b ) ;

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

n = int ( input ( ) ) a , b = 0 , 0 ; ans = 1 for _ in range ( n ) : p , q = map ( int , input ( ) . split ( ) ) ; temp = 0 if a != b : temp = 1 if min ( p , q ) - max ( a , b ) + temp >= 0 : ans += min ( p , q ) - max ( a , b ) + temp a , b = p , qprint ( ans ) NEW_LINE

import sysfrom collections import dequeimport mathinput_ = lambda : sys . stdin . readline ( ) . strip ( " \n " ) ii = lambda : int ( input_ ( ) ) il = lambda : list ( map ( int , input_ ( ) . split ( ) ) ) ilf = lambda : list ( map ( float , input_ ( ) . split ( ) ) ) ip = lambda : input_ ( ) fi = lambda : float ( input_ ( ) ) li = lambda : list ( input_ ( ) ) pr = lambda x : print ( x ) f = lambda : sys . stdout . flush ( )   n = ii ( )   ans = 1 p1 = p2 = 0   for i in range ( n ) : x , y = il ( ) ans += max ( 0 , min ( x , y ) - max ( p1 , p2 ) + 1 ) if ( ( p1 == p2 ) and ans > 0 ) : ans -= 1 p1 , p2 = x , y   print ( ans ) NEW_LINE

import sysimport bisectfrom random import randintinput = lambda : sys . stdin . readline ( ) . strip ( " \n " ) from math import gcdsa = lambda : input ( ) sb = lambda : int ( input ( ) ) sc = lambda : input ( ) . split ( ) sd = lambda : list ( map ( int , input ( ) . split ( ) ) ) se = lambda : float ( input ( ) ) sf = lambda : list ( input ( ) ) flsh = lambda : sys . stdout . flush ( ) mod = 10 ** 9 + 7 def hnbhai ( ) : n = sb ( ) x , y = 0 , 0 ans = [ [ 0 , 0 ] ] for i in range ( n ) : a , b = sd ( ) ans . append ( [ a , b ] ) t = 1 for i in range ( 1 , n + 1 ) : t += max ( 0 , min ( ans [ i ] [ 0 ] , ans [ i ] [ 1 ] ) - max ( ans [ i - 1 ] [ 0 ] , ans [ i - 1 ] [ 1 ] ) + 1 ) if t > 0 and ans [ i - 1 ] [ 0 ] == ans [ i - 1 ] [ 1 ] : t -= 1 print ( t ) for _ in range ( 1 ) : hnbhai ( ) NEW_LINE

n = int ( input ( ) ) arr = [ ] for _ in range ( n ) : a , b = map ( int , input ( ) . split ( ) ) arr . append ( [ a , b ] ) ans = min ( arr [ 0 ] ) + 1 for i in range ( n - 1 ) : if max ( arr [ i ] ) <= min ( arr [ i + 1 ] ) : if arr [ i ] [ 0 ] == arr [ i ] [ 1 ] : ans -= 1 ans += min ( arr [ i + 1 ] ) - max ( arr [ i ] ) + 1 print ( ans ) NEW_LINE

from sys import stdin , stdoutinput = stdin . readline def main ( ) : n = int ( input ( ) ) preva = prevb = - 1 ans = 0 for i in range ( n ) : a , b = map ( int , input ( ) . split ( ) ) if preva != prevb : ans += max ( 0 , min ( a , b ) - max ( preva , prevb ) + 1 ) else : ans += max ( 0 , min ( a , b ) - max ( preva , prevb ) ) preva , prevb = a , b print ( ans ) main ( )   NEW_LINE


import java . util . * ; import java . lang . * ; import java . io . * ;   public class Ideone { public static void main ( String [ ] args ) throws java . lang . Exception { int [ ] [ ] mat = { { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 0 , 0 , 1 , 0 , 1 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } ,


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class A45 { public static void main ( String [ ] args ) throws IOException { BufferedReader inp = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int size = Integer . parseInt ( inp . readLine ( ) ) ; String [ ] s1 = inp . readLine ( ) . split ( " ▁ " ) ; long [ ] given = new long [ size ] ; long totalSum = 0 ; for ( int i = 0 ; i < size ; i ++ ) { given [ i ] = Integer . parseInt ( s1 [ i ] ) ; totalSum += given [ i ] ; } long each = totalSum / size ; long [ ] diff = new long [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { diff [ i ] = given [ i ] - each ; } long sum = Math . abs ( diff [ 0 ] ) ; long carry = diff [ 0 ] ; for ( int i = 1 ; i < size ; i ++ ) { sum += Math . abs ( diff [ i ] + carry ) ; carry = carry + diff [ i ] ; } System . out . println ( sum ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class Matches { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( in . readLine ( ) ) ; String [ ] temp = in . readLine ( ) . split ( " ▁ " ) ; long c = 0 ; long [ ] pp = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int u = Integer . parseInt ( temp [ i ] ) ; c += u ; pp [ i ] = u ; } long h = c / n ; long y = 0 ; for ( int i = 0 ; i < pp . length - 1 ; i ++ ) { long u = pp [ i ] - h ; if ( u > 0 ) { pp [ i ] -= u ; pp [ i + 1 ] += u ; y += u ; } else if ( u < 0 ) { pp [ i + 1 ] = pp [ i + 1 ] - ( h - pp [ i ] ) ; y += ( h - pp [ i ] ) ; pp [ i ] = h ; } } System . out . println ( y ) ; } }

import java . io . * ; import java . util . * ; public class Balancer { static class Reader { final private int BUFFER_SIZE = 1 << 16 ; private DataInputStream din ; private byte [ ] buffer ; private int bufferPointer , bytesRead ;   public Reader ( ) { din = new DataInputStream ( System . in ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; }   public Reader ( String file_name ) throws IOException { din = new DataInputStream ( new FileInputStream ( file_name ) ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; }   public String readLine ( ) throws IOException { byte [ ] buf = new byte [ 64 ] ;

n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) )   k = sum ( arr ) // nmoves = 0   for i in range ( n - 1 ) : arr [ i + 1 ] += arr [ i ] - k moves += abs ( k - arr [ i ] ) print ( moves ) NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) )   need = sum ( a ) // n   ans = 0   from math import *   for i in range ( n - 1 ) : if ( a [ i ] <= need ) : a [ i + 1 ] -= need - a [ i ] else : a [ i + 1 ] += a [ i ] - need ans += abs ( a [ i ] - need )   print ( ans ) NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) )   t = 0 for i in range ( n ) : t += a [ i ]   t = t // ncnt = 0   for i in range ( n ) : if a [ i ] > t : a [ i + 1 ] += abs ( a [ i ] - t ) cnt += ( abs ( a [ i ] - t ) )   elif a [ i ] < t : a [ i + 1 ] -= abs ( a [ i ] - t ) cnt += ( abs ( a [ i ] - t ) )   print ( cnt ) NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) + [ 0 ] s = sum ( a ) // nd = 0 for i in range ( n ) : if a [ i ] > s : a [ i + 1 ] += abs ( a [ i ] - s ) else : a [ i + 1 ] -= abs ( a [ i ] - s ) d += abs ( a [ i ] - s ) print ( d ) NEW_LINE


import java . io . * ; import java . util . * ;   public class Task {   public static void main ( String [ ] args ) throws IOException {   new Task ( ) . go ( ) ; }   PrintWriter out ; Reader in ; BufferedReader br ;   Task ( ) throws IOException {   try {

def func ( a , b , prev ) : if a == 0 : if b == 0 : if prev == 0 : return 0 else : return - 1 else : return - 1   if a == 1 : if b == 0 : if prev == 0 or prev == 1 : return 1 - prev else : return - 1 elif b == 1 : if prev == 1 : return 1 else : return - 1 else : return - 1   if a == 2 : if b == 0 : if prev == 0 or prev == 2 : return 2 - prev else : return - 1 elif b == 2 : if prev == 2 : return 2 else : return - 1 else : return - 1   if a == 3 : if b == 0 : return 3 - prev elif b == 1 : if prev == 1 or prev == 3 : return 4 - prev else : return - 1 elif b == 2 : if prev == 2 or prev == 3 : return 5 - prev else : return - 1 else : if prev == 3 : return 3 else : return - 1     n = input ( ) arr = input ( ) brr = input ( ) arr = list ( arr . split ( " ▁ " ) ) brr = list ( brr . split ( " ▁ " ) )   n = int ( n ) for i in range ( n - 1 ) : arr [ i ] = int ( arr [ i ] ) brr [ i ] = int ( brr [ i ] )   for i in range ( 4 ) : a = arr [ 0 ] b = brr [ 0 ] t = list ( ) prev = i t . append ( prev ) pos = 1   for j in range ( 1 , n ) : prev = func ( a , b , prev ) t . append ( prev ) if prev == - 1 : pos = 0 break   if j == n - 1 : break a = arr [ j ] b = brr [ j ]   if pos == 1 : print ( " YES " ) for x in t : print ( x , end = " ▁ " ) exit ( )   print ( " NO " ) NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 4 ) : c = [ - 1 ] * n c [ 0 ] = i for j in range ( n - 1 ) : if c [ j ] == - 1 : break for k in range ( 4 ) : if ( ( c [ j ] | k ) == a [ j ] and ( c [ j ] & k ) == b [ j ] ) : c [ j + 1 ] = k if - 1 not in c : print ( " YES " ) print ( * c ) exit ( 0 ) print ( " NO " ) NEW_LINE


import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ;   public class A176 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int N = in . nextInt ( ) ; int M = in . nextInt ( ) ; int K = in . nextInt ( ) ; int [ ] [ ] buy = new int [ N ] [ M ] ; int [ ] [ ] sell = new int [ N ] [ M ] ; int [ ] [ ] amount = new int [ N ] [ M ] ; for ( int n = 0 ; n < N ; n ++ ) { in . next ( ) ;

n , m , k = map ( int , input ( ) . split ( ) )   planets = [ ]   for i in range ( n ) : name = input ( ) planets . append ( [ ] ) for j in range ( m ) : item = list ( map ( int , input ( ) . split ( ) ) ) planets [ - 1 ] . append ( item )     res = float ( " - inf " )   from itertools import permutationsfor p1 , p2 in permutations ( planets , 2 ) : sis = sorted ( range ( m ) , key = lambda i : p2 [ i ] [ 1 ] - p1 [ i ] [ 0 ] , reverse = True )   cl = k t = 0 for i in sis : if cl == 0 or p2 [ i ] [ 1 ] - p1 [ i ] [ 0 ] <= 0 : break taken = min ( cl , p1 [ i ] [ 2 ] ) t += ( p2 [ i ] [ 1 ] - p1 [ i ] [ 0 ] ) * taken cl -= taken res = max ( res , t )   print ( res ) NEW_LINE

n , m , k = [ int ( s ) for s in input ( ) . split ( ) ]   BuyingPrice = [ ] SellingPrice = [ ] Number_of_items = [ ] for i in range ( n ) : input ( ) x = [ ] y = [ ] z = [ ] for j in range ( m ) : a , b , c = [ int ( s ) for s in input ( ) . split ( ) ] x . append ( a ) y . append ( b ) z . append ( c ) BuyingPrice . append ( x ) SellingPrice . append ( y ) Number_of_items . append ( z ) def getProfit ( i , j ) : def takeFirst ( z ) : return z [ 0 ] n = [ ] for w in range ( m ) : n . append ( ( SellingPrice [ j ] [ w ] - BuyingPrice [ i ] [ w ] , Number_of_items [ i ] [ w ] ) ) n . sort ( key = takeFirst , reverse = True )   count = 0 profit = 0 for w in n : if count >= k : break profit += min ( w [ 1 ] , k - count ) * max ( w [ 0 ] , 0 ) if ( w [ 0 ] > 0 ) : count += min ( w [ 1 ] , k - count ) return profit   profit = 0 for i in range ( n ) : for j in range ( n ) : profit = max ( profit , getProfit ( i , j ) ) print ( profit )   NEW_LINE

import mathn , m , k = map ( int , input ( ) . split ( ) ) q , z , y , pp = { } , - math . inf , [ ] , kfor i in range ( n ) : input ( ) ; q [ i ] = [ ] for j in range ( m ) : q [ i ] . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in q : r = [ ] for j in q : o = [ ] for p in range ( m ) : o . append ( [ ( q [ j ] [ p ] [ 1 ] - q [ i ] [ p ] [ 0 ] ) , q [ i ] [ p ] [ 2 ] ] ) r . append ( o ) y . append ( r ) for i in y : for j in i : j . sort ( reverse = True ) h , k = 0 , pp for p in j : if p [ 0 ] > 0 and k > 0 : h += p [ 0 ] * min ( p [ 1 ] , k ) ; k -= p [ 1 ] z = max ( z , h ) print ( z ) NEW_LINE

import mathn , m , k = map ( int , input ( ) . split ( ) ) q , z , y , pp = { } , - math . inf , [ ] , kfor i in range ( n ) : input ( ) ; q [ i ] = [ ] for j in range ( m ) : q [ i ] . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in q : r = [ ] for j in q : o = [ ] if i != j : for p in range ( m ) : o . append ( [ ( q [ j ] [ p ] [ 1 ] - q [ i ] [ p ] [ 0 ] ) , q [ i ] [ p ] [ 2 ] ] ) r . append ( o ) y . append ( r ) for i in y : for j in i : j . sort ( reverse = True ) h , k = 0 , pp for p in j : if p [ 0 ] > 0 and k > 0 : h += p [ 0 ] * min ( p [ 1 ] , k ) ; k -= p [ 1 ] z = max ( z , h ) print ( z ) NEW_LINE

import sys   profit = 0 initial = ( list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) ) num_planet = initial [ 0 ] num_goods = initial [ 1 ] capacity = initial [ 2 ] stonks = [ ] for i in range ( 0 , num_planet ) : NEW_LINE


import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; s . nextLine ( ) ; String s1 = s . nextLine ( ) ; String h [ ] = new String [ n ] ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) h [ i ] = s . nextLine ( ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( h [ j ] . contains ( s1 ) ) count ++ ; } if ( count == n && count % 2 == 0 ) System . out . println ( " home " ) ; else System . out . println ( " contest " ) ; } }

import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) {   int n ; String input = " " ; String home ; Scanner sc = new Scanner ( System . in ) ;   n = sc . nextInt ( ) ; home = sc . next ( ) ; for ( int i = 0 ; i < n ; i ++ ) { sc . reset ( ) ; input = sc . next ( ) ; }

import java . io . * ; import java . util . * ; import javax . print . attribute . standard . Finishings ;   import java . math . * ;   public class Compe { static final Random random = new Random ( ) ; static PrintWriter out = new PrintWriter ( ( System . out ) ) ; static Reader sc = new Reader ( ) ;   public static void main ( String args [ ] ) throws IOException {

import java . util . * ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; String h = sc . next ( ) ; String [ ] d = new String [ t ] ; for ( int i = 0 ; i < t ; i ++ ) { d [ i ] = sc . next ( ) ; } if ( t % 2 == 0 ) { System . out . println ( " home " ) ; } else { System . out . println ( " contest " ) ; } } }

n = int ( input ( ) ) home = str ( input ( ) ) for i in range ( n ) : li1 = list ( map ( str , input ( ) . split ( ) ) ) if n % 2 == 0 : print ( " home " ) else : print ( " contest " ) NEW_LINE

t = int ( input ( ) ) a = input ( ) bal = 0 for _ in range ( t ) : b = input ( ) . split ( ' - > ' ) if ( b [ 0 ] == a ) : bal += 1 if ( b [ 1 ] == a ) : bal -= 1 if ( bal == 0 ) : print ( " home " ) else : print ( " contest " ) NEW_LINE

n = int ( input ( ) ) t = nhome = input ( ) departure = [ ] while t > 0 : flight = input ( ) departure . append ( flight [ : 3 ] ) t -= 1   if n % 2 == 0 : print ( ' home ' ) else : print ( ' contest ' ) NEW_LINE

n = int ( input ( ) ) home = input ( ) L = [ ] for i in range ( n ) : L . append ( input ( ) ) NEW_LINE

n = int ( input ( ) )   home = str ( input ( ) ) flights = [ ] for i in range ( n ) : flights . append ( input ( ) )   if ( n % 2 == 0 ) : print ( ' home ' ) else : print ( ' contest ' ) NEW_LINE


import java . util . Scanner ; public class RaceTime { public static void main ( String Args [ ] ) { Scanner sc = new Scanner ( System . in ) ; float h , m , s , t1 , t2 ; h = sc . nextFloat ( ) ; m = sc . nextFloat ( ) ; s = sc . nextFloat ( ) ; t1 = sc . nextFloat ( ) ; t2 = sc . nextFloat ( ) ; int poss = 0 ; if ( h == 12 ) h = 0 ; if ( t2 == 12 ) t2 = 0 ; if ( t1 == 12 ) t1 = 0 ; if ( t1 > t2 ) { float temp = t1 ; t1 = t2 ; t2 = temp ; } m += 0.01667 * s ; h += 0.0083 * m ; if ( ! ( t1 <= h && h <= t2 ) ) {

import java . util . * ; import java . io . * ; public class Main {   static BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static StringTokenizer st ; static PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; public static void main ( String [ ] args ) throws IOException { int h = readInt ( ) , m = readInt ( ) , n = readInt ( ) , u = readInt ( ) , v = readInt ( ) ; int min = Math . min ( u , v ) , max = Math . max ( u , v ) , cur = 0 ; if ( h >= min && h < max ) cur ++ ; if ( m >= min * 5 && m < max * 5 ) cur ++ ; if ( n > min * 5 && n < max * 5 ) cur ++ ; if ( cur == 1 || cur == 2 ) System . out . println ( " NO " ) ; else System . out . println ( " YES " ) ; } static String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( input . readLine ( ) . trim ( ) ) ; return st . nextToken ( ) ; } static long readLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } static int readInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } static double readDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } static char readChar ( ) throws IOException { return next ( ) . charAt ( 0 ) ; } static String readLine ( ) throws IOException { return input . readLine ( ) . trim ( ) ; } }

import sysinput = sys . stdin . readlinedef prog ( ) : h , m , s , t1 , t2 = map ( int , input ( ) . split ( ) ) marked = [ 0 ] * 3600 * 12 h = h % 12 t1 = t1 % 12 t2 = t2 % 12 marked [ 3600 * h + 60 * m + s ] = 1 marked [ 720 * m + 12 * s ] = 1 marked [ 720 * s ] = 1 t1 , t2 = min ( t1 , t2 ) , max ( t1 , t2 ) t1 *= 3600 t2 *= 3600 fail = False NEW_LINE

h , m , s , t1 , t2 = map ( int , input ( ) . split ( ) ) t = [ t1 , t2 ] hms = [ h , m / 5 , s / 5 ] ans = [ [ 0 , 0 ] for i in range ( 3 ) ] for i in range ( 2 ) : for j in range ( 3 ) : ans [ j ] [ i ] = t [ i ] > hms [ j ] ans2 = [ ( ans [ i ] [ 0 ] + ans [ i ] [ 1 ] ) % 2 for i in range ( 3 ) ] if sum ( ans2 ) == 3 or sum ( ans2 ) == 0 : print ( " YES " ) else : print ( " NO " ) NEW_LINE

d = list ( map ( int , input ( ) . split ( ) ) ) d [ 0 ] *= 5 d [ 3 ] *= 5 d [ 4 ] *= 5 t1 = d [ 3 ] t2 = d [ 4 ] d . sort ( ) if abs ( d . index ( t1 ) - d . index ( t2 ) ) == 1 or abs ( d . index ( t1 ) - d . index ( t2 ) ) == 4 : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE


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

import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) {   Scanner scan = new Scanner ( System . in ) ;   int cases = scan . nextInt ( ) ; int counts [ ] = new int [ 1001 ] ; for ( int i = 0 ; i < cases ; i ++ ) { counts [ scan . nextInt ( ) ] ++ ; } int countsInaRow = 0 ; for ( int i = 0 ; i < counts . length ; i ++ ) { if ( counts [ i ] > 0 ) { countsInaRow ++ ; } else { countsInaRow = 0 ; } if ( countsInaRow == 3 ) { break ; } } if ( countsInaRow == 3 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }

import java . util . Scanner ;   public class Problem653A {   public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int balls = input . nextInt ( ) ; int [ ] arr = new int [ 1001 ] ; for ( int i = 0 ; i < balls ; i ++ ) { arr [ input . nextInt ( ) ] ++ ; } int count = 0 ; boolean flag = false ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( arr [ i ] > 0 ) { count ++ ; } else { count = 0 ; } if ( count == 3 ) { flag = true ; break ; } } if ( flag ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }

n = int ( input ( ) ) t = list ( map ( int , input ( ) . split ( ) ) ) t = list ( set ( t ) ) t . sort ( reverse = True )   for i in range ( len ( t ) ) : if len ( t ) > i + 2 : if t [ i ] - t [ i + 1 ] <= 1 : if t [ i + 1 ] - t [ i + 2 ] <= 1 : print ( " YES " ) break else : print ( " NO " ) break NEW_LINE

n = int ( input ( ) ) li = list ( set ( sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) ) ) count = 0 for i in range ( len ( li ) - 1 ) : if li [ i + 1 ] - li [ i ] == 1 : count += 1 else : count = 0 if count >= 2 : print ( " YES " ) exit ( 0 ) else : print ( " NO " )                           NEW_LINE

n = int ( input ( ) ) nums = [ int ( j ) for j in input ( ) . split ( ) ] ref = 1000 * [ 0 ] for j in range ( n ) : ref [ nums [ j ] - 1 ] += 1 output = " NO " for j in range ( 1000 ) : if j + 2 < 1000 : if ref [ j ] > 0 and ref [ j + 1 ] > 0 and ref [ j + 2 ] > 0 : output = " YES " breakprint ( output ) NEW_LINE

n = int ( input ( ) ) t = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in range ( n - 2 ) : if t [ i ] + 1 in t and t [ i ] + 2 in t : print ( " YES " ) breakelse : print ( " NO " ) NEW_LINE

n = int ( input ( ) ) a = sorted ( set ( map ( int , input ( ) . split ( ) ) ) ) ok = Falsefor i in range ( len ( a ) - 2 ) : x = a [ i ] if ( a [ i ] == x and a [ i + 1 ] == x + 1 and a [ i + 2 ] == x + 2 ) : ok = True breakprint ( " YES " if ok else " NO " ) NEW_LINE


import java . util . Scanner ;   public class HongcowCyclicShift { public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) , t = s + s ;   in . close ( ) ; System . out . println ( t . indexOf ( s , 1 ) ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; public class code { public static void main ( String [ ] args ) throws IOException { FastReader sc = new FastReader ( ) ; PrintWriter p = new PrintWriter ( System . out ) ;    String s = sc . next ( ) ; HashSet < String > st = new HashSet < > ( ) ; for ( int i = s . length ( ) - 1 ; i >= 0 ; i -- ) { String q = " " + s . charAt ( s . length ( ) - 1 ) ; q = q + s . substring ( 0 , s . length ( ) - 1 ) ; s = new String ( q ) ;

import java . util . Arrays ; import java . util . Collections ; import java . util . HashSet ; import java . util . LinkedList ; import java . util . Queue ; import java . util . Scanner ; import java . util . Set ;   public class NewMain2 {   public static void main ( String [ ] args ) {

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

s = input ( ) ans = set ( ) ans . add ( s ) c = s [ 1 : ] + s [ 0 ] while c != s : ans . add ( c ) c = c [ 1 : ] + c [ 0 ]     print ( len ( ans ) )   NEW_LINE

s = input ( ) n = len ( s ) res = set ( ) for i in range ( n ) : res . add ( s [ i : ] + s [ : i ] ) print ( len ( res ) ) NEW_LINE

a = input ( ) from collections import defaultdictdict = defaultdict ( int ) for i in range ( len ( a ) ) : dict [ a ] = 1 a = a [ 1 : ] + a [ : 1 ] print ( len ( dict ) ) NEW_LINE

n = str ( input ( ) ) t = [ 0 ] * ( len ( n ) ) j = 0 for i in range ( len ( n ) ) : t [ j ] = n [ len ( n ) - 1 ] + n [ : len ( n ) - 1 ] n = t [ j ] j += 1 x = set ( t ) print ( len ( x ) ) NEW_LINE

s = input ( ) ; print ( len ( { s [ i : ] + s [ : i ] for i in range ( len ( s ) ) } ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ;     public class b { public static void main ( String [ ] args ) { FS in = new FS ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ;   int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int x = in . nextInt ( ) ; int y = in . nextInt ( ) ; int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int gcd = gcd ( a , b ) ; a /= gcd ; b /= gcd ; int tmp = Math . min ( n / a , m / b ) ; a *= tmp ; b *= tmp ; int cornX = Math . max ( 0 , Math . min ( n , x - ( a + 1 ) / 2 ) ) ; int cornY = Math . max ( 0 , Math . min ( m , y - ( b + 1 ) / 2 ) ) ; int otherCornX = cornX + a ; int otherCornY = cornY + b ;   cornX -= Math . max ( 0 , otherCornX - n ) ; cornY -= Math . max ( 0 , otherCornY - m ) ; System . out . println ( cornX + " ▁ " + cornY + " ▁ " + ( cornX + a ) + " ▁ " + ( cornY + b ) ) ; out . close ( ) ; } static int gcd ( int a , int b ) { return b == 0 ? a : gcd ( b , a % b ) ; } static class FS {   BufferedReader in ; StringTokenizer token ; public FS ( InputStream str ) { in = new BufferedReader ( new InputStreamReader ( str ) ) ; } public String next ( ) { if ( token == null || ! token . hasMoreElements ( ) ) { try { token = new StringTokenizer ( in . readLine ( ) ) ; } catch ( IOException ex ) { } return next ( ) ; } return token . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }

import java . io . * ; import java . util . Locale ; import java . util . StringTokenizer ;   public class A implements Runnable {   private static final boolean ONLINE_JUDGE = System . getProperty ( " ONLINE _ JUDGE " ) != null ;   private BufferedReader in ; private PrintWriter out ; private StringTokenizer tok = new StringTokenizer ( " " ) ;   private void init ( ) throws FileNotFoundException { Locale . setDefault ( Locale . US ) ; String fileName = " " ; if ( ONLINE_JUDGE && fileName . isEmpty ( ) ) { in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; out = new PrintWriter ( System . out ) ; } else { if ( fileName . isEmpty ( ) ) { in = new BufferedReader ( new FileReader ( " input . txt " ) ) ; out = new PrintWriter ( " output . txt " ) ; } else { in = new BufferedReader ( new FileReader ( fileName + " . in " ) ) ; out = new PrintWriter ( fileName + " . out " ) ; } } }   String readString ( ) { while ( ! tok . hasMoreTokens ( ) ) { try { tok = new StringTokenizer ( in . readLine ( ) ) ; } catch ( Exception e ) { return null ; } } return tok . nextToken ( ) ; }   int readInt ( ) { return Integer . parseInt ( readString ( ) ) ; }   long readLong ( ) { return Long . parseLong ( readString ( ) ) ; }   double readDouble ( ) { return Double . parseDouble ( readString ( ) ) ; }   int [ ] readIntArray ( int size ) { int [ ] a = new int [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { a [ i ] = readInt ( ) ; } return a ; }   public static void main ( String [ ] args ) {

import java . util . * ; import java . security . * ; import java . io . * ; import java . * ; import java . lang . * ;   public class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } Scanner in ; PrintWriter out ; Main ( ) { in = new Scanner ( System . in ) ; out = new PrintWriter ( System . out ) ; } public void run ( ) { solve ( ) ; out . close ( ) ; } public long gcd ( long a , long b ) { if ( b == 0 ) return a ; else return gcd ( b , a % b ) ; } public void solve ( ) { long m = in . nextLong ( ) , n = in . nextLong ( ) , x = in . nextLong ( ) , y = in . nextLong ( ) , a = in . nextLong ( ) , b = in . nextLong ( ) ; long x1 , x2 , y1 , y2 , xd , yd ; long gc = gcd ( a , b ) ; a = a / gc ; b = b / gc ; xd = ( m % a == 0 ) ? m : ( m / a ) * ( a ) ; yd = xd / a * b ; if ( yd > n ) { yd = ( n % b == 0 ) ? n : ( n / b ) * ( b ) ; xd = yd / b * a ; } x2 = ( x + xd / 2 ) <= m ? x + xd / 2 : m ; x1 = ( x2 - xd ) >= 0 ? x2 - xd : 0 ; x2 = x1 + xd ; y2 = ( y + yd / 2 ) <= n ? y + yd / 2 : n ; y1 = ( y2 - yd ) >= 0 ? y2 - yd : 0 ; y2 = y1 + yd ;   out . print ( x1 + " ▁ " + y1 + " ▁ " + x2 + " ▁ " + y2 ) ; } }

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

import mathn , m , x , y , a , b = map ( int , input ( ) . split ( ) ) gcd = math . gcd ( a , b ) a //= gcdb //= gcdmax_ratio = min ( n // a , m // b ) a *= max_ratiob *= max_ratiox1 = max ( 0 , min ( x - ( a + 1 ) // 2 , n - a ) ) y1 = max ( 0 , min ( y - ( b + 1 ) // 2 , m - b ) ) print ( x1 , y1 , x1 + a , y1 + b ) NEW_LINE

from fractions import gcdn , m , x , y , a , b = map ( int , input ( ) . split ( ) ) k = gcd ( a , b ) a //= kb //= ktimes = min ( n // a , m // b ) a *= timesb *= timesx1 = x - ( a + 1 ) // 2 y1 = y - ( b + 1 ) // 2 if x1 < 0 : x1 = 0 if y1 < 0 : y1 = 0 if x1 + a > n : x1 -= ( x1 + a - n ) if y1 + b > m : y1 -= ( y1 + b - m ) print ( x1 , y1 , x1 + a , y1 + b ) NEW_LINE

from fractions import gcd   n , m , x , y , a , b = map ( int , input ( ) . split ( ) ) g = gcd ( a , b ) a , b = a // g , b // gk = min ( n // a , m // b ) a , b = k * a , k * b   x1 , x2 = x - ( a - a // 2 ) , x + a // 2 y1 , y2 = y - ( b - b // 2 ) , y + b // 2 d = max ( 0 , 0 - x1 ) x1 , x2 = x1 + d , x2 + dd = max ( 0 , x2 - n ) x1 , x2 = x1 - d , x2 - dd = max ( 0 , 0 - y1 ) y1 , y2 = y1 + d , y2 + dd = max ( 0 , y2 - m ) y1 , y2 = y1 - d , y2 - dprint ( " ▁ " . join ( map ( str , [ x1 , y1 , x2 , y2 ] ) ) ) ; NEW_LINE

from fractions import gcd   n , m , x , y , a , b = map ( int , input ( ) . split ( ) ) r = gcd ( a , b ) a , b = a // r , b // rr = min ( n // a , m // b ) a , b = a * r , b * rcx , cy = ( a + 1 ) // 2 , ( b + 1 ) // 2 dx , dy = min ( n - a , max ( cx , x ) - cx ) , min ( m - b , max ( cy , y ) - cy ) print ( dx , dy , a + dx , b + dy ) NEW_LINE

from fractions import gcd       n , m , x , y , a , b = map ( int , input ( ) . split ( ) )   r = gcd ( a , b )   a , b = a // r , b // r   r = min ( n // a , m // b )   a , b = a * r , b * r   cx , cy = ( a + 1 ) // 2 , ( b + 1 ) // 2   dx , dy = min ( n - a , max ( cx , x ) - cx ) , min ( m - b , max ( cy , y ) - cy )   print ( dx , dy , a + dx , b + dy )       NEW_LINE


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

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws java . lang . Exception { try { Scanner sc = new Scanner ( System . in ) ; int n , k , i , flag ; long min , s ; n = sc . nextInt ( ) ; k = sc . nextInt ( ) ; long a [ ] = new long [ n ] ; a [ 0 ] = sc . nextInt ( ) ; min = a [ 0 ] ; for ( i = 1 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( a [ i ] < min ) min = a [ i ] ; } flag = 1 ; s = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( ( a [ i ] - min ) % k != 0 ) { flag = 0 ; break ; } s = s + ( a [ i ] - min ) / k ; } if ( flag == 1 ) System . out . println ( s ) ; else System . out . println ( " - 1" ) ; } catch ( Exception e ) { } } }

import java . io . * ; import java . util . * ; import java . math . * ; import java . lang . * ;

import math   n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) )   a . sort ( ) r = a [ 0 ] % k ; t = 0 for i in range ( 1 , n ) : if a [ i ] % k != r : print ( - 1 ) break else : t += ( a [ i ] - a [ 0 ] ) // kelse : print ( t ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) )   min = min ( arr ) sum = 0 for a in arr : if ( a - min ) % k != 0 : sum = 1 k = 2 break sum += a - min   print ( - 1 ) if sum % k != 0 and n > 1 else print ( int ( ( sum / k ) ) ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) a = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) result = 0 for i in a : if ( i - a [ 0 ] ) % k != 0 : print ( - 1 ) exit ( ) else : result += ( i - a [ 0 ] ) // kprint ( result ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) if n == 1 : print ( 0 ) else : l = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) m = sorted ( list ( { ( x - l [ 0 ] ) % k for x in l [ 1 : ] } ) ) if m [ 0 ] == 0 and len ( m ) == 1 : q = 0 for i in l [ 1 : ] : q += ( i - l [ 0 ] ) // k print ( q ) else : print ( - 1 ) NEW_LINE

nk = input ( ) . split ( ) n = int ( nk [ 0 ] ) k = int ( nk [ 1 ] ) a = [ int ( i ) for i in input ( ) . split ( ) ] m = a [ 0 ] ans = 0 for i in range ( n ) : if m > a [ i ] : m = a [ i ] for i in range ( n ) : if ( a [ i ] - m ) % k != 0 : ans = - 1 break else : ans += ( a [ i ] - m ) // kprint ( ans ) NEW_LINE


import java . util . * ; import java . io . * ;    public class A {    public static void main ( String [ ] args ) throws IOException { FastReader sc = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ;   int n = sc . nextInt ( ) , t1 = sc . nextInt ( ) , t2 = sc . nextInt ( ) , k = sc . nextInt ( ) ; List < Pair > list = new ArrayList < > ( ) ; int t = 0 ; while ( t ++ < n ) { int ai = sc . nextInt ( ) , bi = sc . nextInt ( ) ; double v1 = ( 1.00 * ai * t1 ) - ( 1.00 * ai * t1 * k / 100 ) + ( bi * t2 ) ; double v2 = ( 1.00 * bi * t1 ) - ( 1.00 * bi * t1 * k / 100 ) + ( ai * t2 ) ; list . add ( new Pair ( t , Math . max ( v1 , v2 ) ) ) ; }   list . sort ( new comp ( ) ) ; for ( Pair p : list ) { out . print ( p . i + " ▁ " ) ; out . printf ( " % .2f " , p . h ) ; out . println ( ) ; } out . close ( ) ; } }

import java . io . ByteArrayInputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . text . DecimalFormat ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . InputMismatchException ; import java . util . List ;   public class Main { static InputStream is ; static PrintWriter out ; static String INPUT = " " ; static int lenbuf = 0 , ptrbuf = 0 ; private static byte [ ] inbuf = new byte [ 1024 ] ; private static final long MOD = ( long ) 1e9 + 7 ;   static class Info { int num ; Double score ;   public Info ( int num , double score ) { this . num = num ; this . score = score ; } }   private static DecimalFormat df = new DecimalFormat ( "0.00" ) ;   static void solve ( ) { int n = ni ( ) , t1 = ni ( ) , t2 = ni ( ) , k = ni ( ) ; List < Info > list = new ArrayList < > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { int a = ni ( ) , b = ni ( ) ; double first = a * t1 - ( ( double ) ( a * t1 * k ) / 100 ) + b * t2 ; double second = b * t1 - ( ( double ) ( b * t1 * k ) / 100 ) + a * t2 ;

n , t1 , t2 , k = [ int ( y ) for y in input ( ) . split ( ) ] res = [ ] for i in range ( n ) : a , b = [ int ( y ) for y in input ( ) . split ( ) ] temp = max ( ( a * t1 * ( 100 - k ) ) / 100 + b * t2 , ( b * t1 * ( 100 - k ) ) / 100 + a * t2 ) res . append ( [ i + 1 , round ( temp , 2 ) ] ) res = sorted ( res , key = lambda item : item [ 1 ] , reverse = True ) for i in res : if str ( i [ 1 ] ) [ - 3 ] != ' . ' : i [ 1 ] = str ( i [ 1 ] ) + '0' print ( i [ 0 ] , i [ 1 ] ) NEW_LINE

import sys     def ints_input ( ) : return [ int ( i ) for i in sys . stdin . readline ( ) . strip ( " \n " ) . split ( " ▁ " ) ]     def print_list ( arr ) : sys . stdout . writelines ( str ( x ) + " ▁ " for x in arr ) sys . stdout . write ( " \n " )     def fast_input ( type = str ) : return type ( sys . stdin . readline ( ) . strip ( " \n " ) )     class grower : def __init__ ( self , i , h ) : self . i = i self . h = h def __str__ ( self ) -> str : return " { } ▁ { :0.2f } " . format ( self . i , self . h )   n , t1 , t2 , k = ints_input ( ) arr = [ ] for i in range ( n ) : v1 , v2 = ints_input ( ) if v1 * t1 * ( 100 - k ) / 100 + v2 * t2 > v2 * t1 * ( 100 - k ) / 100 + v1 * t2 : arr . append ( grower ( i + 1 , v1 * t1 * ( 100 - k ) / 100 + v2 * t2 ) ) else : arr . append ( grower ( i + 1 , v2 * t1 * ( 100 - k ) / 100 + v1 * t2 ) )     arr . sort ( key = lambda o : o . h , reverse = True ) for i in arr : print ( i ) NEW_LINE

inputs = input ( ) . split ( ) n = int ( inputs [ 0 ] ) t1 = int ( inputs [ 1 ] ) t2 = int ( inputs [ 2 ] ) k = int ( inputs [ 3 ] ) / 100   inputs . clear ( ) results = [ ] for i in range ( n ) : inputs . append ( [ int ( x ) for x in input ( ) . split ( ) ] ) if k == 1 : results . append ( max ( inputs [ i ] [ 0 ] , inputs [ i ] [ 1 ] ) * t2 ) else : alt1 = inputs [ i ] [ 0 ] * t1 * ( 1 - k ) + inputs [ i ] [ 1 ] * t2 alt2 = inputs [ i ] [ 1 ] * t1 * ( 1 - k ) + inputs [ i ] [ 0 ] * t2 results . append ( round ( max ( alt1 , alt2 ) , 2 ) )   finalResult = { i : ele for i , ele in enumerate ( results ) } finalResult = dict ( sorted ( finalResult . items ( ) , key = lambda item : item [ 1 ] , reverse = True ) ) for key , value in zip ( finalResult . keys ( ) , finalResult . values ( ) ) : print ( " { } ▁ { : . 2f } " . format ( key + 1 , value ) ) NEW_LINE


import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ;   public class A928 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String S = normalize ( in . next ( ) ) ; int N = in . nextInt ( ) ; Set < String > set = new HashSet < > ( ) ; for ( int n = 0 ; n < N ; n ++ ) { set . add ( normalize ( in . next ( ) ) ) ; } System . out . println ( set . contains ( S ) ? " No " : " Yes " ) ; }   private static String normalize ( String s ) { s = s . toUpperCase ( ) ; s = s . replace ( ' O ' , '0' ) ; s = s . replace ( ' L ' , '1' ) ; s = s . replace ( ' I ' , '1' ) ; return s ; }   }

import java . io . * ; import java . util . * ;   public class LoginVer {   static class InputReader { BufferedReader reader ; StringTokenizer tokenizer ;   public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; }   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 ( ) ) ; }   public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } }   static InputReader r = new InputReader ( System . in ) ; static PrintWriter pw = new PrintWriter ( System . out ) ;   public static void main ( String [ ] args ) {

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

import java . util . Scanner ;   public class LoginVerification { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String newLogin = in . next ( ) . toLowerCase ( ) . replace ( " o " , "0" ) . replace ( " l " , "1" ) . replace ( " i " , "1" ) ; int n = in . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String existingLogin = in . next ( ) . toLowerCase ( ) . replace ( " o " , "0" ) . replace ( " l " , "1" ) . replace ( " i " , "1" ) ; if ( newLogin . equals ( existingLogin ) ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; in . close ( ) ; } }

def change ( a : str ) : a = a . upper ( ) a = a . replace ( " O " , "0" ) a = a . replace ( " L " , "1" ) a = a . replace ( " I " , '1' )   return a   NEW_LINE

def transform ( s ) : return s . upper ( ) . replace ( ' O ' , '0' ) . replace ( ' I ' , '1' ) . replace ( ' L ' , '1' ) login = transform ( input ( ) ) reserved = [ transform ( input ( ) ) for i in range ( int ( input ( ) ) ) ] print ( " No " if login in reserved else " Yes " ) NEW_LINE

a = input ( ) a = a . lower ( ) a = a . replace ( ' i ' , '1' ) a = a . replace ( ' l ' , '1' ) a = a . replace ( ' o ' , '0' ) logins = [ ] for _ in range ( int ( input ( ) ) ) : b = input ( ) b = b . lower ( ) b = b . replace ( ' i ' , '1' ) b = b . replace ( ' l ' , '1' ) b = b . replace ( ' o ' , '0' ) logins . append ( b ) print ( [ " Yes " , " No " ] [ a in logins ] ) NEW_LINE

from sys import stdinimport re   def chs ( s , l ) : s = s . upper ( ) . replace ( ' O ' , '0' ) return l . sub ( '1' , s . rstrip ( ' \n ' ) )   def main ( ) : l = re . compile ( r ' [ LI ] ' ) s = chs ( next ( stdin ) , l ) next ( stdin ) for line in stdin : if s == chs ( line , l ) : print ( ' No ' ) break else : print ( ' Yes ' )   main ( ) NEW_LINE

def change ( s ) : s = s . lower ( ) s = s . replace ( ' o ' , '0' ) s = s . replace ( ' l ' , '1' ) s = s . replace ( ' i ' , '1' ) return s   log = change ( input ( ) )   num = int ( input ( ) ) logins = [ ] for i in range ( 0 , num ) : logins . append ( change ( input ( ) ) )   if log in logins : print ( ' No ' ) else : print ( ' Yes ' ) NEW_LINE


import java . util . * ; import java . io . * ;   public class Ring_road { static class Node { int nod ; int val ; public Node ( int x , int y ) { nod = x ; val = y ; } } public static long cost = 0 ; public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ;   int t = 1 ;   while ( t -- > 0 ) { int n = Integer . parseInt ( br . readLine ( ) ) ; ArrayList < Node > adj [ ] = new ArrayList [ n + 1 ] ;   for ( int i = 0 ; i <= n ; i ++ ) adj [ i ] = new ArrayList < > ( ) ; long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String str [ ] = br . readLine ( ) . trim ( ) . split ( " ▁ " ) ; int x = Integer . parseInt ( str [ 0 ] ) ; int y = Integer . parseInt ( str [ 1 ] ) ; int z = Integer . parseInt ( str [ 2 ] ) ; sum += z ; adj [ x ] . add ( new Node ( y , 0 ) ) ; adj [ y ] . add ( new Node ( x , z ) ) ; }   long min = Long . MAX_VALUE ;   for ( Node x : adj [ 1 ] ) { cost = 0 ; min = Math . min ( min , sum - dsf ( adj , x , 1 , new boolean [ n + 1 ] ) ) ; } pw . print ( min ) ; } pw . flush ( ) ; }   public static long dsf ( ArrayList < Node > adj [ ] , Node des , int src , boolean [ ] vis ) { if ( vis [ des . nod ] ) return cost ;   cost += des . val ; vis [ des . nod ] = true ;   for ( Node x : adj [ des . nod ] ) { if ( x . nod != src ) dsf ( adj , x , des . nod , vis ) ; } return cost ;   } }

import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; boolean [ ] visited = new boolean [ n + 1 ] ; int [ ] [ ] map = new int [ n + 1 ] [ 2 ] ; int [ ] [ ] cost = new int [ n + 1 ] [ 2 ] ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int u = scanner . nextInt ( ) ; int v = scanner . nextInt ( ) ; int val = scanner . nextInt ( ) ; if ( map [ u ] [ 0 ] != 0 ) { map [ u ] [ 1 ] = v ; cost [ u ] [ 1 ] = val ; } else { map [ u ] [ 0 ] = v ; cost [ u ] [ 0 ] = val ; } if ( map [ v ] [ 0 ] != 0 ) { map [ v ] [ 1 ] = u ; } else { map [ v ] [ 0 ] = u ; } sum += val ; }   int i = 1 ; int cnt = n ; int cursum = 0 ; visited [ i ] = true ; while ( cnt -- > 1 ) { if ( ! visited [ map [ i ] [ 0 ] ] ) { cursum += cost [ i ] [ 0 ] ; i = map [ i ] [ 0 ] ; visited [ i ] = true ; } else { cursum += cost [ i ] [ 1 ] ; i = map [ i ] [ 1 ] ; visited [ i ] = true ; } } visited [ 1 ] = false ; if ( ! visited [ map [ i ] [ 0 ] ] ) { cursum += cost [ i ] [ 0 ] ; i = map [ i ] [ 0 ] ; visited [ i ] = true ; } else { cursum += cost [ i ] [ 1 ] ; i = map [ i ] [ 1 ] ; visited [ i ] = true ; }   System . out . print ( Math . min ( cursum , sum - cursum ) ) ; } }

import java . util . * ;   public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int cost = 0 , totalCost = 0 ; int [ ] getFrom = new int [ n + 1 ] ; int [ ] getTo = new int [ n + 1 ] ; Arrays . fill ( getFrom , - 1 ) ; Arrays . fill ( getTo , - 1 ) ;   for ( int i = 0 ; i < n ; i ++ ) { int a = s . nextInt ( ) ; int b = s . nextInt ( ) ; int c = s . nextInt ( ) ; if ( getFrom [ a ] != - 1 || getTo [ b ] != - 1 ) { getFrom [ b ] = a ; getTo [ a ] = b ; } else { getFrom [ a ] = b ; getTo [ b ] = a ; cost += c ; }   totalCost += c ; }   System . out . println ( Math . min ( cost , totalCost - cost ) ) ;   s . close ( ) ; } }

n = int ( input ( ) ) a = [ ] for i in range ( n ) : a . append ( list ( map ( int , input ( ) . split ( ) ) ) ) i = 0 b = [ ] c = 0 for k in range ( n ) : b . append ( a [ i ] [ c ] ) for j in range ( n ) : if i != j and a [ i ] [ 1 - c ] in a [ j ] [ : 2 ] : if a [ i ] [ 1 - c ] == a [ j ] [ 0 ] : c = 0 else : c = 1 i = j breakb += [ b [ 0 ] ] c1 , c2 = 0 , 0 for i in range ( 1 , n + 1 ) : for j in range ( n ) : if a [ j ] [ : 2 ] == [ b [ i ] , b [ i - 1 ] ] : c1 += a [ j ] [ 2 ] elif a [ j ] [ : 2 ] == [ b [ i - 1 ] , b [ i ] ] : c2 += a [ j ] [ 2 ] print ( min ( c1 , c2 ) ) NEW_LINE

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

n = int ( input ( ) )   g = { } d = { }   visited = set ( ) solved = Falsepaths = [ ]     def walk ( v , path ) : global solved   if solved : return   if len ( path ) == n : paths . append ( path ) solved = True return   if v in visited : return   visited . add ( v ) path . append ( v ) for v2 in g [ v ] : path2 = path [ : ] walk ( v2 , path2 )     for _ in range ( n ) : a , b , c = map ( int , input ( ) . split ( ) ) if a not in g : g [ a ] = set ( ) g [ a ] . add ( b ) if b not in g : g [ b ] = set ( ) g [ b ] . add ( a ) d [ ( a , b ) ] = c d [ ( b , a ) ] = - c   walk ( 1 , [ ] ) path = paths [ 0 ] NEW_LINE

A = set ( ) B = set ( ) cost1 = 0 cost2 = 0 def swap ( a , b ) : a , b = b , a return a , bn = int ( input ( ) ) for i in range ( n ) : a , b , c = map ( int , input ( ) . split ( ) ) if ( a in A ) or ( b in B ) : a , b = swap ( a , b ) cost1 += c else : cost2 += c A . add ( a ) B . add ( b ) print ( min ( cost1 , cost2 ) ) NEW_LINE


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

import static java . lang . Math . * ; import static java . util . Arrays . * ; import java . util . * ; import java . io . * ;   public class Main { Scanner in = new Scanner ( new BufferedInputStream ( System . in ) ) ; static PrintWriter out = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; void run ( ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; int d = in . nextInt ( ) ; int e = in . nextInt ( ) ; int f = in . nextInt ( ) ; int ans1 = 0 , ans2 = 0 ; if ( a > d ) { ans1 += d * e ; } else { ans1 += a * e ; ans1 += min ( min ( b , c ) , d - a ) * f ; } if ( min ( b , c ) > d ) { ans2 += d * f ; } else { ans2 += min ( b , c ) * f ; ans2 += min ( a , ( d - min ( b , c ) ) ) * e ; } out . println ( max ( ans1 , ans2 ) ) ; } void debug ( Object ... os ) { out . flush ( ) ; System . err . println ( deepToString ( os ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; out . close ( ) ; }   }

import java . util . * ; import java . math . * ; import java . io . * ; import java . lang . * ;   public class Main { static class Pair { int x ; int y ; public Pair ( int x , int y ) { this . x = x ; this . y = y ; } } static class Comp implements Comparator < Pair > { public int compare ( Pair p1 , Pair p2 ) { if ( p1 . x != p2 . x && p1 . y != p2 . y ) { return p1 . x - p2 . x ; } else { return 0 ; } } } public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int e = sc . nextInt ( ) ; int f = sc . nextInt ( ) ; int min1 = Math . min ( b , Math . min ( c , d ) ) ; int min2 = Math . min ( a , d - min1 ) ; long cost1 = min1 * f + min2 * e ; int min3 = Math . min ( a , d ) ; int min4 = Math . min ( b , Math . min ( c , d - min3 ) ) ; long cost2 = min3 * e + min4 * f ; System . out . println ( Math . max ( cost1 , cost2 ) ) ; } public static void swap ( char ch [ ] [ ] , int i , int j , int l , int m ) { char temp = ch [ i ] [ j ] ; ch [ i ] [ j ] = ch [ l ] [ m ] ; ch [ l ] [ m ] = temp ; } public static int bs ( int num [ ] , int x ) { int low = 0 ; int high = num . length - 1 ; int ans = - 1 ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( num [ mid ] == x ) { ans = mid ; high = mid - 1 ; } else if ( num [ mid ] < x ) {

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Collections ; import java . util . StringTokenizer ;     public class A { public static void main ( String [ ] args ) { FastScanner scan = new FastScanner ( ) ; int t = 1 ;

import math   def is_good_string ( l ) : for i in l : count_1 = 0 count_0 = 0 for j in i : if j == "0" : count_0 += 1 else : count_1 += 1 if count_1 == count_0 : return False return True         def main_function ( ) : a = int ( input ( ) ) b = int ( input ( ) ) c = int ( input ( ) ) d = int ( input ( ) ) e = int ( input ( ) ) f = int ( input ( ) ) if e > f : if a >= d : cost = d * e return cost else : cost = a * e d -= a if min ( b , c ) >= d : cost += d * f else : NEW_LINE

a = int ( input ( ) ) b = int ( input ( ) ) c = int ( input ( ) ) d = int ( input ( ) ) e = int ( input ( ) ) f = int ( input ( ) ) s1 = min ( a , d ) s2 = min ( b , c , d )   if e > f : ans = s1 * e + min ( b , c , d - s1 ) * felse : ans = s2 * f + min ( a , d - s2 ) * e   print ( ans ) NEW_LINE

a = int ( input ( ) ) b = int ( input ( ) ) c = int ( input ( ) ) d = int ( input ( ) ) e = int ( input ( ) ) f = int ( input ( ) ) if e > f : x = min ( a , d ) result = x * e a -= x d -= x result += min ( b , c , d ) * f print ( result ) else : x = min ( b , c , d ) result = x * f b -= x c -= x d -= x result += min ( a , d ) * e print ( result ) NEW_LINE

import sys   def main ( ) : a , b , c , d , e , f = map ( int , sys . stdin . read ( ) . strip ( ) . split ( ) ) n1 , n2 = min ( a , d ) , min ( ( b , c , d ) ) if e < f : return n2 * f + min ( a , max ( d - n2 , 0 ) ) * e return n1 * e + min ( ( b , c , max ( d - n1 , 0 ) ) ) * f print ( main ( ) ) NEW_LINE


import java . util . Arrays ; import java . util . Scanner ; import java . util . TreeSet ; import java . util . PriorityQueue ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class Program1 { public static void main ( String [ ] args ) { Scanner num = new Scanner ( System . in ) ; int n = num . nextInt ( ) ;

import java . io . BufferedInputStream ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;      public class Main {    public static void main ( String [ ] args ) throws IOException { Scanner in = new Scanner ( new BufferedInputStream ( System . in ) ) ; int n = in . nextInt ( ) ; int s = in . nextInt ( ) ; int [ ] volumes = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { volumes [ i ] = in . nextInt ( ) ; }

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

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

import java . util . * ; public class test { public static void main ( String args [ ] ) { int x = 0 , mx = 0 ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , s = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; x += a [ i ] ; if ( mx < a [ i ] ) mx = a [ i ] ; } if ( s >= x - mx ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }

n , s = map ( int , input ( ) . split ( ) ) A = list ( map ( int , input ( ) . split ( ) ) ) A . sort ( ) if sum ( A [ : n - 1 ] ) <= s : print ( " YES " ) else : print ( " NO " ) NEW_LINE

n , v = map ( int , input ( ) . split ( ) ) l = [ ] l . extend ( map ( int , input ( ) . split ( ) ) ) l . remove ( max ( l ) ) if sum ( l ) <= v : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE

n , s = map ( int , input ( ) . split ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) count = 0 summation = sum ( arr ) max1 = max ( arr ) if summation - max1 <= s : print ( " YES " ) else : print ( " NO " ) NEW_LINE

def readToInt ( ) : return [ int ( n ) for n in input ( ) . split ( ) ]   line = readToInt ( ) n , s = line [ 0 ] , line [ 1 ] nums = readToInt ( ) if sum ( nums ) - max ( nums ) <= s : print ( " YES " ) else : print ( " NO " ) NEW_LINE