package cz.wrent.advent

fun main() {
	println(partOne(test))

	val result = partOne(input)
	println("8a: $result")

	println(partTwo(test))
	val resultTwo = partTwo(input)
	println("8b: $resultTwo")
}

private fun partOne(input: String): Long {
	val map = input.parse()
	val visible = mutableSetOf<Pair<Int, Int>>()

	processDirectionFromZero(map, visible)
	processDirectionFromZero(map, visible, true)
	processDirectionToZero(map, visible)
	processDirectionToZero(map, visible, true)
	return visible.size.toLong()
}

private fun partTwo(input: String): Long {
	val map = input.parse()

	val scenicMap = map.map { it.key to getScenicScore(it.key, map) }.toMap()
	println(scenicMap)
	return scenicMap.values.maxByOrNull { it }!!.toLong()
}

private fun getScenicScore(coord: Pair<Int, Int>, map: Map<Pair<Int, Int>, Int>): Int {
	val current = map[coord]!!
	val a = map.getRightFrom(coord).getVisible(current)
	val b = map.getLeftFrom(coord).getVisible(current)
	val c = map.getUpFrom(coord).getVisible(current)
	val d = map.getDownFrom(coord).getVisible(current)
	return a * b * c * d
}

private fun List<Int>.getVisible(current: Int): Int {
	val res = this.takeWhile{ it < current }.size

	if (res == this.size) {
		return res
	} else {
		return res + 1
	}
}

private fun Map<Pair<Int, Int>, Int>.getRightFrom(coord: Pair<Int, Int>): List<Int> {
	return this.filter { it.key.second == coord.second }
		.filter { it.key.first > coord.first }.entries.sortedBy { it.key.first }.map { it.value }.toList()
}

private fun Map<Pair<Int, Int>, Int>.getLeftFrom(coord: Pair<Int, Int>): List<Int> {
	return this.filter { it.key.second == coord.second }
		.filter { it.key.first < coord.first }.entries.sortedByDescending { it.key.first }.map { it.value }.toList()
}

private fun Map<Pair<Int, Int>, Int>.getUpFrom(coord: Pair<Int, Int>): List<Int> {
	return this.filter { it.key.first == coord.first }
		.filter { it.key.second < coord.second }.entries.sortedByDescending { it.key.second }.map { it.value }.toList()
}

private fun Map<Pair<Int, Int>, Int>.getDownFrom(coord: Pair<Int, Int>): List<Int> {
	return this.filter { it.key.first == coord.first }
		.filter { it.key.second > coord.second }.entries.sortedBy { it.key.second }.map { it.value }.toList()
}

private fun processDirectionFromZero(
	map: Map<Pair<Int, Int>, Int>,
	visible: MutableSet<Pair<Int, Int>>,
	switch: Boolean = false
) {
	val max = map.keys.maxByOrNull { it.first }!!.first
	var i = 0
	var j = 0
	var localMax = -1
	while (j <= max) {
		while (i <= max) {
			val coord = if (switch) j to i else i to j
			val current = map[coord] ?: break
			if (current > localMax) {
				visible.add(coord)
				localMax = current
			}
			i++
		}
		localMax = -1
		i = 0
		j++
	}
}

private fun processDirectionToZero(
	map: Map<Pair<Int, Int>, Int>,
	visible: MutableSet<Pair<Int, Int>>,
	switch: Boolean = false
) {
	val max = map.keys.maxByOrNull { it.first }!!.first
	var i = max
	var j = max
	var localMax = -1
	while (j >= 0) {
		while (i >= 0) {
			val coord = if (switch) j to i else i to j
			val current = map[coord] ?: break
			if (current > localMax) {
				visible.add(coord)
				localMax = current
			}
			i--
		}
		localMax = -1
		i = max
		j--
	}
}

private fun String.parse(): Map<Pair<Int, Int>, Int> {
	val map = mutableMapOf<Pair<Int, Int>, Int>()
	this.split("\n")
		.mapIndexed { i, row ->
			row.split("").filter { it.isNotEmpty() }.forEachIndexed { j, value ->
				map.put(j to i, value.toInt())
			}
		}
	return map
}

private const val test = """30373
25512
65332
33549
35390"""

private const val input =
	"""003112220410413101104044022234320204233341435252223642044225451531421012104343030211442433410302111
301233004003313130222434121135033231250505241131342032404032560542233000343455552123100410402211201
111301041221333142533352050250154136146324550411565615444115604102531135302000320033233340431313123
011312210420442043155233305201305643445224334303310253225205601265233454400214114322131420224022313
130102441231200141254202121022423405224443210463250415204410624313613034320040015223211432442333110
133121132322223054104323242043651144066341346000104210124535555236324451132555525220523220023202433
110011123024113203143145243605143331512223606564503661350336662505131254503242354031400131012444222
221400422202335053520044325014041432662161415523526711633662600635304000112322014001533351130303321
030222020044115331004065013253364503664435753416641653716424535324654054023321025154331103034342414
030331241153233040140314112524504535172167445223426653152774166352145410064425434012002122431142343
224111232453145423354550035141103644127571711431336236226321752314754510214316215104550522141301020
424321022432003551434012134531644165753146143232242275633762323631713541330463531053004424012234010
221233440041435131321565604060121637542135243721227576264551457171313165211546132314103242442012133
301320232222024200651041405631257577625236256225367443317773421262762172454463051224654015452230401
124314451244222611016300517414362722551374735555353871173242751564427674344212032442221554524035432
000210412345203005364660077252742673773341654558568632445755573574757433452636410261362004114032013
333130514223252440150314572132443233363783556666363566733363262631651361523573335361463232143300044
400403124212626240015541437753711632635435857234865883574647337436376563235264524230225211320425534
430312520241033613150127256341412352564548243842255622454762832274857163157242366022041262252034150
125211521340246341461723355443362487532437274863758283488567453538667642367654751321503343220351304
015045453331430626273664314125778234645658386774837783464366334264476243327176571544650404453253132
354034323663213666746174754737374552772744668787244468236435632534753452366177147233020313054042345
305241054630156250416544221136444247327848337737584777837244467756426322644474332262330430251551212
100144030632532041231474166555527386344645548655948476835366757558682728623657547471260405014131510
155501551351164622444476154658383338677369856795967346765977585753438378656352723127554031451225340
213252046404053134327512554784653544697439375473948735593644477348334755453317243676612665133404310
022440140420166534174335264388542568833984445757393864997986883894574577853347367415453352646352541
303425632364032563633467847288735478557676734393879573848466463466672455482853676764477400452414425
421140260266576264621526686828328833799894373434775335763857585383998562862724435337211515426106224
251234063153345361761483764445395779384568938899876568577359785776678952473247274437226445141011143
124165362100637756715727365876646574835535677777467785479666667584536895483528343623556220650044411
523533116461715454347526758528694839737349689796485884675949699354664766465728468324363766204426020
011655232111314171647378426863359767797699886798595874554677869353593448485338287251255363024600501
201454444103773472628888556987787587788889498545597569965587748496753787964648276727241677205552530
022050015673621733475438774338498584975649879876857968775687577968447843939528275674512475556245535
415145246426622536566872225778388854879897849855475687687595454675468637795674534385355242230005213
515410462156777244275234668693874665788796767699675757959578987749863457937753862877526274731341533
532441044352764132482273798897585496755464759898898996955476545867443535986538526852746625533463346
042116466642255478273735578633656564997786577695957789988869999965866866547392358543326526744105124
305463642721567264236826357995536786844968968785757997557699474697669835738584868845834527260231552
066231251534151145564875937345768799895756579656987695996797768779596848379994862646436522463360266
506513057363414584637639439854956668854878865987777598756576697549657897644947484484534264535522136
131666244551736787837659743739478747677995596779697659755568679946768553647438363837764527562663652
424404413335566473356634745356959967996577965786978695878778775749964899347635788855331715645156443
366410447316422733452686338845457787759555776998978979667795556665499755678449775626855353212651324
302136251253517685366593955978666557656668675898896669776695986549696689467499828826265743355612425
546506521534743584874443398869667685788797956777788696997955989646664668879679457843885333126334344
362262154313747445367249673496655464765879658679769897687679766789496785648597346877862642316202103
026226125354532563527338467655476495659657769687899897897899856576869585587683926347427571714351012
324246031677535478765836973778855888768885696676889798687785885666785975868394627754287365751563132
031351623136767474878299634934847976977866799698978866969865695657475657893553946224747277645245120
026056143144572747422538333594694756756655696798979976879958687957995676939686658475475623336500612
662533125413523284737634669357979456995895856799797767679899585888899799675553357648455413641663031
014206153225663545455694774965848955686699676678777689996997596965668976646983688667633463335404141
413012617325174456878669973969459678955956597997687976869576778966464554568469886777721516427616513
502662203642612255238447486939957458967857897679766997696655868558575999589335922456844736112131654
212661502516734223324889447354689969855787756889968698877896757975877697383989627364337421772343024
062105566125733258245733457473775547779958796868868895787767755559647545379345865238624356123242000
402335614754636628236824679555597465548989986755969565969678898559987586856955673832271674166105362
451334645753376162243335579543677879955598768556565759756869877876795947966569855573232735534601241
500262052615557247375888358635954578969966856685689678868986899965887995757987425824514566556143415
025221464647151347477323745438738647477798995699788989796688598687779795846437577837865212462025305
506261641542645445623578634938859695857548567987658895685668887664467397754563764284864222243613255
544001251632514343434242438697698767785468785559797877757559476976744589553445545348132556324315401
312662335054751647576346847944998349986995969646958568675577475645539379875732364426714676752004534
442336642122316123757636234859863735657746598877646757975758669549947438746824526434264347133600103
110222605363451462773826376864836593598856459788567868745977445869448964569655348846536363204056350
000101232124176476234372634789857987399659768658796566947966644948468844584756623732364133065443412
134465433226374477324823357757785535937975665949586889647565456766846389552458234767667646466124353
421406224300535763513347544755878674693949665984559799965894778876384773264625738631365460212615513
452351220036426717772576544574486575445936589965659469684553983864958887588836456352652752044465624
513131310021516677236857346343788436737376979889979498674877368855367664436225742117611411543534241
025341550553445563557374338552585545787433393754685485676457956894674542662544752536711135543323540
535152616216423251726174753447757785566344854848638858756838495369785886445488572266324260520452211
040010242452167571763413223445374499838658479769797468459895353937866635767567612446231533425561512
540233435611063354343623584674548775576735445736954663985773597646587532834332126771664204465150223
115125460640513624264577427672484376565394997956949478368583668555354324253116433334364541633501141
325235035031330065764773672233563447278366899833655673943396323666327273534372213517324021336301134
210455052102126060367721574443448283734742249765698995536842573866568587565571317173455040136014133
130303041444343616551636147765524538863657233824485633222587838375574238775244261440413305250410213
215411311040450233266672334763832288583822422248882386376826865647256855122326112462046245434214110
230231555011111141243461222762213386584878775753548542777758687642766773174237314624160241043301041
323544455001621231632772663352437368846236258422868628887825466644733647626344222306513541033345051
103143140115330535101443674523313247636278477357763543634765673375252223123145511514215131041302240
232425305344242122243634141575125456216884578682284677823883878251534364736772005201664151453532422
102015414143426060302001452111353522415644252842283555326642135161755673127454553246636405351210230
434225550123100466121402111553624464277266354226553673463535217337233242261322143516321221202244233
241043514014314144343662453056766274716234347315115145214653247673432611160552306341450310405413111
242112143335044304622645260260424573275613637141734623226773527441742321265241643455134145215344111
111301110035433343532532505066367716542154757534155161173124736561116131435620565213531350550432142
242323242143224035106205224411500635634124323342513747342475634262646442514656422055112331122023144
002021344233114150010341663531513334522142253265466242366366534525551142525131661102314124401314042
024004104024242151413420354625126365606642452553232242411563750634302214411623615524332515123123121
322320201030004104054100060453523451362415465573527326430616603635233444523531105134335533102202414
013231044323002420215041311645066036204353535300445225661352044506065120312154410321400034312200320
031030413344440552442114452066553136026033443442226333515665300213012326102141034413121232242040400
133131302014414220215344004521556454235620502443013233464014064103264525100404050140223431001414000
221120341111243124154321401255010441026151433422443520262166251632146441120442553301443334201231200
021222222103332103301112520131442023663055232552042262505152050120510455441325453404132240001402111"""

Compiled from "Comparisons.kt"
public final class cz.wrent.advent.Day8Kt$getUpFrom$$inlined$sortedByDescending$1<T> implements java.util.Comparator {
  public cz.wrent.advent.Day8Kt$getUpFrom$$inlined$sortedByDescending$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_2
       1: checkcast     #23                 // class java/util/Map$Entry
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokeinterface #27,  1           // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
      14: checkcast     #29                 // class kotlin/Pair
      17: invokevirtual #32                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      20: checkcast     #34                 // class java/lang/Integer
      23: checkcast     #36                 // class java/lang/Comparable
      26: aload_1
      27: checkcast     #23                 // class java/util/Map$Entry
      30: astore_3
      31: astore        5
      33: iconst_0
      34: istore        4
      36: aload_3
      37: invokeinterface #27,  1           // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
      42: checkcast     #29                 // class kotlin/Pair
      45: invokevirtual #32                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      48: checkcast     #34                 // class java/lang/Integer
      51: aload         5
      53: swap
      54: checkcast     #36                 // class java/lang/Comparable
      57: invokestatic  #42                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      60: ireturn
}

Compiled from "Comparisons.kt"
public final class cz.wrent.advent.Day8Kt$getLeftFrom$$inlined$sortedByDescending$1<T> implements java.util.Comparator {
  public cz.wrent.advent.Day8Kt$getLeftFrom$$inlined$sortedByDescending$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_2
       1: checkcast     #23                 // class java/util/Map$Entry
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokeinterface #27,  1           // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
      14: checkcast     #29                 // class kotlin/Pair
      17: invokevirtual #32                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      20: checkcast     #34                 // class java/lang/Integer
      23: checkcast     #36                 // class java/lang/Comparable
      26: aload_1
      27: checkcast     #23                 // class java/util/Map$Entry
      30: astore_3
      31: astore        5
      33: iconst_0
      34: istore        4
      36: aload_3
      37: invokeinterface #27,  1           // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
      42: checkcast     #29                 // class kotlin/Pair
      45: invokevirtual #32                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      48: checkcast     #34                 // class java/lang/Integer
      51: aload         5
      53: swap
      54: checkcast     #36                 // class java/lang/Comparable
      57: invokestatic  #42                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      60: ireturn
}

Compiled from "Comparisons.kt"
public final class cz.wrent.advent.Day8Kt$getDownFrom$$inlined$sortedBy$1<T> implements java.util.Comparator {
  public cz.wrent.advent.Day8Kt$getDownFrom$$inlined$sortedBy$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_1
       1: checkcast     #23                 // class java/util/Map$Entry
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokeinterface #27,  1           // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
      14: checkcast     #29                 // class kotlin/Pair
      17: invokevirtual #32                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      20: checkcast     #34                 // class java/lang/Integer
      23: checkcast     #36                 // class java/lang/Comparable
      26: aload_2
      27: checkcast     #23                 // class java/util/Map$Entry
      30: astore_3
      31: astore        5
      33: iconst_0
      34: istore        4
      36: aload_3
      37: invokeinterface #27,  1           // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
      42: checkcast     #29                 // class kotlin/Pair
      45: invokevirtual #32                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      48: checkcast     #34                 // class java/lang/Integer
      51: aload         5
      53: swap
      54: checkcast     #36                 // class java/lang/Comparable
      57: invokestatic  #42                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      60: ireturn
}

Compiled from "Comparisons.kt"
public final class cz.wrent.advent.Day8Kt$getRightFrom$$inlined$sortedBy$1<T> implements java.util.Comparator {
  public cz.wrent.advent.Day8Kt$getRightFrom$$inlined$sortedBy$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_1
       1: checkcast     #23                 // class java/util/Map$Entry
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokeinterface #27,  1           // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
      14: checkcast     #29                 // class kotlin/Pair
      17: invokevirtual #32                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      20: checkcast     #34                 // class java/lang/Integer
      23: checkcast     #36                 // class java/lang/Comparable
      26: aload_2
      27: checkcast     #23                 // class java/util/Map$Entry
      30: astore_3
      31: astore        5
      33: iconst_0
      34: istore        4
      36: aload_3
      37: invokeinterface #27,  1           // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
      42: checkcast     #29                 // class kotlin/Pair
      45: invokevirtual #32                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      48: checkcast     #34                 // class java/lang/Integer
      51: aload         5
      53: swap
      54: checkcast     #36                 // class java/lang/Comparable
      57: invokestatic  #42                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      60: ireturn
}


package cz.wrent.advent

import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

fun main() {
	println(partOne(test, 10))
	val result = partOne(input, 2000000)
	println("15a: $result")
	println(partTwo(test, 20))
	println("15b: ${partTwo(input, 4000000)}")
}

private fun partOne(input: String, row: Int): Int {
	val map = input.parse()
	val sensors = map.flatMap { r -> r.value.filter { it.value > 0 }.map { (it.key to r.key) to it.value } }
	val beacons = map.flatMap { r -> r.value.filter { it.value == BEACON }.map { it.key to r.key } }.toSet()
	val set = mutableSetOf<Pair<Int, Int>>()
	sensors.forEach { (coord, dist) ->
		set.addAll(getCleared(coord, dist, row))
	}
	set.removeAll(beacons)
	return set.size
}

private fun partTwo(input: String, limit: Int): Long {
	val map = input.parse()
	val sensors = map.flatMap { r -> r.value.filter { it.value > 0 }.map { (it.key to r.key) to it.value } }
	for (i in 0..limit) {
		val notCleared = sensors.map { (coord, dist) ->
			getCleared(coord, dist, i, limit)
		}.getNotCleared()
		if (notCleared != null) {
			return notCleared.toLong() * 4000000 + i.toLong()
		}
	}
	return -1
}

private fun getCleared(coord: Pair<Int, Int>, dist: Int, row: Int): Set<Pair<Int, Int>> {
	val distToRow = abs(coord.second - row)
	val remainingDist = dist - distToRow
	return (coord.first - remainingDist..coord.first + remainingDist).map {
		it to row
	}.toSet()
}

private fun getCleared(coord: Pair<Int, Int>, dist: Int, row: Int, limit: Int): IntRange {
	val distToRow = abs(coord.second - row)
	val remainingDist = dist - distToRow
	if (remainingDist < 0) {
		return IntRange.EMPTY
	}
	return (max(0, coord.first - remainingDist)..min(coord.first + remainingDist, limit))
}

private fun List<IntRange>.getNotCleared(): Int? {
	val sorted = this.sortedBy { it.start }
	var current = sorted.first()
	sorted.drop(1).forEach {
		if (!current.contains(it.start)) {
			return it.start - 1
		}
		if (it.endInclusive > current.endInclusive) {
			current = current.start .. it.endInclusive
		}
	}
	return null
}

//private fun getNotCleared(coord: Pair<Int, Int>, dist: Int, row: Int, max: Int): List<IntRange> {
//	val distToRow = abs(coord.second - row)
//	val remainingDist = dist - distToRow
//	return listOf(0 until coord.first - remainingDist, coord.first + remainingDist until max) // todo ta nula tam asi hapruje
//}

//private fun Map<Int, Map<Int, Int>>.fill(): Map<Int, Map<Int, Int>> {
//	val clear = mutableMapOf<Int, MutableMap<Int, Int>>()
//	this.forEach { (y, row) ->
//		row.forEach { (x, value) ->
//				if (value > 0) {
//					addAllClears(x to y, value, clear)
//				}
//		}
//	}
//	this.forEach { (y, row) ->
//		row.forEach { (x, value) ->
//			clear.computeIfAbsent(y) { mutableMapOf() }[x] = value
//		}
//	}
//	return clear
//}
//
//private fun addAllClears(from: Pair<Int, Int>, value: Int, to: MutableMap<Int, MutableMap<Int, Int>>) {
//	val remaining: Deque<Pair<Pair<Int, Int>, Int>> = LinkedList(listOf(from to 0))
//	while (remaining.isNotEmpty()) {
//		val curr = remaining.pop()
//		val coord = curr.first
//		val next = curr.second
//		if (next <= value) {
//			to.computeIfAbsent(coord.second) { mutableMapOf() }[coord.first] = CLEAR
//			curr.first.toNeighbours().map { it to next + 1 }
//				.forEach {
//					remaining.push(it)
//				}
//		}
//	}
//}

private fun String.parse(): Map<Int, Map<Int, Int>> {
	val map = mutableMapOf<Int, MutableMap<Int, Int>>()
	val regex = Regex("Sensor at x=(-?\\d+), y=(-?\\d+): closest beacon is at x=(-?\\d+), y=(-?\\d+)")
	this.split("\n")
		.map { regex.matchEntire(it) }
		.filterNotNull()
		.map { it.groupValues }
		.forEach {
			val beacon = it.get(3).toInt() to it.get(4).toInt()
			val sensor = it.get(1).toInt() to it.get(2).toInt()
			map.computeIfAbsent(sensor.second) { mutableMapOf() }[sensor.first] = dist(sensor, beacon)
			map.computeIfAbsent(beacon.second) { mutableMapOf() }[beacon.first] = BEACON
		}
	return map
}

private fun dist(a: Pair<Int, Int>, b: Pair<Int, Int>): Int {
	return abs(a.first - b.first) + abs(a.second - b.second)
}

private const val BEACON = -1
private const val CLEAR = 0

private const val test = """Sensor at x=2, y=18: closest beacon is at x=-2, y=15
Sensor at x=9, y=16: closest beacon is at x=10, y=16
Sensor at x=13, y=2: closest beacon is at x=15, y=3
Sensor at x=12, y=14: closest beacon is at x=10, y=16
Sensor at x=10, y=20: closest beacon is at x=10, y=16
Sensor at x=14, y=17: closest beacon is at x=10, y=16
Sensor at x=8, y=7: closest beacon is at x=2, y=10
Sensor at x=2, y=0: closest beacon is at x=2, y=10
Sensor at x=0, y=11: closest beacon is at x=2, y=10
Sensor at x=20, y=14: closest beacon is at x=25, y=17
Sensor at x=17, y=20: closest beacon is at x=21, y=22
Sensor at x=16, y=7: closest beacon is at x=15, y=3
Sensor at x=14, y=3: closest beacon is at x=15, y=3
Sensor at x=20, y=1: closest beacon is at x=15, y=3"""

private const val input =
	"""Sensor at x=3844106, y=3888618: closest beacon is at x=3225436, y=4052707
Sensor at x=1380352, y=1857923: closest beacon is at x=10411, y=2000000
Sensor at x=272, y=1998931: closest beacon is at x=10411, y=2000000
Sensor at x=2119959, y=184595: closest beacon is at x=2039500, y=-250317
Sensor at x=1675775, y=2817868: closest beacon is at x=2307516, y=3313037
Sensor at x=2628344, y=2174105: closest beacon is at x=3166783, y=2549046
Sensor at x=2919046, y=3736158: closest beacon is at x=3145593, y=4120490
Sensor at x=16, y=2009884: closest beacon is at x=10411, y=2000000
Sensor at x=2504789, y=3988246: closest beacon is at x=3145593, y=4120490
Sensor at x=2861842, y=2428768: closest beacon is at x=3166783, y=2549046
Sensor at x=3361207, y=130612: closest beacon is at x=2039500, y=-250317
Sensor at x=831856, y=591484: closest beacon is at x=-175938, y=1260620
Sensor at x=3125600, y=1745424: closest beacon is at x=3166783, y=2549046
Sensor at x=21581, y=3243480: closest beacon is at x=10411, y=2000000
Sensor at x=2757890, y=3187285: closest beacon is at x=2307516, y=3313037
Sensor at x=3849488, y=2414083: closest beacon is at x=3166783, y=2549046
Sensor at x=3862221, y=757146: closest beacon is at x=4552923, y=1057347
Sensor at x=3558604, y=2961030: closest beacon is at x=3166783, y=2549046
Sensor at x=3995832, y=1706663: closest beacon is at x=4552923, y=1057347
Sensor at x=1082213, y=3708082: closest beacon is at x=2307516, y=3313037
Sensor at x=135817, y=1427041: closest beacon is at x=-175938, y=1260620
Sensor at x=2467372, y=697908: closest beacon is at x=2039500, y=-250317
Sensor at x=3448383, y=3674287: closest beacon is at x=3225436, y=4052707"""

Compiled from "Day15.kt"
public final class cz.wrent.advent.Day15Kt {
  private static final int BEACON;

  private static final int CLEAR;

  private static final java.lang.String test;

  private static final java.lang.String input;

  public static final void main();
    Code:
       0: ldc           #8                  // String Sensor at x=2, y=18: closest beacon is at x=-2, y=15\nSensor at x=9, y=16: closest beacon is at x=10, y=16\nSensor at x=13, y=2: closest beacon is at x=15, y=3\nSensor at x=12, y=14: closest beacon is at x=10, y=16\nSensor at x=10, y=20: closest beacon is at x=10, y=16\nSensor at x=14, y=17: closest beacon is at x=10, y=16\nSensor at x=8, y=7: closest beacon is at x=2, y=10\nSensor at x=2, y=0: closest beacon is at x=2, y=10\nSensor at x=0, y=11: closest beacon is at x=2, y=10\nSensor at x=20, y=14: closest beacon is at x=25, y=17\nSensor at x=17, y=20: closest beacon is at x=21, y=22\nSensor at x=16, y=7: closest beacon is at x=15, y=3\nSensor at x=14, y=3: closest beacon is at x=15, y=3\nSensor at x=20, y=1: closest beacon is at x=15, y=3
       2: bipush        10
       4: invokestatic  #12                 // Method partOne:(Ljava/lang/String;I)I
       7: istore_0
       8: getstatic     #18                 // Field java/lang/System.out:Ljava/io/PrintStream;
      11: iload_0
      12: invokevirtual #24                 // Method java/io/PrintStream.println:(I)V
      15: ldc           #26                 // String Sensor at x=3844106, y=3888618: closest beacon is at x=3225436, y=4052707\nSensor at x=1380352, y=1857923: closest beacon is at x=10411, y=2000000\nSensor at x=272, y=1998931: closest beacon is at x=10411, y=2000000\nSensor at x=2119959, y=184595: closest beacon is at x=2039500, y=-250317\nSensor at x=1675775, y=2817868: closest beacon is at x=2307516, y=3313037\nSensor at x=2628344, y=2174105: closest beacon is at x=3166783, y=2549046\nSensor at x=2919046, y=3736158: closest beacon is at x=3145593, y=4120490\nSensor at x=16, y=2009884: closest beacon is at x=10411, y=2000000\nSensor at x=2504789, y=3988246: closest beacon is at x=3145593, y=4120490\nSensor at x=2861842, y=2428768: closest beacon is at x=3166783, y=2549046\nSensor at x=3361207, y=130612: closest beacon is at x=2039500, y=-250317\nSensor at x=831856, y=591484: closest beacon is at x=-175938, y=1260620\nSensor at x=3125600, y=1745424: closest beacon is at x=3166783, y=2549046\nSensor at x=21581, y=3243480: closest beacon is at x=10411, y=2000000\nSensor at x=2757890, y=3187285: closest beacon is at x=2307516, y=3313037\nSensor at x=3849488, y=2414083: closest beacon is at x=3166783, y=2549046\nSensor at x=3862221, y=757146: closest beacon is at x=4552923, y=1057347\nSensor at x=3558604, y=2961030: closest beacon is at x=3166783, y=2549046\nSensor at x=3995832, y=1706663: closest beacon is at x=4552923, y=1057347\nSensor at x=1082213, y=3708082: closest beacon is at x=2307516, y=3313037\nSensor at x=135817, y=1427041: closest beacon is at x=-175938, y=1260620\nSensor at x=2467372, y=697908: closest beacon is at x=2039500, y=-250317\nSensor at x=3448383, y=3674287: closest beacon is at x=3225436, y=4052707
      17: ldc           #27                 // int 2000000
      19: invokestatic  #12                 // Method partOne:(Ljava/lang/String;I)I
      22: istore_0
      23: new           #29                 // class java/lang/StringBuilder
      26: dup
      27: invokespecial #32                 // Method java/lang/StringBuilder."<init>":()V
      30: ldc           #34                 // String 15a:
      32: invokevirtual #38                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      35: iload_0
      36: invokevirtual #41                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      39: invokevirtual #45                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      42: getstatic     #18                 // Field java/lang/System.out:Ljava/io/PrintStream;
      45: swap
      46: invokevirtual #48                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      49: ldc           #8                  // String Sensor at x=2, y=18: closest beacon is at x=-2, y=15\nSensor at x=9, y=16: closest beacon is at x=10, y=16\nSensor at x=13, y=2: closest beacon is at x=15, y=3\nSensor at x=12, y=14: closest beacon is at x=10, y=16\nSensor at x=10, y=20: closest beacon is at x=10, y=16\nSensor at x=14, y=17: closest beacon is at x=10, y=16\nSensor at x=8, y=7: closest beacon is at x=2, y=10\nSensor at x=2, y=0: closest beacon is at x=2, y=10\nSensor at x=0, y=11: closest beacon is at x=2, y=10\nSensor at x=20, y=14: closest beacon is at x=25, y=17\nSensor at x=17, y=20: closest beacon is at x=21, y=22\nSensor at x=16, y=7: closest beacon is at x=15, y=3\nSensor at x=14, y=3: closest beacon is at x=15, y=3\nSensor at x=20, y=1: closest beacon is at x=15, y=3
      51: bipush        20
      53: invokestatic  #52                 // Method partTwo:(Ljava/lang/String;I)J
      56: lstore_1
      57: getstatic     #18                 // Field java/lang/System.out:Ljava/io/PrintStream;
      60: lload_1
      61: invokevirtual #55                 // Method java/io/PrintStream.println:(J)V
      64: new           #29                 // class java/lang/StringBuilder
      67: dup
      68: invokespecial #32                 // Method java/lang/StringBuilder."<init>":()V
      71: ldc           #57                 // String 15b:
      73: invokevirtual #38                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      76: ldc           #26                 // String Sensor at x=3844106, y=3888618: closest beacon is at x=3225436, y=4052707\nSensor at x=1380352, y=1857923: closest beacon is at x=10411, y=2000000\nSensor at x=272, y=1998931: closest beacon is at x=10411, y=2000000\nSensor at x=2119959, y=184595: closest beacon is at x=2039500, y=-250317\nSensor at x=1675775, y=2817868: closest beacon is at x=2307516, y=3313037\nSensor at x=2628344, y=2174105: closest beacon is at x=3166783, y=2549046\nSensor at x=2919046, y=3736158: closest beacon is at x=3145593, y=4120490\nSensor at x=16, y=2009884: closest beacon is at x=10411, y=2000000\nSensor at x=2504789, y=3988246: closest beacon is at x=3145593, y=4120490\nSensor at x=2861842, y=2428768: closest beacon is at x=3166783, y=2549046\nSensor at x=3361207, y=130612: closest beacon is at x=2039500, y=-250317\nSensor at x=831856, y=591484: closest beacon is at x=-175938, y=1260620\nSensor at x=3125600, y=1745424: closest beacon is at x=3166783, y=2549046\nSensor at x=21581, y=3243480: closest beacon is at x=10411, y=2000000\nSensor at x=2757890, y=3187285: closest beacon is at x=2307516, y=3313037\nSensor at x=3849488, y=2414083: closest beacon is at x=3166783, y=2549046\nSensor at x=3862221, y=757146: closest beacon is at x=4552923, y=1057347\nSensor at x=3558604, y=2961030: closest beacon is at x=3166783, y=2549046\nSensor at x=3995832, y=1706663: closest beacon is at x=4552923, y=1057347\nSensor at x=1082213, y=3708082: closest beacon is at x=2307516, y=3313037\nSensor at x=135817, y=1427041: closest beacon is at x=-175938, y=1260620\nSensor at x=2467372, y=697908: closest beacon is at x=2039500, y=-250317\nSensor at x=3448383, y=3674287: closest beacon is at x=3225436, y=4052707
      78: ldc           #58                 // int 4000000
      80: invokestatic  #52                 // Method partTwo:(Ljava/lang/String;I)J
      83: invokevirtual #61                 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
      86: invokevirtual #45                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      89: getstatic     #18                 // Field java/lang/System.out:Ljava/io/PrintStream;
      92: swap
      93: invokevirtual #48                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      96: return

  private static final int partOne(java.lang.String, int);
    Code:
       0: aload_0
       1: invokestatic  #67                 // Method parse:(Ljava/lang/String;)Ljava/util/Map;
       4: astore_2
       5: aload_2
       6: astore        4
       8: iconst_0
       9: istore        5
      11: aload         4
      13: astore        6
      15: new           #69                 // class java/util/ArrayList
      18: dup
      19: invokespecial #70                 // Method java/util/ArrayList."<init>":()V
      22: checkcast     #72                 // class java/util/Collection
      25: astore        7
      27: iconst_0
      28: istore        8
      30: aload         6
      32: invokeinterface #78,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
      37: invokeinterface #84,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
      42: astore        9
      44: aload         9
      46: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          343
      54: aload         9
      56: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: checkcast     #96                 // class java/util/Map$Entry
      64: astore        10
      66: aload         10
      68: astore        11
      70: iconst_0
      71: istore        12
      73: aload         11
      75: invokeinterface #99,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
      80: checkcast     #74                 // class java/util/Map
      83: astore        13
      85: iconst_0
      86: istore        14
      88: aload         13
      90: astore        15
      92: new           #101                // class java/util/LinkedHashMap
      95: dup
      96: invokespecial #102                // Method java/util/LinkedHashMap."<init>":()V
      99: checkcast     #74                 // class java/util/Map
     102: astore        16
     104: iconst_0
     105: istore        17
     107: aload         15
     109: invokeinterface #78,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     114: invokeinterface #84,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     119: astore        18
     121: aload         18
     123: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     128: ifeq          199
     131: aload         18
     133: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     138: checkcast     #96                 // class java/util/Map$Entry
     141: astore        19
     143: aload         19
     145: astore        20
     147: iconst_0
     148: istore        21
     150: aload         20
     152: invokeinterface #99,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     157: checkcast     #104                // class java/lang/Number
     160: invokevirtual #108                // Method java/lang/Number.intValue:()I
     163: ifle          170
     166: iconst_1
     167: goto          171
     170: iconst_0
     171: ifeq          121
     174: aload         16
     176: aload         19
     178: invokeinterface #111,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     183: aload         19
     185: invokeinterface #99,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     190: invokeinterface #115,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     195: pop
     196: goto          121
     199: aload         16
     201: nop
     202: astore        13
     204: nop
     205: iconst_0
     206: istore        14
     208: aload         13
     210: astore        15
     212: new           #69                 // class java/util/ArrayList
     215: dup
     216: aload         13
     218: invokeinterface #118,  1          // InterfaceMethod java/util/Map.size:()I
     223: invokespecial #120                // Method java/util/ArrayList."<init>":(I)V
     226: checkcast     #72                 // class java/util/Collection
     229: astore        16
     231: iconst_0
     232: istore        17
     234: aload         15
     236: invokeinterface #78,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     241: invokeinterface #84,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     246: astore        18
     248: aload         18
     250: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     255: ifeq          320
     258: aload         18
     260: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     265: checkcast     #96                 // class java/util/Map$Entry
     268: astore        19
     270: aload         16
     272: aload         19
     274: astore        20
     276: astore        22
     278: iconst_0
     279: istore        21
     281: aload         20
     283: invokeinterface #111,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     288: aload         11
     290: invokeinterface #111,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     295: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     298: aload         20
     300: invokeinterface #99,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     305: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     308: aload         22
     310: swap
     311: invokeinterface #130,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     316: pop
     317: goto          248
     320: aload         16
     322: checkcast     #132                // class java/util/List
     325: nop
     326: checkcast     #134                // class java/lang/Iterable
     329: nop
     330: astore        11
     332: aload         7
     334: aload         11
     336: invokestatic  #140                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     339: pop
     340: goto          44
     343: aload         7
     345: checkcast     #132                // class java/util/List
     348: nop
     349: astore_3
     350: aload_2
     351: astore        5
     353: iconst_0
     354: istore        6
     356: aload         5
     358: astore        7
     360: new           #69                 // class java/util/ArrayList
     363: dup
     364: invokespecial #70                 // Method java/util/ArrayList."<init>":()V
     367: checkcast     #72                 // class java/util/Collection
     370: astore        8
     372: iconst_0
     373: istore        9
     375: aload         7
     377: invokeinterface #78,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     382: invokeinterface #84,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     387: astore        10
     389: aload         10
     391: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     396: ifeq          679
     399: aload         10
     401: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     406: checkcast     #96                 // class java/util/Map$Entry
     409: astore        11
     411: aload         11
     413: astore        12
     415: iconst_0
     416: istore        13
     418: aload         12
     420: invokeinterface #99,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     425: checkcast     #74                 // class java/util/Map
     428: astore        14
     430: iconst_0
     431: istore        15
     433: aload         14
     435: astore        16
     437: new           #101                // class java/util/LinkedHashMap
     440: dup
     441: invokespecial #102                // Method java/util/LinkedHashMap."<init>":()V
     444: checkcast     #74                 // class java/util/Map
     447: astore        17
     449: iconst_0
     450: istore        18
     452: aload         16
     454: invokeinterface #78,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     459: invokeinterface #84,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     464: astore        19
     466: aload         19
     468: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     473: ifeq          545
     476: aload         19
     478: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     483: checkcast     #96                 // class java/util/Map$Entry
     486: astore        20
     488: aload         20
     490: astore        21
     492: iconst_0
     493: istore        22
     495: aload         21
     497: invokeinterface #99,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     502: checkcast     #104                // class java/lang/Number
     505: invokevirtual #108                // Method java/lang/Number.intValue:()I
     508: iconst_m1
     509: if_icmpne     516
     512: iconst_1
     513: goto          517
     516: iconst_0
     517: ifeq          466
     520: aload         17
     522: aload         20
     524: invokeinterface #111,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     529: aload         20
     531: invokeinterface #99,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     536: invokeinterface #115,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     541: pop
     542: goto          466
     545: aload         17
     547: nop
     548: astore        14
     550: nop
     551: iconst_0
     552: istore        15
     554: aload         14
     556: astore        16
     558: new           #69                 // class java/util/ArrayList
     561: dup
     562: aload         14
     564: invokeinterface #118,  1          // InterfaceMethod java/util/Map.size:()I
     569: invokespecial #120                // Method java/util/ArrayList."<init>":(I)V
     572: checkcast     #72                 // class java/util/Collection
     575: astore        17
     577: iconst_0
     578: istore        18
     580: aload         16
     582: invokeinterface #78,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     587: invokeinterface #84,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     592: astore        19
     594: aload         19
     596: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     601: ifeq          656
     604: aload         19
     606: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     611: checkcast     #96                 // class java/util/Map$Entry
     614: astore        20
     616: aload         17
     618: aload         20
     620: astore        21
     622: astore        23
     624: iconst_0
     625: istore        22
     627: aload         21
     629: invokeinterface #111,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     634: aload         12
     636: invokeinterface #111,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     641: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     644: aload         23
     646: swap
     647: invokeinterface #130,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     652: pop
     653: goto          594
     656: aload         17
     658: checkcast     #132                // class java/util/List
     661: nop
     662: checkcast     #134                // class java/lang/Iterable
     665: nop
     666: astore        12
     668: aload         8
     670: aload         12
     672: invokestatic  #140                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     675: pop
     676: goto          389
     679: aload         8
     681: checkcast     #132                // class java/util/List
     684: nop
     685: checkcast     #134                // class java/lang/Iterable
     688: invokestatic  #144                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     691: astore        4
     693: new           #146                // class java/util/LinkedHashSet
     696: dup
     697: invokespecial #147                // Method java/util/LinkedHashSet."<init>":()V
     700: checkcast     #80                 // class java/util/Set
     703: astore        5
     705: aload_3
     706: checkcast     #134                // class java/lang/Iterable
     709: astore        6
     711: iconst_0
     712: istore        7
     714: aload         6
     716: invokeinterface #148,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     721: astore        8
     723: aload         8
     725: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     730: ifeq          799
     733: aload         8
     735: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     740: astore        9
     742: aload         9
     744: checkcast     #150                // class kotlin/Pair
     747: astore        10
     749: iconst_0
     750: istore        11
     752: aload         10
     754: invokevirtual #153                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     757: checkcast     #150                // class kotlin/Pair
     760: astore        12
     762: aload         10
     764: invokevirtual #156                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     767: checkcast     #104                // class java/lang/Number
     770: invokevirtual #108                // Method java/lang/Number.intValue:()I
     773: istore        13
     775: aload         5
     777: aload         12
     779: iload         13
     781: iload_1
     782: invokestatic  #160                // Method getCleared:(Lkotlin/Pair;II)Ljava/util/Set;
     785: checkcast     #72                 // class java/util/Collection
     788: invokeinterface #163,  2          // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z
     793: pop
     794: nop
     795: nop
     796: goto          723
     799: nop
     800: aload         5
     802: aload         4
     804: checkcast     #72                 // class java/util/Collection
     807: invokeinterface #166,  2          // InterfaceMethod java/util/Set.removeAll:(Ljava/util/Collection;)Z
     812: pop
     813: aload         5
     815: invokeinterface #167,  1          // InterfaceMethod java/util/Set.size:()I
     820: ireturn

  private static final long partTwo(java.lang.String, int);
    Code:
       0: aload_0
       1: invokestatic  #67                 // Method parse:(Ljava/lang/String;)Ljava/util/Map;
       4: astore_2
       5: aload_2
       6: astore        4
       8: iconst_0
       9: istore        5
      11: aload         4
      13: astore        6
      15: new           #69                 // class java/util/ArrayList
      18: dup
      19: invokespecial #70                 // Method java/util/ArrayList."<init>":()V
      22: checkcast     #72                 // class java/util/Collection
      25: astore        7
      27: iconst_0
      28: istore        8
      30: aload         6
      32: invokeinterface #78,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
      37: invokeinterface #84,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
      42: astore        9
      44: aload         9
      46: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          343
      54: aload         9
      56: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: checkcast     #96                 // class java/util/Map$Entry
      64: astore        10
      66: aload         10
      68: astore        11
      70: iconst_0
      71: istore        12
      73: aload         11
      75: invokeinterface #99,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
      80: checkcast     #74                 // class java/util/Map
      83: astore        13
      85: iconst_0
      86: istore        14
      88: aload         13
      90: astore        15
      92: new           #101                // class java/util/LinkedHashMap
      95: dup
      96: invokespecial #102                // Method java/util/LinkedHashMap."<init>":()V
      99: checkcast     #74                 // class java/util/Map
     102: astore        16
     104: iconst_0
     105: istore        17
     107: aload         15
     109: invokeinterface #78,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     114: invokeinterface #84,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     119: astore        18
     121: aload         18
     123: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     128: ifeq          199
     131: aload         18
     133: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     138: checkcast     #96                 // class java/util/Map$Entry
     141: astore        19
     143: aload         19
     145: astore        20
     147: iconst_0
     148: istore        21
     150: aload         20
     152: invokeinterface #99,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     157: checkcast     #104                // class java/lang/Number
     160: invokevirtual #108                // Method java/lang/Number.intValue:()I
     163: ifle          170
     166: iconst_1
     167: goto          171
     170: iconst_0
     171: ifeq          121
     174: aload         16
     176: aload         19
     178: invokeinterface #111,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     183: aload         19
     185: invokeinterface #99,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     190: invokeinterface #115,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     195: pop
     196: goto          121
     199: aload         16
     201: nop
     202: astore        13
     204: nop
     205: iconst_0
     206: istore        14
     208: aload         13
     210: astore        15
     212: new           #69                 // class java/util/ArrayList
     215: dup
     216: aload         13
     218: invokeinterface #118,  1          // InterfaceMethod java/util/Map.size:()I
     223: invokespecial #120                // Method java/util/ArrayList."<init>":(I)V
     226: checkcast     #72                 // class java/util/Collection
     229: astore        16
     231: iconst_0
     232: istore        17
     234: aload         15
     236: invokeinterface #78,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     241: invokeinterface #84,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     246: astore        18
     248: aload         18
     250: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     255: ifeq          320
     258: aload         18
     260: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     265: checkcast     #96                 // class java/util/Map$Entry
     268: astore        19
     270: aload         16
     272: aload         19
     274: astore        20
     276: astore        22
     278: iconst_0
     279: istore        21
     281: aload         20
     283: invokeinterface #111,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     288: aload         11
     290: invokeinterface #111,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     295: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     298: aload         20
     300: invokeinterface #99,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     305: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     308: aload         22
     310: swap
     311: invokeinterface #130,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     316: pop
     317: goto          248
     320: aload         16
     322: checkcast     #132                // class java/util/List
     325: nop
     326: checkcast     #134                // class java/lang/Iterable
     329: nop
     330: astore        11
     332: aload         7
     334: aload         11
     336: invokestatic  #140                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     339: pop
     340: goto          44
     343: aload         7
     345: checkcast     #132                // class java/util/List
     348: nop
     349: astore_3
     350: iconst_0
     351: istore        4
     353: iload         4
     355: iload_1
     356: if_icmpgt     524
     359: aload_3
     360: checkcast     #134                // class java/lang/Iterable
     363: astore        6
     365: iconst_0
     366: istore        7
     368: aload         6
     370: astore        8
     372: new           #69                 // class java/util/ArrayList
     375: dup
     376: aload         6
     378: bipush        10
     380: invokestatic  #218                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     383: invokespecial #120                // Method java/util/ArrayList."<init>":(I)V
     386: checkcast     #72                 // class java/util/Collection
     389: astore        9
     391: iconst_0
     392: istore        10
     394: aload         8
     396: invokeinterface #148,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     401: astore        11
     403: aload         11
     405: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     410: ifeq          481
     413: aload         11
     415: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     420: astore        12
     422: aload         9
     424: aload         12
     426: checkcast     #150                // class kotlin/Pair
     429: astore        13
     431: astore        23
     433: iconst_0
     434: istore        14
     436: aload         13
     438: invokevirtual #153                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     441: checkcast     #150                // class kotlin/Pair
     444: astore        15
     446: aload         13
     448: invokevirtual #156                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     451: checkcast     #104                // class java/lang/Number
     454: invokevirtual #108                // Method java/lang/Number.intValue:()I
     457: istore        16
     459: aload         15
     461: iload         16
     463: iload         4
     465: iload_1
     466: invokestatic  #221                // Method getCleared:(Lkotlin/Pair;III)Lkotlin/ranges/IntRange;
     469: aload         23
     471: swap
     472: invokeinterface #130,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     477: pop
     478: goto          403
     481: aload         9
     483: checkcast     #132                // class java/util/List
     486: nop
     487: invokestatic  #225                // Method getNotCleared:(Ljava/util/List;)Ljava/lang/Integer;
     490: astore        5
     492: aload         5
     494: ifnull        512
     497: aload         5
     499: invokevirtual #228                // Method java/lang/Integer.intValue:()I
     502: i2l
     503: ldc           #58                 // int 4000000
     505: i2l
     506: lmul
     507: iload         4
     509: i2l
     510: ladd
     511: lreturn
     512: iload         4
     514: iload_1
     515: if_icmpeq     524
     518: iinc          4, 1
     521: goto          359
     524: ldc2_w        #229                // long -1l
     527: lreturn

  private static final java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>> getCleared(kotlin.Pair<java.lang.Integer, java.lang.Integer>, int, int);
    Code:
       0: aload_0
       1: invokevirtual #242                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
       4: checkcast     #104                // class java/lang/Number
       7: invokevirtual #108                // Method java/lang/Number.intValue:()I
      10: iload_2
      11: isub
      12: invokestatic  #248                // Method java/lang/Math.abs:(I)I
      15: istore_3
      16: iload_1
      17: iload_3
      18: isub
      19: istore        4
      21: new           #250                // class kotlin/ranges/IntRange
      24: dup
      25: aload_0
      26: invokevirtual #253                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      29: checkcast     #104                // class java/lang/Number
      32: invokevirtual #108                // Method java/lang/Number.intValue:()I
      35: iload         4
      37: isub
      38: aload_0
      39: invokevirtual #253                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      42: checkcast     #104                // class java/lang/Number
      45: invokevirtual #108                // Method java/lang/Number.intValue:()I
      48: iload         4
      50: iadd
      51: invokespecial #256                // Method kotlin/ranges/IntRange."<init>":(II)V
      54: checkcast     #134                // class java/lang/Iterable
      57: astore        5
      59: iconst_0
      60: istore        6
      62: aload         5
      64: astore        7
      66: new           #69                 // class java/util/ArrayList
      69: dup
      70: aload         5
      72: bipush        10
      74: invokestatic  #218                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      77: invokespecial #120                // Method java/util/ArrayList."<init>":(I)V
      80: checkcast     #72                 // class java/util/Collection
      83: astore        8
      85: iconst_0
      86: istore        9
      88: aload         7
      90: invokeinterface #148,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      95: astore        10
      97: aload         10
      99: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     104: ifeq          152
     107: aload         10
     109: checkcast     #258                // class kotlin/collections/IntIterator
     112: invokevirtual #261                // Method kotlin/collections/IntIterator.nextInt:()I
     115: istore        11
     117: aload         8
     119: iload         11
     121: istore        12
     123: astore        14
     125: iconst_0
     126: istore        13
     128: iload         12
     130: invokestatic  #265                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     133: iload_2
     134: invokestatic  #265                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     137: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     140: aload         14
     142: swap
     143: invokeinterface #130,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     148: pop
     149: goto          97
     152: aload         8
     154: checkcast     #132                // class java/util/List
     157: nop
     158: checkcast     #134                // class java/lang/Iterable
     161: invokestatic  #144                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     164: areturn

  private static final kotlin.ranges.IntRange getCleared(kotlin.Pair<java.lang.Integer, java.lang.Integer>, int, int, int);
    Code:
       0: aload_0
       1: invokevirtual #242                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
       4: checkcast     #104                // class java/lang/Number
       7: invokevirtual #108                // Method java/lang/Number.intValue:()I
      10: iload_2
      11: isub
      12: invokestatic  #248                // Method java/lang/Math.abs:(I)I
      15: istore        4
      17: iload_1
      18: iload         4
      20: isub
      21: istore        5
      23: iload         5
      25: ifge          35
      28: getstatic     #273                // Field kotlin/ranges/IntRange.Companion:Lkotlin/ranges/IntRange$Companion;
      31: invokevirtual #279                // Method kotlin/ranges/IntRange$Companion.getEMPTY:()Lkotlin/ranges/IntRange;
      34: areturn
      35: new           #250                // class kotlin/ranges/IntRange
      38: dup
      39: iconst_0
      40: aload_0
      41: invokevirtual #253                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      44: checkcast     #104                // class java/lang/Number
      47: invokevirtual #108                // Method java/lang/Number.intValue:()I
      50: iload         5
      52: isub
      53: invokestatic  #283                // Method java/lang/Math.max:(II)I
      56: aload_0
      57: invokevirtual #253                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      60: checkcast     #104                // class java/lang/Number
      63: invokevirtual #108                // Method java/lang/Number.intValue:()I
      66: iload         5
      68: iadd
      69: iload_3
      70: invokestatic  #286                // Method java/lang/Math.min:(II)I
      73: invokespecial #256                // Method kotlin/ranges/IntRange."<init>":(II)V
      76: areturn

  private static final java.lang.Integer getNotCleared(java.util.List<kotlin.ranges.IntRange>);
    Code:
       0: aload_0
       1: checkcast     #134                // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: new           #289                // class cz/wrent/advent/Day15Kt$getNotCleared$$inlined$sortedBy$1
      11: dup
      12: invokespecial #290                // Method cz/wrent/advent/Day15Kt$getNotCleared$$inlined$sortedBy$1."<init>":()V
      15: checkcast     #292                // class java/util/Comparator
      18: invokestatic  #296                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
      21: astore_1
      22: aconst_null
      23: astore_2
      24: aload_1
      25: invokestatic  #300                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      28: astore_2
      29: aload_1
      30: checkcast     #134                // class java/lang/Iterable
      33: iconst_1
      34: invokestatic  #304                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
      37: checkcast     #134                // class java/lang/Iterable
      40: astore_3
      41: iconst_0
      42: istore        4
      44: aload_3
      45: invokeinterface #148,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      50: astore        5
      52: aload         5
      54: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      59: ifeq          165
      62: aload         5
      64: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      69: astore        6
      71: aload         6
      73: checkcast     #250                // class kotlin/ranges/IntRange
      76: astore        7
      78: iconst_0
      79: istore        8
      81: aload_2
      82: checkcast     #250                // class kotlin/ranges/IntRange
      85: aload         7
      87: invokevirtual #308                // Method kotlin/ranges/IntRange.getStart:()Ljava/lang/Integer;
      90: invokevirtual #228                // Method java/lang/Integer.intValue:()I
      93: invokevirtual #312                // Method kotlin/ranges/IntRange.contains:(I)Z
      96: ifne          113
      99: aload         7
     101: invokevirtual #308                // Method kotlin/ranges/IntRange.getStart:()Ljava/lang/Integer;
     104: invokevirtual #228                // Method java/lang/Integer.intValue:()I
     107: iconst_1
     108: isub
     109: invokestatic  #265                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     112: areturn
     113: aload         7
     115: invokevirtual #315                // Method kotlin/ranges/IntRange.getEndInclusive:()Ljava/lang/Integer;
     118: invokevirtual #228                // Method java/lang/Integer.intValue:()I
     121: aload_2
     122: checkcast     #250                // class kotlin/ranges/IntRange
     125: invokevirtual #315                // Method kotlin/ranges/IntRange.getEndInclusive:()Ljava/lang/Integer;
     128: invokevirtual #228                // Method java/lang/Integer.intValue:()I
     131: if_icmple     160
     134: new           #250                // class kotlin/ranges/IntRange
     137: dup
     138: aload_2
     139: checkcast     #250                // class kotlin/ranges/IntRange
     142: invokevirtual #308                // Method kotlin/ranges/IntRange.getStart:()Ljava/lang/Integer;
     145: invokevirtual #228                // Method java/lang/Integer.intValue:()I
     148: aload         7
     150: invokevirtual #315                // Method kotlin/ranges/IntRange.getEndInclusive:()Ljava/lang/Integer;
     153: invokevirtual #228                // Method java/lang/Integer.intValue:()I
     156: invokespecial #256                // Method kotlin/ranges/IntRange."<init>":(II)V
     159: astore_2
     160: nop
     161: nop
     162: goto          52
     165: nop
     166: aconst_null
     167: areturn

  private static final java.util.Map<java.lang.Integer, java.util.Map<java.lang.Integer, java.lang.Integer>> parse(java.lang.String);
    Code:
       0: new           #101                // class java/util/LinkedHashMap
       3: dup
       4: invokespecial #102                // Method java/util/LinkedHashMap."<init>":()V
       7: checkcast     #74                 // class java/util/Map
      10: astore_1
      11: new           #325                // class kotlin/text/Regex
      14: dup
      15: ldc_w         #327                // String Sensor at x=(-?\\d+), y=(-?\\d+): closest beacon is at x=(-?\\d+), y=(-?\\d+)
      18: invokespecial #330                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      21: astore_2
      22: aload_0
      23: checkcast     #332                // class java/lang/CharSequence
      26: iconst_1
      27: anewarray     #214                // class java/lang/String
      30: astore_3
      31: aload_3
      32: iconst_0
      33: ldc_w         #334                // String \n
      36: aastore
      37: aload_3
      38: iconst_0
      39: iconst_0
      40: bipush        6
      42: aconst_null
      43: invokestatic  #340                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      46: checkcast     #134                // class java/lang/Iterable
      49: astore_3
      50: nop
      51: iconst_0
      52: istore        4
      54: aload_3
      55: astore        5
      57: new           #69                 // class java/util/ArrayList
      60: dup
      61: aload_3
      62: bipush        10
      64: invokestatic  #218                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      67: invokespecial #120                // Method java/util/ArrayList."<init>":(I)V
      70: checkcast     #72                 // class java/util/Collection
      73: astore        6
      75: iconst_0
      76: istore        7
      78: aload         5
      80: invokeinterface #148,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      85: astore        8
      87: aload         8
      89: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      94: ifeq          141
      97: aload         8
      99: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     104: astore        9
     106: aload         6
     108: aload         9
     110: checkcast     #214                // class java/lang/String
     113: astore        10
     115: astore        14
     117: iconst_0
     118: istore        11
     120: aload_2
     121: aload         10
     123: checkcast     #332                // class java/lang/CharSequence
     126: invokevirtual #344                // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;
     129: aload         14
     131: swap
     132: invokeinterface #130,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     137: pop
     138: goto          87
     141: aload         6
     143: checkcast     #132                // class java/util/List
     146: nop
     147: checkcast     #134                // class java/lang/Iterable
     150: invokestatic  #348                // Method kotlin/collections/CollectionsKt.filterNotNull:(Ljava/lang/Iterable;)Ljava/util/List;
     153: checkcast     #134                // class java/lang/Iterable
     156: astore_3
     157: nop
     158: iconst_0
     159: istore        4
     161: aload_3
     162: astore        5
     164: new           #69                 // class java/util/ArrayList
     167: dup
     168: aload_3
     169: bipush        10
     171: invokestatic  #218                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     174: invokespecial #120                // Method java/util/ArrayList."<init>":(I)V
     177: checkcast     #72                 // class java/util/Collection
     180: astore        6
     182: iconst_0
     183: istore        7
     185: aload         5
     187: invokeinterface #148,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     192: astore        8
     194: aload         8
     196: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     201: ifeq          246
     204: aload         8
     206: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     211: astore        9
     213: aload         6
     215: aload         9
     217: checkcast     #350                // class kotlin/text/MatchResult
     220: astore        10
     222: astore        14
     224: iconst_0
     225: istore        11
     227: aload         10
     229: invokeinterface #354,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     234: aload         14
     236: swap
     237: invokeinterface #130,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     242: pop
     243: goto          194
     246: aload         6
     248: checkcast     #132                // class java/util/List
     251: nop
     252: checkcast     #134                // class java/lang/Iterable
     255: astore_3
     256: nop
     257: iconst_0
     258: istore        4
     260: aload_3
     261: invokeinterface #148,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     266: astore        5
     268: aload         5
     270: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     275: ifeq          502
     278: aload         5
     280: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     285: astore        6
     287: aload         6
     289: checkcast     #132                // class java/util/List
     292: astore        7
     294: iconst_0
     295: istore        8
     297: aload         7
     299: iconst_3
     300: invokeinterface #358,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     305: checkcast     #214                // class java/lang/String
     308: invokestatic  #362                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     311: invokestatic  #265                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     314: aload         7
     316: iconst_4
     317: invokeinterface #358,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     322: checkcast     #214                // class java/lang/String
     325: invokestatic  #362                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     328: invokestatic  #265                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     331: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     334: astore        9
     336: aload         7
     338: iconst_1
     339: invokeinterface #358,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     344: checkcast     #214                // class java/lang/String
     347: invokestatic  #362                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     350: invokestatic  #265                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     353: aload         7
     355: iconst_2
     356: invokeinterface #358,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     361: checkcast     #214                // class java/lang/String
     364: invokestatic  #362                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     367: invokestatic  #265                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     370: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     373: astore        10
     375: aload_1
     376: aload         10
     378: invokevirtual #242                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     381: invokedynamic #381,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     386: invokedynamic #392,  0            // InvokeDynamic #1:apply:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Function;
     391: invokeinterface #396,  3          // InterfaceMethod java/util/Map.computeIfAbsent:(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;
     396: dup
     397: ldc_w         #398                // String computeIfAbsent(...)
     400: invokestatic  #404                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     403: checkcast     #74                 // class java/util/Map
     406: astore        11
     408: aload         10
     410: invokevirtual #253                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     413: astore        12
     415: aload         10
     417: aload         9
     419: invokestatic  #407                // Method dist:(Lkotlin/Pair;Lkotlin/Pair;)I
     422: invokestatic  #265                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     425: astore        13
     427: aload         11
     429: aload         12
     431: aload         13
     433: invokeinterface #115,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     438: pop
     439: aload_1
     440: aload         9
     442: invokevirtual #242                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     445: invokedynamic #412,  0            // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;
     450: invokedynamic #417,  0            // InvokeDynamic #3:apply:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Function;
     455: invokeinterface #396,  3          // InterfaceMethod java/util/Map.computeIfAbsent:(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;
     460: dup
     461: ldc_w         #398                // String computeIfAbsent(...)
     464: invokestatic  #404                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     467: checkcast     #74                 // class java/util/Map
     470: astore        11
     472: aload         9
     474: invokevirtual #253                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     477: astore        12
     479: iconst_m1
     480: invokestatic  #265                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     483: astore        13
     485: aload         11
     487: aload         12
     489: aload         13
     491: invokeinterface #115,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     496: pop
     497: nop
     498: nop
     499: goto          268
     502: nop
     503: aload_1
     504: areturn

  private static final int dist(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: invokevirtual #253                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
       4: checkcast     #104                // class java/lang/Number
       7: invokevirtual #108                // Method java/lang/Number.intValue:()I
      10: aload_1
      11: invokevirtual #253                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      14: checkcast     #104                // class java/lang/Number
      17: invokevirtual #108                // Method java/lang/Number.intValue:()I
      20: isub
      21: invokestatic  #248                // Method java/lang/Math.abs:(I)I
      24: aload_0
      25: invokevirtual #242                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      28: checkcast     #104                // class java/lang/Number
      31: invokevirtual #108                // Method java/lang/Number.intValue:()I
      34: aload_1
      35: invokevirtual #242                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      38: checkcast     #104                // class java/lang/Number
      41: invokevirtual #108                // Method java/lang/Number.intValue:()I
      44: isub
      45: invokestatic  #248                // Method java/lang/Math.abs:(I)I
      48: iadd
      49: ireturn

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #432                // Method main:()V
       3: return

  private static final java.util.Map parse$lambda$20$lambda$16(java.lang.Integer);
    Code:
       0: aload_0
       1: ldc_w         #435                // String it
       4: invokestatic  #438                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: new           #101                // class java/util/LinkedHashMap
      10: dup
      11: invokespecial #102                // Method java/util/LinkedHashMap."<init>":()V
      14: checkcast     #74                 // class java/util/Map
      17: areturn

  private static final java.util.Map parse$lambda$20$lambda$17(kotlin.jvm.functions.Function1, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: invokeinterface #442,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
       7: checkcast     #74                 // class java/util/Map
      10: areturn

  private static final java.util.Map parse$lambda$20$lambda$18(java.lang.Integer);
    Code:
       0: aload_0
       1: ldc_w         #435                // String it
       4: invokestatic  #438                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: new           #101                // class java/util/LinkedHashMap
      10: dup
      11: invokespecial #102                // Method java/util/LinkedHashMap."<init>":()V
      14: checkcast     #74                 // class java/util/Map
      17: areturn

  private static final java.util.Map parse$lambda$20$lambda$19(kotlin.jvm.functions.Function1, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: invokeinterface #442,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
       7: checkcast     #74                 // class java/util/Map
      10: areturn
}

Compiled from "Comparisons.kt"
public final class cz.wrent.advent.Day15Kt$getNotCleared$$inlined$sortedBy$1<T> implements java.util.Comparator {
  public cz.wrent.advent.Day15Kt$getNotCleared$$inlined$sortedBy$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_1
       1: checkcast     #23                 // class kotlin/ranges/IntRange
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method kotlin/ranges/IntRange.getStart:()Ljava/lang/Integer;
      12: checkcast     #29                 // class java/lang/Comparable
      15: aload_2
      16: checkcast     #23                 // class kotlin/ranges/IntRange
      19: astore_3
      20: astore        5
      22: iconst_0
      23: istore        4
      25: aload_3
      26: invokevirtual #27                 // Method kotlin/ranges/IntRange.getStart:()Ljava/lang/Integer;
      29: aload         5
      31: swap
      32: checkcast     #29                 // class java/lang/Comparable
      35: invokestatic  #35                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      38: ireturn
}